From: Thomas Lamprecht Date: Sat, 30 Nov 2019 17:17:17 +0000 (+0100) Subject: api: allow to clear vmstate actively X-Git-Url: https://git.proxmox.com/?p=qemu-server.git;a=commitdiff_plain;h=546644e23da41038b0aef10b20a0f45a23b32b8c api: allow to clear vmstate actively Sometimes, a user wants to remove the 'suspended' state without resuming the vm from that state. Since the vm is locked with 'suspended', this was not possible without help from root@pam This patch allows to delete the vmstate and the suspended lock and related config entries with it. The user still has to have the right priviliges and the vm cannot be 'protected' for this to work Inspired-by: Dominik Csapak Signed-off-by: Thomas Lamprecht --- diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index a466121..51fe142 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -1091,6 +1091,15 @@ my $update_vm_api = sub { die "checksum missmatch (file change by other user?)\n" if $digest && $digest ne $conf->{digest}; + # FIXME: 'suspended' lock should probabyl be a state or "weak" lock?! + if (scalar(@delete) && grep { $_ eq 'vmstate'} @delete) { + if (defined($conf->{lock}) && $conf->{lock} eq 'suspended') { + delete $conf->{lock}; # for check lock check, not written out + push @delete, 'lock'; # this is the real deal to write it out + } + push @delete, 'runningmachine' if $conf->{runningmachine}; + } + PVE::QemuConfig->check_lock($conf) if !$skiplock; foreach my $opt (keys %$revert) {