From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server v4 08/16] move get_vm_machine() function to machine module
Date: Fri, 17 Jan 2025 15:24:22 +0100 [thread overview]
Message-ID: <20250117142430.99484-9-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250117142430.99484-1-f.ebner@proxmox.com>
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
next prev parent reply other threads:[~2025-01-17 14:26 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Fiona Ebner [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250117142430.99484-9-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox