Supports custom basemodels (model shown to QEMU, i.e. must be a default model), vendors and (host-)phys-bits for VMs with large amounts of RAM (see bug #2318).
Signed-off-by: Stefan Reiter <s.rei...@proxmox.com> --- PVE/QemuServer.pm | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 97fa955..417bea8 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -37,6 +37,7 @@ use PVE::QemuServer::PCI qw(print_pci_addr print_pcie_addr); use PVE::QemuServer::Memory; use PVE::QemuServer::USB qw(parse_usb_device); use PVE::QemuServer::Cloudinit; +use PVE::QemuServer::CustomCPUConfig; use PVE::SysFSTools; use PVE::Systemd; use Time::HiRes qw(gettimeofday); @@ -3595,10 +3596,30 @@ sub get_cpu_options { $cpu = 'cortex-a57'; } my $hv_vendor_id; + my $custom_cpu_config; if (my $cputype = $conf->{cpu}) { my $cpuconf = PVE::JSONSchema::parse_property_string($cpu_fmt, $cputype) or die "Cannot parse cpu description: $cputype\n"; $cpu = $cpuconf->{cputype}; + + if (!defined($cpu_vendor_list->{$cpu})) { + # not a default CPU model, read config and see if $cpu is name of + # a custom model + my $cpu_models = PVE::QemuServer::CustomCPUConfig::config_from_file(); + if ($cpu_models && ($custom_cpu_config = $cpu_models->get_model_by_name($cpu))) { + $cpu = $custom_cpu_config->{basemodel}; + + # 'basemodel' could be custom as well + while (!defined($cpu_vendor_list->{$cpu})) { + my $custom_base = $cpu_models->get_model_by_name($cpu); + die "unknown CPU basemodel: $cpu\n" if !$custom_base; + $cpu = $custom_base->{basemodel}; + } + } else { + die "unknown CPU model (neither default nor custom): $cpu\n"; + } + } + $kvm_off = 1 if $cpuconf->{hidden}; $hv_vendor_id = $cpuconf->{'hv-vendor-id'}; @@ -3628,13 +3649,22 @@ sub get_cpu_options { push @$cpuFlags, 'kvm=off' if $kvm_off; - if (my $cpu_vendor = $cpu_vendor_list->{$cpu}) { + if (defined($custom_cpu_config) && (my $custom_vendor = $custom_cpu_config->{vendor})) { + push @$cpuFlags, "vendor=${custom_vendor}" + if $custom_vendor ne 'default'; + } elsif (my $cpu_vendor = $cpu_vendor_list->{$cpu}) { push @$cpuFlags, "vendor=${cpu_vendor}" if $cpu_vendor ne 'default'; } elsif ($arch ne 'aarch64') { die "internal error"; # should not happen } + $cpu .= ",host-phys-bits=true" + if defined($custom_cpu_config) && $custom_cpu_config->{'host-phys-bits'}; + $cpu .= ",phys-bits=$custom_cpu_config->{'phys-bits'}" + if defined($custom_cpu_config) && $custom_cpu_config->{'phys-bits'} + && !$custom_cpu_config->{'host-phys-bits'}; + $cpu .= "," . join(',', @$cpuFlags) if scalar(@$cpuFlags); return ('-cpu', $cpu); -- 2.20.1 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel