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(a)redhat.com>
---
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 372f84f..caf6f37 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) {
@@ -7907,30 +7945,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 b10fc29..6e22872 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -115,17 +115,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