]> git.proxmox.com Git - pve-common.git/commitdiff
tools: get_host_arch: return raw uname machine entry
authorStefan Reiter <s.reiter@proxmox.com>
Mon, 28 Oct 2019 11:59:13 +0000 (12:59 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 29 Oct 2019 06:13:54 +0000 (07:13 +0100)
The current version had only one user in LXC, so move the LXC-specific
code there to reuse this in QemuServer.

Also cache, since the host's architecture can't change during runtime.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
src/PVE/Tools.pm

index 550da09a609ddcf39f7999cc384bb312515192ed..c9d37ec9672aaf95a90a20001a065b0bba1b6005 100644 (file)
@@ -47,6 +47,7 @@ safe_print
 trim
 extract_param
 file_copy
+get_host_arch
 O_PATH
 O_TMPFILE
 );
@@ -1630,18 +1631,10 @@ sub readline_nointr {
     return $line;
 }
 
-sub get_host_arch {
-
-    my @uname = POSIX::uname();
-    my $machine = $uname[4];
-
-    if ($machine eq 'x86_64') {
-       return 'amd64';
-    } elsif ($machine eq 'aarch64') {
-       return 'arm64';
-    } else {
-       die "unsupported host architecture '$machine'\n";
-    }
+my $host_arch;
+sub get_host_arch() {
+    $host_arch = (POSIX::uname())[4] if !$host_arch;
+    return $host_arch;
 }
 
 # Devices are: [ (12 bits minor) (12 bits major) (8 bits minor) ]