[pve-devel] [PATCH qemu-server 4/4] add special case for clearing suspended state
Thomas Lamprecht
t.lamprecht at proxmox.com
Sat Nov 30 18:47:09 CET 2019
On 11/29/19 11:06 AM, Dominik Csapak wrote:
> 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 at 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
>
> also, the lock will only be skipped, if the deletion of the vmstate
> is the only thing that is done
>
replaced this with an alternative method, I don't care if there are
multiple changes requested, it can be still safely done (or at least
as safe as in the other case). If you add such special semantics, some
good reasoning would be nice to have in commit message or comment
(why, not what/how).
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> PVE/API2/Qemu.pm | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index a466121..d3fbbfd 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -1091,7 +1091,20 @@ my $update_vm_api = sub {
> die "checksum missmatch (file change by other user?)\n"
> if $digest && $digest ne $conf->{digest};
>
> - PVE::QemuConfig->check_lock($conf) if !$skiplock;
> + my $clear_suspend = 0;
> + # special case for removing vmstate
> + # if the only thing we want to delete is the vmstate, we skip the
> + #'suspended' lock and remove it as well as the running machine and vmstate
> + if (scalar(@delete) == 1 && $delete[0] eq 'vmstate' &&
> + !scalar(keys %$param) && !scalar(keys %$revert) &&
> + defined($conf->{lock}) && $conf->{lock} eq 'suspended')
> + {
> + $clear_suspend = 1;
> + push @delete, 'lock';
> + push @delete, 'runningmachine' if $conf->{runningmachine};
> + }
> +
> + PVE::QemuConfig->check_lock($conf) if !$skiplock && !$clear_suspend;
>
> foreach my $opt (keys %$revert) {
> if (defined($conf->{$opt})) {
>
More information about the pve-devel
mailing list