]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: command: move qemuBuildGraphicsSDLCommandLine validation to qemu_domain.c
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Mon, 9 Dec 2019 23:15:25 +0000 (20:15 -0300)
committerCole Robinson <crobinso@redhat.com>
Mon, 16 Dec 2019 22:51:19 +0000 (17:51 -0500)
There are validations for SDL, VNC, SPICE and EGL_HEADLESS
around several BuildGraphics*CommandLine in qemu_command.c. This
patch starts to move all of them to qemu_domain.c, inside the
existent qemuDomainDeviceDefValidateGraphics() function. This
function is called by qemuDomainDefValidate(), validating the
graphics parameters in domain define time.

In this patch we'll move the SDL validation code from
qemuBuildGraphicsSDLCommandLine(). Tests were adapted to consider
SDL validation in this earlier stage.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
tests/qemuxml2xmltest.c

index e547474f9a63b105d83b24443cad0b951eb7c179..3a360b72e0ed789bc90b598777befd5135310333 100644 (file)
@@ -7428,19 +7428,10 @@ qemuBuildGraphicsSDLCommandLine(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED,
     virCommandAddArg(cmd, "-display");
     virBufferAddLit(&opt, "sdl");
 
-    if (graphics->data.sdl.gl != VIR_TRISTATE_BOOL_ABSENT) {
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SDL_GL)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("OpenGL for SDL is not supported with this QEMU "
-                             "binary"));
-            return -1;
-        }
-
+    if (graphics->data.sdl.gl != VIR_TRISTATE_BOOL_ABSENT)
         virBufferAsprintf(&opt, ",gl=%s",
                           virTristateSwitchTypeToString(graphics->data.sdl.gl));
 
-    }
-
     virCommandAddArgBuffer(cmd, &opt);
 
     return 0;
@@ -7896,9 +7887,6 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
             break;
         case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
         case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("unsupported graphics type '%s'"),
-                           virDomainGraphicsTypeToString(graphics->type));
             return -1;
         case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
         default:
index 058c75d5878f9866db27fb72007ae5a7529dd5f8..3a636097c7e2db7d612d393b20d16d31df4eea4b 100644 (file)
@@ -7681,6 +7681,35 @@ qemuDomainDeviceDefValidateGraphics(const virDomainGraphicsDef *graphics,
         }
     }
 
+    switch (graphics->type) {
+    case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
+        if (graphics->data.sdl.gl != VIR_TRISTATE_BOOL_ABSENT) {
+            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SDL_GL)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("OpenGL for SDL is not supported with this QEMU "
+                                 "binary"));
+                return -1;
+            }
+        }
+        break;
+
+    case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
+        break;
+    case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
+        break;
+    case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
+        break;
+    case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
+    case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("unsupported graphics type '%s'"),
+                       virDomainGraphicsTypeToString(graphics->type));
+        return -1;
+    case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
+    default:
+        return -1;
+    }
+
     return 0;
 }
 
index d1eee0f00f12e8b2f699cf406cb8d89f88de6b41..3a696434569c71bb9484a9fdb4beced0abb7bc53 100644 (file)
@@ -1174,7 +1174,8 @@ mymain(void)
             QEMU_CAPS_VIRTIO_GPU_VIRGL);
     DO_TEST("video-virtio-gpu-sdl-gl",
             QEMU_CAPS_DEVICE_VIRTIO_GPU,
-            QEMU_CAPS_VIRTIO_GPU_VIRGL);
+            QEMU_CAPS_VIRTIO_GPU_VIRGL,
+            QEMU_CAPS_SDL_GL);
 
     DO_TEST("virtio-input",
             QEMU_CAPS_VIRTIO_KEYBOARD,