From 9fb7ccb3cfc13fc58d9575813f276fa049368cd9 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 10 Feb 2020 14:23:30 +0100 Subject: [PATCH] qemu: domain: Refactor formatting of node names into status XML MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use virXMLFormatElement to simplify the logic. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_domain.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 1adb5d7454..14e8c38c7b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2370,15 +2370,12 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src, { g_auto(virBuffer) tmp = VIR_BUFFER_INIT_CHILD(buf); qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src); + g_auto(virBuffer) nodenamesChildBuf = VIR_BUFFER_INIT_CHILD(buf); - if (src->nodestorage || src->nodeformat) { - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); - virBufferEscapeString(buf, "\n", src->nodestorage); - virBufferEscapeString(buf, "\n", src->nodeformat); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } + virBufferEscapeString(&nodenamesChildBuf, "\n", src->nodestorage); + virBufferEscapeString(&nodenamesChildBuf, "\n", src->nodeformat); + + virXMLFormatElement(buf, "nodenames", NULL, &nodenamesChildBuf); if (src->pr) virBufferAsprintf(buf, "\n", src->pr->mgralias);