]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: command: Fix building of the SDL display command line
authorErik Skultety <eskultet@redhat.com>
Tue, 19 Jun 2018 16:04:57 +0000 (18:04 +0200)
committerErik Skultety <eskultet@redhat.com>
Mon, 9 Jul 2018 15:45:19 +0000 (17:45 +0200)
QEMU uses a shorthand '-sdl' which maps to '-display sdl'. However, if
there are any options to be passed to SDL, the full command version must
be used. Everything seemingly worked for us until commit 5038b300437
introduced OpenGL support for SDL and added ',gl=on/off' option which as
mentioned above could have never worked with the shorthand version of
the command. Indeed starting a domain with an SDL display and OpenGL
enabled, QEMU produces a rather cryptic error:

-sdl: Could not open 'gl=on': No such file or directory

This patch provides fixes to both the SDL cmdline generation and the
test suite.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_command.c
tests/qemuxml2argvdata/graphics-sdl-fullscreen.args
tests/qemuxml2argvdata/graphics-sdl.args
tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.args

index 8a1bfbd5fe0174d0e659b43280a5ecc680595be5..cea31e6a24e7d9bf56e16e57f0ec06db19b8a7ec 100644 (file)
@@ -7765,7 +7765,6 @@ qemuBuildGraphicsSDLCommandLine(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
 {
     int ret = -1;
     virBuffer opt = VIR_BUFFER_INITIALIZER;
-    const char *optContent;
 
     if (graphics->data.sdl.xauth)
         virCommandAddEnvPair(cmd, "XAUTHORITY", graphics->data.sdl.xauth);
@@ -7781,22 +7780,26 @@ qemuBuildGraphicsSDLCommandLine(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
     virCommandAddEnvPassBlockSUID(cmd, "QEMU_AUDIO_DRV", NULL);
     virCommandAddEnvPassBlockSUID(cmd, "SDL_AUDIODRIVER", NULL);
 
-    virCommandAddArg(cmd, "-sdl");
+    virCommandAddArg(cmd, "-display");
+    virBufferAddLit(&opt, "sdl");
 
-    if (graphics->data.sdl.gl == VIR_TRISTATE_BOOL_YES) {
+    if (graphics->data.sdl.gl != VIR_TRISTATE_BOOL_ABSENT) {
         if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SDL_GL)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("This QEMU doesn't support SDL OpenGL"));
+                           _("OpenGL for SDL is not supported with this QEMU "
+                             "binary"));
             goto cleanup;
         }
 
-        virBufferAsprintf(&opt, "gl=%s",
+        virBufferAsprintf(&opt, ",gl=%s",
                           virTristateSwitchTypeToString(graphics->data.sdl.gl));
+
     }
 
-    optContent = virBufferCurrentContent(&opt);
-    if (optContent && STRNEQ(optContent, ""))
-        virCommandAddArgBuffer(cmd, &opt);
+    if (virBufferCheckError(&opt) < 0)
+        goto cleanup;
+
+    virCommandAddArgBuffer(cmd, &opt);
 
     ret = 0;
  cleanup:
index 2da9d1e3270b5648a8dc949efea9e200cc7f8943..0741baa0396f1bba664ed9203d0f32426acfd518 100644 (file)
@@ -25,5 +25,5 @@ server,nowait \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
 -full-screen \
--sdl \
+-display sdl \
 -vga cirrus
index 29a0a3d8239fb1430df5e832c2be5223154b0336..2553679738f56c9f7f5c21cbdade9bf2615c438f 100644 (file)
@@ -24,5 +24,5 @@ server,nowait \
 -usb \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
--sdl \
+-display sdl \
 -vga std
index 4172320ede2defdd18ca278789e82902db18920e..f8610e53b0ada87cfb3405de9ec3e5200860f3a0 100644 (file)
@@ -23,6 +23,6 @@ server,nowait \
 -drive file=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=none,\
 id=drive-ide0-0-0,cache=none \
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
--sdl gl=on \
+-display sdl,gl=on \
 -device virtio-gpu-pci,id=video0,virgl=on,bus=pci.0,addr=0x2 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3