5
0
mirror of git://git.proxmox.com/git/qemu-server.git synced 2025-01-25 06:03:52 +03:00

pass $skiplock all the way through to destroy_vm

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.
This commit is contained in:
Wolfgang Bumiller 2016-02-05 08:46:35 +01:00 committed by Dietmar Maurer
parent f7b4356fe6
commit 15cc878469

View 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";
}