public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server 09/19] move windows_get_pinned_machine_version() function to machine module
Date: Fri,  3 Jan 2025 16:57:52 +0100	[thread overview]
Message-ID: <20250103155802.143669-10-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250103155802.143669-1-f.ebner@proxmox.com>

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


  parent reply	other threads:[~2025-01-03 16:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` [pve-devel] [PATCH qemu-server 03/19] move get_command_for_arch() helper to helpers module 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
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 ` [pve-devel] [PATCH qemu-server 06/19] move get_vm_arch() helper " Fiona Ebner
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 ` [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 [this message]
2025-01-03 15:57 ` [pve-devel] [PATCH qemu-server 10/19] move get_vm_machine() function " Fiona Ebner
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 ` [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 ` [pve-devel] [PATCH qemu-server 13/19] machine: add check_and_pin_machine_string() helper 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
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 ` [pve-devel] [PATCH qemu-server 16/19] machine: rename machine_version() function to machine_version_at_least() 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
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 ` [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
2025-01-04  8:00   ` Dietmar Maurer

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=20250103155802.143669-10-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal