render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From 3559a27948b48c93295867ff5c8390aad0456a34 Mon Sep 17 00:00:00 2001
Message-Id: <3559a27948b48c93295867ff5c8390aad0456a34@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 19 Feb 2020 15:10:12 +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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 9fb7ccb3cfc13fc58d9575813f276fa049368cd9)

https://bugzilla.redhat.com/show_bug.cgi?id=1791788
Message-Id: <772d21f8bcf6d76ceec0d4dc0dc2c507cab70912.1582120424.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 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 8e0e919f9a..cf069e2b79 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2402,15 +2402,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, "<nodenames>\n");
-        virBufferAdjustIndent(buf, 2);
-        virBufferEscapeString(buf, "<nodename type='storage' name='%s'/>\n", src->nodestorage);
-        virBufferEscapeString(buf, "<nodename type='format' name='%s'/>\n", src->nodeformat);
-        virBufferAdjustIndent(buf, -2);
-        virBufferAddLit(buf, "</nodenames>\n");
-    }
+    virBufferEscapeString(&nodenamesChildBuf, "<nodename type='storage' name='%s'/>\n", src->nodestorage);
+    virBufferEscapeString(&nodenamesChildBuf, "<nodename type='format' name='%s'/>\n", src->nodeformat);
+
+    virXMLFormatElement(buf, "nodenames", NULL, &nodenamesChildBuf);
 
     if (src->pr)
         virBufferAsprintf(buf, "<reservations mgralias='%s'/>\n", src->pr->mgralias);
-- 
2.25.0