Instead of source to enable use of virBuffer functions in string construction. Signed-off-by: Anya Harter <aharter@xxxxxxxxxx> --- src/qemu/qemu_command.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e05b106a5e..a99240992a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4657,7 +4657,8 @@ static char * qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, virQEMUCapsPtr qemuCaps) { - char *source = NULL; + virBuffer buf = VIR_BUFFER_INITIALIZER; + char *netsource = NULL; virJSONValuePtr srcprops = NULL; virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi; @@ -4670,21 +4671,25 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, goto cleanup; if (!(netsource = virQEMUBuildDriveCommandlineFromJSON(srcprops))) goto cleanup; - if (virAsprintf(&source, "%s,if=none,format=raw", netsource) < 0) - goto cleanup; + virBufferAsprintf(&buf, "%s,if=none,format=raw", netsource); } else { /* Rather than pull what we think we want - use the network disk code */ if (!(netsource = qemuBuildNetworkDriveStr(iscsisrc->src, srcPriv ? srcPriv->secinfo : NULL))) goto cleanup; - if (virAsprintf(&source, "file=%s,if=none,format=raw", netsource) < 0) - goto cleanup; + virBufferAsprintf(&buf, "file=%s,if=none,format=raw", netsource); } + if (virBufferCheckError(&buf) < 0) + goto cleanup; + + return virBufferContentAndReset(&buf); + cleanup: VIR_FREE(netsource); virJSONValueFree(srcprops); - return source; + virBufferFreeAndReset(&buf); + return NULL; } char * -- 2.17.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list