[pve-devel] [PATCH common 1/1] tools: Add is_native sub to compare the CPU architecture

Filip Schauer f.schauer at proxmox.com
Tue Dec 19 10:40:19 CET 2023


Add an is_native($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..7bb1809 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
 O_PATH
 O_TMPFILE
 AT_EMPTY_PATH
@@ -1841,6 +1842,11 @@ sub get_host_arch {
     return $host_arch;
 }
 
+sub is_native($) {
+    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