* [pve-devel] [PATCH v3 qemu-server] Prevent starting a 32-bit VM using a 64-bit OVMF BIOS
@ 2023-12-12 10:58 Filip Schauer
2023-12-12 11:12 ` Fiona Ebner
0 siblings, 1 reply; 3+ messages in thread
From: Filip Schauer @ 2023-12-12 10:58 UTC (permalink / raw)
To: pve-devel
Instead of starting a VM with a 32-bit CPU type and a 64-bit OVMF image,
throw an error before starting the VM telling the user that OVMF is not
supported on 32-bit CPU types.
Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
---
Changes since v2:
* Simplify the check whether a 32-bit CPU type is used in combination
with OVMF
PVE/QemuServer.pm | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 2063e66..b25a3cd 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3570,6 +3570,16 @@ my sub print_ovmf_drive_commandlines {
return ("if=pflash,unit=0,format=raw,readonly=on,file=$ovmf_code", $var_drive_str);
}
+my @cputypes_32bit = (
+ '486',
+ 'pentium',
+ 'pentium2',
+ 'pentium3',
+ 'coreduo',
+ 'athlon',
+ 'kvm32',
+ 'qemu32',
+);
sub config_to_command {
my ($storecfg, $vmid, $conf, $defaults, $forcemachine, $forcecpu,
$pbs_backing) = @_;
@@ -3689,6 +3699,9 @@ sub config_to_command {
}
if ($conf->{bios} && $conf->{bios} eq 'ovmf') {
+ die "OVMF (UEFI) BIOS is not supported on 32-bit CPU types\n"
+ if ($conf->{cpu} && first {$_ eq $conf->{cpu}} @cputypes_32bit);
+
my ($code_drive_str, $var_drive_str) =
print_ovmf_drive_commandlines($conf, $storecfg, $vmid, $arch, $q35, $version_guard);
push $cmd->@*, '-drive', $code_drive_str;
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH v3 qemu-server] Prevent starting a 32-bit VM using a 64-bit OVMF BIOS
2023-12-12 10:58 [pve-devel] [PATCH v3 qemu-server] Prevent starting a 32-bit VM using a 64-bit OVMF BIOS Filip Schauer
@ 2023-12-12 11:12 ` Fiona Ebner
2023-12-13 17:00 ` Filip Schauer
0 siblings, 1 reply; 3+ messages in thread
From: Fiona Ebner @ 2023-12-12 11:12 UTC (permalink / raw)
To: Proxmox VE development discussion, Filip Schauer
Am 12.12.23 um 11:58 schrieb Filip Schauer:
> Instead of starting a VM with a 32-bit CPU type and a 64-bit OVMF image,
> throw an error before starting the VM telling the user that OVMF is not
> supported on 32-bit CPU types.
>
> Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
> ---
> Changes since v2:
> * Simplify the check whether a 32-bit CPU type is used in combination
> with OVMF
>
Yes, it's much nicer than extending the EFI-related functions with new
parameters :)
> PVE/QemuServer.pm | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 2063e66..b25a3cd 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -3570,6 +3570,16 @@ my sub print_ovmf_drive_commandlines {
> return ("if=pflash,unit=0,format=raw,readonly=on,file=$ovmf_code", $var_drive_str);
> }
>
> +my @cputypes_32bit = (
> + '486',
> + 'pentium',
> + 'pentium2',
> + 'pentium3',
> + 'coreduo',
> + 'athlon',
> + 'kvm32',
> + 'qemu32',
> +);
I'd like to put this list in CPUConfig.pm and have a small helper
function there. The QemuServer.pm module already has way too many
functions and variables ;) And since it's only used for lookup, maybe
using a hash is better?
A short comment in the commit message about how you got the list would
be nice too (I just checked for absence of CPUID_EXT2_LM in
target/i386/cpu.c to verify your list).
> sub config_to_command {
> my ($storecfg, $vmid, $conf, $defaults, $forcemachine, $forcecpu,
> $pbs_backing) = @_;
> @@ -3689,6 +3699,9 @@ sub config_to_command {
> }
>
> if ($conf->{bios} && $conf->{bios} eq 'ovmf') {
> + die "OVMF (UEFI) BIOS is not supported on 32-bit CPU types\n"
> + if ($conf->{cpu} && first {$_ eq $conf->{cpu}} @cputypes_32bit);
Style nit: usually we don't have parentheses for post-if
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH v3 qemu-server] Prevent starting a 32-bit VM using a 64-bit OVMF BIOS
2023-12-12 11:12 ` Fiona Ebner
@ 2023-12-13 17:00 ` Filip Schauer
0 siblings, 0 replies; 3+ messages in thread
From: Filip Schauer @ 2023-12-13 17:00 UTC (permalink / raw)
To: Fiona Ebner, Proxmox VE development discussion
Patch v5 is available:
https://lists.proxmox.com/pipermail/pve-devel/2023-December/061079.html
On 12/12/2023 12:12, Fiona Ebner wrote:
> Am 12.12.23 um 11:58 schrieb Filip Schauer:
>> Instead of starting a VM with a 32-bit CPU type and a 64-bit OVMF image,
>> throw an error before starting the VM telling the user that OVMF is not
>> supported on 32-bit CPU types.
>>
>> Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
>> ---
>> Changes since v2:
>> * Simplify the check whether a 32-bit CPU type is used in combination
>> with OVMF
>>
> Yes, it's much nicer than extending the EFI-related functions with new
> parameters :)
>
>> PVE/QemuServer.pm | 13 +++++++++++++
>> 1 file changed, 13 insertions(+)
>>
>> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
>> index 2063e66..b25a3cd 100644
>> --- a/PVE/QemuServer.pm
>> +++ b/PVE/QemuServer.pm
>> @@ -3570,6 +3570,16 @@ my sub print_ovmf_drive_commandlines {
>> return ("if=pflash,unit=0,format=raw,readonly=on,file=$ovmf_code", $var_drive_str);
>> }
>>
>> +my @cputypes_32bit = (
>> + '486',
>> + 'pentium',
>> + 'pentium2',
>> + 'pentium3',
>> + 'coreduo',
>> + 'athlon',
>> + 'kvm32',
>> + 'qemu32',
>> +);
> I'd like to put this list in CPUConfig.pm and have a small helper
> function there. The QemuServer.pm module already has way too many
> functions and variables ;) And since it's only used for lookup, maybe
> using a hash is better?
>
> A short comment in the commit message about how you got the list would
> be nice too (I just checked for absence of CPUID_EXT2_LM in
> target/i386/cpu.c to verify your list).
>
>> sub config_to_command {
>> my ($storecfg, $vmid, $conf, $defaults, $forcemachine, $forcecpu,
>> $pbs_backing) = @_;
>> @@ -3689,6 +3699,9 @@ sub config_to_command {
>> }
>>
>> if ($conf->{bios} && $conf->{bios} eq 'ovmf') {
>> + die "OVMF (UEFI) BIOS is not supported on 32-bit CPU types\n"
>> + if ($conf->{cpu} && first {$_ eq $conf->{cpu}} @cputypes_32bit);
> Style nit: usually we don't have parentheses for post-if
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-13 17:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-12 10:58 [pve-devel] [PATCH v3 qemu-server] Prevent starting a 32-bit VM using a 64-bit OVMF BIOS Filip Schauer
2023-12-12 11:12 ` Fiona Ebner
2023-12-13 17:00 ` Filip Schauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox