]> git.proxmox.com Git - pve-container.git/blobdiff - src/PVE/LXC/Setup.pm
backup: log errors from rsync
[pve-container.git] / src / PVE / LXC / Setup.pm
index 891231f0dce666ef9544109def253d0d42a8422b..5c9114cd1bcbc612af15feb876f11f00742967d5 100644 (file)
@@ -124,11 +124,29 @@ sub new {
     $plugin->{host_localtime} = $1;
 
     # pass on user namespace information:
-    my ($id_map, $rootuid, $rootgid) = PVE::LXC::parse_id_maps($conf);
+    my ($id_map, $root_uid, $root_gid) = PVE::LXC::parse_id_maps($conf);
     if (@$id_map) {
        $plugin->{id_map} = $id_map;
-       $plugin->{rootuid} = $rootuid;
-       $plugin->{rootgid} = $rootgid;
+       $plugin->{root_uid} = $root_uid;
+       $plugin->{root_gid} = $root_gid;
+    }
+
+    # if arch is unset, we try to autodetect it
+    if (!defined($conf->{arch})) {
+       my $arch = eval { $self->protected_call(sub { $plugin->detect_architecture() }) };
+
+       if (my $err = $@) {
+           warn "Architecture detection failed: $err" if $err;
+       }
+
+       if (!defined($arch)) {
+           $arch = 'amd64';
+           print "Falling back to $arch.\nUse `pct set VMID --arch ARCH` to change.\n";
+       } else {
+           print "Detected container architecture: $arch\n";
+       }
+
+       $conf->{arch} = $arch;
     }
 
     return $self;