]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage.pm
bump version to 5.0-17
[pve-storage.git] / PVE / Storage.pm
index 4772c6c06c1f2b64b8b4903d457ba77ffbb25481..73b21e11fcffa57d23602d9220a81e3f6043e9e1 100755 (executable)
@@ -145,6 +145,17 @@ sub storage_check_enabled {
     return storage_check_node($cfg, $storeid, $node, $noerr);
 }
 
+# storage_can_replicate:
+# return true if storage supports replication
+# (volumes alocated with vdisk_alloc() has replication feature)
+sub storage_can_replicate {
+    my ($cfg, $storeid, $format) = @_;
+
+    my $scfg = storage_config($cfg, $storeid);
+    my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
+    return $plugin->storage_can_replicate($scfg, $storeid, $format);
+}
+
 sub storage_ids {
     my ($cfg) = @_;
 
@@ -525,7 +536,7 @@ sub abs_filesystem_path {
 }
 
 sub storage_migrate {
-    my ($cfg, $volid, $target_sshinfo, $target_storeid, $target_volname, $base_snapshot, $snapshot, $ratelimit_bps, $insecure, $with_snapshots) = @_;
+    my ($cfg, $volid, $target_sshinfo, $target_storeid, $target_volname, $base_snapshot, $snapshot, $ratelimit_bps, $insecure, $with_snapshots, $logfunc) = @_;
 
     my ($storeid, $volname) = parse_volume_id($volid);
     $target_volname = $volname if !$target_volname;
@@ -608,7 +619,7 @@ sub storage_migrate {
                die "import failed: exit code ".($?>>8)."\n";
            }
        } else {
-           run_command([$send, @cstream, $recv]);
+           run_command([$send, @cstream, $recv], logfunc => $logfunc);
        }
     };
     my $err = $@;
@@ -990,7 +1001,7 @@ sub deactivate_volumes {
 }
 
 sub storage_info {
-    my ($cfg, $content) = @_;
+    my ($cfg, $content, $includeformat) = @_;
 
     my $ids = $cfg->{ids};
 
@@ -1000,8 +1011,7 @@ sub storage_info {
 
     my $slist = [];
     foreach my $storeid (keys %$ids) {
-
-       next if !storage_check_enabled($cfg, $storeid, undef, 1);
+       my $storage_enabled = defined(storage_check_enabled($cfg, $storeid, undef, 1));
 
        if (defined($content)) {
            my $want_ctype = 0;
@@ -1011,7 +1021,7 @@ sub storage_info {
                    last;
                }
            }
-           next if !$want_ctype;
+           next if !$want_ctype || !$storage_enabled;
        }
 
        my $type = $ids->{$storeid}->{type};
@@ -1024,6 +1034,7 @@ sub storage_info {
            shared => $ids->{$storeid}->{shared} ? 1 : 0,
            content => PVE::Storage::Plugin::content_hash_to_string($ids->{$storeid}->{content}),
            active => 0,
+           enabled => $storage_enabled ? 1 : 0,
        };
 
        push @$slist, $storeid;
@@ -1033,7 +1044,18 @@ sub storage_info {
 
     foreach my $storeid (keys %$ids) {
        my $scfg = $ids->{$storeid};
+
        next if !$info->{$storeid};
+       next if !$info->{$storeid}->{enabled};
+
+       my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
+       if ($includeformat) {
+           my $pd = $plugin->plugindata();
+           $info->{$storeid}->{format} = $pd->{format}
+               if $pd->{format};
+           $info->{$storeid}->{select_existing} = $pd->{select_existing}
+               if $pd->{select_existing};
+       }
 
        eval { activate_storage($cfg, $storeid, $cache); };
        if (my $err = $@) {
@@ -1041,7 +1063,6 @@ sub storage_info {
            next;
        }
 
-       my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
        my ($total, $avail, $used, $active);
        eval { ($total, $avail, $used, $active) = $plugin->status($storeid, $scfg, $cache); };
        warn $@ if $@;