[pve-devel] [PATCH qemu-server 2/2] cfg2cmd: split out helper for vga properties

Fiona Ebner f.ebner at proxmox.com
Fri May 31 17:13:30 CEST 2024


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

Signed-off-by: Fiona Ebner <f.ebner at 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





More information about the pve-devel mailing list