render / rpms / libvirt

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