render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
d76c62
From 3559a27948b48c93295867ff5c8390aad0456a34 Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <3559a27948b48c93295867ff5c8390aad0456a34@dist-git>
d76c62
From: Peter Krempa <pkrempa@redhat.com>
d76c62
Date: Wed, 19 Feb 2020 15:10:12 +0100
d76c62
Subject: [PATCH] qemu: domain: Refactor formatting of node names into status
d76c62
 XML
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
Use virXMLFormatElement to simplify the logic.
d76c62
d76c62
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
(cherry picked from commit 9fb7ccb3cfc13fc58d9575813f276fa049368cd9)
d76c62
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1791788
d76c62
Message-Id: <772d21f8bcf6d76ceec0d4dc0dc2c507cab70912.1582120424.git.pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 src/qemu/qemu_domain.c | 13 +++++--------
d76c62
 1 file changed, 5 insertions(+), 8 deletions(-)
d76c62
d76c62
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
d76c62
index 8e0e919f9a..cf069e2b79 100644
d76c62
--- a/src/qemu/qemu_domain.c
d76c62
+++ b/src/qemu/qemu_domain.c
d76c62
@@ -2402,15 +2402,12 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src,
d76c62
 {
d76c62
     g_auto(virBuffer) tmp = VIR_BUFFER_INIT_CHILD(buf);
d76c62
     qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
d76c62
+    g_auto(virBuffer) nodenamesChildBuf = VIR_BUFFER_INIT_CHILD(buf);
d76c62
 
d76c62
-    if (src->nodestorage || src->nodeformat) {
d76c62
-        virBufferAddLit(buf, "<nodenames>\n");
d76c62
-        virBufferAdjustIndent(buf, 2);
d76c62
-        virBufferEscapeString(buf, "<nodename type='storage' name='%s'/>\n", src->nodestorage);
d76c62
-        virBufferEscapeString(buf, "<nodename type='format' name='%s'/>\n", src->nodeformat);
d76c62
-        virBufferAdjustIndent(buf, -2);
d76c62
-        virBufferAddLit(buf, "</nodenames>\n");
d76c62
-    }
d76c62
+    virBufferEscapeString(&nodenamesChildBuf, "<nodename type='storage' name='%s'/>\n", src->nodestorage);
d76c62
+    virBufferEscapeString(&nodenamesChildBuf, "<nodename type='format' name='%s'/>\n", src->nodeformat);
d76c62
+
d76c62
+    virXMLFormatElement(buf, "nodenames", NULL, &nodenamesChildBuf);
d76c62
 
d76c62
     if (src->pr)
d76c62
         virBufferAsprintf(buf, "<reservations mgralias='%s'/>\n", src->pr->mgralias);
d76c62
-- 
d76c62
2.25.0
d76c62