]> git.proxmox.com Git - pve-container.git/commitdiff
fix #2270: allow custom lxc options to be restored as root
authorStefan Reiter <s.reiter@proxmox.com>
Tue, 9 Jul 2019 15:20:57 +0000 (17:20 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 9 Jul 2019 18:06:18 +0000 (20:06 +0200)
Seems to be a regression introduced with
f360d7f16b094fa258cf82d2557d06f3284435e4 (related to #2028).
$conf->{'lxc'} would always be defined, hence we never replaced it with
the restored options.

Co-developed-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
src/PVE/LXC/Create.pm

index 029c940396798c5ea91656f02adfde04b30b855f..ee83052a3d454298f63c48c2501c19b0aa843261 100644 (file)
@@ -175,16 +175,22 @@ sub restore_configuration {
            # we know if it was a template in the restore API call and check if the target
            # storage supports creating a template there
            next if $key =~ /^template$/;
-           if ($restricted && $key eq 'lxc') {
-               warn "skipping custom lxc options, restore manually as root:\n";
-               warn "--------------------------------\n";
+
+           if ($key eq 'lxc') {
                my $lxc_list = $oldconf->{'lxc'};
-               foreach my $lxc_opt (@$lxc_list) {
-                   warn "$lxc_opt->[0]: $lxc_opt->[1]\n"
+               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 "--------------------------------\n";
                next;
            }
+
            if ($unique && $key =~ /^net\d+$/) {
                my $net = PVE::LXC::Config->parse_lxc_network($oldconf->{$key});
                my $dc = PVE::Cluster::cfs_read_file('datacenter.cfg');