[libvirt] [PATCH v2 1/5] qemu_command: Move SDL command line building into helper

Maciej Wolny posted 5 patches 7 years ago
[libvirt] [PATCH v2 1/5] qemu_command: Move SDL command line building into helper
Posted by Maciej Wolny 7 years ago
Create a function called `qemuBuildGraphicsSDLCommandLine` which is
called from qemuBuildGraphicsCommandLine.

Signed-off-by: Maciej Wolny <maciej.wolny@codethink.co.uk>
---
 src/qemu/qemu_command.c | 49 +++++++++++++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 20 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c6bf6d583..d8a44b9e6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7568,6 +7568,34 @@ qemuBuildMemoryDeviceCommandLine(virCommandPtr cmd,
 
 
 static int
+qemuBuildGraphicsSDLCommandLine(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
+                                virCommandPtr cmd,
+                                virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED,
+                                virDomainGraphicsDefPtr graphics)
+{
+    if (graphics->data.sdl.xauth)
+        virCommandAddEnvPair(cmd, "XAUTHORITY", graphics->data.sdl.xauth);
+    if (graphics->data.sdl.display)
+        virCommandAddEnvPair(cmd, "DISPLAY", graphics->data.sdl.display);
+    if (graphics->data.sdl.fullscreen)
+        virCommandAddArg(cmd, "-full-screen");
+
+    /* If using SDL for video, then we should just let it
+     * use QEMU's host audio drivers, possibly SDL too
+     * User can set these two before starting libvirtd
+     */
+    virCommandAddEnvPassBlockSUID(cmd, "QEMU_AUDIO_DRV", NULL);
+    virCommandAddEnvPassBlockSUID(cmd, "SDL_AUDIODRIVER", NULL);
+
+    /* New QEMU has this flag to let us explicitly ask for
+     * SDL graphics. This is better than relying on the
+     * default, since the default changes :-( */
+    virCommandAddArg(cmd, "-sdl");
+    return 0;
+}
+
+
+static int
 qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
                                 virCommandPtr cmd,
                                 virQEMUCapsPtr qemuCaps,
@@ -7946,26 +7974,7 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
 {
     switch (graphics->type) {
     case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
-        if (graphics->data.sdl.xauth)
-            virCommandAddEnvPair(cmd, "XAUTHORITY", graphics->data.sdl.xauth);
-        if (graphics->data.sdl.display)
-            virCommandAddEnvPair(cmd, "DISPLAY", graphics->data.sdl.display);
-        if (graphics->data.sdl.fullscreen)
-            virCommandAddArg(cmd, "-full-screen");
-
-        /* If using SDL for video, then we should just let it
-         * use QEMU's host audio drivers, possibly SDL too
-         * User can set these two before starting libvirtd
-         */
-        virCommandAddEnvPassBlockSUID(cmd, "QEMU_AUDIO_DRV", NULL);
-        virCommandAddEnvPassBlockSUID(cmd, "SDL_AUDIODRIVER", NULL);
-
-        /* New QEMU has this flag to let us explicitly ask for
-         * SDL graphics. This is better than relying on the
-         * default, since the default changes :-( */
-        virCommandAddArg(cmd, "-sdl");
-
-        break;
+        return qemuBuildGraphicsSDLCommandLine(cfg, cmd, qemuCaps, graphics);
 
     case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
         return qemuBuildGraphicsVNCCommandLine(cfg, cmd, qemuCaps, graphics);
-- 
2.11.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 1/5] qemu_command: Move SDL command line building into helper
Posted by John Ferlan 7 years ago

On 05/10/2018 06:53 AM, Maciej Wolny wrote:
> Create a function called `qemuBuildGraphicsSDLCommandLine` which is
> called from qemuBuildGraphicsCommandLine.
> 
> Signed-off-by: Maciej Wolny <maciej.wolny@codethink.co.uk>
> ---
>  src/qemu/qemu_command.c | 49 +++++++++++++++++++++++++++++--------------------
>  1 file changed, 29 insertions(+), 20 deletions(-)
> 

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

[yes, the new function could be a void now, but it's changing in a
couple patches so leave things as is]

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list