On 03/08/2016 02:03 PM, John Ferlan wrote: > 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 <jfer...@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; > + } > + } > +
Can you do the (!QEMU_CAPS_FSDEV && def->nfss) return -1; check up front, so the logic doesn't need to be indented? ACK with that if you agree - Cole -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list