[PATCH 1/1] qemu: fix type of default video device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If a graphics device is added to XML that has no video device, libvirt
automatically adds a video device which is always of type 'cirrus', even if
the underlying qemu doesn't support cirrus.

This patch refines a bit the decision about the type of the video device.
Based on QEMU capabilities, cirrus is still preferred but only added if QEMU
supports it, otherwise QXL is preferred for SPICE and Bochs for UEFI guests.
VGA is used as a fallback.

(For some info about QEMU display devices see e.g.
https://www.kraxel.org/blog/2019/09/display-devices-in-qemu/ .)

https://bugzilla.redhat.com/show_bug.cgi?id=1668141

Signed-off-by: Pavel Mores <pmores@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index b4175a846e..a37ff1d384 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7821,7 +7821,8 @@ qemuDomainDeviceNetDefPostParse(virDomainNetDefPtr net,
 
 static int
 qemuDomainDeviceVideoDefPostParse(virDomainVideoDefPtr video,
-                                  const virDomainDef *def)
+                                  const virDomainDef *def,
+                                  virQEMUCapsPtr qemuCaps)
 {
     if (video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) {
         if (ARCH_IS_PPC64(def->os.arch))
@@ -7830,8 +7831,20 @@ qemuDomainDeviceVideoDefPostParse(virDomainVideoDefPtr video,
                  qemuDomainIsRISCVVirt(def) ||
                  ARCH_IS_S390(def->os.arch))
             video->type = VIR_DOMAIN_VIDEO_TYPE_VIRTIO;
-        else
-            video->type = VIR_DOMAIN_VIDEO_TYPE_CIRRUS;
+        else {
+            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA)) {
+                video->type = VIR_DOMAIN_VIDEO_TYPE_CIRRUS;
+            } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE)
+                    && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL)) {
+                video->type = VIR_DOMAIN_VIDEO_TYPE_QXL;
+                video->vgamem = QEMU_QXL_VGAMEM_DEFAULT;
+            } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_BOCHS_DISPLAY)
+                    && def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_EFI) {
+                video->type = VIR_DOMAIN_VIDEO_TYPE_BOCHS;
+            } else {
+                video->type = VIR_DOMAIN_VIDEO_TYPE_VGA;
+            }
+        }
     }
 
     if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
@@ -7926,7 +7939,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
         break;
 
     case VIR_DOMAIN_DEVICE_VIDEO:
-        ret = qemuDomainDeviceVideoDefPostParse(dev->data.video, def);
+        ret = qemuDomainDeviceVideoDefPostParse(dev->data.video, def, qemuCaps);
         break;
 
     case VIR_DOMAIN_DEVICE_PANIC:
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux