]> git.proxmox.com Git - qemu-server.git/commitdiff
pass $skiplock all the way through to destroy_vm
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 5 Feb 2016 07:46:35 +0000 (08:46 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 8 Feb 2016 10:52:23 +0000 (11:52 +0100)
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

index b63444dff28eebe9c5a5403cf7f6b64fade9e0c1..047c5a4a750caeea3181db6888f2e47743fc98fb 100644 (file)
@@ -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";
        }