all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH-SERIES qemu-server 0/3] fix #7014: fix regression starting aarch64 VMs with machine type >= 10.1
@ 2025-11-12 11:29 Fiona Ebner
  2025-11-12 11:29 ` [pve-devel] [PATCH qemu-server 1/3] machine: add machine_base_type() helper Fiona Ebner
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Fiona Ebner @ 2025-11-12 11:29 UTC (permalink / raw)
  To: pve-devel

The 'virt' machine type used for 'aarch64' does not support the 'hpet'
machine flag. Add the flag only if supported by the current machine
type.

qemu-server:

Fiona Ebner (3):
  machine: add machine_base_type() helper
  machine: add machine_supports_flag() helper
  fix #7014: fix regression starting aarch64 VMs with machine type >=
    10.1

 src/PVE/QemuServer.pm               |  3 +-
 src/PVE/QemuServer/Cfg2Cmd.pm       | 26 +++++++++++--
 src/PVE/QemuServer/Cfg2Cmd/Timer.pm |  4 +-
 src/PVE/QemuServer/Machine.pm       | 57 ++++++++++++++++++++++++++++-
 4 files changed, 82 insertions(+), 8 deletions(-)


Summary over all repositories:
  4 files changed, 82 insertions(+), 8 deletions(-)

-- 
Generated by git-murpp 0.5.0


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pve-devel] [PATCH qemu-server 1/3] machine: add machine_base_type() helper
  2025-11-12 11:29 [pve-devel] [PATCH-SERIES qemu-server 0/3] fix #7014: fix regression starting aarch64 VMs with machine type >= 10.1 Fiona Ebner
@ 2025-11-12 11:29 ` Fiona Ebner
  2025-11-12 11:29 ` [pve-devel] [PATCH qemu-server 2/3] machine: add machine_supports_flag() helper Fiona Ebner
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Fiona Ebner @ 2025-11-12 11:29 UTC (permalink / raw)
  To: pve-devel

Use the helper for machine_type_is_q35() to start out. The plan is to
re-use the helper for a function checking which machine flags are
supported for a given machine type.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/QemuServer/Machine.pm | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/PVE/QemuServer/Machine.pm b/src/PVE/QemuServer/Machine.pm
index b2ff7e24..7a401087 100644
--- a/src/PVE/QemuServer/Machine.pm
+++ b/src/PVE/QemuServer/Machine.pm
@@ -142,11 +142,34 @@ sub assert_valid_machine_property {
         if $machine_conf->{'aw-bits'} && !$machine_conf->{viommu};
 }
 
+=head3 machine_base_type
+
+    my $base_type = machine_base_type($machine_type);
+
+Returns the base type of the machine, currently either C<i440fx>, C<q35> or C<virt>. A value must be
+passed in. Dies if the machine type cannot be determined, but should not happen if it is valid for
+the C<$machine_fmt> schema.
+
+=cut
+
+my sub machine_base_type {
+    my ($machine_type) = @_;
+
+    die "unable to determine machine base type - no value\n" if !$machine_type;
+
+    return 'q35' if $machine_type =~ m/q35/;
+    return 'i440fx' if $machine_type =~ m/^pc/;
+    return 'virt' if $machine_type =~ m/^virt/;
+
+    die "unable to determine machine base type '$machine_type'\n";
+}
+
 sub machine_type_is_q35 {
     my ($conf) = @_;
 
     my $machine_conf = parse_machine($conf->{machine});
-    return $machine_conf->{type} && ($machine_conf->{type} =~ m/q35/) ? 1 : 0;
+    return 0 if !$machine_conf || !$machine_conf->{type};
+    return machine_base_type($machine_conf->{type}) eq 'q35' ? 1 : 0;
 }
 
 # In list context, also returns whether the current machine is deprecated or not.
-- 
2.47.3



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pve-devel] [PATCH qemu-server 2/3] machine: add machine_supports_flag() helper
  2025-11-12 11:29 [pve-devel] [PATCH-SERIES qemu-server 0/3] fix #7014: fix regression starting aarch64 VMs with machine type >= 10.1 Fiona Ebner
  2025-11-12 11:29 ` [pve-devel] [PATCH qemu-server 1/3] machine: add machine_base_type() helper Fiona Ebner
@ 2025-11-12 11:29 ` Fiona Ebner
  2025-11-12 11:29 ` [pve-devel] [PATCH qemu-server 3/3] fix #7014: fix regression starting aarch64 VMs with machine type >= 10.1 Fiona Ebner
  2025-11-13 22:13 ` [pve-devel] applied: [PATCH-SERIES qemu-server 0/3] " Thomas Lamprecht
  3 siblings, 0 replies; 6+ messages in thread
From: Fiona Ebner @ 2025-11-12 11:29 UTC (permalink / raw)
  To: pve-devel

Starting out with the 'hpet' flag, to be able to check it when
generating the timer commandline in a future commit.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/QemuServer/Machine.pm | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/src/PVE/QemuServer/Machine.pm b/src/PVE/QemuServer/Machine.pm
index 7a401087..ece90e80 100644
--- a/src/PVE/QemuServer/Machine.pm
+++ b/src/PVE/QemuServer/Machine.pm
@@ -172,6 +172,38 @@ sub machine_type_is_q35 {
     return machine_base_type($machine_conf->{type}) eq 'q35' ? 1 : 0;
 }
 
+# When you need to check a new flag, extend here and the POD for machine_supports_flag().
+my $supported_machine_flags = {
+    i440fx => {
+        hpet => 1,
+    },
+    q35 => {
+        hpet => 1,
+    },
+    virt => {},
+};
+
+=head3 machine_supports_flag
+
+    if (machine_supports_flag($machine_type, $flag)) {
+        push $machine_flags->@*, $flag;
+    }
+
+Check whether the machine type C<$machine_type> supports the machine flag C<$flag>. Both arguments
+must have a value. Flags which can be checked currently: C<hpet>.
+
+=cut
+
+sub machine_supports_flag {
+    my ($machine_type, $flag) = @_;
+
+    die "cannot check machine flag support - no machine type provided\n" if !$machine_type;
+    die "cannot check machine flag support - no flag provided\n" if !$flag;
+
+    my $base_type = machine_base_type($machine_type);
+    return $supported_machine_flags->{$base_type}->{$flag};
+}
+
 # In list context, also returns whether the current machine is deprecated or not.
 sub current_from_query_machines {
     my ($machines) = @_;
-- 
2.47.3



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pve-devel] [PATCH qemu-server 3/3] fix #7014: fix regression starting aarch64 VMs with machine type >= 10.1
  2025-11-12 11:29 [pve-devel] [PATCH-SERIES qemu-server 0/3] fix #7014: fix regression starting aarch64 VMs with machine type >= 10.1 Fiona Ebner
  2025-11-12 11:29 ` [pve-devel] [PATCH qemu-server 1/3] machine: add machine_base_type() helper Fiona Ebner
  2025-11-12 11:29 ` [pve-devel] [PATCH qemu-server 2/3] machine: add machine_supports_flag() helper Fiona Ebner
@ 2025-11-12 11:29 ` Fiona Ebner
  2025-11-12 11:52   ` Fiona Ebner
  2025-11-13 22:13 ` [pve-devel] applied: [PATCH-SERIES qemu-server 0/3] " Thomas Lamprecht
  3 siblings, 1 reply; 6+ messages in thread
From: Fiona Ebner @ 2025-11-12 11:29 UTC (permalink / raw)
  To: pve-devel

The 'virt' machine type used for 'aarch64' does not support the 'hpet'
machine flag. Change add_machine_flag() to only add the flag when the
current machine type supports it and rename the method to
add_machine_flag_if_supported() to make the behavior obvious from the
name. If a future caller really depends on adding a specific flag and
would rather die when the machine type does not support it, it can
check the return value whether the flag was successfully added or not.

Fixes: 3a4e0144 ("cfg2cmd: turn off hpet for Linux VMs running at least kernel 2.6 and machine type >= 10.1")
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/QemuServer.pm               |  3 ++-
 src/PVE/QemuServer/Cfg2Cmd.pm       | 26 ++++++++++++++++++++++----
 src/PVE/QemuServer/Cfg2Cmd/Timer.pm |  4 ++--
 3 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index cf195ccc..9abcd5bf 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -3388,7 +3388,8 @@ sub config_to_command {
     }
 
     # For now, handles only specific parts, but the final goal is to cover everything.
-    my $cfg2cmd = PVE::QemuServer::Cfg2Cmd->new($conf, $defaults, $version_guard);
+    my $cfg2cmd_opts = { forcemachine => $forcemachine };
+    my $cfg2cmd = PVE::QemuServer::Cfg2Cmd->new($conf, $defaults, $version_guard, $cfg2cmd_opts);
     my $generated = $cfg2cmd->generate();
     push $cmd->@*, '-global', $_ for ($generated->global_flags() // [])->@*;
     push $machineFlags->@*, ($generated->machine_flags() // [])->@*;
diff --git a/src/PVE/QemuServer/Cfg2Cmd.pm b/src/PVE/QemuServer/Cfg2Cmd.pm
index c7ee0165..36149aba 100644
--- a/src/PVE/QemuServer/Cfg2Cmd.pm
+++ b/src/PVE/QemuServer/Cfg2Cmd.pm
@@ -5,9 +5,10 @@ use strict;
 
 use PVE::QemuServer::Cfg2Cmd::Timer;
 use PVE::QemuServer::Helpers;
+use PVE::QemuServer::Machine;
 
 sub new {
-    my ($class, $conf, $defaults, $version_guard) = @_;
+    my ($class, $conf, $defaults, $version_guard, $opts) = @_;
 
     my $self = bless {
         conf => $conf,
@@ -18,6 +19,10 @@ sub new {
     $self->{ostype} = $self->get_prop('ostype');
     $self->{'windows-version'} = PVE::QemuServer::Helpers::windows_version($self->{ostype});
 
+    my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
+    $self->{'machine-type'} =
+        PVE::QemuServer::Machine::get_vm_machine($conf, $opts->{forcemachine}, $arch);
+
     return $self;
 }
 
@@ -51,10 +56,23 @@ sub global_flags {
     return $self->{'global-flags'};
 }
 
-sub add_machine_flag {
-    my ($self, $flag) = @_;
+=head3 add_machine_flag_if_supported
 
-    push $self->{'machine-flags'}->@*, $flag;
+    my $success = $self->add_machine_flag_if_supported($flag_name, $value);
+
+Add flag C<$flag_name> with value C<$value> to the machine flags if the current machine type
+supports it. Returns whether the flag was added or not.
+
+=cut
+
+sub add_machine_flag_if_supported {
+    my ($self, $flag_name, $value) = @_;
+
+    return if !PVE::QemuServer::Machine::machine_supports_flag($self->{'machine-type'}, $flag_name);
+
+    push $self->{'machine-flags'}->@*, "${flag_name}=${value}";
+
+    return 1;
 }
 
 sub machine_flags {
diff --git a/src/PVE/QemuServer/Cfg2Cmd/Timer.pm b/src/PVE/QemuServer/Cfg2Cmd/Timer.pm
index 452c15b2..d03715a0 100644
--- a/src/PVE/QemuServer/Cfg2Cmd/Timer.pm
+++ b/src/PVE/QemuServer/Cfg2Cmd/Timer.pm
@@ -20,9 +20,9 @@ sub generate {
 
     if ($cfg2cmd->windows_version() >= 6) {
         $cfg2cmd->add_global_flag('kvm-pit.lost_tick_policy=discard');
-        $cfg2cmd->add_machine_flag('hpet=off');
+        $cfg2cmd->add_machine_flag_if_supported('hpet', 'off');
     } elsif ($cfg2cmd->is_linux() && $cfg2cmd->version_guard(10, 1, 0)) {
-        $cfg2cmd->add_machine_flag('hpet=off');
+        $cfg2cmd->add_machine_flag_if_supported('hpet', 'off');
     }
 
     $cfg2cmd->add_rtc_flag('driftfix=slew') if $time_drift_fix;
-- 
2.47.3



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pve-devel] [PATCH qemu-server 3/3] fix #7014: fix regression starting aarch64 VMs with machine type >= 10.1
  2025-11-12 11:29 ` [pve-devel] [PATCH qemu-server 3/3] fix #7014: fix regression starting aarch64 VMs with machine type >= 10.1 Fiona Ebner
@ 2025-11-12 11:52   ` Fiona Ebner
  0 siblings, 0 replies; 6+ messages in thread
From: Fiona Ebner @ 2025-11-12 11:52 UTC (permalink / raw)
  To: pve-devel

Am 12.11.25 um 12:30 PM schrieb Fiona Ebner:
> diff --git a/src/PVE/QemuServer/Cfg2Cmd/Timer.pm b/src/PVE/QemuServer/Cfg2Cmd/Timer.pm
> index 452c15b2..d03715a0 100644
> --- a/src/PVE/QemuServer/Cfg2Cmd/Timer.pm
> +++ b/src/PVE/QemuServer/Cfg2Cmd/Timer.pm
> @@ -20,9 +20,9 @@ sub generate {
>  
>      if ($cfg2cmd->windows_version() >= 6) {
>          $cfg2cmd->add_global_flag('kvm-pit.lost_tick_policy=discard');
> -        $cfg2cmd->add_machine_flag('hpet=off');
> +        $cfg2cmd->add_machine_flag_if_supported('hpet', 'off');

Turns out, it was actually a pre-existing issue for the Windows case
here even before the introduction of the Cfg2Cmd module, so these
patches do not only fix the regression, but that as well :) Shouldn't
have relied on pre-existing code to be correct :P

>      } elsif ($cfg2cmd->is_linux() && $cfg2cmd->version_guard(10, 1, 0)) {
> -        $cfg2cmd->add_machine_flag('hpet=off');
> +        $cfg2cmd->add_machine_flag_if_supported('hpet', 'off');
>      }
>  
>      $cfg2cmd->add_rtc_flag('driftfix=slew') if $time_drift_fix;



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pve-devel] applied: [PATCH-SERIES qemu-server 0/3] fix #7014: fix regression starting aarch64 VMs with machine type >= 10.1
  2025-11-12 11:29 [pve-devel] [PATCH-SERIES qemu-server 0/3] fix #7014: fix regression starting aarch64 VMs with machine type >= 10.1 Fiona Ebner
                   ` (2 preceding siblings ...)
  2025-11-12 11:29 ` [pve-devel] [PATCH qemu-server 3/3] fix #7014: fix regression starting aarch64 VMs with machine type >= 10.1 Fiona Ebner
@ 2025-11-13 22:13 ` Thomas Lamprecht
  3 siblings, 0 replies; 6+ messages in thread
From: Thomas Lamprecht @ 2025-11-13 22:13 UTC (permalink / raw)
  To: pve-devel, Fiona Ebner

On Wed, 12 Nov 2025 12:29:37 +0100, Fiona Ebner wrote:
> The 'virt' machine type used for 'aarch64' does not support the 'hpet'
> machine flag. Add the flag only if supported by the current machine
> type.
> 
> qemu-server:
> 
> Fiona Ebner (3):
>   machine: add machine_base_type() helper
>   machine: add machine_supports_flag() helper
>   fix #7014: fix regression starting aarch64 VMs with machine type >=
>     10.1
> 
> [...]

Applied, thanks!

[1/3] machine: add machine_base_type() helper
      commit 87eb1068
[2/3] machine: add machine_supports_flag() helper
      commit fb94ad00
[3/3] fix #7014: fix regression starting aarch64 VMs with machine type >= 10.1
      commit 1de4998e


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-11-13 22:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-12 11:29 [pve-devel] [PATCH-SERIES qemu-server 0/3] fix #7014: fix regression starting aarch64 VMs with machine type >= 10.1 Fiona Ebner
2025-11-12 11:29 ` [pve-devel] [PATCH qemu-server 1/3] machine: add machine_base_type() helper Fiona Ebner
2025-11-12 11:29 ` [pve-devel] [PATCH qemu-server 2/3] machine: add machine_supports_flag() helper Fiona Ebner
2025-11-12 11:29 ` [pve-devel] [PATCH qemu-server 3/3] fix #7014: fix regression starting aarch64 VMs with machine type >= 10.1 Fiona Ebner
2025-11-12 11:52   ` Fiona Ebner
2025-11-13 22:13 ` [pve-devel] applied: [PATCH-SERIES qemu-server 0/3] " Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal