[pve-devel] applied: [PATCH qemu-server] api/restore: do not trigger autostart task from locked context

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Dec 16 16:01:04 CET 2019


Do the same as for the "create" case, only trigger the "start after
create/restore" task after the locked "realcmd" was done. Else, the
start can never succeed, it also acquires a lock, but restore only
release it once outside of realcmd.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 PVE/API2/Qemu.pm | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index cf9da16..5bae513 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -574,17 +574,18 @@ __PACKAGE__->register_method({
 		}
 
 		PVE::AccessControl::add_vm_to_pool($vmid, $pool) if $pool;
-
-		if ($start_after_create) {
-		    eval { PVE::API2::Qemu->vm_start({ vmid => $vmid, node => $node }) };
-		    warn $@ if $@;
-		}
 	    };
 
 	    # ensure no old replication state are exists
 	    PVE::ReplicationState::delete_guest_states($vmid);
 
-	    return PVE::QemuConfig->lock_config_full($vmid, 1, $realcmd);
+	    PVE::QemuConfig->lock_config_full($vmid, 1, $realcmd);
+
+	    if ($start_after_create) {
+		print "Execute autostart\n";
+		eval { PVE::API2::Qemu->vm_start({ vmid => $vmid, node => $node }) };
+		warn $@ if $@;
+	    }
 	};
 
 	my $createfn = sub {
-- 
2.20.1




More information about the pve-devel mailing list