public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal
@ 2025-01-17 14:24 Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 01/16] machine: drop unused parameter from assert_valid_machine_property() helper Fiona Ebner
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

Changes in v4:
* dropped already applied patch
* move import for get_host_arch() to earlier patch where it is already needed
* squash rename and move patches for get_command_for_arch() together
* rename machine_version_at_least -> is_machine_version_at_least
* use a dedicated section to describe the new removal policy
* drop table, instead describe how the cut-off decision is made with examples

Changes in v3:
* improve code readibility for Windows machine version fallback change

Changes in v2:
* change deprecation logic into QEMU itself rather than just weakening
  the warning there (so no need to change the deprecation logic in
  qemu-server anymore)
* get rid of outdated information from "Update to a Newer Machine
  Version" section in docs

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.

This series is intended to allow broader QEMU 9.1 rollout. Still
required in addition to this series before PVE 9:
* wiki article about what to look out for when changing machine
  version
* checks in pve8to9 script giving errors/warnings when machine version
  is too old

qemu-server:

Fiona Ebner (15):
  machine: drop unused parameter from assert_valid_machine_property()
    helper
  move get_command_for_arch() helper to helpers module
  move kvm_user_version() function to helpers module
  move get_vm_arch() helper to helpers module
  machine: add default_machine_for_arch() helper
  move get_installed_machine_version() helper to machine module
  move windows_get_pinned_machine_version() function to machine module
  move get_vm_machine() function to machine module
  move meta information handling to its own module
  machine: fallback to creation QEMU version for windows starting with
    9.1
  machine: add check_and_pin_machine_string() helper
  api: update vm config: pin machine version when switching to windows
    os type
  machine: log informational line when pinning machine version for
    Windows guest
  machine: rename machine_version() function to
    is_machine_version_at_least()
  machine: code cleanup: avoid superfluous augmented assignment operator

 PVE/API2/Qemu.pm                 |  44 +++++---
 PVE/QemuServer.pm                | 184 +++----------------------------
 PVE/QemuServer/Helpers.pm        |  49 ++++++++
 PVE/QemuServer/Machine.pm        | 108 +++++++++++++++++-
 PVE/QemuServer/Makefile          |   1 +
 PVE/QemuServer/MetaInfo.pm       |  47 ++++++++
 test/run_config2command_tests.pl |   3 +-
 7 files changed, 249 insertions(+), 187 deletions(-)
 create mode 100644 PVE/QemuServer/MetaInfo.pm


pve-docs:

Fiona Ebner (1):
  qm: machine version: document support in PVE

 qm.adoc | 34 ++++++++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 8 deletions(-)


Summary over all repositories:
  8 files changed, 275 insertions(+), 195 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] 18+ messages in thread

* [pve-devel] [PATCH qemu-server v4 01/16] machine: drop unused parameter from assert_valid_machine_property() helper
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
@ 2025-01-17 14:24 ` Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 02/16] move get_command_for_arch() helper to helpers module Fiona Ebner
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

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

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 8392400e..52425ee8 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1250,7 +1250,7 @@ __PACKAGE__->register_method({
 			    $conf->{machine} = PVE::QemuServer::Machine::print_machine($machine_conf);
 			}
 		    }
-		    PVE::QemuServer::Machine::assert_valid_machine_property($conf, $machine_conf);
+		    PVE::QemuServer::Machine::assert_valid_machine_property($machine_conf);
 
 		    $conf->{lock} = 'import' if $live_import_mapping;
 
@@ -2113,7 +2113,7 @@ my $update_vm_api  = sub {
 		    $conf->{pending}->{$opt} = $param->{$opt};
 		} elsif ($opt eq 'machine') {
 		    my $machine_conf = PVE::QemuServer::Machine::parse_machine($param->{$opt});
-		    PVE::QemuServer::Machine::assert_valid_machine_property($conf, $machine_conf);
+		    PVE::QemuServer::Machine::assert_valid_machine_property($machine_conf);
 		    $conf->{pending}->{$opt} = $param->{$opt};
 		} elsif ($opt eq 'cipassword') {
 		    if (!PVE::QemuServer::Helpers::windows_version($conf->{ostype})) {
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 5cde94a1..bc38fb1b 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4193,7 +4193,7 @@ sub config_to_command {
     $machine_type_min .= "+pve$required_pve_version";
     push @$machineFlags, "type=${machine_type_min}";
 
-    PVE::QemuServer::Machine::assert_valid_machine_property($conf, $machine_conf);
+    PVE::QemuServer::Machine::assert_valid_machine_property($machine_conf);
 
     if (my $viommu = $machine_conf->{viommu}) {
 	if ($viommu eq 'intel') {
diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
index a072ac29..7f03ef20 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -56,7 +56,7 @@ sub print_machine {
 }
 
 sub assert_valid_machine_property {
-    my ($conf, $machine_conf) = @_;
+    my ($machine_conf) = @_;
     my $q35 = $machine_conf->{type} && ($machine_conf->{type} =~ m/q35/) ? 1 : 0;
     if ($machine_conf->{viommu} && $machine_conf->{viommu} eq "intel" && !$q35) {
 	die "to use Intel vIOMMU please set the machine type to q35\n";
-- 
2.39.5



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


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

* [pve-devel] [PATCH qemu-server v4 02/16] move get_command_for_arch() helper to helpers module
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 01/16] machine: drop unused parameter from assert_valid_machine_property() helper Fiona Ebner
@ 2025-01-17 14:24 ` Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 03/16] move kvm_user_version() function " Fiona Ebner
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

Cannot use the is_native_arch() helper inside the function anymore,
to avoid a cyclic dependency between the 'CPUConfig' and 'Helpers'
modules, inline it.

While at it, improve the variable name for the mapping.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---

Changes in v4:
* add import for get_host_arch()
* squash rename from following patch into this one

 PVE/QemuServer.pm         | 19 +++----------------
 PVE/QemuServer/Helpers.pm | 14 ++++++++++++++
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index bc38fb1b..ce962b7a 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1199,7 +1199,7 @@ my $kvm_mtime = {};
 sub kvm_user_version {
     my ($binary) = @_;
 
-    $binary //= get_command_for_arch(get_host_arch()); # get the native arch by default
+    $binary //= PVE::QemuServer::Helpers::get_command_for_arch(get_host_arch()); # get the native arch by default
     my $st = stat($binary);
 
     my $cachedmtime = $kvm_mtime->{$binary} // -1;
@@ -3397,19 +3397,6 @@ sub get_ovmf_files($$$) {
     return ($ovmf_code, $ovmf_vars);
 }
 
-my $Arch2Qemu = {
-    aarch64 => '/usr/bin/qemu-system-aarch64',
-    x86_64 => '/usr/bin/qemu-system-x86_64',
-};
-sub get_command_for_arch($) {
-    my ($arch) = @_;
-    return '/usr/bin/kvm' if is_native_arch($arch);
-
-    my $cmd = $Arch2Qemu->{$arch}
-	or die "don't know how to emulate architecture '$arch'\n";
-    return $cmd;
-}
-
 # To use query_supported_cpu_flags and query_understood_cpu_flags to get flags
 # to use in a QEMU command line (-cpu element), first array_intersect the result
 # of query_supported_ with query_understood_. This is necessary because:
@@ -3444,7 +3431,7 @@ sub query_supported_cpu_flags {
 	$arch eq "aarch64";
 
     my $kvm_supported = defined(kvm_version());
-    my $qemu_cmd = get_command_for_arch($arch);
+    my $qemu_cmd = PVE::QemuServer::Helpers::get_command_for_arch($arch);
     my $fakevmid = -1;
     my $pidfile = PVE::QemuServer::Helpers::pidfile_name($fakevmid);
 
@@ -3634,7 +3621,7 @@ sub config_to_command {
     my $machine_conf = PVE::QemuServer::Machine::parse_machine($conf->{machine});
 
     my $arch = get_vm_arch($conf);
-    my $kvm_binary = get_command_for_arch($arch);
+    my $kvm_binary = PVE::QemuServer::Helpers::get_command_for_arch($arch);
     my $kvmver = kvm_user_version($kvm_binary);
 
     if (!$kvmver || $kvmver !~ m/^(\d+)\.(\d+)/ || $1 < 5) {
diff --git a/PVE/QemuServer/Helpers.pm b/PVE/QemuServer/Helpers.pm
index 72a46a0a..7b65ba44 100644
--- a/PVE/QemuServer/Helpers.pm
+++ b/PVE/QemuServer/Helpers.pm
@@ -8,6 +8,7 @@ use JSON;
 
 use PVE::INotify;
 use PVE::ProcFSTools;
+use PVE::Tools qw(get_host_arch);
 
 use base 'Exporter';
 our @EXPORT_OK = qw(
@@ -19,6 +20,19 @@ windows_version
 
 my $nodename = PVE::INotify::nodename();
 
+my $arch_to_qemu_binary = {
+    aarch64 => '/usr/bin/qemu-system-aarch64',
+    x86_64 => '/usr/bin/qemu-system-x86_64',
+};
+sub get_command_for_arch($) {
+    my ($arch) = @_;
+    return '/usr/bin/kvm' if get_host_arch() eq $arch; # i.e. native arch
+
+    my $cmd = $arch_to_qemu_binary->{$arch}
+	or die "don't know how to emulate architecture '$arch'\n";
+    return $cmd;
+}
+
 # Paths and directories
 
 our $var_run_tmpdir = "/var/run/qemu-server";
-- 
2.39.5



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


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

* [pve-devel] [PATCH qemu-server v4 03/16] move kvm_user_version() function to helpers module
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 01/16] machine: drop unused parameter from assert_valid_machine_property() helper Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 02/16] move get_command_for_arch() helper to helpers module Fiona Ebner
@ 2025-01-17 14:24 ` Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 04/16] move get_vm_arch() helper " Fiona Ebner
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

Add an export, since the function is rather commonly used (in
particular inlined in function calls, where prefixing with the module
name would hurt readability) and there won't be much potential for
confusion name-wise.

This was the only user of stat(), so remove the File::stat include.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 PVE/API2/Qemu.pm                 |  2 +-
 PVE/QemuServer.pm                | 32 +-------------------------------
 PVE/QemuServer/Helpers.pm        | 30 ++++++++++++++++++++++++++++++
 test/run_config2command_tests.pl |  3 ++-
 4 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 52425ee8..868508e7 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -854,7 +854,7 @@ sub assert_scsi_feature_compatibility {
 
     my $machine_type = PVE::QemuServer::get_vm_machine($conf, undef, $conf->{arch});
     my $machine_version = PVE::QemuServer::Machine::extract_version(
-	$machine_type, PVE::QemuServer::kvm_user_version());
+	$machine_type, PVE::QemuServer::Helpers::kvm_user_version());
     my $drivetype = PVE::QemuServer::Drive::get_scsi_device_type(
 	$drive, $storecfg, $machine_version);
 
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index ce962b7a..fd1feada 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -10,7 +10,6 @@ use Fcntl;
 use File::Basename;
 use File::Copy qw(copy);
 use File::Path;
-use File::stat;
 use Getopt::Long;
 use IO::Dir;
 use IO::File;
@@ -51,7 +50,7 @@ use PVE::Tools qw(run_command file_read_firstline file_get_contents dir_glob_for
 
 use PVE::QMPClient;
 use PVE::QemuConfig;
-use PVE::QemuServer::Helpers qw(config_aware_timeout min_version windows_version);
+use PVE::QemuServer::Helpers qw(config_aware_timeout min_version kvm_user_version windows_version);
 use PVE::QemuServer::Cloudinit;
 use PVE::QemuServer::CGroup;
 use PVE::QemuServer::CPUConfig qw(print_cpu_device get_cpu_options get_cpu_bitness is_native_arch get_amd_sev_object);
@@ -1193,35 +1192,6 @@ sub kvm_version {
     return $kvm_api_version;
 }
 
-my $kvm_user_version = {};
-my $kvm_mtime = {};
-
-sub kvm_user_version {
-    my ($binary) = @_;
-
-    $binary //= PVE::QemuServer::Helpers::get_command_for_arch(get_host_arch()); # get the native arch by default
-    my $st = stat($binary);
-
-    my $cachedmtime = $kvm_mtime->{$binary} // -1;
-    return $kvm_user_version->{$binary} if $kvm_user_version->{$binary} &&
-	$cachedmtime == $st->mtime;
-
-    $kvm_user_version->{$binary} = 'unknown';
-    $kvm_mtime->{$binary} = $st->mtime;
-
-    my $code = sub {
-	my $line = shift;
-	if ($line =~ m/^QEMU( PC)? emulator version (\d+\.\d+(\.\d+)?)(\.\d+)?[,\s]/) {
-	    $kvm_user_version->{$binary} = $2;
-	}
-    };
-
-    eval { run_command([$binary, '--version'], outfunc => $code); };
-    warn $@ if $@;
-
-    return $kvm_user_version->{$binary};
-
-}
 my sub extract_version {
     my ($machine_type, $version) = @_;
     $version = kvm_user_version() if !defined($version);
diff --git a/PVE/QemuServer/Helpers.pm b/PVE/QemuServer/Helpers.pm
index 7b65ba44..07b2ff6e 100644
--- a/PVE/QemuServer/Helpers.pm
+++ b/PVE/QemuServer/Helpers.pm
@@ -14,6 +14,7 @@ use base 'Exporter';
 our @EXPORT_OK = qw(
 min_version
 config_aware_timeout
+kvm_user_version
 parse_number_sets
 windows_version
 );
@@ -33,6 +34,35 @@ sub get_command_for_arch($) {
     return $cmd;
 }
 
+my $kvm_user_version = {};
+my $kvm_mtime = {};
+
+sub kvm_user_version {
+    my ($binary) = @_;
+
+    $binary //= get_command_for_arch(get_host_arch()); # get the native arch by default
+    my $st = stat($binary);
+
+    my $cachedmtime = $kvm_mtime->{$binary} // -1;
+    return $kvm_user_version->{$binary} if $kvm_user_version->{$binary} &&
+	$cachedmtime == $st->mtime;
+
+    $kvm_user_version->{$binary} = 'unknown';
+    $kvm_mtime->{$binary} = $st->mtime;
+
+    my $code = sub {
+	my $line = shift;
+	if ($line =~ m/^QEMU( PC)? emulator version (\d+\.\d+(\.\d+)?)(\.\d+)?[,\s]/) {
+	    $kvm_user_version->{$binary} = $2;
+	}
+    };
+
+    eval { PVE::Tools::run_command([$binary, '--version'], outfunc => $code); };
+    warn $@ if $@;
+
+    return $kvm_user_version->{$binary};
+}
+
 # Paths and directories
 
 our $var_run_tmpdir = "/var/run/qemu-server";
diff --git a/test/run_config2command_tests.pl b/test/run_config2command_tests.pl
index 5308b1fc..2feebd4a 100755
--- a/test/run_config2command_tests.pl
+++ b/test/run_config2command_tests.pl
@@ -15,6 +15,7 @@ use PVE::SysFSTools;
 
 use PVE::QemuConfig;
 use PVE::QemuServer;
+use PVE::QemuServer::Helpers;
 use PVE::QemuServer::Monitor;
 use PVE::QemuServer::QMPHelpers;
 use PVE::QemuServer::CPUConfig;
@@ -72,7 +73,7 @@ my $base_env = {
 	}
     },
     vmid => 8006,
-    real_qemu_version => PVE::QemuServer::kvm_user_version(), # not yet mocked
+    real_qemu_version => PVE::QemuServer::Helpers::kvm_user_version(), # not yet mocked
 };
 
 my $pci_devs = [
-- 
2.39.5



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


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

* [pve-devel] [PATCH qemu-server v4 04/16] move get_vm_arch() helper to helpers module
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
                   ` (2 preceding siblings ...)
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 03/16] move kvm_user_version() function " Fiona Ebner
@ 2025-01-17 14:24 ` Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 05/16] machine: add default_machine_for_arch() helper Fiona Ebner
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 PVE/API2/Qemu.pm          |  4 ++--
 PVE/QemuServer.pm         | 13 ++++---------
 PVE/QemuServer/Helpers.pm |  5 +++++
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 868508e7..2840de1b 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1198,7 +1198,7 @@ __PACKAGE__->register_method({
 
 	    my $realcmd = sub {
 		my $conf = $param;
-		my $arch = PVE::QemuServer::get_vm_arch($conf);
+		my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
 
 		for my $opt (sort keys $param->%*) {
 		    next if $opt !~ m/^scsi\d+$/;
@@ -2034,7 +2034,7 @@ my $update_vm_api  = sub {
 		$conf = PVE::QemuConfig->load_config($vmid); # update/reload
 		next if defined($conf->{pending}->{$opt}) && ($param->{$opt} eq $conf->{pending}->{$opt}); # skip if nothing changed
 
-		my $arch = PVE::QemuServer::get_vm_arch($conf);
+		my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
 
 		if (PVE::QemuServer::is_valid_drivename($opt)) {
 		    # old drive
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index fd1feada..164cb0e8 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3271,11 +3271,6 @@ sub vga_conf_has_spice {
     return $1 || 1;
 }
 
-sub get_vm_arch {
-    my ($conf) = @_;
-    return $conf->{arch} // get_host_arch();
-}
-
 my $default_machines = {
     x86_64 => 'pc',
     aarch64 => 'virt',
@@ -3590,7 +3585,7 @@ sub config_to_command {
 
     my $machine_conf = PVE::QemuServer::Machine::parse_machine($conf->{machine});
 
-    my $arch = get_vm_arch($conf);
+    my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
     my $kvm_binary = PVE::QemuServer::Helpers::get_command_for_arch($arch);
     my $kvmver = kvm_user_version($kvm_binary);
 
@@ -4670,7 +4665,7 @@ sub qemu_cpu_hotplug {
 	if scalar(@{$currentrunningvcpus}) != $currentvcpus;
 
     if (PVE::QemuServer::Machine::machine_version($machine_type, 2, 7)) {
-	my $arch = get_vm_arch($conf);
+	my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
 
 	for (my $i = $currentvcpus+1; $i <= $vcpus; $i++) {
 	    my $cpustr = print_cpu_device($conf, $arch, $i);
@@ -4912,7 +4907,7 @@ sub vmconfig_hotplug_pending {
     my ($vmid, $conf, $storecfg, $selection, $errors) = @_;
 
     my $defaults = load_defaults();
-    my $arch = get_vm_arch($conf);
+    my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
     my $machine_type = get_vm_machine($conf, undef, $arch);
 
     # commit values which do not have any impact on running VM first
@@ -8493,7 +8488,7 @@ sub qemu_use_old_bios_files {
 sub get_efivars_size {
     my ($conf, $efidisk) = @_;
 
-    my $arch = get_vm_arch($conf);
+    my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
     $efidisk //= $conf->{efidisk0} ? parse_drive('efidisk0', $conf->{efidisk0}) : undef;
     my $smm = PVE::QemuServer::Machine::machine_type_is_q35($conf);
     my (undef, $ovmf_vars) = get_ovmf_files($arch, $efidisk, $smm);
diff --git a/PVE/QemuServer/Helpers.pm b/PVE/QemuServer/Helpers.pm
index 07b2ff6e..8e9f4fc0 100644
--- a/PVE/QemuServer/Helpers.pm
+++ b/PVE/QemuServer/Helpers.pm
@@ -34,6 +34,11 @@ sub get_command_for_arch($) {
     return $cmd;
 }
 
+sub get_vm_arch {
+    my ($conf) = @_;
+    return $conf->{arch} // get_host_arch();
+}
+
 my $kvm_user_version = {};
 my $kvm_mtime = {};
 
-- 
2.39.5



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


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

* [pve-devel] [PATCH qemu-server v4 05/16] machine: add default_machine_for_arch() helper
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
                   ` (3 preceding siblings ...)
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 04/16] move get_vm_arch() helper " Fiona Ebner
@ 2025-01-17 14:24 ` Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 06/16] move get_installed_machine_version() helper to machine module Fiona Ebner
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

There are already other places where 'aarch64' and 'x86_64' are
checked to be the only valid architectures, for example, the
get_command_for_arch() helper, so the new error scenario for an
unknown arch should not cause any regressions.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 PVE/QemuServer.pm         |  9 ++-------
 PVE/QemuServer/Machine.pm | 12 ++++++++++++
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 164cb0e8..82795767 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3271,11 +3271,6 @@ sub vga_conf_has_spice {
     return $1 || 1;
 }
 
-my $default_machines = {
-    x86_64 => 'pc',
-    aarch64 => 'virt',
-};
-
 sub get_installed_machine_version {
     my ($kvmversion) = @_;
     $kvmversion = kvm_user_version() if !defined($kvmversion);
@@ -3320,7 +3315,7 @@ sub get_vm_machine {
 	    $machine = windows_get_pinned_machine_version($machine, '5.1', $kvmversion);
 	}
 	$arch //= 'x86_64';
-	$machine ||= $default_machines->{$arch};
+	$machine ||= PVE::QemuServer::Machine::default_machine_for_arch($arch);
 	my $pvever = PVE::QemuServer::Machine::get_pve_version($kvmversion);
 	$machine .= "+pve$pvever";
     }
@@ -3386,7 +3381,7 @@ sub query_supported_cpu_flags {
     my ($arch) = @_;
 
     $arch //= get_host_arch();
-    my $default_machine = $default_machines->{$arch};
+    my $default_machine = PVE::QemuServer::Machine::default_machine_for_arch($arch);
 
     my $flags = {};
 
diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
index 7f03ef20..5a039244 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -55,6 +55,18 @@ sub print_machine {
     return print_property_string($machine_conf, $machine_fmt);
 }
 
+my $default_machines = {
+    x86_64 => 'pc',
+    aarch64 => 'virt',
+};
+
+sub default_machine_for_arch {
+    my ($arch) = @_;
+
+    my $machine = $default_machines->{$arch} or die "unsupported architecture '$arch'\n";
+    return $machine;
+}
+
 sub assert_valid_machine_property {
     my ($machine_conf) = @_;
     my $q35 = $machine_conf->{type} && ($machine_conf->{type} =~ m/q35/) ? 1 : 0;
-- 
2.39.5



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


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

* [pve-devel] [PATCH qemu-server v4 06/16] move get_installed_machine_version() helper to machine module
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
                   ` (4 preceding siblings ...)
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 05/16] machine: add default_machine_for_arch() helper Fiona Ebner
@ 2025-01-17 14:24 ` Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 07/16] move windows_get_pinned_machine_version() function " Fiona Ebner
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 PVE/QemuServer.pm         | 9 +--------
 PVE/QemuServer/Machine.pm | 7 +++++++
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 82795767..ee7bb017 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3271,13 +3271,6 @@ sub vga_conf_has_spice {
     return $1 || 1;
 }
 
-sub get_installed_machine_version {
-    my ($kvmversion) = @_;
-    $kvmversion = kvm_user_version() if !defined($kvmversion);
-    $kvmversion =~ m/^(\d+\.\d+)/;
-    return $1;
-}
-
 sub windows_get_pinned_machine_version {
     my ($machine, $base_version, $kvmversion) = @_;
 
@@ -3285,7 +3278,7 @@ sub windows_get_pinned_machine_version {
     if (!defined($base_version) ||
 	!PVE::QemuServer::Machine::can_run_pve_machine_version($base_version, $kvmversion)
     ) {
-	$pin_version = get_installed_machine_version($kvmversion);
+	$pin_version = PVE::QemuServer::Machine::get_installed_machine_version($kvmversion);
     }
     if (!$machine || $machine eq 'pc') {
 	$machine = "pc-i440fx-$pin_version";
diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
index 5a039244..075554f4 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -186,4 +186,11 @@ sub qemu_machine_pxe {
     return $machine;
 }
 
+sub get_installed_machine_version {
+    my ($kvmversion) = @_;
+    $kvmversion = PVE::QemuServer::Helpers::kvm_user_version() if !defined($kvmversion);
+    $kvmversion =~ m/^(\d+\.\d+)/;
+    return $1;
+}
+
 1;
-- 
2.39.5



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


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

* [pve-devel] [PATCH qemu-server v4 07/16] move windows_get_pinned_machine_version() function to machine module
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
                   ` (5 preceding siblings ...)
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 06/16] move get_installed_machine_version() helper to machine module Fiona Ebner
@ 2025-01-17 14:24 ` Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 08/16] move get_vm_machine() " Fiona Ebner
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 PVE/API2/Qemu.pm          |  3 ++-
 PVE/QemuServer.pm         | 24 +-----------------------
 PVE/QemuServer/Machine.pm | 20 ++++++++++++++++++++
 3 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 2840de1b..8d0d788f 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1246,7 +1246,8 @@ __PACKAGE__->register_method({
 		    if (!$machine || $machine =~ m/^(?:pc|q35|virt)$/) {
 			# always pin Windows' machine version on create, they get to easily confused
 			if (PVE::QemuServer::Helpers::windows_version($conf->{ostype})) {
-			    $machine_conf->{type} = PVE::QemuServer::windows_get_pinned_machine_version($machine);
+			    $machine_conf->{type} =
+				PVE::QemuServer::Machine::windows_get_pinned_machine_version($machine);
 			    $conf->{machine} = PVE::QemuServer::Machine::print_machine($machine_conf);
 			}
 		    }
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index ee7bb017..989fafbd 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3271,28 +3271,6 @@ sub vga_conf_has_spice {
     return $1 || 1;
 }
 
-sub windows_get_pinned_machine_version {
-    my ($machine, $base_version, $kvmversion) = @_;
-
-    my $pin_version = $base_version;
-    if (!defined($base_version) ||
-	!PVE::QemuServer::Machine::can_run_pve_machine_version($base_version, $kvmversion)
-    ) {
-	$pin_version = PVE::QemuServer::Machine::get_installed_machine_version($kvmversion);
-    }
-    if (!$machine || $machine eq 'pc') {
-	$machine = "pc-i440fx-$pin_version";
-    } elsif ($machine eq 'q35') {
-	$machine = "pc-q35-$pin_version";
-    } elsif ($machine eq 'virt') {
-	$machine = "virt-$pin_version";
-    } else {
-	warn "unknown machine type '$machine', not touching that!\n";
-    }
-
-    return $machine;
-}
-
 sub get_vm_machine {
     my ($conf, $forcemachine, $arch) = @_;
 
@@ -3305,7 +3283,7 @@ sub get_vm_machine {
 	# 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
 	if (windows_version($conf->{ostype})) {
-	    $machine = windows_get_pinned_machine_version($machine, '5.1', $kvmversion);
+	    $machine = PVE::QemuServer::Machine::windows_get_pinned_machine_version($machine, '5.1', $kvmversion);
 	}
 	$arch //= 'x86_64';
 	$machine ||= PVE::QemuServer::Machine::default_machine_for_arch($arch);
diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
index 075554f4..04c77ed5 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -193,4 +193,24 @@ sub get_installed_machine_version {
     return $1;
 }
 
+sub windows_get_pinned_machine_version {
+    my ($machine, $base_version, $kvmversion) = @_;
+
+    my $pin_version = $base_version;
+    if (!defined($base_version) || !can_run_pve_machine_version($base_version, $kvmversion)) {
+	$pin_version = get_installed_machine_version($kvmversion);
+    }
+    if (!$machine || $machine eq 'pc') {
+	$machine = "pc-i440fx-$pin_version";
+    } elsif ($machine eq 'q35') {
+	$machine = "pc-q35-$pin_version";
+    } elsif ($machine eq 'virt') {
+	$machine = "virt-$pin_version";
+    } else {
+	warn "unknown machine type '$machine', not touching that!\n";
+    }
+
+    return $machine;
+}
+
 1;
-- 
2.39.5



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


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

* [pve-devel] [PATCH qemu-server v4 08/16] move get_vm_machine() function to machine module
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
                   ` (6 preceding siblings ...)
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 07/16] move windows_get_pinned_machine_version() function " Fiona Ebner
@ 2025-01-17 14:24 ` Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 09/16] move meta information handling to its own module Fiona Ebner
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 PVE/API2/Qemu.pm          |  2 +-
 PVE/QemuServer.pm         | 38 ++------------------------------------
 PVE/QemuServer/Machine.pm | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 8d0d788f..868049cb 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -852,7 +852,7 @@ sub assert_scsi_feature_compatibility {
 
     my $drive = PVE::QemuServer::Drive::parse_drive($opt, $drive_attributes, 1);
 
-    my $machine_type = PVE::QemuServer::get_vm_machine($conf, undef, $conf->{arch});
+    my $machine_type = PVE::QemuServer::Machine::get_vm_machine($conf, undef, $conf->{arch});
     my $machine_version = PVE::QemuServer::Machine::extract_version(
 	$machine_type, PVE::QemuServer::Helpers::kvm_user_version());
     my $drivetype = PVE::QemuServer::Drive::get_scsi_device_type(
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 989fafbd..04d251e0 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3271,40 +3271,6 @@ sub vga_conf_has_spice {
     return $1 || 1;
 }
 
-sub get_vm_machine {
-    my ($conf, $forcemachine, $arch) = @_;
-
-    my $machine_conf = PVE::QemuServer::Machine::parse_machine($conf->{machine});
-    my $machine = $forcemachine || $machine_conf->{type};
-
-    if (!$machine || $machine =~ m/^(?:pc|q35|virt)$/) {
-	my $kvmversion //= 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..
-	# see: https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg08484.html
-	if (windows_version($conf->{ostype})) {
-	    $machine = PVE::QemuServer::Machine::windows_get_pinned_machine_version($machine, '5.1', $kvmversion);
-	}
-	$arch //= 'x86_64';
-	$machine ||= PVE::QemuServer::Machine::default_machine_for_arch($arch);
-	my $pvever = PVE::QemuServer::Machine::get_pve_version($kvmversion);
-	$machine .= "+pve$pvever";
-    }
-
-    if ($machine !~ m/\+pve\d+?(?:\.pxe)?$/) {
-	my $is_pxe = $machine =~ m/^(.*?)\.pxe$/;
-	$machine = $1 if $is_pxe;
-
-	# for version-pinned machines that do not include a pve-version (e.g.
-	# pc-q35-4.1), we assume 0 to keep them stable in case we bump
-	$machine .= '+pve0';
-
-	$machine .= '.pxe' if $is_pxe;
-    }
-
-    return $machine;
-}
-
 sub get_ovmf_files($$$) {
     my ($arch, $efidisk, $smm) = @_;
 
@@ -3560,7 +3526,7 @@ sub config_to_command {
 	die "Detected old QEMU binary ('$kvmver', at least 5.0 is required)\n";
     }
 
-    my $machine_type = get_vm_machine($conf, $forcemachine, $arch);
+    my $machine_type = PVE::QemuServer::Machine::get_vm_machine($conf, $forcemachine, $arch);
     my $machine_version = extract_version($machine_type, $kvmver);
     $kvm //= 1 if is_native_arch($arch);
 
@@ -4874,7 +4840,7 @@ sub vmconfig_hotplug_pending {
 
     my $defaults = load_defaults();
     my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
-    my $machine_type = get_vm_machine($conf, undef, $arch);
+    my $machine_type = PVE::QemuServer::Machine::get_vm_machine($conf, undef, $arch);
 
     # commit values which do not have any impact on running VM first
     # Note: those option cannot raise errors, we we do not care about
diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
index 04c77ed5..915913c0 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -213,4 +213,38 @@ sub windows_get_pinned_machine_version {
     return $machine;
 }
 
+sub get_vm_machine {
+    my ($conf, $forcemachine, $arch) = @_;
+
+    my $machine_conf = parse_machine($conf->{machine});
+    my $machine = $forcemachine || $machine_conf->{type};
+
+    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..
+	# see: https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg08484.html
+	if (PVE::QemuServer::Helpers::windows_version($conf->{ostype})) {
+	    $machine = windows_get_pinned_machine_version($machine, '5.1', $kvmversion);
+	}
+	$arch //= 'x86_64';
+	$machine ||= default_machine_for_arch($arch);
+	my $pvever = get_pve_version($kvmversion);
+	$machine .= "+pve$pvever";
+    }
+
+    if ($machine !~ m/\+pve\d+?(?:\.pxe)?$/) {
+	my $is_pxe = $machine =~ m/^(.*?)\.pxe$/;
+	$machine = $1 if $is_pxe;
+
+	# for version-pinned machines that do not include a pve-version (e.g.
+	# pc-q35-4.1), we assume 0 to keep them stable in case we bump
+	$machine .= '+pve0';
+
+	$machine .= '.pxe' if $is_pxe;
+    }
+
+    return $machine;
+}
+
 1;
-- 
2.39.5



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


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

* [pve-devel] [PATCH qemu-server v4 09/16] move meta information handling to its own module
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
                   ` (7 preceding siblings ...)
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 08/16] move get_vm_machine() " Fiona Ebner
@ 2025-01-17 14:24 ` Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 10/16] machine: fallback to creation QEMU version for windows starting with 9.1 Fiona Ebner
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

Like this, it can be used by modules that cannot depend on
QemuServer.pm without creating a cyclic dependency.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 PVE/API2/Qemu.pm           |  3 ++-
 PVE/QemuServer.pm          | 42 +++-------------------------------
 PVE/QemuServer/Makefile    |  1 +
 PVE/QemuServer/MetaInfo.pm | 47 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 53 insertions(+), 40 deletions(-)
 create mode 100644 PVE/QemuServer/MetaInfo.pm

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 868049cb..60b8a4cc 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -35,6 +35,7 @@ use PVE::QemuServer::ImportDisk;
 use PVE::QemuServer::Monitor qw(mon_cmd);
 use PVE::QemuServer::Machine;
 use PVE::QemuServer::Memory qw(get_current_memory);
+use PVE::QemuServer::MetaInfo;
 use PVE::QemuServer::PCI;
 use PVE::QemuServer::QMPHelpers;
 use PVE::QemuServer::USB;
@@ -1205,7 +1206,7 @@ __PACKAGE__->register_method({
 		    assert_scsi_feature_compatibility($opt, $conf, $storecfg, $param->{$opt});
 		}
 
-		$conf->{meta} = PVE::QemuServer::new_meta_info_string();
+		$conf->{meta} = PVE::QemuServer::MetaInfo::new_meta_info_string();
 
 		my $vollist = [];
 		eval {
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 04d251e0..6f2a9aed 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -57,6 +57,7 @@ use PVE::QemuServer::CPUConfig qw(print_cpu_device get_cpu_options get_cpu_bitne
 use PVE::QemuServer::Drive qw(is_valid_drivename checked_volume_format drive_is_cloudinit drive_is_cdrom drive_is_read_only parse_drive print_drive);
 use PVE::QemuServer::Machine;
 use PVE::QemuServer::Memory qw(get_current_memory);
+use PVE::QemuServer::MetaInfo;
 use PVE::QemuServer::Monitor qw(mon_cmd);
 use PVE::QemuServer::PCI qw(print_pci_addr print_pcie_addr print_pcie_root_port parse_hostpci);
 use PVE::QemuServer::QMPHelpers qw(qemu_deviceadd qemu_devicedel qemu_objectadd qemu_objectdel);
@@ -281,21 +282,6 @@ my $rng_fmt = {
     },
 };
 
-my $meta_info_fmt = {
-    'ctime' => {
-	type => 'integer',
-	description => "The guest creation timestamp as UNIX epoch time",
-	minimum => 0,
-	optional => 1,
-    },
-    'creation-qemu' => {
-	type => 'string',
-	description => "The QEMU (machine) version from the time this VM was created.",
-	pattern => '\d+(\.\d+)+',
-	optional => 1,
-    },
-};
-
 my $confdesc = {
     onboot => {
 	optional => 1,
@@ -729,7 +715,7 @@ EODESCR
     },
     meta => {
 	type => 'string',
-	format => $meta_info_fmt,
+	format => $PVE::QemuServer::MetaInfo::meta_info_fmt,
 	description => "Some (read-only) meta-information about this guest.",
 	optional => 1,
     },
@@ -2058,32 +2044,10 @@ sub parse_rng {
     return $res;
 }
 
-sub parse_meta_info {
-    my ($value) = @_;
-
-    return if !$value;
-
-    my $res = eval { parse_property_string($meta_info_fmt, $value) };
-    warn $@ if $@;
-    return $res;
-}
-
-sub new_meta_info_string {
-    my () = @_; # for now do not allow to override any value
-
-    return PVE::JSONSchema::print_property_string(
-	{
-	    'creation-qemu' => kvm_user_version(),
-	    ctime => "". int(time()),
-	},
-	$meta_info_fmt
-    );
-}
-
 sub qemu_created_version_fixups {
     my ($conf, $forcemachine, $kvmver) = @_;
 
-    my $meta = parse_meta_info($conf->{meta}) // {};
+    my $meta = PVE::QemuServer::MetaInfo::parse_meta_info($conf->{meta}) // {};
     my $forced_vers = PVE::QemuServer::Machine::extract_version($forcemachine);
 
     # check if we need to apply some handling for VMs that always use the latest machine version but
diff --git a/PVE/QemuServer/Makefile b/PVE/QemuServer/Makefile
index 89d12091..18fd13ea 100644
--- a/PVE/QemuServer/Makefile
+++ b/PVE/QemuServer/Makefile
@@ -7,6 +7,7 @@ SOURCES=PCI.pm		\
 	Helpers.pm	\
 	Monitor.pm	\
 	Machine.pm	\
+	MetaInfo.pm	\
 	CPUConfig.pm	\
 	CGroup.pm	\
 	Drive.pm	\
diff --git a/PVE/QemuServer/MetaInfo.pm b/PVE/QemuServer/MetaInfo.pm
new file mode 100644
index 00000000..a8cb6c5e
--- /dev/null
+++ b/PVE/QemuServer/MetaInfo.pm
@@ -0,0 +1,47 @@
+package PVE::QemuServer::MetaInfo;
+
+use strict;
+use warnings;
+
+use PVE::JSONSchema;
+
+use PVE::QemuServer::Helpers;
+
+our $meta_info_fmt = {
+    'ctime' => {
+	type => 'integer',
+	description => "The guest creation timestamp as UNIX epoch time",
+	minimum => 0,
+	optional => 1,
+    },
+    'creation-qemu' => {
+	type => 'string',
+	description => "The QEMU (machine) version from the time this VM was created.",
+	pattern => '\d+(\.\d+)+',
+	optional => 1,
+    },
+};
+
+sub parse_meta_info {
+    my ($value) = @_;
+
+    return if !$value;
+
+    my $res = eval { PVE::JSONSchema::parse_property_string($meta_info_fmt, $value) };
+    warn $@ if $@;
+    return $res;
+}
+
+sub new_meta_info_string {
+    my () = @_; # for now do not allow to override any value
+
+    return PVE::JSONSchema::print_property_string(
+	{
+	    'creation-qemu' => PVE::QemuServer::Helpers::kvm_user_version(),
+	    ctime => "". int(time()),
+	},
+	$meta_info_fmt,
+    );
+}
+
+1;
-- 
2.39.5



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


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

* [pve-devel] [PATCH qemu-server v4 10/16] machine: fallback to creation QEMU version for windows starting with 9.1
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
                   ` (8 preceding siblings ...)
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 09/16] move meta information handling to its own module Fiona Ebner
@ 2025-01-17 14:24 ` Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 11/16] machine: add check_and_pin_machine_string() helper Fiona Ebner
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

Starting from QEMU creation version 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 | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
index 915913c0..40100555 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,24 @@ 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})) {
+		if (PVE::QemuServer::Helpers::min_version($meta->{'creation-qemu'}, 9, 1)) {
+		    # need only major.minor
+		    ($base_version) = ($meta->{'creation-qemu'} =~ m/^(\d+.\d+)/);
+		}
+	    }
+	    $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


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

* [pve-devel] [PATCH qemu-server v4 11/16] machine: add check_and_pin_machine_string() helper
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
                   ` (9 preceding siblings ...)
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 10/16] machine: fallback to creation QEMU version for windows starting with 9.1 Fiona Ebner
@ 2025-01-17 14:24 ` Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 12/16] api: update vm config: pin machine version when switching to windows os type Fiona Ebner
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

Extract the logic for guest OS-type dependent machine version pinning
into a dedicated helper, so it can be re-used.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 PVE/API2/Qemu.pm          | 14 +++-----------
 PVE/QemuServer/Machine.pm | 16 ++++++++++++++++
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 60b8a4cc..b1410df6 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1242,17 +1242,9 @@ __PACKAGE__->register_method({
 			$conf->{vmgenid} = PVE::QemuServer::generate_uuid();
 		    }
 
-		    my $machine_conf = PVE::QemuServer::Machine::parse_machine($conf->{machine});
-		    my $machine = $machine_conf->{type};
-		    if (!$machine || $machine =~ m/^(?:pc|q35|virt)$/) {
-			# always pin Windows' machine version on create, they get to easily confused
-			if (PVE::QemuServer::Helpers::windows_version($conf->{ostype})) {
-			    $machine_conf->{type} =
-				PVE::QemuServer::Machine::windows_get_pinned_machine_version($machine);
-			    $conf->{machine} = PVE::QemuServer::Machine::print_machine($machine_conf);
-			}
-		    }
-		    PVE::QemuServer::Machine::assert_valid_machine_property($machine_conf);
+		    # always pin Windows' machine version on create, they get confused too easily
+		    $conf->{machine} = PVE::QemuServer::Machine::check_and_pin_machine_string(
+			$conf->{machine}, $conf->{ostype});
 
 		    $conf->{lock} = 'import' if $live_import_mapping;
 
diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
index 40100555..e6fbd865 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -261,4 +261,20 @@ sub get_vm_machine {
     return $machine;
 }
 
+sub check_and_pin_machine_string {
+    my ($machine_string, $ostype) = @_;
+
+    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_conf->{type} = windows_get_pinned_machine_version($machine);
+	}
+    }
+
+    assert_valid_machine_property($machine_conf);
+    return print_machine($machine_conf);
+}
+
 1;
-- 
2.39.5



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


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

* [pve-devel] [PATCH qemu-server v4 12/16] api: update vm config: pin machine version when switching to windows os type
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
                   ` (10 preceding siblings ...)
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 11/16] machine: add check_and_pin_machine_string() helper Fiona Ebner
@ 2025-01-17 14:24 ` Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 13/16] machine: log informational line when pinning machine version for Windows guest Fiona Ebner
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

During virtual machine creation, the machine version is pinned when
the guest OS is Windows. The same should be done when the guest OS
type is newly set to Windows for consistency.

NOTE RFC

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 PVE/API2/Qemu.pm | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index b1410df6..8acd8d9f 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -2109,6 +2109,24 @@ my $update_vm_api  = sub {
 		    my $machine_conf = PVE::QemuServer::Machine::parse_machine($param->{$opt});
 		    PVE::QemuServer::Machine::assert_valid_machine_property($machine_conf);
 		    $conf->{pending}->{$opt} = $param->{$opt};
+		} elsif ($opt eq 'ostype') {
+		    # Check if machine version pinning is needed when switching OS type, just like
+		    # upon creation. Skip if 'machine' is explicitly set or removed at the same time
+		    # to honor the users request. While it should be enough to look at $modified,
+		    # because 'machine' is sorted before 'ostype', be explicit just to be sure.
+		    if (
+			!defined($param->{machine})
+			&& !defined($conf->{pending}->{machine})
+			&& !$modified->{machine} # detects deletion
+		    ) {
+			eval {
+			    $conf->{pending}->{machine} =
+				PVE::QemuServer::Machine::check_and_pin_machine_string(
+				    $conf->{machine}, $param->{ostype});
+			};
+			print "automatic pinning of machine version failed - $@" if $@;
+		    }
+		    $conf->{pending}->{$opt} = $param->{$opt};
 		} elsif ($opt eq 'cipassword') {
 		    if (!PVE::QemuServer::Helpers::windows_version($conf->{ostype})) {
 			# Same logic as in cloud-init (but with the regex fixed...)
-- 
2.39.5



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


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

* [pve-devel] [PATCH qemu-server v4 13/16] machine: log informational line when pinning machine version for Windows guest
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
                   ` (11 preceding siblings ...)
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 12/16] api: update vm config: pin machine version when switching to windows os type Fiona Ebner
@ 2025-01-17 14:24 ` Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 14/16] machine: rename machine_version() function to is_machine_version_at_least() Fiona Ebner
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

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

diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
index e6fbd865..3cac294c 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -270,6 +270,7 @@ sub check_and_pin_machine_string {
 	# always pin Windows' machine version on create, they get confused too easily
 	if (PVE::QemuServer::Helpers::windows_version($ostype)) {
 	    $machine_conf->{type} = windows_get_pinned_machine_version($machine);
+	    print "pinning machine type to '$machine_conf->{type}' for Windows guest OS\n";
 	}
     }
 
-- 
2.39.5



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


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

* [pve-devel] [PATCH qemu-server v4 14/16] machine: rename machine_version() function to is_machine_version_at_least()
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
                   ` (12 preceding siblings ...)
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 13/16] machine: log informational line when pinning machine version for Windows guest Fiona Ebner
@ 2025-01-17 14:24 ` Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 15/16] machine: code cleanup: avoid superfluous augmented assignment operator Fiona Ebner
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

The old name does not make it clear what exactly the function does.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---

Changes in v4:
* rename to is_machine_version_at_least()

 PVE/QemuServer.pm         | 4 ++--
 PVE/QemuServer/Machine.pm | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 6f2a9aed..58aa3c6f 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4532,7 +4532,7 @@ sub qemu_cpu_hotplug {
 
     if ($vcpus < $currentvcpus) {
 
-	if (PVE::QemuServer::Machine::machine_version($machine_type, 2, 7)) {
+	if (PVE::QemuServer::Machine::is_machine_version_at_least($machine_type, 2, 7)) {
 
 	    for (my $i = $currentvcpus; $i > $vcpus; $i--) {
 		qemu_devicedel($vmid, "cpu$i");
@@ -4560,7 +4560,7 @@ sub qemu_cpu_hotplug {
     die "vcpus in running vm does not match its configuration\n"
 	if scalar(@{$currentrunningvcpus}) != $currentvcpus;
 
-    if (PVE::QemuServer::Machine::machine_version($machine_type, 2, 7)) {
+    if (PVE::QemuServer::Machine::is_machine_version_at_least($machine_type, 2, 7)) {
 	my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
 
 	for (my $i = $currentvcpus+1; $i <= $vcpus; $i++) {
diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
index 3cac294c..66988bf3 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -136,7 +136,7 @@ sub extract_version {
     return;
 }
 
-sub machine_version {
+sub is_machine_version_at_least {
     my ($machine_type, $major, $minor, $pve) = @_;
 
     return PVE::QemuServer::Helpers::min_version(
-- 
2.39.5



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


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

* [pve-devel] [PATCH qemu-server v4 15/16] machine: code cleanup: avoid superfluous augmented assignment operator
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
                   ` (13 preceding siblings ...)
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 14/16] machine: rename machine_version() function to is_machine_version_at_least() Fiona Ebner
@ 2025-01-17 14:24 ` Fiona Ebner
  2025-01-17 14:24 ` [pve-devel] [PATCH docs v4 16/16] qm: machine version: document support in PVE Fiona Ebner
  2025-01-17 18:55 ` [pve-devel] applied-series: [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Thomas Lamprecht
  16 siblings, 0 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

Suggested by perlcritic.

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

diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
index 66988bf3..f1acde8f 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -221,7 +221,7 @@ sub get_vm_machine {
     my $machine = $forcemachine || $machine_conf->{type};
 
     if (!$machine || $machine =~ m/^(?:pc|q35|virt)$/) {
-	my $kvmversion //= PVE::QemuServer::Helpers::kvm_user_version();
+	my $kvmversion = PVE::QemuServer::Helpers::kvm_user_version();
 	# 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..
-- 
2.39.5



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


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

* [pve-devel] [PATCH docs v4 16/16] qm: machine version: document support in PVE
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
                   ` (14 preceding siblings ...)
  2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 15/16] machine: code cleanup: avoid superfluous augmented assignment operator Fiona Ebner
@ 2025-01-17 14:24 ` Fiona Ebner
  2025-01-17 18:55 ` [pve-devel] applied-series: [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Thomas Lamprecht
  16 siblings, 0 replies; 18+ messages in thread
From: Fiona Ebner @ 2025-01-17 14:24 UTC (permalink / raw)
  To: pve-devel

Elaborate on new QEMU machine version removal policy and how PVE will
support machine versions.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---

Changes in v4:
* use a dedicated section to describe the new removal policy
* drop table, instead describe how the cut-off decision is made with examples
* address other smaller comments, thanks @Thomas!

 qm.adoc | 34 ++++++++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/qm.adoc b/qm.adoc
index 94fdd4e..4bb8f2c 100644
--- a/qm.adoc
+++ b/qm.adoc
@@ -173,19 +173,37 @@ This means that after a fresh start, the newest machine version supported by the
 QEMU binary is used (e.g. the newest machine version QEMU 8.1 supports is
 version 8.1 for each machine type).
 
+QEMU Machine Version Deprecation
+++++++++++++++++++++++++++++++++
+
+Starting with QEMU 10.1, machine versions are removed from upstream QEMU after 6
+years. In {pve}, major releases happen approximately every 2 years, so a major
+{pve} release will support machine versions from approximately two previous
+major {pve} releases.
+
+Before upgrading to a new major {pve} release, you should update VM
+configurations to avoid all machine versions that will be dropped during the
+next major {pve} release. This ensures that the guests can still be used
+throughout that release. See the section
+xref:qm_machine_update[Update to a Newer Machine Version].
+
+The removal policy is not yet in effect for {pve} 8, so the baseline for
+supported machine versions is 2.4. The last QEMU binary version released for
+{pve} 9 is expected to be QEMU 11.2. This QEMU binary will remove support for
+machine versions older than 6.0, so 6.0 is the baseline for the {pve} 9 release
+life cycle. The baseline is expected to increase by 2 major versions for each
+major {pve} release, for example 8.0 for {pve} 10.
+
 [[qm_machine_update]]
 
 Update to a Newer Machine Version
 +++++++++++++++++++++++++++++++++
 
-Very old machine versions might become deprecated in QEMU. For example, this is
-the case for versions 1.4 to 1.7 for the i440fx machine type. It is expected
-that support for these machine versions will be dropped at some point. If you
-see a deprecation warning, you should change the machine version to a newer one.
-Be sure to have a working backup first and be prepared for changes to how the
-guest sees hardware. In some scenarios, re-installing certain drivers might be
-required. You should also check for snapshots with RAM that were taken with
-these machine versions (i.e. the `runningmachine` configuration entry).
+If you see a deprecation warning, you should change the machine version to a
+newer one. Be sure to have a working backup first and be prepared for changes to
+how the guest sees hardware. In some scenarios, re-installing certain drivers
+might be required. You should also check for snapshots with RAM that were taken
+with these machine versions (i.e. the `runningmachine` configuration entry).
 Unfortunately, there is no way to change the machine version of a snapshot, so
 you'd need to load the snapshot to salvage any data from it.
 
-- 
2.39.5



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


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

* [pve-devel] applied-series: [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal
  2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
                   ` (15 preceding siblings ...)
  2025-01-17 14:24 ` [pve-devel] [PATCH docs v4 16/16] qm: machine version: document support in PVE Fiona Ebner
@ 2025-01-17 18:55 ` Thomas Lamprecht
  16 siblings, 0 replies; 18+ messages in thread
From: Thomas Lamprecht @ 2025-01-17 18:55 UTC (permalink / raw)
  To: Proxmox VE development discussion, Fiona Ebner

Am 17.01.25 um 15:24 schrieb Fiona Ebner:
> Changes in v4:
> * dropped already applied patch
> * move import for get_host_arch() to earlier patch where it is already needed
> * squash rename and move patches for get_command_for_arch() together
> * rename machine_version_at_least -> is_machine_version_at_least
> * use a dedicated section to describe the new removal policy
> * drop table, instead describe how the cut-off decision is made with examples
> 
> Changes in v3:
> * improve code readibility for Windows machine version fallback change
> 
> Changes in v2:
> * change deprecation logic into QEMU itself rather than just weakening
>   the warning there (so no need to change the deprecation logic in
>   qemu-server anymore)
> * get rid of outdated information from "Update to a Newer Machine
>   Version" section in docs
> 
> 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.
> 
> This series is intended to allow broader QEMU 9.1 rollout. Still
> required in addition to this series before PVE 9:
> * wiki article about what to look out for when changing machine
>   version
> * checks in pve8to9 script giving errors/warnings when machine version
>   is too old
> 
> qemu-server:
> 
> Fiona Ebner (15):
>   machine: drop unused parameter from assert_valid_machine_property()
>     helper
>   move get_command_for_arch() helper to helpers module
>   move kvm_user_version() function to helpers module
>   move get_vm_arch() helper to helpers module
>   machine: add default_machine_for_arch() helper
>   move get_installed_machine_version() helper to machine module
>   move windows_get_pinned_machine_version() function to machine module
>   move get_vm_machine() function to machine module
>   move meta information handling to its own module
>   machine: fallback to creation QEMU version for windows starting with
>     9.1
>   machine: add check_and_pin_machine_string() helper
>   api: update vm config: pin machine version when switching to windows
>     os type
>   machine: log informational line when pinning machine version for
>     Windows guest
>   machine: rename machine_version() function to
>     is_machine_version_at_least()
>   machine: code cleanup: avoid superfluous augmented assignment operator
> 
>  PVE/API2/Qemu.pm                 |  44 +++++---
>  PVE/QemuServer.pm                | 184 +++----------------------------
>  PVE/QemuServer/Helpers.pm        |  49 ++++++++
>  PVE/QemuServer/Machine.pm        | 108 +++++++++++++++++-
>  PVE/QemuServer/Makefile          |   1 +
>  PVE/QemuServer/MetaInfo.pm       |  47 ++++++++
>  test/run_config2command_tests.pl |   3 +-
>  7 files changed, 249 insertions(+), 187 deletions(-)
>  create mode 100644 PVE/QemuServer/MetaInfo.pm
> 
> 
> pve-docs:
> 
> Fiona Ebner (1):
>   qm: machine version: document support in PVE
> 
>  qm.adoc | 34 ++++++++++++++++++++++++++--------
>  1 file changed, 26 insertions(+), 8 deletions(-)
> 
> 
> Summary over all repositories:
>   8 files changed, 275 insertions(+), 195 deletions(-)
> 


applied, thanks!


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


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

end of thread, other threads:[~2025-01-17 18:56 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-17 14:24 [pve-devel] [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 01/16] machine: drop unused parameter from assert_valid_machine_property() helper Fiona Ebner
2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 02/16] move get_command_for_arch() helper to helpers module Fiona Ebner
2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 03/16] move kvm_user_version() function " Fiona Ebner
2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 04/16] move get_vm_arch() helper " Fiona Ebner
2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 05/16] machine: add default_machine_for_arch() helper Fiona Ebner
2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 06/16] move get_installed_machine_version() helper to machine module Fiona Ebner
2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 07/16] move windows_get_pinned_machine_version() function " Fiona Ebner
2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 08/16] move get_vm_machine() " Fiona Ebner
2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 09/16] move meta information handling to its own module Fiona Ebner
2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 10/16] machine: fallback to creation QEMU version for windows starting with 9.1 Fiona Ebner
2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 11/16] machine: add check_and_pin_machine_string() helper Fiona Ebner
2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 12/16] api: update vm config: pin machine version when switching to windows os type Fiona Ebner
2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 13/16] machine: log informational line when pinning machine version for Windows guest Fiona Ebner
2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 14/16] machine: rename machine_version() function to is_machine_version_at_least() Fiona Ebner
2025-01-17 14:24 ` [pve-devel] [PATCH qemu-server v4 15/16] machine: code cleanup: avoid superfluous augmented assignment operator Fiona Ebner
2025-01-17 14:24 ` [pve-devel] [PATCH docs v4 16/16] qm: machine version: document support in PVE Fiona Ebner
2025-01-17 18:55 ` [pve-devel] applied-series: [PATCH qemu-server/docs v4 00/16] adapt to changes in QEMU machine version deprecation/removal Thomas Lamprecht

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