render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
51d9a2
From cb21f171f5b3e4b8579fa5344e533a8390c011f5 Mon Sep 17 00:00:00 2001
51d9a2
Message-Id: <cb21f171f5b3e4b8579fa5344e533a8390c011f5@dist-git>
51d9a2
From: Erik Skultety <eskultet@redhat.com>
51d9a2
Date: Thu, 19 Jul 2018 15:03:49 +0200
51d9a2
Subject: [PATCH] qemu: command: Move graphics iteration to its own function
51d9a2
MIME-Version: 1.0
51d9a2
Content-Type: text/plain; charset=UTF-8
51d9a2
Content-Transfer-Encoding: 8bit
51d9a2
51d9a2
It should be the command line helper who takes care of the iteration
51d9a2
rather than the caller.
51d9a2
51d9a2
Signed-off-by: Erik Skultety <eskultet@redhat.com>
51d9a2
Reviewed-by: John Ferlan <jferlan@redhat.com>
51d9a2
(cherry picked from commit afc107c20f6dc40529154a361222f9eca0cec94c)
51d9a2
51d9a2
https://bugzilla.redhat.com/show_bug.cgi?id=1475770
51d9a2
Signed-off-by: Erik Skultety <eskultet@redhat.com>
51d9a2
Reviewed-by: Ján Tomko <jtomko@redhat.com>
51d9a2
---
51d9a2
 src/qemu/qemu_command.c | 57 ++++++++++++++++++++++++++---------------
51d9a2
 1 file changed, 36 insertions(+), 21 deletions(-)
51d9a2
51d9a2
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
51d9a2
index f38ae668a7..8a8cbfd7f6 100644
51d9a2
--- a/src/qemu/qemu_command.c
51d9a2
+++ b/src/qemu/qemu_command.c
51d9a2
@@ -8212,26 +8212,44 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
51d9a2
 static int
51d9a2
 qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
51d9a2
                              virCommandPtr cmd,
51d9a2
-                             virQEMUCapsPtr qemuCaps,
51d9a2
-                             virDomainGraphicsDefPtr graphics)
51d9a2
+                             virDomainDefPtr def,
51d9a2
+                             virQEMUCapsPtr qemuCaps)
51d9a2
 {
51d9a2
-    switch (graphics->type) {
51d9a2
-    case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
51d9a2
-        return qemuBuildGraphicsSDLCommandLine(cfg, cmd, qemuCaps, graphics);
51d9a2
+    size_t i;
51d9a2
 
51d9a2
-    case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
51d9a2
-        return qemuBuildGraphicsVNCCommandLine(cfg, cmd, qemuCaps, graphics);
51d9a2
+    for (i = 0; i < def->ngraphics; i++) {
51d9a2
+        virDomainGraphicsDefPtr graphics = def->graphics[i];
51d9a2
 
51d9a2
-    case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
51d9a2
-        return qemuBuildGraphicsSPICECommandLine(cfg, cmd, qemuCaps, graphics);
51d9a2
+        switch (graphics->type) {
51d9a2
+        case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
51d9a2
+            if (qemuBuildGraphicsSDLCommandLine(cfg, cmd,
51d9a2
+                                                qemuCaps, graphics) < 0)
51d9a2
+                return -1;
51d9a2
 
51d9a2
-    case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
51d9a2
-    case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
51d9a2
-    case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
51d9a2
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
51d9a2
-                       _("unsupported graphics type '%s'"),
51d9a2
-                       virDomainGraphicsTypeToString(graphics->type));
51d9a2
-        return -1;
51d9a2
+            break;
51d9a2
+        case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
51d9a2
+            if (qemuBuildGraphicsVNCCommandLine(cfg, cmd,
51d9a2
+                                                qemuCaps, graphics) < 0)
51d9a2
+                return -1;
51d9a2
+
51d9a2
+            break;
51d9a2
+        case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
51d9a2
+            if (qemuBuildGraphicsSPICECommandLine(cfg, cmd,
51d9a2
+                                                  qemuCaps, graphics) < 0)
51d9a2
+                return -1;
51d9a2
+
51d9a2
+            break;
51d9a2
+        case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
51d9a2
+        case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
51d9a2
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
51d9a2
+                           _("unsupported graphics type '%s'"),
51d9a2
+                           virDomainGraphicsTypeToString(graphics->type));
51d9a2
+            return -1;
51d9a2
+        case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
51d9a2
+        default:
51d9a2
+            virReportEnumRangeError(virDomainGraphicsType, graphics->type);
51d9a2
+            return -1;
51d9a2
+        }
51d9a2
     }
51d9a2
 
51d9a2
     return 0;
51d9a2
@@ -10382,11 +10400,8 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
51d9a2
     if (qemuBuildInputCommandLine(cmd, def, qemuCaps) < 0)
51d9a2
         goto error;
51d9a2
 
51d9a2
-    for (i = 0; i < def->ngraphics; ++i) {
51d9a2
-        if (qemuBuildGraphicsCommandLine(cfg, cmd, qemuCaps,
51d9a2
-                                         def->graphics[i]) < 0)
51d9a2
-            goto error;
51d9a2
-    }
51d9a2
+    if (qemuBuildGraphicsCommandLine(cfg, cmd, def, qemuCaps) < 0)
51d9a2
+        goto error;
51d9a2
 
51d9a2
     if (qemuBuildVideoCommandLine(cmd, def, qemuCaps) < 0)
51d9a2
         goto error;
51d9a2
-- 
51d9a2
2.18.0
51d9a2