all lists on 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 2/2] cfg2cmd: split out helper for vga properties
Date: Fri, 31 May 2024 17:13:30 +0200	[thread overview]
Message-ID: <20240531151330.106977-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20240531151330.106977-1-f.ebner@proxmox.com>

To remove some line bloat from the config_to_command() function.

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

Original motivation was to prepare for a deprectation warning for
display type 'cirrus'. However, it might not get deprecated after
all:
https://lore.kernel.org/qemu-devel/usd6hvncbao47zklcb5qlpvjcuk7odryu57f45imxienyltlec@2ujm6g2gr2od/

Still, adding the helper doesn't hurt IMHO.

 PVE/QemuServer.pm | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index cf593383..a1f8adea 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3493,6 +3493,27 @@ my sub print_ovmf_drive_commandlines {
     return ("if=pflash,unit=0,format=raw,readonly=on,file=$ovmf_code", $var_drive_str);
 }
 
+my sub get_vga_properties {
+    my ($conf, $arch, $machine_version, $winversion) = @_;
+
+    my $vga = parse_vga($conf->{vga});
+
+    my $qxlnum = vga_conf_has_spice($conf->{vga});
+    $vga->{type} = 'qxl' if $qxlnum;
+
+    if (!$vga->{type}) {
+	if ($arch eq 'aarch64') {
+	    $vga->{type} = 'virtio';
+	} elsif (min_version($machine_version, 2, 9)) {
+	    $vga->{type} = (!$winversion || $winversion >= 6) ? 'std' : 'cirrus';
+	} else {
+	    $vga->{type} = ($winversion >= 6) ? 'std' : 'cirrus';
+	}
+    }
+
+    return ($vga, $qxlnum);
+}
+
 sub config_to_command {
     my ($storecfg, $vmid, $conf, $defaults, $forcemachine, $forcecpu,
         $live_restore_backing) = @_;
@@ -3644,20 +3665,8 @@ sub config_to_command {
     my @usbcontrollers = PVE::QemuServer::USB::get_usb_controllers(
 	$conf, $bridges, $arch, $machine_type, $machine_version);
     push @$devices, @usbcontrollers if @usbcontrollers;
-    my $vga = parse_vga($conf->{vga});
 
-    my $qxlnum = vga_conf_has_spice($conf->{vga});
-    $vga->{type} = 'qxl' if $qxlnum;
-
-    if (!$vga->{type}) {
-	if ($arch eq 'aarch64') {
-	    $vga->{type} = 'virtio';
-	} elsif (min_version($machine_version, 2, 9)) {
-	    $vga->{type} = (!$winversion || $winversion >= 6) ? 'std' : 'cirrus';
-	} else {
-	    $vga->{type} = ($winversion >= 6) ? 'std' : 'cirrus';
-	}
-    }
+    my ($vga, $qxlnum) = get_vga_properties($conf, $arch, $machine_version, $winversion);
 
     # enable absolute mouse coordinates (needed by vnc)
     my $tablet = $conf->{tablet};
-- 
2.39.2



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


  reply	other threads:[~2024-05-31 15:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-31 15:13 [pve-devel] [PATCH qemu-server 1/2] schema: vga: mention that type 'cirrus' should not be used Fiona Ebner
2024-05-31 15:13 ` Fiona Ebner [this message]
2024-07-04 11:57   ` [pve-devel] applied: [PATCH qemu-server 2/2] cfg2cmd: split out helper for vga properties Fabian Grünbichler
2024-07-04 11:57 ` [pve-devel] applied: [PATCH qemu-server 1/2] schema: vga: mention that type 'cirrus' should not be used Fabian Grünbichler

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=20240531151330.106977-2-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal