]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage.pm
pvesm import: allow to pass a tcp://<IP> as file
[pve-storage.git] / PVE / Storage.pm
index 6ad88d3d41b92b9a975a91d8b89af3578a78c0c1..5925c696bced9c2f9cf507d4c552ce634d821188 100755 (executable)
@@ -29,7 +29,6 @@ use PVE::Storage::CIFSPlugin;
 use PVE::Storage::ISCSIPlugin;
 use PVE::Storage::RBDPlugin;
 use PVE::Storage::CephFSPlugin;
-use PVE::Storage::SheepdogPlugin;
 use PVE::Storage::ISCSIDirectPlugin;
 use PVE::Storage::GlusterfsPlugin;
 use PVE::Storage::ZFSPoolPlugin;
@@ -52,7 +51,6 @@ PVE::Storage::CIFSPlugin->register();
 PVE::Storage::ISCSIPlugin->register();
 PVE::Storage::RBDPlugin->register();
 PVE::Storage::CephFSPlugin->register();
-PVE::Storage::SheepdogPlugin->register();
 PVE::Storage::ISCSIDirectPlugin->register();
 PVE::Storage::GlusterfsPlugin->register();
 PVE::Storage::ZFSPoolPlugin->register();
@@ -592,17 +590,15 @@ sub storage_migrate {
     die "cannot migrate from storage type '$scfg->{type}' to '$tcfg->{type}'\n" if !@formats;
     my $format = $formats[0];
 
-    my @insecurecmd;
+    my $import_fn = '-'; # let pvesm import read from stdin per default
     if ($insecure) {
-       @insecurecmd = ('pvecm', 'mtunnel', '-run-command', 1);
-       if (my $network = $target_sshinfo->{network}) {
-           push @insecurecmd, '-migration_network', $network;
-       }
+       my $net = $target_sshinfo->{network} // $target_sshinfo->{ip};
+       $import_fn = "tcp://$net";
     }
 
     $with_snapshots = $with_snapshots ? 1 : 0; # sanitize for passing as cli parameter
     my $send = ['pvesm', 'export', $volid, $format, '-', '-with-snapshots', $with_snapshots];
-    my $recv = [@$ssh, @insecurecmd, '--', 'pvesm', 'import', $volid, $format, '-', '-with-snapshots', $with_snapshots];
+    my $recv = [@$ssh, '--', 'pvesm', 'import', $volid, $format, $import_fn, '-with-snapshots', $with_snapshots];
     if (defined($snapshot)) {
        push @$send, '-snapshot', $snapshot
     }
@@ -802,7 +798,7 @@ sub snippets_list {
                push @{$res->{$sid}}, {
                    volid => "$sid:snippets/". basename($fn),
                    format => 'snippet',
-                   size => -s $fn,
+                   size => -s $fn // 0,
                };
            }
        }
@@ -869,7 +865,7 @@ sub template_list {
                    $info = { volid => "$sid:backup/$1", format => $2 };
                }
 
-               $info->{size} = -s $fn;
+               $info->{size} = -s $fn // 0;
 
                push @{$res->{$sid}}, $info;
            }
@@ -1635,7 +1631,7 @@ sub get_bandwidth_limit {
     }
 
     # Apply per-storage limits - if there are storages involved.
-    if (@$storage_list) {
+    if (defined($storage_list) && @$storage_list) {
        my $config = config();
 
        # The Datastore.Allocate permission allows us to modify the per-storage
@@ -1646,6 +1642,7 @@ sub get_bandwidth_limit {
 
        my %done;
        foreach my $storage (@$storage_list) {
+           next if !defined($storage);
            # Avoid duplicate checks:
            next if $done{$storage};
            $done{$storage} = 1;