From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id 760561FF164
	for <inbox@lore.proxmox.com>; Fri,  3 Jan 2025 16:59:58 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 335A629300;
	Fri,  3 Jan 2025 16:58:42 +0100 (CET)
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Fri,  3 Jan 2025 16:57:55 +0100
Message-Id: <20250103155802.143669-13-f.ebner@proxmox.com>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20250103155802.143669-1-f.ebner@proxmox.com>
References: <20250103155802.143669-1-f.ebner@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.051 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
Subject: [pve-devel] [PATCH qemu-server 12/19] machine: get vm machine:
 fallback to creation QEMU version for windows starting with 9.1
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

Starting from QEMU 9.1, pin to the creation version instead. Support
for machine version 5.1 is expected to drop with QEMU 11.1 and it
would still be good to handle Windows VMs that do not have explicit
machine version for whatever reason. For example, explicitly setting
the machine without a version on the CLI/API after creation is one way
to end up with such a machine.

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

diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
index 915913c0..679d69c7 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 
 use PVE::QemuServer::Helpers;
+use PVE::QemuServer::MetaInfo;
 use PVE::QemuServer::Monitor;
 use PVE::JSONSchema qw(get_standard_option parse_property_string print_property_string);
 
@@ -221,11 +222,23 @@ sub get_vm_machine {
 
     if (!$machine || $machine =~ m/^(?:pc|q35|virt)$/) {
 	my $kvmversion //= PVE::QemuServer::Helpers::kvm_user_version();
-	# we must pin Windows VMs without a specific version to 5.1, as 5.2 fixed a bug in ACPI
-	# layout which confuses windows quite a bit and may result in various regressions..
+	# 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..
 	# see: https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg08484.html
+	# Starting from QEMU 9.1, pin to the creation version instead. Support for 5.1 is expected
+	# to drop with QEMU 11.1 and it would still be good to handle Windows VMs that do not have
+	# an explicit machine version for whatever reason.
 	if (PVE::QemuServer::Helpers::windows_version($conf->{ostype})) {
-	    $machine = windows_get_pinned_machine_version($machine, '5.1', $kvmversion);
+	    my $base_version = '5.1';
+	    # TODO PVE 10 - die early if there is a Windows VM both without explicit machine version
+	    # and without meta info.
+	    if (my $meta = PVE::QemuServer::MetaInfo::parse_meta_info($conf->{meta})) {
+		$base_version = $meta->{'creation-qemu'}
+		    if PVE::QemuServer::Helpers::min_version($meta->{'creation-qemu'}, 9, 1);
+		($base_version) = ($base_version =~ m/^(\d+.\d+)/); # need only major.minor
+	    }
+	    $machine = windows_get_pinned_machine_version($machine, $base_version, $kvmversion);
 	}
 	$arch //= 'x86_64';
 	$machine ||= default_machine_for_arch($arch);
-- 
2.39.5



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