[pve-devel] [PATCH container] create: don't skip arch detection on unpack errors

Wolfgang Bumiller w.bumiller at proxmox.com
Tue Dec 1 14:55:05 CET 2015


The -ignore-unpack-errors option needs to be taken into
account in restore_archive instead of restore_and_configure
as restore_archive is also responsible for arch detection.
---
 src/PVE/LXC/Create.pm | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/PVE/LXC/Create.pm b/src/PVE/LXC/Create.pm
index 1a1675e..53bcd2a 100644
--- a/src/PVE/LXC/Create.pm
+++ b/src/PVE/LXC/Create.pm
@@ -24,7 +24,7 @@ sub next_free_nbd_dev {
 }
 
 sub restore_archive {
-    my ($archive, $rootdir, $conf) = @_;
+    my ($archive, $rootdir, $conf, $no_unpack_error) = @_;
 
     my ($id_map, $rootuid, $rootgid) = PVE::LXC::parse_id_maps($conf);
     my $userns_cmd = PVE::LXC::userns_command($id_map);
@@ -43,11 +43,12 @@ sub restore_archive {
 
     if ($archive eq '-') {
 	print "extracting archive from STDIN\n";
-	PVE::Tools::run_command($cmd, input => "<&STDIN");
+	eval { PVE::Tools::run_command($cmd, input => "<&STDIN"); };
     } else {
 	print "extracting archive '$archive'\n";
-	PVE::Tools::run_command($cmd);
+	eval { PVE::Tools::run_command($cmd); };
     }
+    die $@ if $@ && !$no_unpack_error;
     
     # determine file type of /usr/bin/file itself to get guests' architecture
     $cmd = [@$userns_cmd, '/usr/bin/file', '-b', '-L', "$rootdir/usr/bin/file"];
@@ -135,8 +136,7 @@ sub recover_config {
 sub restore_and_configure {
     my ($vmid, $archive, $rootdir, $conf, $password, $restore, $no_unpack_error) = @_;
 
-    eval { restore_archive($archive, $rootdir, $conf) };
-    die $@ if $@ && !$no_unpack_error;
+    restore_archive($archive, $rootdir, $conf, $no_unpack_error);
 
     if (!$restore) {
 	my $lxc_setup = PVE::LXC::Setup->new($conf, $rootdir); # detect OS
-- 
2.1.4





More information about the pve-devel mailing list