]> git.proxmox.com Git - qemu-server.git/commitdiff
api: vm clone: unlink zombie target config at end of error cleanup
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 15 Jan 2020 07:12:22 +0000 (08:12 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 15 Jan 2020 07:12:24 +0000 (08:12 +0100)
This is the guarantee that this call operates on it's created config.
A VMID cannot be reused afterall. So only remove the guarantee at the
last step, just before throwing up the error message about the clone
failure.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/Qemu.pm

index f5e757a52473b549f54c79a0d305098bdaedc747..0d543ff4c0e3ed96cc985e7f37ff64ee456d720c 100644 (file)
@@ -2931,8 +2931,6 @@ __PACKAGE__->register_method({
                    PVE::AccessControl::add_vm_to_pool($newid, $pool) if $pool;
                };
                if (my $err = $@) {
-                   unlink $conffile;
-
                    eval { PVE::QemuServer::qemu_blockjobs_cancel($vmid, $jobs) };
                    sleep 1; # some storage like rbd need to wait before release volume - really?
 
@@ -2943,6 +2941,8 @@ __PACKAGE__->register_method({
 
                    PVE::Firewall::remove_vmfw_conf($newid);
 
+                   unlink $conffile; # avoid races -> last thing before die
+
                    die "clone failed: $err";
                }