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

Alen Grizonic a.grizonic at proxmox.com
Thu Sep 10 10:59:09 CEST 2015


v2 changes:

- protection mode removal prevention

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

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index ebf5d23..7679670 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,21 @@ sub update_pct_config {
 		my $netid = $1;
 		PVE::Network::veth_delete("veth${vmid}i$netid");
 	    } elsif ($opt eq 'protection') {
+		if (($conf->{protection}) && ($conf->{protection} == 1)) {
+		    die "can't delete CT $vmid protection option - protection mode enabled\n";
+		}
 		delete $conf->{$opt};
 	    } elsif ($opt =~ m/^mp(\d+)$/) {
+		if (($conf->{protection}) && ($conf->{protection} == 1)) {
+		    die "can't remove CT $vmid storage - protection mode enabled\n";
+		}
 		delete $conf->{$opt};
 		push @nohotplug, $opt;
 		next if $running;
 	    } elsif ($opt eq 'rootfs') {
-		die "implement me"
+		if (($conf->{protection}) && ($conf->{protection} == 1)) {
+		    die "can't remove CT $vmid storage - protection mode enabled\n";
+		}
 	    } else {
 		die "implement me"
 	    }
-- 
2.1.4





More information about the pve-devel mailing list