public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemu-server 2/2] machine: fix Windows machine version pinning on aarch64
Date: Thu, 29 Jan 2026 12:05:57 +0100	[thread overview]
Message-ID: <20260129110607.65416-3-f.ebner@proxmox.com> (raw)
In-Reply-To: <20260129110607.65416-1-f.ebner@proxmox.com>

Have windows_get_pinned_machine_version() require passing an
explicitly set $machine and adapt the callers.

Note that the callers of check_and_pin_machine_string() use the
get_vm_arch() helper too, so the $arch variable is not undef there.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/API2/Qemu.pm          |  4 ++--
 src/PVE/QemuServer/Machine.pm | 12 ++++++++----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
index d6046a25..c2e185a6 100644
--- a/src/PVE/API2/Qemu.pm
+++ b/src/PVE/API2/Qemu.pm
@@ -1483,7 +1483,7 @@ __PACKAGE__->register_method({
 
                     # always pin Windows' machine version on create, they get confused too easily
                     my $machine_string = PVE::QemuServer::Machine::check_and_pin_machine_string(
-                        $conf->{machine}, $conf->{ostype},
+                        $conf->{machine}, $conf->{ostype}, $arch,
                     );
                     $conf->{machine} = $machine_string if $machine_string;
 
@@ -2464,7 +2464,7 @@ my $update_vm_api = sub {
                         eval {
                             my $machine_string =
                                 PVE::QemuServer::Machine::check_and_pin_machine_string(
-                                    $conf->{machine}, $param->{ostype},
+                                    $conf->{machine}, $param->{ostype}, $arch,
                                 );
                             $conf->{pending}->{machine} = $machine_string if $machine_string;
                         };
diff --git a/src/PVE/QemuServer/Machine.pm b/src/PVE/QemuServer/Machine.pm
index 21c62a8f..0d4b77af 100644
--- a/src/PVE/QemuServer/Machine.pm
+++ b/src/PVE/QemuServer/Machine.pm
@@ -379,11 +379,13 @@ sub latest_installed_machine_version {
 sub windows_get_pinned_machine_version {
     my ($machine, $base_version, $kvmversion) = @_;
 
+    die "internal error - no machine provided" if !$machine;
+
     my $pin_version = $base_version;
     if (!defined($base_version) || !can_run_pve_machine_version($base_version, $kvmversion)) {
         $pin_version = latest_installed_machine_version($kvmversion);
     }
-    if (!$machine || $machine eq 'pc') {
+    if ($machine eq 'pc') {
         $machine = "pc-i440fx-$pin_version";
     } elsif ($machine eq 'q35') {
         $machine = "pc-q35-$pin_version";
@@ -404,6 +406,9 @@ sub get_vm_machine {
 
     if (!$machine || $machine =~ m/^(?:pc|q35|virt)$/) {
         my $kvmversion = PVE::QemuServer::Helpers::kvm_user_version();
+        my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
+        $machine ||= default_machine_for_arch($arch);
+
         # we must pin Windows VMs without a specific version and no meta info about creation QEMU to
         # 5.1, as 5.2 fixed a bug in ACPI layout which confuses windows quite a bit and may result
         # in various regressions..
@@ -423,8 +428,6 @@ sub get_vm_machine {
             }
             $machine = windows_get_pinned_machine_version($machine, $base_version, $kvmversion);
         } else {
-            my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
-            $machine ||= default_machine_for_arch($arch);
             my $pvever = get_pve_version($kvmversion);
             $machine .= "+pve$pvever";
         }
@@ -445,13 +448,14 @@ sub get_vm_machine {
 }
 
 sub check_and_pin_machine_string {
-    my ($machine_string, $ostype) = @_;
+    my ($machine_string, $ostype, $arch) = @_;
 
     my $machine_conf = parse_machine($machine_string);
     my $machine = $machine_conf->{type};
     if (!$machine || $machine =~ m/^(?:pc|q35|virt)$/) {
         # always pin Windows' machine version on create, they get confused too easily
         if (PVE::QemuServer::Helpers::windows_version($ostype)) {
+            $machine = default_machine_for_arch($arch) if !$machine;
             $machine_conf->{type} = windows_get_pinned_machine_version($machine);
             print "pinning machine type to '$machine_conf->{type}' for Windows guest OS\n";
         }
-- 
2.47.3





  parent reply	other threads:[~2026-01-29 11:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-29 11:05 [PATCH-SERIES qemu-server 0/2] machine: use correct default for aarch64 Fiona Ebner
2026-01-29 11:05 ` [PATCH qemu-server 1/2] machine: get vm machine: fix default for arch on non-x86 hosts Fiona Ebner
2026-01-29 11:05 ` Fiona Ebner [this message]
2026-01-29 12:41 ` applied: [PATCH-SERIES qemu-server 0/2] machine: use correct default for aarch64 Thomas Lamprecht
2026-01-29 13:28   ` Fiona Ebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260129110607.65416-3-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal