[pve-devel] applied: [PATCH qemu-server 3/4] implement removal of vmstate via api
Thomas Lamprecht
t.lamprecht at proxmox.com
Sat Nov 30 18:45:11 CET 2019
On 11/29/19 11:06 AM, Dominik Csapak wrote:
> we did not actually delete the state if we deleted the 'vmstate' config,
> leaving stray vmstates on the disks
>
> actually implement the removal, requiring 'VM.Config.Disk' and
> 'VM.PowerMgmt' privs
>
applied, but not to sure about the Protection check, but as it's easily
workaround-able (temp. disable protection, or quick start+stop) I let it
as is.
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> PVE/API2/Qemu.pm | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index 1811795..a466121 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -315,6 +315,7 @@ my $check_vm_modify_config_perm = sub {
> # some checks (e.g., disk, serial port, usb) need to be done somewhere
> # else, as there the permission can be value dependend
> next if PVE::QemuServer::is_valid_drivename($opt);
> + next if $opt eq 'vmstate';
> next if $opt eq 'cdrom';
> next if $opt =~ m/^(?:unused|serial|usb)\d+$/;
>
> @@ -1140,6 +1141,14 @@ my $update_vm_api = sub {
> delete $conf->{$opt};
> PVE::QemuConfig->write_config($vmid, $conf);
> }
> + } elsif ($opt eq 'vmstate') {
> + PVE::QemuConfig->check_protection($conf, "can't remove vmstate '$val'");
> + # the user needs Disk and PowerMgmt privileges to remove the vmstate
> + $rpcenv->check_vm_perm($authuser, $vmid, undef, ['VM.Config.Disk', 'VM.PowerMgmt' ]);
> + if (PVE::QemuServer::try_deallocate_drive($storecfg, $vmid, $conf, $opt, { file => $val }, $rpcenv, $authuser, 1)) {
> + delete $conf->{$opt};
> + PVE::QemuConfig->write_config($vmid, $conf);
> + }
> } elsif (PVE::QemuServer::is_valid_drivename($opt)) {
> PVE::QemuConfig->check_protection($conf, "can't remove drive '$opt'");
> $rpcenv->check_vm_perm($authuser, $vmid, undef, ['VM.Config.Disk']);
>
More information about the pve-devel
mailing list