]> git.proxmox.com Git - qemu-server.git/commitdiff
api: allow to clear vmstate actively
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 30 Nov 2019 17:17:17 +0000 (18:17 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 30 Nov 2019 17:22:38 +0000 (18:22 +0100)
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 <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/Qemu.pm

index a466121c840179ed97f020e6c6acd6d4a440e4fb..51fe1420a85c240aa6a0331f39f009d56bd4de25 100644 (file)
@@ -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) {