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@xxxxxxxxxx> --- 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 d06974f..45c6c63 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3732,8 +3732,8 @@ qemuBuildUSBHostdevDevStr(virDomainDefPtr def, } -char * -qemuBuildHubDevStr(virDomainDefPtr def, +static char * +qemuBuildHubDevStr(const virDomainDef *def, virDomainHubDefPtr dev, virQEMUCapsPtr qemuCaps) { @@ -3768,6 +3768,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) { @@ -7689,16 +7711,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 a2a566e..2e8521c 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -202,9 +202,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 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list