]> git.proxmox.com Git - pve-container.git/blobdiff - src/PVE/LXC/Setup.pm
d/copyright: update years
[pve-container.git] / src / PVE / LXC / Setup.pm
index 4f602f026a3386628564c4bab891e342a297f62c..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;
@@ -340,11 +358,7 @@ sub get_ct_init_path {
     my ($self) = @_;
 
     my $init = $self->protected_call(sub {
-       my $init_path = "/sbin/init";
-       if ($self->{plugin}->ct_is_symlink($init_path)) {
-           $init_path = $self->{plugin}->ct_readlink($init_path);
-       }
-       return $init_path;
+       return $self->{plugin}->get_ct_init_path();
     });
 
     return $init;