* [pve-devel] [PATCH qemu 01/19] weaken machine version deprecation warning
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
@ 2025-01-03 15:57 ` Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 02/19] machine: drop unused parameter from assert_valid_machine_property() helper Fiona Ebner
` (18 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:57 UTC (permalink / raw)
To: pve-devel
In 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.
PVE will warn about deprecated machine versions when it considers them
to be deprecated, so avoid a scary-sounding warning from QEMU proper
and turn it into an informational message about pre-deprecation.
Reported-by: Martin Maurer <martin@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
...-machine-version-deprecation-warning.patch | 56 +++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 57 insertions(+)
create mode 100644 debian/patches/pve/0052-weaken-machine-version-deprecation-warning.patch
diff --git a/debian/patches/pve/0052-weaken-machine-version-deprecation-warning.patch b/debian/patches/pve/0052-weaken-machine-version-deprecation-warning.patch
new file mode 100644
index 0000000..b8cfc67
--- /dev/null
+++ b/debian/patches/pve/0052-weaken-machine-version-deprecation-warning.patch
@@ -0,0 +1,56 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Fiona Ebner <f.ebner@proxmox.com>
+Date: Fri, 3 Jan 2025 14:03:12 +0100
+Subject: [PATCH] weaken machine version deprecation warning
+
+In 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.
+
+PVE will warn about deprecated machine versions when it considers them
+to be deprecated, so avoid a scary-sounding warning from QEMU proper
+and turn it into an informational message about pre-deprecation.
+
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
+---
+ include/hw/boards.h | 4 +---
+ system/vl.c | 2 +-
+ 2 files changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/include/hw/boards.h b/include/hw/boards.h
+index 5cddeb7fcb..4f30824b57 100644
+--- a/include/hw/boards.h
++++ b/include/hw/boards.h
+@@ -619,9 +619,7 @@ struct MachineState {
+ * message for a versioned machine type
+ */
+ #define MACHINE_VER_DEPRECATION_MSG \
+- "machines more than " stringify(MACHINE_VER_DEPRECATION_MAJOR) \
+- " years old are subject to deletion after " \
+- stringify(MACHINE_VER_DELETION_MAJOR) " years"
++ "machine version is rather old"
+
+ #define _MACHINE_VER_IS_EXPIRED_IMPL(cutoff, major, minor) \
+ (((QEMU_VERSION_MAJOR - major) > cutoff) || \
+diff --git a/system/vl.c b/system/vl.c
+index 0dbdba6421..67822c6b6c 100644
+--- a/system/vl.c
++++ b/system/vl.c
+@@ -3769,7 +3769,7 @@ void qemu_init(int argc, char **argv)
+
+ machine_class = MACHINE_GET_CLASS(current_machine);
+ if (!qtest_enabled() && machine_class->deprecation_reason) {
+- warn_report("Machine type '%s' is deprecated: %s",
++ info_report("Machine type '%s': %s",
+ machine_class->name, machine_class->deprecation_reason);
+ }
+
diff --git a/debian/patches/series b/debian/patches/series
index 0b48878..ffbfd29 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -61,3 +61,4 @@ pve/0048-PVE-backup-fixup-error-handling-for-fleecing.patch
pve/0049-PVE-backup-factor-out-setting-up-snapshot-access-for.patch
pve/0050-PVE-backup-save-device-name-in-device-info-structure.patch
pve/0051-PVE-backup-include-device-name-in-error-when-setting.patch
+pve/0052-weaken-machine-version-deprecation-warning.patch
--
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] 22+ messages in thread
* [pve-devel] [PATCH qemu-server 02/19] machine: drop unused parameter from assert_valid_machine_property() helper
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu 01/19] weaken machine version deprecation warning Fiona Ebner
@ 2025-01-03 15:57 ` Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 03/19] move get_command_for_arch() helper to helpers module Fiona Ebner
` (17 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:57 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 c7f45051..dc46e2e0 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1249,7 +1249,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;
@@ -2112,7 +2112,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 b3d5f8f2..19324e96 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4182,7 +4182,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] 22+ messages in thread
* [pve-devel] [PATCH qemu-server 03/19] move get_command_for_arch() helper to helpers module
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu 01/19] weaken machine version deprecation warning Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 02/19] machine: drop unused parameter from assert_valid_machine_property() helper Fiona Ebner
@ 2025-01-03 15:57 ` Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 04/19] helpers: improve name for variable for mapping arch to binary Fiona Ebner
` (16 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:57 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.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
PVE/QemuServer.pm | 19 +++----------------
PVE/QemuServer/Helpers.pm | 13 +++++++++++++
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 19324e96..468c9a2d 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;
@@ -3386,19 +3386,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:
@@ -3433,7 +3420,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);
@@ -3623,7 +3610,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..d58bad2b 100644
--- a/PVE/QemuServer/Helpers.pm
+++ b/PVE/QemuServer/Helpers.pm
@@ -19,6 +19,19 @@ windows_version
my $nodename = PVE::INotify::nodename();
+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 get_host_arch() eq $arch; # i.e. native arch
+
+ my $cmd = $Arch2Qemu->{$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] 22+ messages in thread
* [pve-devel] [PATCH qemu-server 04/19] helpers: improve name for variable for mapping arch to binary
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (2 preceding siblings ...)
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 03/19] move get_command_for_arch() helper to helpers module Fiona Ebner
@ 2025-01-03 15:57 ` Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 05/19] move kvm_user_version() function to helpers module Fiona Ebner
` (15 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:57 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
PVE/QemuServer/Helpers.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/PVE/QemuServer/Helpers.pm b/PVE/QemuServer/Helpers.pm
index d58bad2b..be10a92a 100644
--- a/PVE/QemuServer/Helpers.pm
+++ b/PVE/QemuServer/Helpers.pm
@@ -19,7 +19,7 @@ windows_version
my $nodename = PVE::INotify::nodename();
-my $Arch2Qemu = {
+my $arch_to_qemu_binary = {
aarch64 => '/usr/bin/qemu-system-aarch64',
x86_64 => '/usr/bin/qemu-system-x86_64',
};
@@ -27,7 +27,7 @@ sub get_command_for_arch($) {
my ($arch) = @_;
return '/usr/bin/kvm' if get_host_arch() eq $arch; # i.e. native arch
- my $cmd = $Arch2Qemu->{$arch}
+ my $cmd = $arch_to_qemu_binary->{$arch}
or die "don't know how to emulate architecture '$arch'\n";
return $cmd;
}
--
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] 22+ messages in thread
* [pve-devel] [PATCH qemu-server 05/19] move kvm_user_version() function to helpers module
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (3 preceding siblings ...)
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 04/19] helpers: improve name for variable for mapping arch to binary Fiona Ebner
@ 2025-01-03 15:57 ` Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 06/19] move get_vm_arch() helper " Fiona Ebner
` (14 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:57 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 | 31 +++++++++++++++++++++++++++++++
test/run_config2command_tests.pl | 3 ++-
4 files changed, 35 insertions(+), 33 deletions(-)
diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index dc46e2e0..41ad1cb6 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -853,7 +853,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 468c9a2d..1827c024 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 be10a92a..07b2ff6e 100644
--- a/PVE/QemuServer/Helpers.pm
+++ b/PVE/QemuServer/Helpers.pm
@@ -8,11 +8,13 @@ use JSON;
use PVE::INotify;
use PVE::ProcFSTools;
+use PVE::Tools qw(get_host_arch);
use base 'Exporter';
our @EXPORT_OK = qw(
min_version
config_aware_timeout
+kvm_user_version
parse_number_sets
windows_version
);
@@ -32,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] 22+ messages in thread
* [pve-devel] [PATCH qemu-server 06/19] move get_vm_arch() helper to helpers module
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (4 preceding siblings ...)
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 05/19] move kvm_user_version() function to helpers module Fiona Ebner
@ 2025-01-03 15:57 ` Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 07/19] machine: add default_machine_for_arch() helper Fiona Ebner
` (13 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:57 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 41ad1cb6..4c8b2bc0 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1197,7 +1197,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+$/;
@@ -2033,7 +2033,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 1827c024..32b2a835 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3260,11 +3260,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',
@@ -3579,7 +3574,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);
@@ -4659,7 +4654,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);
@@ -4901,7 +4896,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
@@ -8482,7 +8477,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] 22+ messages in thread
* [pve-devel] [PATCH qemu-server 07/19] machine: add default_machine_for_arch() helper
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (5 preceding siblings ...)
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 06/19] move get_vm_arch() helper " Fiona Ebner
@ 2025-01-03 15:57 ` Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 08/19] move get_installed_machine_version() helper to machine module Fiona Ebner
` (12 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:57 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 32b2a835..85bbb38f 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3260,11 +3260,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);
@@ -3309,7 +3304,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";
}
@@ -3375,7 +3370,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] 22+ messages in thread
* [pve-devel] [PATCH qemu-server 08/19] move get_installed_machine_version() helper to machine module
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (6 preceding siblings ...)
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 07/19] machine: add default_machine_for_arch() helper Fiona Ebner
@ 2025-01-03 15:57 ` Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 09/19] move windows_get_pinned_machine_version() function " Fiona Ebner
` (11 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:57 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 85bbb38f..5b1ad3bc 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3260,13 +3260,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) = @_;
@@ -3274,7 +3267,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] 22+ messages in thread
* [pve-devel] [PATCH qemu-server 09/19] move windows_get_pinned_machine_version() function to machine module
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (7 preceding siblings ...)
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 08/19] move get_installed_machine_version() helper to machine module Fiona Ebner
@ 2025-01-03 15:57 ` Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 10/19] move get_vm_machine() " Fiona Ebner
` (10 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:57 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 4c8b2bc0..528fc261 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1245,7 +1245,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 5b1ad3bc..6ae524b2 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3260,28 +3260,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) = @_;
@@ -3294,7 +3272,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] 22+ messages in thread
* [pve-devel] [PATCH qemu-server 10/19] move get_vm_machine() function to machine module
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (8 preceding siblings ...)
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 09/19] move windows_get_pinned_machine_version() function " Fiona Ebner
@ 2025-01-03 15:57 ` Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 11/19] move meta information handling to its own module Fiona Ebner
` (9 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:57 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 528fc261..4ad9165a 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -851,7 +851,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 6ae524b2..af8712f6 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3260,40 +3260,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) = @_;
@@ -3549,7 +3515,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);
@@ -4863,7 +4829,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] 22+ messages in thread
* [pve-devel] [PATCH qemu-server 11/19] move meta information handling to its own module
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (9 preceding siblings ...)
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 10/19] move get_vm_machine() " Fiona Ebner
@ 2025-01-03 15:57 ` Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 12/19] machine: get vm machine: fallback to creation QEMU version for windows starting with 9.1 Fiona Ebner
` (8 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:57 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 4ad9165a..7eba3a33 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;
@@ -1204,7 +1205,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 af8712f6..12e5543d 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] 22+ messages in thread
* [pve-devel] [PATCH qemu-server 12/19] machine: get vm machine: fallback to creation QEMU version for windows starting with 9.1
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (10 preceding siblings ...)
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 11/19] move meta information handling to its own module Fiona Ebner
@ 2025-01-03 15:57 ` Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 13/19] machine: add check_and_pin_machine_string() helper Fiona Ebner
` (7 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:57 UTC (permalink / raw)
To: pve-devel
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
^ permalink raw reply [flat|nested] 22+ messages in thread
* [pve-devel] [PATCH qemu-server 13/19] machine: add check_and_pin_machine_string() helper
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (11 preceding siblings ...)
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 12/19] machine: get vm machine: fallback to creation QEMU version for windows starting with 9.1 Fiona Ebner
@ 2025-01-03 15:57 ` Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [RFC qemu-server 14/19] api: update vm config: pin machine version when switching to windows os type Fiona Ebner
` (6 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:57 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 7eba3a33..27711ee6 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1241,17 +1241,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 679d69c7..cf00da6d 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -260,4 +260,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] 22+ messages in thread
* [pve-devel] [RFC qemu-server 14/19] api: update vm config: pin machine version when switching to windows os type
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (12 preceding siblings ...)
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 13/19] machine: add check_and_pin_machine_string() helper Fiona Ebner
@ 2025-01-03 15:57 ` Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 15/19] machine: log informational line when pinning machine version for Windows guest Fiona Ebner
` (5 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:57 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.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
RFC because it is rather auto-magic-y, so not fully sure we want it.
PVE/API2/Qemu.pm | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 27711ee6..4f5448e3 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -2108,6 +2108,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] 22+ messages in thread
* [pve-devel] [PATCH qemu-server 15/19] machine: log informational line when pinning machine version for Windows guest
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (13 preceding siblings ...)
2025-01-03 15:57 ` [pve-devel] [RFC qemu-server 14/19] api: update vm config: pin machine version when switching to windows os type Fiona Ebner
@ 2025-01-03 15:57 ` Fiona Ebner
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 16/19] machine: rename machine_version() function to machine_version_at_least() Fiona Ebner
` (4 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:57 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 cf00da6d..9b18cf6e 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -269,6 +269,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] 22+ messages in thread
* [pve-devel] [PATCH qemu-server 16/19] machine: rename machine_version() function to machine_version_at_least()
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (14 preceding siblings ...)
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 15/19] machine: log informational line when pinning machine version for Windows guest Fiona Ebner
@ 2025-01-03 15:57 ` Fiona Ebner
2025-01-03 15:58 ` [pve-devel] [PATCH qemu-server 17/19] machine: adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (3 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:57 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>
---
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 12e5543d..5e577431 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4521,7 +4521,7 @@ sub qemu_cpu_hotplug {
if ($vcpus < $currentvcpus) {
- if (PVE::QemuServer::Machine::machine_version($machine_type, 2, 7)) {
+ if (PVE::QemuServer::Machine::machine_version_at_least($machine_type, 2, 7)) {
for (my $i = $currentvcpus; $i > $vcpus; $i--) {
qemu_devicedel($vmid, "cpu$i");
@@ -4549,7 +4549,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::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 9b18cf6e..6398e756 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -136,7 +136,7 @@ sub extract_version {
return;
}
-sub machine_version {
+sub 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] 22+ messages in thread
* [pve-devel] [PATCH qemu-server 17/19] machine: adapt to changes in QEMU machine version deprecation/removal
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (15 preceding siblings ...)
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 16/19] machine: rename machine_version() function to machine_version_at_least() Fiona Ebner
@ 2025-01-03 15:58 ` Fiona Ebner
2025-01-03 15:58 ` [pve-devel] [PATCH qemu-server 18/19] machine: code cleanup: avoid superfluous augmented assignment operator Fiona Ebner
` (2 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:58 UTC (permalink / raw)
To: pve-devel
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
^ permalink raw reply [flat|nested] 22+ messages in thread
* [pve-devel] [PATCH qemu-server 18/19] machine: code cleanup: avoid superfluous augmented assignment operator
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (16 preceding siblings ...)
2025-01-03 15:58 ` [pve-devel] [PATCH qemu-server 17/19] machine: adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
@ 2025-01-03 15:58 ` Fiona Ebner
2025-01-03 15:58 ` [pve-devel] [PATCH docs 19/19] qm: machine version: document support in PVE Fiona Ebner
2025-01-04 7:58 ` [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Dietmar Maurer
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:58 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 79be4a0e..3b9c826e 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -248,7 +248,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] 22+ messages in thread
* [pve-devel] [PATCH docs 19/19] qm: machine version: document support in PVE
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (17 preceding siblings ...)
2025-01-03 15:58 ` [pve-devel] [PATCH qemu-server 18/19] machine: code cleanup: avoid superfluous augmented assignment operator Fiona Ebner
@ 2025-01-03 15:58 ` Fiona Ebner
2025-01-04 7:58 ` [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Dietmar Maurer
19 siblings, 0 replies; 22+ messages in thread
From: Fiona Ebner @ 2025-01-03 15:58 UTC (permalink / raw)
To: pve-devel
Elaborate on new QEMU machine version removal policy and how PVE will
support machine versions. Make sure to also mention the years, so that
users immediately have a good idea for how long it will be.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
qm.adoc | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/qm.adoc b/qm.adoc
index 94fdd4e..695013c 100644
--- a/qm.adoc
+++ b/qm.adoc
@@ -173,6 +173,32 @@ 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).
+Starting with QEMU 10.1, machine versions will be 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, more details below.
+
+There will be an early informational message if a machine version is used that
+is going to be dropped at some point during the next major {pve} release life
+cycle. Before upgrading to a new major {pve} release, you should update all
+those machine versions to ensure that the guests can still be used throughout
+that release.
+
+The following table shows the expected baselines of supported machine versions
+for the current and upcoming major {pve} releases (best guesses):
+
+[width="100%",cols=">s,>,>s,2*>",options="header"]
+|===============================================================================================
+| {pve} | active development | supported baseline | dropped during life cycle | last QEMU binary
+| 8 | 2023-2025 | 2.4 | 2.3 and older | 9.2
+| 9 | 2025-2027 | 6.0 | 5.2 and older | 11.2
+| 10 | 2027-2029 | 8.0 | 7.2 and older | 13.2
+|===============================================================================================
+
+NOTE: Support for {pve} releases is longer than active development, but no new
+QEMU binary versions will be added after active development, just backports and
+fixes for existing binary versions.
+
[[qm_machine_update]]
Update to a Newer Machine 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] 22+ messages in thread
* Re: [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal
2025-01-03 15:57 [pve-devel] [PATCH qemu/qemu-server/docs 00/19] adapt to changes in QEMU machine version deprecation/removal Fiona Ebner
` (18 preceding siblings ...)
2025-01-03 15:58 ` [pve-devel] [PATCH docs 19/19] qm: machine version: document support in PVE Fiona Ebner
@ 2025-01-04 7:58 ` Dietmar Maurer
2025-01-04 8:00 ` Dietmar Maurer
19 siblings, 1 reply; 22+ messages in thread
From: Dietmar Maurer @ 2025-01-04 7:58 UTC (permalink / raw)
To: Proxmox VE development discussion, Fiona Ebner
19 patches for this seems to be too much. Maybe we can try to cleanup the qemu code for those checks and send those patches upstream (In order to make this series shorter)?
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 22+ messages in thread