From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 19B80B9957 for ; Mon, 11 Dec 2023 15:13:34 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E7CAA181DA for ; Mon, 11 Dec 2023 15:13:03 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 11 Dec 2023 15:13:03 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id EBFA8455EE for ; Mon, 11 Dec 2023 15:13:02 +0100 (CET) From: Filip Schauer To: pve-devel@lists.proxmox.com Date: Mon, 11 Dec 2023 15:12:56 +0100 Message-Id: <20231211141256.27565-1-f.schauer@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.183 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH qemu-server] Properly identify the CPU architecture of 32-bit VMs X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Dec 2023 14:13:34 -0000 Add an i386 CPU architecture which is used when a 32 bit CPU type is detected. This now prevents starting a 32-bit VM using a 64-bit OVMF BIOS. Instead it throws the error, "no OVMF images known for architecture 'i386'", triggered in get_ovmf_file. This behaviour is intended since we do not support 32 bit OVMF images. Signed-off-by: Filip Schauer --- PVE/QemuServer.pm | 8 +++++--- PVE/QemuServer/CPUConfig.pm | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 2063e66..54590df 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -52,7 +52,7 @@ 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); +use PVE::QemuServer::CPUConfig qw(print_cpu_device get_cpu_options cpu_type_to_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); @@ -649,7 +649,7 @@ EODESCR description => "Virtual processor architecture. Defaults to the host.", optional => 1, type => 'string', - enum => [qw(x86_64 aarch64)], + enum => [qw(x86_64 i386 aarch64)], }, smbios1 => { description => "Specify SMBIOS type 1 fields.", @@ -3293,11 +3293,12 @@ sub is_native($) { sub get_vm_arch { my ($conf) = @_; - return $conf->{arch} // get_host_arch(); + return $conf->{arch} // cpu_type_to_arch($conf->{cpu}) // get_host_arch(); } my $default_machines = { x86_64 => 'pc', + i386 => 'pc', aarch64 => 'virt', }; @@ -3390,6 +3391,7 @@ sub get_ovmf_files($$$) { my $Arch2Qemu = { aarch64 => '/usr/bin/qemu-system-aarch64', + i386 => '/usr/bin/qemu-system-i386', x86_64 => '/usr/bin/qemu-system-x86_64', }; sub get_command_for_arch($) { diff --git a/PVE/QemuServer/CPUConfig.pm b/PVE/QemuServer/CPUConfig.pm index 750d3b6..cc71298 100644 --- a/PVE/QemuServer/CPUConfig.pm +++ b/PVE/QemuServer/CPUConfig.pm @@ -3,6 +3,8 @@ package PVE::QemuServer::CPUConfig; use strict; use warnings; +use List::Util qw(first); + use PVE::JSONSchema; use PVE::Cluster qw(cfs_register_file cfs_read_file); use PVE::QemuServer::Helpers qw(min_version); @@ -12,6 +14,7 @@ use base qw(PVE::SectionConfig Exporter); our @EXPORT_OK = qw( print_cpu_device get_cpu_options +cpu_type_to_arch ); # under certain race-conditions, this module might be loaded before pve-cluster @@ -57,6 +60,17 @@ my $depreacated_cpu_map = { 'Icelake-Client-noTSX' => 'Icelake-Server-noTSX', }; +my @cpu_32bit_list = ( + '486', + 'pentium', + 'pentium2', + 'pentium3', + 'coreduo', + 'athlon', + 'kvm32', + 'qemu32', +); + my $cpu_vendor_list = { # Intel CPUs 486 => 'GenuineIntel', @@ -646,6 +660,20 @@ sub get_pve_cpu_flags { return $pve_flags; } +sub cpu_type_to_arch { + my ($cputype) = @_; + + if ($cputype) { + if (first {$_ eq $cputype} @cpu_32bit_list) { + return 'i386'; + } elsif ($cpu_vendor_list->{$cputype}) { + return 'x86_64'; + } + } + + return undef; +} + sub get_hyperv_enlightenments { my ($winversion, $machine_version, $bios, $gpu_passthrough, $hv_vendor_id) = @_; -- 2.39.2