[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH REPOST 6/9] qemu: Introduce qemuBuildHubCommandLine



Add new function to manage adding the hub -device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also make qemuBuildHubDevStr static to the module since it's only
used here.

Signed-off-by: John Ferlan <jferlan redhat com>
---
 src/qemu/qemu_command.c | 38 ++++++++++++++++++++++++++------------
 src/qemu/qemu_command.h |  3 ---
 2 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index bf2cb1a..ef94af8 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3744,8 +3744,8 @@ qemuBuildUSBHostdevDevStr(virDomainDefPtr def,
 }
 
 
-char *
-qemuBuildHubDevStr(virDomainDefPtr def,
+static char *
+qemuBuildHubDevStr(const virDomainDef *def,
                    virDomainHubDefPtr dev,
                    virQEMUCapsPtr qemuCaps)
 {
@@ -3780,6 +3780,28 @@ qemuBuildHubDevStr(virDomainDefPtr def,
 }
 
 
+static int
+qemuBuildHubCommandLine(virCommandPtr cmd,
+                        const virDomainDef *def,
+                        virQEMUCapsPtr qemuCaps)
+{
+    size_t i;
+
+    for (i = 0; i < def->nhubs; i++) {
+        virDomainHubDefPtr hub = def->hubs[i];
+        char *optstr;
+
+        virCommandAddArg(cmd, "-device");
+        if (!(optstr = qemuBuildHubDevStr(def, hub, qemuCaps)))
+            return -1;
+        virCommandAddArg(cmd, optstr);
+        VIR_FREE(optstr);
+    }
+
+    return 0;
+}
+
+
 char *
 qemuBuildUSBHostdevUSBDevStr(virDomainHostdevDefPtr dev)
 {
@@ -7718,16 +7740,8 @@ qemuBuildCommandLine(virConnectPtr conn,
     if (qemuBuildControllerDevCommandLine(cmd, def, qemuCaps) < 0)
         goto error;
 
-    for (i = 0; i < def->nhubs; i++) {
-        virDomainHubDefPtr hub = def->hubs[i];
-        char *optstr;
-
-        virCommandAddArg(cmd, "-device");
-        if (!(optstr = qemuBuildHubDevStr(def, hub, qemuCaps)))
-            goto error;
-        virCommandAddArg(cmd, optstr);
-        VIR_FREE(optstr);
-    }
+    if (qemuBuildHubCommandLine(cmd, def, qemuCaps) < 0)
+        goto error;
 
     if ((virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_BOOT) || emitBootindex)) {
         /* bootDevs will get translated into either bootindex=N or boot=on
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index ec18869..ed4f5bd 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -205,9 +205,6 @@ char *qemuBuildSCSIHostdevDevStr(virDomainDefPtr def,
                                  virDomainHostdevDefPtr dev,
                                  virQEMUCapsPtr qemuCaps);
 
-char *qemuBuildHubDevStr(virDomainDefPtr def,
-                         virDomainHubDefPtr dev,
-                         virQEMUCapsPtr qemuCaps);
 char *qemuBuildRedirdevDevStr(virDomainDefPtr def,
                               virDomainRedirdevDefPtr dev,
                               virQEMUCapsPtr qemuCaps);
-- 
2.5.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]