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 [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 367FB1FF164
	for <inbox@lore.proxmox.com>; Fri,  3 Jan 2025 17:05:10 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 355902962D;
	Fri,  3 Jan 2025 17:05:01 +0100 (CET)
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Fri,  3 Jan 2025 16:58:00 +0100
Message-Id: <20250103155802.143669-18-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.052 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
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 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 17/19] machine: adapt to changes in
 QEMU machine version deprecation/removal
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>

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@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@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



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