[pve-devel] [PATCH qemu-server 17/19] machine: adapt to changes in QEMU machine version deprecation/removal

Fiona Ebner f.ebner at proxmox.com
Fri Jan 3 16:58:00 CET 2025


In QEMU commit a35f8577a0 ("include/hw: add macros for deprecation &
removal of versioned machines"), a new machine version deprecation and
removal policy was introduced. After only 3 years a machine version
will be deprecated while being removed after 6 years.

The deprecation is a bit early considering major PVE releases are
approximately every 2 years. This means that a deprecation warning can
already happen for a machine version that was introduced during the
previous major release. This would scare users for no good reason, so
avoid deprecating machine versions in PVE too early and define a
baseline of machine versions that will be supported throughout a
single major PVE release.

The new policy takes effect only in QEMU 10.1, see QEMU commit
c9fd2d9a48 ("include/hw: temporarily disable deletion of versioned
machine types"). Machine versions <=2.3 were already deprecated for a
while, with PVE also warning about it since commit dec371d9 ("vm
start: add warning about deprecated machine version") in qemu-server
8.0.8. These have been dropped in QEMU 9.1, so the baseline for PVE 8
is 2.4.

Reported-by: Martin Maurer <martin at proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
 PVE/QemuServer.pm         | 19 +++++++++++++------
 PVE/QemuServer/Machine.pm | 31 +++++++++++++++++++++++++++++--
 2 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 5e577431..5abd7bc8 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6018,13 +6018,20 @@ sub vm_start_nolock {
 
     PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'post-start');
 
-    my ($current_machine, $is_deprecated) =
+    my ($current_machine, $removal_during_pve_release) =
 	PVE::QemuServer::Machine::get_current_qemu_machine($vmid);
-    if ($is_deprecated) {
-	log_warn(
-	    "current machine version '$current_machine' is deprecated - see the documentation and ".
-	    "change to a newer one",
-	);
+    if ($removal_during_pve_release) {
+	if ($removal_during_pve_release eq 'current') {
+	    log_warn(
+		"current machine version '$current_machine' is deprecated - see the documentation"
+		." and change to a newer one",
+	    );
+	} elsif ($removal_during_pve_release eq 'next') {
+	    print "INFO: current machine version '$current_machine' is rather old - see the"
+		." documentation for more information\n";
+	} else {
+	    log_warn("unexpected machine version deprecation status '$removal_during_pve_release'");
+	}
     }
 
     return $res;
diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
index 6398e756..79be4a0e 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -83,7 +83,10 @@ sub machine_type_is_q35 {
     return $machine_conf->{type} && ($machine_conf->{type} =~ m/q35/) ? 1 : 0;
 }
 
-# In list context, also returns whether the current machine is deprecated or not.
+# In list context, also returns the deprecation status of the current machine:
+# undef - machine version is not deprecated
+# 'current' - machine version will be removed during the 'current' major PVE release
+# 'next' - machine version will be removed during the 'next' major PVE release
 sub current_from_query_machines {
     my ($machines) = @_;
 
@@ -95,7 +98,31 @@ sub current_from_query_machines {
 	    $current = $machine->{name};
 	    # pve-version only exists for the current machine
 	    $current .= "+$machine->{'pve-version'}" if $machine->{'pve-version'};
-	    return wantarray ? ($current, $machine->{deprecated} ? 1 : 0) : $current;
+
+	    return $current if !wantarray;
+
+	    # Machine versions older than this are considered to be deprecated in Proxmox VE.
+	    #
+	    # See include/hw/boards.h in QEMU: QEMU will delete machine versions after 6 major
+	    # releases. This policy takes effect with QEMU 10.1.
+	    #
+	    # QEMU release cylce N.0 in ~April, N.1 in ~August, N.2 in ~December
+	    # Debian/PVE release cylce ~every two years in summer
+	    #
+	    # PVE - last QEMU - machine versions dropped - baseline
+	    #   8         9.2              2.3 and older        2.4
+	    #   9        11.2              5.2 and older        6.0
+	    #  10        13.2              7.2 and older        8.0
+	    #
+	    # TODO PVE 9 - check the above comment still applies and update baseline accordingly
+	    my $removal_during_pve_release;
+	    # NOTE the order of the checks matters
+	    $removal_during_pve_release = 'next'
+		if !machine_version_at_least($machine->{name}, 6, 0);
+	    $removal_during_pve_release = 'current'
+		if !machine_version_at_least($machine->{name}, 2, 4);
+
+	    return ($current, $removal_during_pve_release);
 	}
     }
 
-- 
2.39.5





More information about the pve-devel mailing list