]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: use virDomainDefHasGraphics
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Sun, 16 Mar 2025 08:18:30 +0000 (12:18 +0400)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 18 Mar 2025 13:15:56 +0000 (14:15 +0100)
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_validate.c

index ef217ffc9ecf0acebcc9eecbbb19ef6148320270..eae75d7bf5ecc4494f7a0844b14c50d02da56d6b 100644 (file)
@@ -4491,8 +4491,6 @@ qemuValidateDomainDeviceDefGraphics(const virDomainGraphicsDef *graphics,
                                     virQEMUCaps *qemuCaps)
 {
     virDomainCapsDeviceGraphics graphicsCaps = { 0 };
-    bool have_egl_headless = false;
-    size_t i;
 
     virQEMUCapsFillDomainDeviceGraphicsCaps(qemuCaps, &graphicsCaps);
 
@@ -4503,18 +4501,11 @@ qemuValidateDomainDeviceDefGraphics(const virDomainGraphicsDef *graphics,
         return -1;
     }
 
-    for (i = 0; i < def->ngraphics; i++) {
-        if (def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS) {
-            have_egl_headless = true;
-            break;
-        }
-    }
-
     /* Only VNC and SPICE can be paired with egl-headless, the other types
      * either don't make sense to pair with egl-headless or aren't even
      * supported by QEMU.
      */
-    if (have_egl_headless) {
+    if (virDomainDefHasGraphics(def, VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS)) {
         if (graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS &&
             graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
             graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {