From ff767f083f559ee1143b7347169ffdeb51de65e7 Mon Sep 17 00:00:00 2001 From: Erik Skultety Date: Tue, 19 Jun 2018 18:04:57 +0200 Subject: [PATCH] qemu: command: Fix building of the SDL display command line 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 Reviewed-by: John Ferlan --- src/qemu/qemu_command.c | 19 +++++++++++-------- .../graphics-sdl-fullscreen.args | 2 +- tests/qemuxml2argvdata/graphics-sdl.args | 2 +- .../video-virtio-gpu-sdl-gl.args | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8a1bfbd5fe..cea31e6a24 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -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: diff --git a/tests/qemuxml2argvdata/graphics-sdl-fullscreen.args b/tests/qemuxml2argvdata/graphics-sdl-fullscreen.args index 2da9d1e327..0741baa039 100644 --- a/tests/qemuxml2argvdata/graphics-sdl-fullscreen.args +++ b/tests/qemuxml2argvdata/graphics-sdl-fullscreen.args @@ -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 diff --git a/tests/qemuxml2argvdata/graphics-sdl.args b/tests/qemuxml2argvdata/graphics-sdl.args index 29a0a3d823..2553679738 100644 --- a/tests/qemuxml2argvdata/graphics-sdl.args +++ b/tests/qemuxml2argvdata/graphics-sdl.args @@ -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 diff --git a/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.args b/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.args index 4172320ede..f8610e53b0 100644 --- a/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.args +++ b/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.args @@ -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 -- 2.47.2