]> git.proxmox.com Git - qemu-server.git/commitdiff
pending apply/hotplug: don't hard code force to true
authorOguz Bektas <o.bektas@proxmox.com>
Tue, 22 Oct 2019 10:34:27 +0000 (12:34 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 22 Oct 2019 10:45:51 +0000 (12:45 +0200)
Each pending options has a hash value which has the 'force'
information encoded as entry. But, this can be { force => 1 } or
{ force => 0 }, so we actually need to check the value and not just
set force to the hash directly, as else we have force always truthy..

fixes a bug where 'detach' caused disks to be destroyed immediately,
because $force parameter was always true since hash is true.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/QemuServer.pm

index 3408898dea3ca3783378b5916d331d5aa73cc125..a054199c81331b810b25bc38b6eda42352e0427f 100644 (file)
@@ -4856,7 +4856,8 @@ sub vmconfig_hotplug_pending {
     my $hotplug_features = parse_hotplug_features(defined($conf->{hotplug}) ? $conf->{hotplug} : '1');
 
     my $pending_delete_hash = PVE::QemuConfig->parse_pending_delete($conf->{pending}->{delete});
-    while (my ($opt, $force) = each %$pending_delete_hash) {
+    foreach my $opt (keys %$pending_delete_hash) {
+       my $force = $pending_delete_hash->{$opt}->{force};
        next if $selection && !$selection->{$opt};
        eval {
            if ($opt eq 'hotplug') {
@@ -5054,8 +5055,9 @@ sub vmconfig_apply_pending {
     # cold plug
 
     my $pending_delete_hash = PVE::QemuConfig->parse_pending_delete($conf->{pending}->{delete});
-    while (my ($opt, $force) = each %$pending_delete_hash) {
+    foreach my $opt (keys %$pending_delete_hash) {
        die "internal error" if $opt =~ m/^unused/;
+       my $force = $pending_delete_hash->{$opt}->{force};
        $conf = PVE::QemuConfig->load_config($vmid); # update/reload
        if (!defined($conf->{$opt})) {
            PVE::QemuConfig->remove_from_pending_delete($conf, $opt);