From 5ebb6018ed757236eeac94dc8a9f522c0d8a54c8 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 8 Mar 2024 15:06:25 +0100 Subject: [PATCH] cpu config: implement is_native_arch locally for now could be a better fit in PVE::Tools, like proposed by Filip, but OTOH. Tools is already crowded as is, so wait if we need it on more places outside of qemu-server. Signed-off-by: Thomas Lamprecht --- PVE/QemuServer.pm | 4 ++-- PVE/QemuServer/CPUConfig.pm | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 1fbc8e65..f9099dc6 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -45,14 +45,14 @@ use PVE::RPCEnvironment; use PVE::Storage; use PVE::SysFSTools; use PVE::Systemd; -use PVE::Tools qw(run_command file_read_firstline file_get_contents dir_glob_foreach get_host_arch is_native_arch $IPV6RE); +use PVE::Tools qw(run_command file_read_firstline file_get_contents dir_glob_foreach get_host_arch $IPV6RE); use PVE::QMPClient; use PVE::QemuConfig; use PVE::QemuServer::Helpers qw(config_aware_timeout min_version windows_version); use PVE::QemuServer::Cloudinit; use PVE::QemuServer::CGroup; -use PVE::QemuServer::CPUConfig qw(print_cpu_device get_cpu_options get_cpu_bitness); +use PVE::QemuServer::CPUConfig qw(print_cpu_device get_cpu_options get_cpu_bitness is_native_arch); use PVE::QemuServer::Drive qw(is_valid_drivename drive_is_cloudinit drive_is_cdrom drive_is_read_only parse_drive print_drive); use PVE::QemuServer::Machine; use PVE::QemuServer::Memory qw(get_current_memory); diff --git a/PVE/QemuServer/CPUConfig.pm b/PVE/QemuServer/CPUConfig.pm index 7d471f4b..7e574883 100644 --- a/PVE/QemuServer/CPUConfig.pm +++ b/PVE/QemuServer/CPUConfig.pm @@ -5,7 +5,7 @@ use warnings; use PVE::JSONSchema; use PVE::Cluster qw(cfs_register_file cfs_read_file); -use PVE::Tools qw(is_native_arch); +use PVE::Tools qw(get_host_arch); use PVE::QemuServer::Helpers qw(min_version); use base qw(PVE::SectionConfig Exporter); @@ -14,6 +14,7 @@ our @EXPORT_OK = qw( print_cpu_device get_cpu_options get_cpu_bitness +is_native_arch ); # under certain race-conditions, this module might be loaded before pve-cluster @@ -738,6 +739,11 @@ sub get_default_cpu_type { return $cputype; } +sub is_native_arch($) { + my ($arch) = @_; + return get_host_arch() eq $arch; +} + sub get_cpu_bitness { my ($cpu_prop_str, $arch) = @_;