Use the new helper to initialize child XML element buffers. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 58a82fbd60..16cbc41118 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2298,7 +2298,7 @@ static int qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src, virBufferPtr buf) { - g_auto(virBuffer) tmp = VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) tmp = VIR_BUFFER_INIT_CHILD(buf); qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src); int ret = -1; @@ -2317,8 +2317,6 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src, if (virStorageSourcePrivateDataFormatRelPath(src, buf) < 0) goto cleanup; - virBufferSetChildIndent(&tmp, buf); - if (srcPriv) { qemuStorageSourcePrivateDataFormatSecinfo(&tmp, srcPriv->secinfo, "auth"); qemuStorageSourcePrivateDataFormatSecinfo(&tmp, srcPriv->encinfo, "encryption"); @@ -2444,11 +2442,9 @@ qemuDomainObjPrivateXMLFormatBlockjobFormatSource(virBufferPtr buf, bool chain) { g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; - g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf); unsigned int xmlflags = VIR_DOMAIN_DEF_FORMAT_STATUS; - virBufferSetChildIndent(&childBuf, buf); - virBufferAsprintf(&attrBuf, " type='%s' format='%s'", virStorageTypeToString(src->type), virStorageFileFormatTypeToString(src->format)); @@ -2471,20 +2467,17 @@ qemuDomainObjPrivateXMLFormatBlockjobIterator(void *payload, const void *name G_GNUC_UNUSED, void *opaque) { + struct qemuDomainPrivateBlockJobFormatData *data = opaque; g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; - g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER; - g_auto(virBuffer) chainsBuf = VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(data->buf); + g_auto(virBuffer) chainsBuf = VIR_BUFFER_INIT_CHILD(&childBuf); qemuBlockJobDataPtr job = payload; const char *state = qemuBlockjobStateTypeToString(job->state); const char *newstate = NULL; - struct qemuDomainPrivateBlockJobFormatData *data = opaque; if (job->newstate != -1) newstate = qemuBlockjobStateTypeToString(job->newstate); - virBufferSetChildIndent(&childBuf, data->buf); - virBufferSetChildIndent(&chainsBuf, &childBuf); - virBufferEscapeString(&attrBuf, " name='%s'", job->name); virBufferEscapeString(&attrBuf, " type='%s'", qemuBlockjobTypeToString(job->type)); virBufferEscapeString(&attrBuf, " state='%s'", state); @@ -2567,7 +2560,7 @@ qemuDomainObjPrivateXMLFormatBlockjobs(virBufferPtr buf, { qemuDomainObjPrivatePtr priv = vm->privateData; g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; - g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf); bool bj = qemuDomainHasBlockjob(vm, false); struct qemuDomainPrivateBlockJobFormatData iterdata = { priv->driver->xmlopt, &childBuf }; @@ -2575,8 +2568,6 @@ qemuDomainObjPrivateXMLFormatBlockjobs(virBufferPtr buf, virBufferAsprintf(&attrBuf, " active='%s'", virTristateBoolTypeToString(virTristateBoolFromBool(bj))); - virBufferSetChildIndent(&childBuf, buf); - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) && virHashForEach(priv->blockjobs, qemuDomainObjPrivateXMLFormatBlockjobIterator, @@ -2613,11 +2604,9 @@ qemuDomainObjPrivateXMLFormatNBDMigrationSource(virBufferPtr buf, virDomainXMLOptionPtr xmlopt) { g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; - g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf); int ret = -1; - virBufferSetChildIndent(&childBuf, buf); - virBufferAsprintf(&attrBuf, " type='%s' format='%s'", virStorageTypeToString(src->type), virStorageFileFormatTypeToString(src->format)); @@ -2640,19 +2629,17 @@ qemuDomainObjPrivateXMLFormatNBDMigration(virBufferPtr buf, virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; - g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; - g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER; size_t i; virDomainDiskDefPtr disk; qemuDomainDiskPrivatePtr diskPriv; int ret = -1; for (i = 0; i < vm->def->ndisks; i++) { + g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf); disk = vm->def->disks[i]; diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); - virBufferSetChildIndent(&childBuf, buf); - virBufferAsprintf(&attrBuf, " dev='%s' migrating='%s'", disk->dst, diskPriv->migrating ? "yes" : "no"); @@ -2678,7 +2665,7 @@ qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf, qemuDomainObjPrivatePtr priv) { g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; - g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf); qemuDomainJob job = priv->job.active; int ret = -1; @@ -2689,8 +2676,6 @@ qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf, priv->job.asyncJob == QEMU_ASYNC_JOB_NONE) return 0; - virBufferSetChildIndent(&childBuf, buf); - virBufferAsprintf(&attrBuf, " type='%s' async='%s'", qemuDomainJobTypeToString(job), qemuDomainAsyncJobTypeToString(priv->job.asyncJob)); -- 2.23.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list