[pve-devel] [PATCH common 1/1] tools: add is_native_arch to compare the CPU architecture

Filip Schauer f.schauer at proxmox.com
Wed Feb 21 15:33:12 CET 2024


Add an is_native_arch($arch) subroutine to compare a CPU architecture to
the host CPU architecture. This is brought in from PVE::QemuServer.

Signed-off-by: Filip Schauer <f.schauer at proxmox.com>
---
 src/PVE/Tools.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
index 766c809..234f16a 100644
--- a/src/PVE/Tools.pm
+++ b/src/PVE/Tools.pm
@@ -52,6 +52,7 @@ extract_param
 extract_sensitive_params
 file_copy
 get_host_arch
+is_native_arch
 O_PATH
 O_TMPFILE
 AT_EMPTY_PATH
@@ -1841,6 +1842,11 @@ sub get_host_arch {
     return $host_arch;
 }
 
+sub is_native_arch($) {
+    my ($arch) = @_;
+    return get_host_arch() eq $arch;
+}
+
 # Devices are: [ (12 bits minor) (12 bits major) (8 bits minor) ]
 sub dev_t_major($) {
     my ($dev_t) = @_;
-- 
2.39.2





More information about the pve-devel mailing list