libvirt/libvirt-qemuDeviceVideoGetModel-Simplify-by-relying-on-checks-from-qemuValidateDomainDeviceDefVideo.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

141 lines
4.7 KiB
Diff

From 4c33439fbcd0eb9ea09ab9a8a6aa5b8780ac9175 Mon Sep 17 00:00:00 2001
Message-ID: <4c33439fbcd0eb9ea09ab9a8a6aa5b8780ac9175.1784297532.git.jdenemar@redhat.com>
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 10 Jun 2026 12:38:00 +0200
Subject: [PATCH] qemuDeviceVideoGetModel: Simplify by relying on checks from
'qemuValidateDomainDeviceDefVideo'
'qemuValidateDomainDeviceDefVideo' ensures that only the correct video
device models are selected as well as that only QXL and VIRTIO video
devices can be selected as secondary.
Remove unnecessary checks and simplify the code.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 736c0f455a0edf1ed6961558f6ece877f5f7dbc6)
https://redhat.atlassian.net/browse/RHEL-186019
https://redhat.atlassian.net/browse/RHEL-177646 (rhel-9.9)
---
src/qemu/qemu_command.c | 94 ++++++++++++++++++-----------------------
1 file changed, 40 insertions(+), 54 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 2f19a6c1ff..963dc2afa3 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -737,7 +737,32 @@ qemuDeviceVideoGetModel(const virDomainVideoDef *video,
*virtio = false;
*virtioBusSuffix = false;
- if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO) {
+ /* 'qemuValidateDomainDeviceDefVideo' ensures that only supported models
+ * are used as well as that only 'QXL' and 'virtio' graphics can be
+ * secondary */
+ 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:
+ if (video->primary)
+ return "qxl-vga";
+
+ return "qxl";
+
+ case VIR_DOMAIN_VIDEO_TYPE_BOCHS:
+ return "bochs-display";
+
+ case VIR_DOMAIN_VIDEO_TYPE_RAMFB:
+ return "ramfb";
+
+ case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: {
struct qemuDeviceVideoModelVirtioOpts *opts = &qemuDeviceVideoGetModelVirtioOptsTable[video->virtiodevice];
*virtio = opts->virtio;
@@ -746,61 +771,22 @@ qemuDeviceVideoGetModel(const virDomainVideoDef *video,
return virDomainVideoVirtioDeviceTypeToString(video->virtiodevice);
}
- if (video->primary) {
- switch ((virDomainVideoType) video->type) {
- case VIR_DOMAIN_VIDEO_TYPE_VGA:
- return "VGA";
+ 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:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("invalid model for video type '%1$s'"),
+ virDomainVideoTypeToString(video->type));
+ return NULL;
- 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_BOCHS:
- return "bochs-display";
-
- case VIR_DOMAIN_VIDEO_TYPE_RAMFB:
- return "ramfb";
- case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
- 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:
- return "qxl";
-
- case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
- 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;
- }
+ case VIR_DOMAIN_VIDEO_TYPE_LAST:
+ default:
+ virReportEnumRangeError(virDomainVideoType, video->type);
+ return NULL;
}
-
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("invalid model for video type '%1$s'"),
- virDomainVideoTypeToString(video->type));
- return NULL;
}
--
2.55.0