]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: domain: gfx: Iterate over graphics devices when doing validation
authorErik Skultety <eskultet@redhat.com>
Fri, 7 Dec 2018 13:53:46 +0000 (14:53 +0100)
committerErik Skultety <eskultet@redhat.com>
Wed, 12 Dec 2018 14:12:35 +0000 (15:12 +0100)
The QEMU validation code for graphics has been in place for a while, but
because it is only executed from virDomainDeviceInfoIterateInternal, it
was never run, since the iterator expects the device to have boot info
which graphics don't have. The unfortunate side effect of this whole mess
was that a few capabilities were missing from the test suite (as commit
d8266ebe1 demonstrated with graphics-spice-invalid-egl-headless test),
which in turn meant that a few graphics tests which expected a failure
happily accepted any failure the test runtime returned which made them
succeed. The impact of this was that we then allowed to start a domain
with multiple OpenGL-enabled graphics devices.

This patch enables iteration over graphics devices. Unsurprisingly,
a few tests started to fail as a result, so fix those too.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/conf/domain_conf.c
tests/qemuxml2argvtest.c
tests/qemuxml2xmltest.c

index e03bfbce90c78015cf53deca3a591e2c0e28c78c..0c7e69c12ee7df34b22eacaafc9cdaf16b101a02 100644 (file)
@@ -3705,6 +3705,7 @@ virDomainSkipBackcompatConsole(virDomainDefPtr def,
 
 enum {
     DOMAIN_DEVICE_ITERATE_ALL_CONSOLES = 1 << 0,
+    DOMAIN_DEVICE_ITERATE_GRAPHICS = 1 << 1
 } virDomainDeviceIterateFlags;
 
 /*
@@ -3870,6 +3871,17 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def,
             return rc;
     }
 
+    /* If the flag below is set, make sure @cb can handle @info being NULL, as
+     * graphics don't have any boot info */
+    if (iteratorFlags & DOMAIN_DEVICE_ITERATE_GRAPHICS) {
+        device.type = VIR_DOMAIN_DEVICE_GRAPHICS;
+        for (i = 0; i < def->ngraphics; i++) {
+            device.data.graphics = def->graphics[i];
+            if ((rc = cb(def, &device, NULL, opaque)) != 0)
+                return rc;
+        }
+    }
+
     /* Coverity is not very happy with this - all dead_error_condition */
 #if !STATIC_ANALYSIS
     /* This switch statement is here to trigger compiler warning when adding
@@ -6348,7 +6360,8 @@ virDomainDefValidate(virDomainDefPtr def,
     /* iterate the devices */
     if (virDomainDeviceInfoIterateInternal(def,
                                            virDomainDefValidateDeviceIterator,
-                                           DOMAIN_DEVICE_ITERATE_ALL_CONSOLES,
+                                           (DOMAIN_DEVICE_ITERATE_ALL_CONSOLES |
+                                            DOMAIN_DEVICE_ITERATE_GRAPHICS),
                                            &data) < 0)
         return -1;
 
index d031b9b08cc5e6a46a1ca320105900743cf2d178..88ecbba1c96b5b6e8112a16fa354bbd5115c2c9e 100644 (file)
@@ -1299,7 +1299,7 @@ mymain(void)
 
     DO_TEST("graphics-sdl",
             QEMU_CAPS_DEVICE_VGA);
-    DO_TEST_FAILURE("graphics-sdl-egl-headless", NONE);
+    DO_TEST_CAPS_LATEST_PARSE_ERROR("graphics-sdl-egl-headless");
     DO_TEST("graphics-sdl-fullscreen",
             QEMU_CAPS_DEVICE_CIRRUS_VGA);
     DO_TEST("graphics-spice",
@@ -1358,10 +1358,7 @@ mymain(void)
             QEMU_CAPS_SPICE,
             QEMU_CAPS_EGL_HEADLESS,
             QEMU_CAPS_DEVICE_QXL);
-    DO_TEST_FAILURE("graphics-spice-invalid-egl-headless",
-                    QEMU_CAPS_SPICE,
-                    QEMU_CAPS_EGL_HEADLESS,
-                    QEMU_CAPS_DEVICE_QXL);
+    DO_TEST_CAPS_LATEST_PARSE_ERROR("graphics-spice-invalid-egl-headless");
     DO_TEST_CAPS_LATEST("graphics-spice-gl-auto-rendernode");
 
     DO_TEST("input-usbmouse", NONE);
index c98b9571ef070fa13650d1706d33a25861198efc..1062deee37ff3bf09b7bafedd19f62769f5cc6d7 100644 (file)
@@ -402,7 +402,8 @@ mymain(void)
     cfg->vncAutoUnixSocket = false;
     DO_TEST("graphics-vnc-socket", NONE);
     DO_TEST("graphics-vnc-auto-socket", NONE);
-    DO_TEST("graphics-vnc-egl-headless", NONE);
+    DO_TEST("graphics-vnc-egl-headless",
+            QEMU_CAPS_EGL_HEADLESS);
 
     DO_TEST("graphics-sdl", NONE);
     DO_TEST("graphics-sdl-fullscreen", NONE);
@@ -414,9 +415,12 @@ mymain(void)
     cfg->spiceAutoUnixSocket = true;
     DO_TEST("graphics-spice-auto-socket-cfg", NONE);
     cfg->spiceAutoUnixSocket = false;
-    DO_TEST("graphics-spice-egl-headless", NONE);
+    DO_TEST("graphics-spice-egl-headless",
+            QEMU_CAPS_EGL_HEADLESS);
 
-    DO_TEST("graphics-egl-headless-rendernode", NONE);
+    DO_TEST("graphics-egl-headless-rendernode",
+            QEMU_CAPS_EGL_HEADLESS,
+            QEMU_CAPS_EGL_HEADLESS_RENDERNODE);
 
     DO_TEST("input-usbmouse", NONE);
     DO_TEST("input-usbtablet", NONE);