From: Wolfgang Bumiller Date: Thu, 12 Nov 2015 13:00:28 +0000 (+0100) Subject: vzdump: userns support X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=01dce99b82314690a92952b5e4128735a944a3ce;p=pve-container.git vzdump: userns support --- diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index 07ac4fc..ccab284 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -2411,4 +2411,12 @@ sub parse_id_maps { return ($id_map, $rootuid, $rootgid); } +sub userns_command { + my ($id_map) = @_; + if (@$id_map) { + return ['lxc-usernsexec', (map { ('-m', join(':', @$_)) } @$id_map), '--']; + } + return []; +} + 1; diff --git a/src/PVE/LXC/Create.pm b/src/PVE/LXC/Create.pm index cb9c85a..b146ea7 100644 --- a/src/PVE/LXC/Create.pm +++ b/src/PVE/LXC/Create.pm @@ -25,11 +25,9 @@ sub next_free_nbd_dev { sub restore_archive { my ($archive, $rootdir, $conf) = @_; - my $userns_cmd = []; - my ($id_map, $rootuid, $rootgid) = PVE::LXC::parse_id_maps($conf); + my $userns_cmd = PVE::LXC::userns_command($id_map); if (@$id_map) { - $userns_cmd = ['lxc-usernsexec', (map { ('-m', join(':', @$_)) } @$id_map), '--']; PVE::Tools::run_command(['chown', '-R', "$rootuid:$rootgid", $rootdir]); } diff --git a/src/PVE/VZDump/LXC.pm b/src/PVE/VZDump/LXC.pm index f138588..72ad9c0 100644 --- a/src/PVE/VZDump/LXC.pm +++ b/src/PVE/VZDump/LXC.pm @@ -105,6 +105,9 @@ sub prepare { $task->{hostname} = $conf->{'hostname'} || "CT$vmid"; + my ($id_map, $rootuid, $rootgid) = PVE::LXC::parse_id_maps($conf); + $task->{userns_cmd} = PVE::LXC::userns_command($id_map); + PVE::LXC::foreach_mountpoint($conf, sub { my ($name, $data) = @_; my $volid = $data->{volume}; @@ -278,7 +281,8 @@ sub archive { my $snapdir = $task->{snapdir}; my $tmpdir = $task->{tmpdir}; - my $tar = ['tar', 'cpf', '-', '--totals', + my $userns_cmd = $task->{userns_cmd}; + my $tar = [@$userns_cmd, 'tar', 'cpf', '-', '--totals', @$PVE::LXC::COMMON_TAR_FLAGS, '--one-file-system', '--warning=no-file-ignored'];