libvirt/libvirt-qemuDeviceVideoGetModel-Directly-return-picked-model.patch
Jiri Denemark ea91cce6f3 libvirt-11.10.0-15.el9
- qemu: capabilities: Apply 'capability_filters' configration option on all capabilities (RHEL-177646)
- qemu: capabilities: Export 'virQEMUCapsNewCopy' outside of 'qemu_capspriv' (RHEL-177646)
- qemu: Allow reuse of 'qemuProcessStartUpdateCustomCaps' (RHEL-177646)
- qemu: validate: Validate VM config with qemuCaps influenced by <qemu:capabilities> (RHEL-177646)
- qemu: postparse: Process VM config with qemuCaps influenced by <qemu:capabilities> (RHEL-177646)
- virQEMUCapsCacheLookupDefault: Fix error message when no emulators are installed (RHEL-177646)
- qemuxmlconfdata: un-symlink 'video-virtio-vga-gpu-gl' output (RHEL-177646)
- qemuxmlconftest: Add 'video-virtio-vga' invocation with QEMU_CAPS_DEVICE_VIRTIO_VGA disabled (RHEL-177646)
- qemuxmlconftest: Add test cases for configs asking for 'virtio-gpu-gl' or 'virtio-vga-gl' without the capability (RHEL-177646)
- qemuxmlconftest: Add invocation of 'video-virtio-vga-gpu-gl' with missing caps and VIR_DOMAIN_DEF_PARSE_ABI_UPDATE (RHEL-177646)
- qemustatusxml2xml: Add test case capturing virtio video device (RHEL-177646)
- virDomainVideoDefFormat: Use 'virXMLFormatElement' instead of custom formatter (RHEL-177646)
- conf: Add fields for recording actually-selected virtio video device (RHEL-177646)
- qemuxmlconftest: Add test case for specifying 'virtio-gpu' where 'virtio-vga' would be picked (RHEL-177646)
- qemuDeviceVideoGetModel: Directly return picked model (RHEL-177646)
- qemu: postparse: Fill in selected virtio video frondend device in the XML (RHEL-177646)
- qemuValidateDomainDeviceDefVideo: Fix checks of virtio video devices (RHEL-177646)
- qemuDeviceVideoGetModel: Remove logic for selecting 'virtio' devices (RHEL-177646)
- qemuDeviceVideoGetModel: Simplify by relying on checks from 'qemuValidateDomainDeviceDefVideo' (RHEL-177646)
- qemu: Remove 'qemuDomainSupportsVideoVga' (RHEL-177646)

Resolves: RHEL-177646
2026-07-17 16:12:12 +02:00

213 lines
7.5 KiB
Diff

From a3f72e88927f270bc17a7cb47f7abec988b208c9 Mon Sep 17 00:00:00 2001
Message-ID: <a3f72e88927f270bc17a7cb47f7abec988b208c9.1784297532.git.jdenemar@redhat.com>
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 8 Jun 2026 15:11:45 +0200
Subject: [PATCH] qemuDeviceVideoGetModel: Directly return picked model
There's no point in falling through to the check reporting invalid
type since if the code picks a model that one will be valid.
Reorganize the code so that we can return final decision right away.
This means that the two flags 'virtio' and 'virtioBusSuffix' need to be
set prior to the return.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit d3bd2142095e8203d9cc49448e7761553b0b2600)
https://redhat.atlassian.net/browse/RHEL-186019
https://redhat.atlassian.net/browse/RHEL-177646 (rhel-9.9)
---
src/qemu/qemu_command.c | 156 +++++++++++++++++++---------------------
1 file changed, 75 insertions(+), 81 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index db72407ecc..619ad7a835 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -719,7 +719,6 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps,
bool *virtio,
bool *virtioBusSuffix)
{
- const char *model = NULL;
bool primaryVga = false;
virTristateBool accel3d = VIR_TRISTATE_BOOL_ABSENT;
@@ -732,98 +731,93 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps,
if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps))
primaryVga = true;
+ if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) {
+ if (primaryVga)
+ return "vhost-user-vga";
+
+ *virtio = true;
+ *virtioBusSuffix = true;
+ return "vhost-user-gpu";
+ }
+
/* We try to chose the best model for primary video device by preferring
* model with VGA compatibility mode. For some video devices on some
* architectures there might not be such model so fallback to one
* without VGA compatibility mode. */
- if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) {
- if (primaryVga) {
- model = "vhost-user-vga";
- } else {
- model = "vhost-user-gpu";
+ if (primaryVga) {
+ switch ((virDomainVideoType) video->type) {
+ case VIR_DOMAIN_VIDEO_TYPE_VGA:
+ return "VGA";
+
+ case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
+ return "cirrus-vga";
+
+ case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
+ return "vmware-svga";
+
+ case VIR_DOMAIN_VIDEO_TYPE_QXL:
+ return "qxl-vga";
+
+ case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
*virtio = true;
- *virtioBusSuffix = true;
+ *virtioBusSuffix = false;
+
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_VGA_GL) &&
+ accel3d == VIR_TRISTATE_BOOL_YES)
+ return "virtio-vga-gl";
+
+ return "virtio-vga";
+
+ case VIR_DOMAIN_VIDEO_TYPE_BOCHS:
+ return "bochs-display";
+
+ case VIR_DOMAIN_VIDEO_TYPE_RAMFB:
+ return "ramfb";
+
+ case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
+ case VIR_DOMAIN_VIDEO_TYPE_XEN:
+ case VIR_DOMAIN_VIDEO_TYPE_VBOX:
+ case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
+ case VIR_DOMAIN_VIDEO_TYPE_GOP:
+ case VIR_DOMAIN_VIDEO_TYPE_NONE:
+ case VIR_DOMAIN_VIDEO_TYPE_LAST:
+ break;
}
} else {
- if (primaryVga) {
- switch ((virDomainVideoType) video->type) {
- case VIR_DOMAIN_VIDEO_TYPE_VGA:
- model = "VGA";
- break;
- case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
- model = "cirrus-vga";
- break;
- case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
- model = "vmware-svga";
- break;
- case VIR_DOMAIN_VIDEO_TYPE_QXL:
- model = "qxl-vga";
- break;
- case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
- if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_VGA_GL) &&
- accel3d == VIR_TRISTATE_BOOL_YES)
- model = "virtio-vga-gl";
- else
- model = "virtio-vga";
+ switch ((virDomainVideoType) video->type) {
+ case VIR_DOMAIN_VIDEO_TYPE_QXL:
+ return "qxl";
- *virtio = true;
- *virtioBusSuffix = false;
- break;
- case VIR_DOMAIN_VIDEO_TYPE_BOCHS:
- model = "bochs-display";
- break;
- case VIR_DOMAIN_VIDEO_TYPE_RAMFB:
- model = "ramfb";
- break;
- case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
- case VIR_DOMAIN_VIDEO_TYPE_XEN:
- case VIR_DOMAIN_VIDEO_TYPE_VBOX:
- case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
- case VIR_DOMAIN_VIDEO_TYPE_GOP:
- case VIR_DOMAIN_VIDEO_TYPE_NONE:
- case VIR_DOMAIN_VIDEO_TYPE_LAST:
- break;
- }
- } else {
- switch ((virDomainVideoType) video->type) {
- case VIR_DOMAIN_VIDEO_TYPE_QXL:
- model = "qxl";
- break;
- case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
- if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_GL_PCI) &&
- accel3d == VIR_TRISTATE_BOOL_YES)
- model = "virtio-gpu-gl";
- else
- model = "virtio-gpu";
+ case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
+ *virtio = true;
+ *virtioBusSuffix = true;
- *virtio = true;
- *virtioBusSuffix = true;
- break;
- case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
- case VIR_DOMAIN_VIDEO_TYPE_VGA:
- case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
- case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
- case VIR_DOMAIN_VIDEO_TYPE_XEN:
- case VIR_DOMAIN_VIDEO_TYPE_VBOX:
- case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
- case VIR_DOMAIN_VIDEO_TYPE_GOP:
- case VIR_DOMAIN_VIDEO_TYPE_NONE:
- case VIR_DOMAIN_VIDEO_TYPE_BOCHS:
- case VIR_DOMAIN_VIDEO_TYPE_RAMFB:
- case VIR_DOMAIN_VIDEO_TYPE_LAST:
- break;
- }
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_GL_PCI) &&
+ accel3d == VIR_TRISTATE_BOOL_YES)
+ return "virtio-gpu-gl";
+
+ return "virtio-gpu";
+
+ case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
+ case VIR_DOMAIN_VIDEO_TYPE_VGA:
+ case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
+ case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
+ case VIR_DOMAIN_VIDEO_TYPE_XEN:
+ case VIR_DOMAIN_VIDEO_TYPE_VBOX:
+ case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
+ case VIR_DOMAIN_VIDEO_TYPE_GOP:
+ case VIR_DOMAIN_VIDEO_TYPE_NONE:
+ case VIR_DOMAIN_VIDEO_TYPE_BOCHS:
+ case VIR_DOMAIN_VIDEO_TYPE_RAMFB:
+ case VIR_DOMAIN_VIDEO_TYPE_LAST:
+ break;
}
}
- if (!model || STREQ(model, "")) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("invalid model for video type '%1$s'"),
- virDomainVideoTypeToString(video->type));
- return NULL;
- }
-
- return model;
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("invalid model for video type '%1$s'"),
+ virDomainVideoTypeToString(video->type));
+ return NULL;
}
--
2.55.0