fix perl scope issues

Add parameter array to foreach_volid to use is in the functions.
correct typos.
This commit is contained in:
Wolfgang Link 2016-06-16 11:22:30 +02:00 committed by Dietmar Maurer
parent 3629c19d23
commit b6adff3385
2 changed files with 7 additions and 9 deletions

View File

@ -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) {

View File

@ -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);
}
}