[pve-devel] [PATCH v2 container 2/3] skip some additional config options when restoring

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Apr 20 12:30:43 CEST 2016


-unusedX in all cases, even when creating
-parent when merging config from backup
---
 src/PVE/API2/LXC.pm   | 3 +++
 src/PVE/LXC/Create.pm | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 90cdba6..03c20fa 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -261,6 +261,9 @@ __PACKAGE__->register_method({
 	    if ($opt eq 'rootfs' || $opt =~ m/^mp\d+$/) {
 		# allow to use simple numbers (add default storage in that case)
 		$param->{$opt} = "$storage:$value" if $value =~ m/^\d+(\.\d+)?$/;
+	    } elsif ($opt =~ m/^unused\d+$/) {
+		warn "ignoring '$opt', cannot create/restore with unused volume\n";
+		delete $param->{$opt};
 	    } else {
 		$no_disk_param->{$opt} = $value;
 	    }
diff --git a/src/PVE/LXC/Create.pm b/src/PVE/LXC/Create.pm
index 6c47ceb..9375f43 100644
--- a/src/PVE/LXC/Create.pm
+++ b/src/PVE/LXC/Create.pm
@@ -154,8 +154,9 @@ sub restore_and_configure {
 	    my $oldconf = PVE::LXC::Config::parse_pct_config("/lxc/$vmid.conf", $raw);
 
 	    foreach my $key (keys %$oldconf) {
-		next if $key eq 'digest' || $key eq 'rootfs' || $key eq 'snapshots' || $key eq 'unprivileged';
+		next if $key eq 'digest' || $key eq 'rootfs' || $key eq 'snapshots' || $key eq 'unprivileged' || $key eq 'parent';
 		next if $key =~ /^mp\d+$/; # don't recover mountpoints
+		next if $key =~ /^unused\d+$/; # don't recover unused disks
 		$conf->{$key} = $oldconf->{$key} if !defined($conf->{$key});
 	    }
 	    unlink($pct_cfg_fn);
-- 
2.1.4




More information about the pve-devel mailing list