diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 7e1d3147..db436b3d 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -1498,8 +1498,9 @@ __PACKAGE__->register_method({ PVE::QemuServer::destroy_vm($storecfg, $vmid, 1, $skiplock); PVE::AccessControl::remove_vm_access($vmid); PVE::Firewall::remove_vmfw_conf($vmid); - unlink PVE::QemuConfig->config_file($vmid) - or die "Removal of VM $vmid config file failed: $!\n"; + + # only now remove the zombie config, else we can have reuse race + PVE::QemuConfig->destroy_config($vmid); }); }; diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index edb49bc7..9fc81ae4 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -2665,7 +2665,7 @@ sub destroy_vm { if ($keep_empty_config) { PVE::Tools::file_set_contents($conffile, "memory: 128\n"); } else { - unlink $conffile; + PVE::QemuConfig->destroy_config($vmid); } # also remove unused disk