diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 20d73f74..1687a07a 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -1142,6 +1142,9 @@ __PACKAGE__->register_method({ my $storecfg = PVE::Storage::config(); + die "can't remove VM $vmid - protection mode enabled\n" + if ($conf->{protection} == 1); + die "unable to remove VM $vmid - used in HA resources\n" if PVE::HA::Config::vm_is_ha_managed($vmid); diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 42be37be..b2a83565 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -384,6 +384,12 @@ EODESCR maxLength => 256, optional => 1, }, + protection => { + optional => 1, + type => 'boolean', + description => "Sets the protection flag of the VM. This will prevent the remove operation.", + default => 0, + }, }; # what about other qemu settings ?