[pve-devel] [PATCH qemu-server 2/2] pass $skiplock all the way through to destroy_vm

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Feb 5 08:46:35 CET 2016


The API passes $skiplock to vm_destroy() which performed a
check conditionally depending on the $skiplock parameter and
then simply calls destroy_vm() inside lock_config() which
did yet another check_lock() without any way to avoid that.

Added the $skiplock parameter to destroy_vm() and removed
the conditional check in vm_destroy() as both happened after
locking the config.
---
 PVE/QemuServer.pm | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 14a18f0..19e2791 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1972,13 +1972,13 @@ sub touch_config {
 }
 
 sub destroy_vm {
-    my ($storecfg, $vmid, $keep_empty_config) = @_;
+    my ($storecfg, $vmid, $keep_empty_config, $skiplock) = @_;
 
     my $conffile = config_file($vmid);
 
     my $conf = load_config($vmid);
 
-    check_lock($conf);
+    check_lock($conf) if !$skiplock;
 
     # only remove disks owned by this VM
     foreach_drive($conf, sub {
@@ -4857,10 +4857,8 @@ sub vm_destroy {
 
 	my $conf = load_config($vmid);
 
-	check_lock($conf) if !$skiplock;
-
 	if (!check_running($vmid)) {
-	    destroy_vm($storecfg, $vmid);
+	    destroy_vm($storecfg, $vmid, undef, $skiplock);
 	} else {
 	    die "VM $vmid is running - destroy failed\n";
 	}
-- 
2.1.4





More information about the pve-devel mailing list