[pve-devel] [PATCH v2 storage 17/28] Collect optional parameters for storage_migrate into $opts

Fabian Ebner f.ebner at proxmox.com
Mon Feb 24 13:44:07 CET 2020


Sanitizing $with_snapshots is done on extraction to save a line.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 PVE/API2/Storage/Content.pm |  2 +-
 PVE/Storage.pm              | 11 ++++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/PVE/API2/Storage/Content.pm b/PVE/API2/Storage/Content.pm
index ce89ec5..db0148b 100644
--- a/PVE/API2/Storage/Content.pm
+++ b/PVE/API2/Storage/Content.pm
@@ -412,7 +412,7 @@ __PACKAGE__->register_method ({
 	    # you need to get this working (fails currently, because storage_migrate() uses
 	    # ssh to connect to local host (which is not needed
 	    my $sshinfo = PVE::SSHInfo::get_ssh_info($target_node);
-	    PVE::Storage::storage_migrate($cfg, $src_volid, $sshinfo, $target_sid, $target_volname);
+	    PVE::Storage::storage_migrate($cfg, $src_volid, $sshinfo, $target_sid, {'target_volname' => $target_volname});
 
 	    print "DEBUG: end worker $upid\n";
 
diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index bed6e81..851c59d 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -563,10 +563,16 @@ sub abs_filesystem_path {
 }
 
 sub storage_migrate {
-    my ($cfg, $volid, $target_sshinfo, $target_storeid, $target_volname, $base_snapshot, $snapshot, $ratelimit_bps, $insecure, $with_snapshots, $logfunc) = @_;
+    my ($cfg, $volid, $target_sshinfo, $target_storeid, $opts, $logfunc) = @_;
+
+    my $base_snapshot = $opts->{base_snapshot};
+    my $snapshot = $opts->{snapshot};
+    my $ratelimit_bps = $opts->{ratelimit_bps};
+    my $insecure = $opts->{insecure};
+    my $with_snapshots = $opts->{with_snapshots} ? 1 : 0; # sanitize for passing as cli parameter
 
     my ($storeid, $volname) = parse_volume_id($volid);
-    $target_volname = $volname if !$target_volname;
+    my $target_volname = $opts->{target_volname} || $volname;
 
     my $scfg = storage_config($cfg, $storeid);
 
@@ -604,7 +610,6 @@ sub storage_migrate {
 	$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, '--', 'pvesm', 'import', $target_volid, $format, $import_fn, '-with-snapshots', $with_snapshots];
     if (defined($snapshot)) {
-- 
2.20.1





More information about the pve-devel mailing list