rename qemuBuildRNGDeviceArgs to qemuBuildRNGDevStr, we need this function to build a cmdline. Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx> --- src/qemu/qemu_command.c | 33 ++++++++++++++++----------------- src/qemu/qemu_command.h | 4 ++++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c1e9bca..46e289d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5800,22 +5800,19 @@ qemuBuildRNGBackendArgs(virCommandPtr cmd, return ret; } - -static int -qemuBuildRNGDeviceArgs(virCommandPtr cmd, - virDomainDefPtr def, - virDomainRNGDefPtr dev, - virQEMUCapsPtr qemuCaps) +char * +qemuBuildRNGDevStr(virDomainDefPtr def, + virDomainRNGDefPtr dev, + virQEMUCapsPtr qemuCaps) { virBuffer buf = VIR_BUFFER_INITIALIZER; - int ret = -1; if (dev->model != VIR_DOMAIN_RNG_MODEL_VIRTIO || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("this qemu doesn't support RNG device type '%s'"), virDomainRNGModelTypeToString(dev->model)); - goto cleanup; + goto error; } if (dev->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) @@ -5836,16 +5833,14 @@ qemuBuildRNGDeviceArgs(virCommandPtr cmd, } if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0) - goto cleanup; - - virCommandAddArg(cmd, "-device"); - virCommandAddArgBuffer(cmd, &buf); - - ret = 0; + goto error; + if (virBufferCheckError(&buf) < 0) + goto error; - cleanup: + return virBufferContentAndReset(&buf); + error: virBufferFreeAndReset(&buf); - return ret; + return NULL; } @@ -9802,13 +9797,17 @@ qemuBuildCommandLine(virConnectPtr conn, } for (i = 0; i < def->nrngs; i++) { + char *devstr; /* add the RNG source backend */ if (qemuBuildRNGBackendArgs(cmd, def->rngs[i], qemuCaps) < 0) goto error; /* add the device */ - if (qemuBuildRNGDeviceArgs(cmd, def, def->rngs[i], qemuCaps) < 0) + virCommandAddArg(cmd, "-device"); + if (!(devstr = qemuBuildRNGDevStr(def, def->rngs[i], qemuCaps))) goto error; + virCommandAddArg(cmd, devstr); + VIR_FREE(devstr); } if (def->nvram) { diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 9f3f249..4264215 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -163,6 +163,10 @@ char *qemuBuildPCIHostdevDevStr(virDomainDefPtr def, const char *configfd, virQEMUCapsPtr qemuCaps); +char *qemuBuildRNGDevStr(virDomainDefPtr def, + virDomainRNGDefPtr dev, + virQEMUCapsPtr qemuCaps); + int qemuOpenPCIConfig(virDomainHostdevDefPtr dev); /* Legacy, pre device support */ -- 1.8.3.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list