diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index da00676d..eef149b8 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -1448,7 +1448,7 @@ __PACKAGE__->register_method({ die "VM $vmid is running - destroy failed\n" if (PVE::QemuServer::check_running($vmid)); - PVE::QemuServer::destroy_vm($storecfg, $vmid, 1, $skiplock); + PVE::QemuServer::destroy_vm($storecfg, $vmid, $skiplock, { lock => 'destroyed' }); PVE::AccessControl::remove_vm_access($vmid); PVE::Firewall::remove_vmfw_conf($vmid); diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm index 59a38611..13615815 100755 --- a/PVE/CLI/qm.pm +++ b/PVE/CLI/qm.pm @@ -659,7 +659,7 @@ __PACKAGE__->register_method ({ if ($err) { my $skiplock = 1; # eval for additional safety in error path - eval { PVE::QemuServer::destroy_vm($storecfg, $vmid, undef, $skiplock) }; + eval { PVE::QemuServer::destroy_vm($storecfg, $vmid, $skiplock) }; warn "Could not destroy VM $vmid: $@" if "$@"; die "import failed - $err"; } diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index e1763478..a50b4e12 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -2550,7 +2550,7 @@ sub check_type { } sub destroy_vm { - my ($storecfg, $vmid, $keep_empty_config, $skiplock) = @_; + my ($storecfg, $vmid, $skiplock, $replacement_conf) = @_; my $conf = PVE::QemuConfig->load_config($vmid); @@ -2594,8 +2594,8 @@ sub destroy_vm { warn $@ if $@; }); - if ($keep_empty_config) { - PVE::QemuConfig->write_config($vmid, { memory => 128 }); + if (defined $replacement_conf) { + PVE::LXC::Config->write_config($vmid, $replacement_conf); } else { PVE::QemuConfig->destroy_config($vmid); } @@ -6595,7 +6595,7 @@ sub restore_tar_archive { # pass keep_empty_config=1 to keep the config (thus VMID) reserved for us # skiplock=1 because qmrestore has set the 'create' lock itself already my $vmcfgfn = PVE::QemuConfig->config_file($vmid); - destroy_vm($storecfg, $vmid, 1, 1) if -f $vmcfgfn; + destroy_vm($storecfg, $vmid, 1, { lock => 'restore' }) if -f $vmcfgfn; my $tocmd = "/usr/lib/qemu-server/qmextract";