mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-01 18:53:07 +00:00
clone: use new config_lock_shared
and move the lock call and decision logic closer together Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> Tested-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
5a5ba29460
commit
45fd77bbe3
@ -2858,9 +2858,6 @@ __PACKAGE__->register_method({
|
||||
|
||||
my $running = PVE::QemuServer::check_running($vmid) || 0;
|
||||
|
||||
# exclusive lock if VM is running - else shared lock is enough;
|
||||
my $shared_lock = $running ? 0 : 1;
|
||||
|
||||
my $clonefn = sub {
|
||||
# do all tests after lock but before forking worker - if possible
|
||||
|
||||
@ -3048,11 +3045,17 @@ __PACKAGE__->register_method({
|
||||
return $rpcenv->fork_worker('qmclone', $vmid, $authuser, $realcmd);
|
||||
};
|
||||
|
||||
return PVE::QemuConfig->lock_config_mode($vmid, 1, $shared_lock, sub {
|
||||
# Aquire exclusive lock lock for $newid
|
||||
my $lock_target_vm = sub {
|
||||
return PVE::QemuConfig->lock_config_full($newid, 1, $clonefn);
|
||||
});
|
||||
};
|
||||
|
||||
# exclusive lock if VM is running - else shared lock is enough;
|
||||
if ($running) {
|
||||
return PVE::QemuConfig->lock_config_full($vmid, 1, $lock_target_vm);
|
||||
} else {
|
||||
return PVE::QemuConfig->lock_config_shared($vmid, 1, $lock_target_vm);
|
||||
}
|
||||
}});
|
||||
|
||||
__PACKAGE__->register_method({
|
||||
|
Loading…
Reference in New Issue
Block a user