From 5a7a51d0ca6feca3c1bdf3189413c289e3b63739 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 7 Jan 2019 15:32:42 +0100 Subject: [PATCH] only recover id mapping on restore Signed-off-by: Wolfgang Bumiller --- src/PVE/API2/LXC.pm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm index 70b1906..873e70f 100644 --- a/src/PVE/API2/LXC.pm +++ b/src/PVE/API2/LXC.pm @@ -360,13 +360,16 @@ __PACKAGE__->register_method({ PVE::Cluster::check_cfs_quorum(); my $vollist = []; eval { - my ($orig_conf, $orig_mp_param) = PVE::LXC::Create::recover_config($archive); - if ($is_root) { - # When we're root call 'restore_configuration' with ristricted=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}}]; + my $orig_mp_param; # only used if $restore + if ($restore) { + (my $orig_conf, $orig_mp_param) = PVE::LXC::Create::recover_config($archive); + if ($is_root) { + # When we're root call 'restore_configuration' with ristricted=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}}]; + } } if ($storage_only_mode) { if ($restore) { -- 2.39.2