render / rpms / libvirt

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