[pve-devel] [PATCH qemu-server] fix perl scope issues

Wolfgang Link w.link at proxmox.com
Thu Jun 16 11:22:30 CEST 2016


Add parameter array to foreach_volid to use is in the functions.
correct typos.
---
 PVE/QemuMigrate.pm | 12 +++++-------
 PVE/QemuServer.pm  |  4 ++--
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index f0734cb..3e90a46 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -164,7 +164,7 @@ sub prepare {
 
     my $running = 0;
     if (my $pid = PVE::QemuServer::check_running($vmid)) {
-	die "cant migrate running VM without --online\n" if !$online;
+	die "can't migrate running VM without --online\n" if !$online;
 	$running = $pid;
 
 	$self->{forcemachine} = PVE::QemuServer::qemu_machine_pxe($vmid, $conf);
@@ -248,17 +248,15 @@ sub sync_disks {
             });
         }
 
-	my $snapname;
-
 	my $test_volid = sub {
-	    my ($volid, $is_cdrom) = @_;
+	    my ($volid, $is_cdrom, $snapname) = @_;
 
 	    return if !$volid;
 
 	    die "can't migrate local file/device '$volid'\n" if $volid =~ m|^/|;
 
 	    if ($is_cdrom) {
-		die "cant migrate local cdrom drive\n" if $volid eq 'cdrom';
+		die "can't migrate local cdrom drive\n" if $volid eq 'cdrom';
 		return if $volid eq 'none';
 		$cdromhash->{$volid} = 1;
 	    }
@@ -299,8 +297,8 @@ sub sync_disks {
 	};
 
 	PVE::QemuServer::foreach_volid($conf, $test_volid);
-	foreach $snapname (keys %{$conf->{snapshots}}) {
-	    PVE::QemuServer::foreach_volid($conf->{snapshots}->{$snapname}, $test_volid);
+	foreach my $snapname (keys %{$conf->{snapshots}}) {
+	    PVE::QemuServer::foreach_volid($conf->{snapshots}->{$snapname}, $test_volid, $snapname);
 	}
 
 	if ($self->{running} && !$sharedvm) {
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 666b756..4226f50 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2658,7 +2658,7 @@ sub foreach_drive {
 }
 
 sub foreach_volid {
-    my ($conf, $func) = @_;
+    my ($conf, $func, @param) = @_;
 
     my $volhash = {};
 
@@ -2685,7 +2685,7 @@ sub foreach_volid {
     }
 
     foreach my $volid (keys %$volhash) {
-	&$func($volid, $volhash->{$volid});
+	&$func($volid, $volhash->{$volid}, @param);
     }
 }
 
-- 
2.1.4




More information about the pve-devel mailing list