[PATCH 08/25] qemu: Introduce qemuBuildFSDevCommandLine

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

 



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

Since both qemuBuildFSStr and qemuBuildFSDevStr are local, make them
static and fix their prototypes to use the const virDomainDef as well.
Make some minor formatting changes for long lines.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 74 ++++++++++++++++++++++++++++++-------------------
 src/qemu/qemu_command.h |  6 +---
 2 files changed, 46 insertions(+), 34 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ae478d8..7b25a7c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1928,8 +1928,9 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
 }
 
 
-char *qemuBuildFSStr(virDomainFSDefPtr fs,
-                     virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED)
+static char *
+qemuBuildFSStr(virDomainFSDefPtr fs,
+               virQEMUCapsPtr qemuCaps)
 {
     virBuffer opt = VIR_BUFFER_INITIALIZER;
     const char *driver = qemuDomainFSDriverTypeToString(fs->fsdriver);
@@ -2002,8 +2003,8 @@ char *qemuBuildFSStr(virDomainFSDefPtr fs,
 }
 
 
-char *
-qemuBuildFSDevStr(virDomainDefPtr def,
+static char *
+qemuBuildFSDevStr(const virDomainDef *def,
                   virDomainFSDefPtr fs,
                   virQEMUCapsPtr qemuCaps)
 {
@@ -2021,7 +2022,8 @@ qemuBuildFSDevStr(virDomainDefPtr def,
         virBufferAddLit(&opt, "virtio-9p-pci");
 
     virBufferAsprintf(&opt, ",id=%s", fs->info.alias);
-    virBufferAsprintf(&opt, ",fsdev=%s%s", QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
+    virBufferAsprintf(&opt, ",fsdev=%s%s",
+                      QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
     virBufferAsprintf(&opt, ",mount_tag=%s", fs->dst);
 
     if (qemuBuildDeviceAddressStr(&opt, def, &fs->info, qemuCaps) < 0)
@@ -2039,6 +2041,42 @@ qemuBuildFSDevStr(virDomainDefPtr def,
 
 
 static int
+qemuBuildFSDevCommandLine(virCommandPtr cmd,
+                          const virDomainDef *def,
+                          virQEMUCapsPtr qemuCaps)
+{
+    size_t i;
+
+    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_FSDEV)) {
+        for (i = 0; i < def->nfss; i++) {
+            char *optstr;
+            virDomainFSDefPtr fs = def->fss[i];
+
+            virCommandAddArg(cmd, "-fsdev");
+            if (!(optstr = qemuBuildFSStr(fs, qemuCaps)))
+                return -1;
+            virCommandAddArg(cmd, optstr);
+            VIR_FREE(optstr);
+
+            virCommandAddArg(cmd, "-device");
+            if (!(optstr = qemuBuildFSDevStr(def, fs, qemuCaps)))
+                return -1;
+            virCommandAddArg(cmd, optstr);
+            VIR_FREE(optstr);
+        }
+    } else {
+        if (def->nfss) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("filesystem passthrough not supported by this QEMU"));
+            return -1;
+        }
+    }
+
+    return 0;
+}
+
+
+static int
 qemuControllerModelUSBToCaps(int model)
 {
     switch (model) {
@@ -7878,30 +7916,8 @@ qemuBuildCommandLine(virConnectPtr conn,
                                       emitBootindex) < 0)
         goto error;
 
-    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_FSDEV)) {
-        for (i = 0; i < def->nfss; i++) {
-            char *optstr;
-            virDomainFSDefPtr fs = def->fss[i];
-
-            virCommandAddArg(cmd, "-fsdev");
-            if (!(optstr = qemuBuildFSStr(fs, qemuCaps)))
-                goto error;
-            virCommandAddArg(cmd, optstr);
-            VIR_FREE(optstr);
-
-            virCommandAddArg(cmd, "-device");
-            if (!(optstr = qemuBuildFSDevStr(def, fs, qemuCaps)))
-                goto error;
-            virCommandAddArg(cmd, optstr);
-            VIR_FREE(optstr);
-        }
-    } else {
-        if (def->nfss) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("filesystem passthrough not supported by this QEMU"));
-            goto error;
-        }
-    }
+    if (qemuBuildFSDevCommandLine(cmd, def, qemuCaps) < 0)
+        goto error;
 
     if (!def->nnets) {
         /* If we have -device, then we set -nodefault already */
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 9bed794..2a71ac6 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -112,17 +112,13 @@ char *qemuBuildDriveStr(virConnectPtr conn,
                         virDomainDiskDefPtr disk,
                         bool bootable,
                         virQEMUCapsPtr qemuCaps);
-char *qemuBuildFSStr(virDomainFSDefPtr fs,
-                     virQEMUCapsPtr qemuCaps);
 
 /* Current, best practice */
 char *qemuBuildDriveDevStr(const virDomainDef *def,
                            virDomainDiskDefPtr disk,
                            int bootindex,
                            virQEMUCapsPtr qemuCaps);
-char *qemuBuildFSDevStr(virDomainDefPtr domainDef,
-                        virDomainFSDefPtr fs,
-                        virQEMUCapsPtr qemuCaps);
+
 /* Current, best practice */
 char *qemuBuildControllerDevStr(const virDomainDef *domainDef,
                                 virDomainControllerDefPtr def,
-- 
2.5.0

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]