[pve-devel] [PATCH qemu-server] restore_tar_archive: Add skiplock to destroy_vm

Dominic Jäger d.jaeger at proxmox.com
Thu Nov 7 13:00:57 CET 2019


When calling qmrestore a config file is created and locked with a lock
property. The following destroy_vm has been impossible as skiplock has not
been set.

Signed-off-by: Dominic Jäger <d.jaeger at proxmox.com>
---
 PVE/QemuServer.pm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index bfe6662..345ffab 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6604,9 +6604,14 @@ sub restore_tar_archive {
 
     my $storecfg = PVE::Storage::config();
 
-    # destroy existing data - keep empty config
+    # Restoring a backup can replace an existing VM. In this case, we need to
+    # remove existing data such as disks as they would pile up as unused disks
+    # in the new VM otherwise.
+    # keep_empty_config=1 to prevent races until overwriting it with the
+    # restored config.
+    # skiplock=1 because qmrestore has set the lock itself.
     my $vmcfgfn = PVE::QemuConfig->config_file($vmid);
-    destroy_vm($storecfg, $vmid, 1) if -f $vmcfgfn;
+    destroy_vm($storecfg, $vmid, 1, 1) if -f $vmcfgfn;
 
     my $tocmd = "/usr/lib/qemu-server/qmextract";
 
-- 
2.20.1




More information about the pve-devel mailing list