[pve-devel] [PATCH qemu-server] use the proper pending delete format while looping

Oguz Bektas o.bektas at proxmox.com
Tue Oct 22 12:34:27 CEST 2019


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 at proxmox.com>
---
 PVE/QemuServer.pm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 3408898..a054199 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -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);
-- 
2.20.1




More information about the pve-devel mailing list