[libvirt] [PATCH 4/4] conf: domain: gfx: Iterate over graphics devices when doing validation

Erik Skultety eskultet at redhat.com
Fri Dec 7 14:47:56 UTC 2018


The validation code for graphics has been in place for a while, but
because it is only executed from the device iterator, that validation
code was never truly run. The unfortunate side effect of this whole mess
was that a few capabilities were missing from the test suite, which in
turn meant that a few graphics test which expected a failure happily
accepted whatever failure the parser returned which made them succeed
even though in reality we allowed to start a domain with multiple
OpenGL-enabled graphics devices.
This patch enables iteration over graphics devices. Unsurprisingly,
a few tests started failing as a result, so fix those too.

Signed-off-by: Erik Skultety <eskultet at redhat.com>
---
 src/conf/domain_conf.c   | 13 ++++++++++++-
 tests/qemuxml2argvtest.c |  7 ++-----
 tests/qemuxml2xmltest.c  | 10 +++++++---
 3 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 11552bff5b..a4c762a210 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3705,6 +3705,7 @@ virDomainSkipBackcompatConsole(virDomainDefPtr def,
 
 typedef enum {
     DEVICE_INFO_ITERATE_ALL_CONSOLES = 1 << 0, /* Iterate console[0] */
+    DEVICE_INFO_ITERATE_GRAPHICS = 1 << 1 /* Iterate graphics */
 } virDomainDeviceInfoIterateFlags;
 
 /*
@@ -3870,6 +3871,15 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def,
             return rc;
     }
 
+    if (iteratorFlags & DEVICE_INFO_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 +6358,8 @@ virDomainDefValidate(virDomainDefPtr def,
     /* iterate the devices */
     if (virDomainDeviceInfoIterateInternal(def,
                                            virDomainDefValidateDeviceIterator,
-                                           DEVICE_INFO_ITERATE_ALL_CONSOLES,
+                                           (DEVICE_INFO_ITERATE_ALL_CONSOLES |
+                                            DEVICE_INFO_ITERATE_GRAPHICS),
                                            &data) < 0)
         return -1;
 
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 528139654c..05451863ad 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1299,7 +1299,7 @@ mymain(void)
 
     DO_TEST("graphics-sdl",
             QEMU_CAPS_DEVICE_VGA);
-    DO_TEST_FAILURE("graphics-sdl-egl-headless", NONE);
+    DO_TEST_PARSE_ERROR_CAPS_LATEST("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_PARSE_ERROR_CAPS_LATEST("graphics-spice-invalid-egl-headless");
     DO_TEST_CAPS_LATEST("graphics-spice-gl-auto-rendernode");
 
     DO_TEST("input-usbmouse", NONE);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index c98b9571ef..1062deee37 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -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);
-- 
2.19.2




More information about the libvir-list mailing list