[pve-devel] [PATCH qemu-server] adapt /config and /pending API calls to force-delete

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Aug 17 12:03:46 CEST 2015


---
 PVE/API2/Qemu.pm | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 5d3b352..60687e1 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -674,7 +674,8 @@ __PACKAGE__->register_method({
 		next if ref($value); # just to be sure
 		$conf->{$opt} = $value;
 	    }
-	    foreach my $opt (PVE::Tools::split_list($conf->{pending}->{delete})) {
+	    my $pending_delete_hash = PVE::QemuServer::split_flagged_list($conf->{pending}->{delete});
+	    foreach my $opt (keys $pending_delete_hash) {
 		delete $conf->{$opt} if $conf->{$opt};
 	    }
 	}
@@ -721,7 +722,7 @@ __PACKAGE__->register_method({
 		},
 		delete => {
 		    description => "Indicated a pending delete request.",
-		    type => 'boolean',
+		    type => 'integer',
 		    optional => 1,
 		},
 	    },
@@ -732,10 +733,7 @@ __PACKAGE__->register_method({
 
 	my $conf = PVE::QemuServer::load_config($param->{vmid});
 
-	my $pending_delete_hash = {};
-	foreach my $opt (PVE::Tools::split_list($conf->{pending}->{delete})) {
-	    $pending_delete_hash->{$opt} = 1;
-	}
+	my $pending_delete_hash = PVE::QemuServer::split_flagged_list($conf->{pending}->{delete});
 
 	my $res = [];
 
@@ -744,7 +742,7 @@ __PACKAGE__->register_method({
 	    my $item = { key => $opt };
 	    $item->{value} = $conf->{$opt} if defined($conf->{$opt});
 	    $item->{pending} = $conf->{pending}->{$opt} if defined($conf->{pending}->{$opt});
-	    $item->{delete} = 1 if $pending_delete_hash->{$opt};
+	    $item->{delete} = ($pending_delete_hash->{$opt} ? 2 : 1) if exists $pending_delete_hash->{$opt};
 	    push @$res, $item;
 	}
 
@@ -757,10 +755,10 @@ __PACKAGE__->register_method({
 	    push @$res, $item;
 	}
 
-	foreach my $opt (PVE::Tools::split_list($conf->{pending}->{delete})) {
+	while (my ($opt, $force) = each %$pending_delete_hash) {
 	    next if $conf->{pending}->{$opt}; # just to be sure
 	    next if $conf->{$opt};
-	    my $item = { key => $opt, delete => 1};
+	    my $item = { key => $opt, delete => ($force ? 2 : 1)};
 	    push @$res, $item;
 	}
 
-- 
2.1.4





More information about the pve-devel mailing list