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 <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2024-03-08 15:06:25 +01:00
parent c7c2e4dbd1
commit 5ebb6018ed
2 changed files with 9 additions and 3 deletions

View File

@ -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);

View File

@ -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) = @_;