move get_vm_arch() helper to helpers module

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fiona Ebner 2025-01-17 15:24:18 +01:00 committed by Thomas Lamprecht
parent 1715febd33
commit 82dff842f0
3 changed files with 11 additions and 11 deletions

View File

@ -1198,7 +1198,7 @@ __PACKAGE__->register_method({
my $realcmd = sub { my $realcmd = sub {
my $conf = $param; my $conf = $param;
my $arch = PVE::QemuServer::get_vm_arch($conf); my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
for my $opt (sort keys $param->%*) { for my $opt (sort keys $param->%*) {
next if $opt !~ m/^scsi\d+$/; next if $opt !~ m/^scsi\d+$/;
@ -2034,7 +2034,7 @@ my $update_vm_api = sub {
$conf = PVE::QemuConfig->load_config($vmid); # update/reload $conf = PVE::QemuConfig->load_config($vmid); # update/reload
next if defined($conf->{pending}->{$opt}) && ($param->{$opt} eq $conf->{pending}->{$opt}); # skip if nothing changed next if defined($conf->{pending}->{$opt}) && ($param->{$opt} eq $conf->{pending}->{$opt}); # skip if nothing changed
my $arch = PVE::QemuServer::get_vm_arch($conf); my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
if (PVE::QemuServer::is_valid_drivename($opt)) { if (PVE::QemuServer::is_valid_drivename($opt)) {
# old drive # old drive

View File

@ -3271,11 +3271,6 @@ sub vga_conf_has_spice {
return $1 || 1; return $1 || 1;
} }
sub get_vm_arch {
my ($conf) = @_;
return $conf->{arch} // get_host_arch();
}
my $default_machines = { my $default_machines = {
x86_64 => 'pc', x86_64 => 'pc',
aarch64 => 'virt', aarch64 => 'virt',
@ -3590,7 +3585,7 @@ sub config_to_command {
my $machine_conf = PVE::QemuServer::Machine::parse_machine($conf->{machine}); my $machine_conf = PVE::QemuServer::Machine::parse_machine($conf->{machine});
my $arch = get_vm_arch($conf); my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
my $kvm_binary = PVE::QemuServer::Helpers::get_command_for_arch($arch); my $kvm_binary = PVE::QemuServer::Helpers::get_command_for_arch($arch);
my $kvmver = kvm_user_version($kvm_binary); my $kvmver = kvm_user_version($kvm_binary);
@ -4670,7 +4665,7 @@ sub qemu_cpu_hotplug {
if scalar(@{$currentrunningvcpus}) != $currentvcpus; if scalar(@{$currentrunningvcpus}) != $currentvcpus;
if (PVE::QemuServer::Machine::machine_version($machine_type, 2, 7)) { if (PVE::QemuServer::Machine::machine_version($machine_type, 2, 7)) {
my $arch = get_vm_arch($conf); my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
for (my $i = $currentvcpus+1; $i <= $vcpus; $i++) { for (my $i = $currentvcpus+1; $i <= $vcpus; $i++) {
my $cpustr = print_cpu_device($conf, $arch, $i); my $cpustr = print_cpu_device($conf, $arch, $i);
@ -4912,7 +4907,7 @@ sub vmconfig_hotplug_pending {
my ($vmid, $conf, $storecfg, $selection, $errors) = @_; my ($vmid, $conf, $storecfg, $selection, $errors) = @_;
my $defaults = load_defaults(); my $defaults = load_defaults();
my $arch = get_vm_arch($conf); my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
my $machine_type = get_vm_machine($conf, undef, $arch); my $machine_type = get_vm_machine($conf, undef, $arch);
# commit values which do not have any impact on running VM first # commit values which do not have any impact on running VM first
@ -8493,7 +8488,7 @@ sub qemu_use_old_bios_files {
sub get_efivars_size { sub get_efivars_size {
my ($conf, $efidisk) = @_; my ($conf, $efidisk) = @_;
my $arch = get_vm_arch($conf); my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
$efidisk //= $conf->{efidisk0} ? parse_drive('efidisk0', $conf->{efidisk0}) : undef; $efidisk //= $conf->{efidisk0} ? parse_drive('efidisk0', $conf->{efidisk0}) : undef;
my $smm = PVE::QemuServer::Machine::machine_type_is_q35($conf); my $smm = PVE::QemuServer::Machine::machine_type_is_q35($conf);
my (undef, $ovmf_vars) = get_ovmf_files($arch, $efidisk, $smm); my (undef, $ovmf_vars) = get_ovmf_files($arch, $efidisk, $smm);

View File

@ -34,6 +34,11 @@ sub get_command_for_arch($) {
return $cmd; return $cmd;
} }
sub get_vm_arch {
my ($conf) = @_;
return $conf->{arch} // get_host_arch();
}
my $kvm_user_version = {}; my $kvm_user_version = {};
my $kvm_mtime = {}; my $kvm_mtime = {};