[pve-devel] applied: [PATCH RESEND container] restore lxc.* entries once

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Sep 30 11:38:02 CEST 2019


either via recover_config, OR via restore_configuration. non-root behaviour stays the same.

Tested-by: Oguz Bektas <o.bektas at proxmox.com>
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
Note: added Tested-by

 src/PVE/API2/LXC.pm   |  4 ++--
 src/PVE/LXC/Create.pm | 16 ++++++----------
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 07280fb..28c9047 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -353,11 +353,11 @@ __PACKAGE__->register_method({
 			my $orig_conf;
 			($orig_conf, $orig_mp_param) = PVE::LXC::Create::recover_config($archive);
 			$was_template = delete $orig_conf->{template};
-			# When we're root call 'restore_configuration' with ristricted=0,
+			# When we're root call 'restore_configuration' with restricted=0,
 			# causing it to restore the raw lxc entries, among which there may be
 			# 'lxc.idmap' entries. We need to make sure that the extracted contents
 			# of the container match up with the restored configuration afterwards:
-			$conf->{lxc} = [grep { $_->[0] eq 'lxc.idmap' } @{$orig_conf->{lxc}}];
+			$conf->{lxc} = $orig_conf->{lxc};
 		    }
 		}
 		if ($storage_only_mode) {
diff --git a/src/PVE/LXC/Create.pm b/src/PVE/LXC/Create.pm
index a46a50c..241ca88 100644
--- a/src/PVE/LXC/Create.pm
+++ b/src/PVE/LXC/Create.pm
@@ -176,18 +176,14 @@ sub restore_configuration {
 	    # storage supports creating a template there
 	    next if $key =~ /^template$/;
 
-	    if ($key eq 'lxc') {
+	    if ($key eq 'lxc' && $restricted) {
 		my $lxc_list = $oldconf->{'lxc'};
-		if ($restricted) {
-		    warn "skipping custom lxc options, restore manually as root:\n";
-		    warn "--------------------------------\n";
-		    foreach my $lxc_opt (@$lxc_list) {
-			warn "$lxc_opt->[0]: $lxc_opt->[1]\n"
-		    }
-		    warn "--------------------------------\n";
-		} else {
-		    @{$conf->{$key}} = (@$lxc_list, @{$conf->{$key}});
+		warn "skipping custom lxc options, restore manually as root:\n";
+		warn "--------------------------------\n";
+		foreach my $lxc_opt (@$lxc_list) {
+		    warn "$lxc_opt->[0]: $lxc_opt->[1]\n"
 		}
+		warn "--------------------------------\n";
 		next;
 	    }
 
-- 
2.20.1





More information about the pve-devel mailing list