[pve-devel] [RFC v3 qemu-server] VM protection mode added

Alen Grizonic a.grizonic at proxmox.com
Thu Sep 3 15:35:37 CEST 2015


used to prevent an unintended virtual machine remove operation

v3 changes:

- changed man page message
- removed protection parameter (where not needed)
---
 PVE/API2/Qemu.pm  | 3 +++
 PVE/QemuServer.pm | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 20d73f7..1687a07 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 be53a1e..91de46d 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 ?
-- 
2.1.4





More information about the pve-devel mailing list