[pve-devel] [RFC vb2 pve-container] CT protection mode

Alen Grizonic a.grizonic at proxmox.com
Thu Sep 10 10:20:41 CEST 2015


v2 changes:

- protection mode removal prevention

- disk removal prevention
---
 src/PVE/LXC.pm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index ebf5d23..4cb7809 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -179,7 +179,7 @@ my $confdesc = {
     protection => {
 	optional => 1,
 	type => 'boolean',
-	description => "Sets the protection flag of the container. This will prevent the remove operation.",
+	description => "Sets the protection flag of the container. This will prevent the container or container's disk remove operation.",
 	default => 0,
     },
 };
@@ -1108,13 +1108,18 @@ sub update_pct_config {
 		my $netid = $1;
 		PVE::Network::veth_delete("veth${vmid}i$netid");
 	    } elsif ($opt eq 'protection') {
+		die "can't delete CT $vmid protection option - protection mode enabled\n"
+		    if ($conf->{protection} == 1);
 		delete $conf->{$opt};
 	    } elsif ($opt =~ m/^mp(\d+)$/) {
+		die "can't remove CT $vmid storage - protection mode enabled\n"
+                    if ($conf->{protection} == 1);
 		delete $conf->{$opt};
 		push @nohotplug, $opt;
 		next if $running;
 	    } elsif ($opt eq 'rootfs') {
-		die "implement me"
+		die "can't remove CT $vmid storage - protection mode enabled\n"
+		    if ($conf->{protection} == 1);
 	    } else {
 		die "implement me"
 	    }
-- 
2.1.4





More information about the pve-devel mailing list