render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
a41c76
From d77f180068dab8747f5e2c098a9c59213ce19108 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <d77f180068dab8747f5e2c098a9c59213ce19108@dist-git>
a41c76
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
a41c76
Date: Wed, 4 Mar 2020 12:42:29 +0100
a41c76
Subject: [PATCH] conf: use virXMLFormatElement in virDomainFSDefFormat
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Use the virXMLFormatElement helper to format the driver element
a41c76
to simplify adding further sub-elements.
a41c76
a41c76
Signed-off-by: Ján Tomko <jtomko@redhat.com>
a41c76
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
a41c76
(cherry picked from commit 3efdbae5bf054d1a2bdc98fdccff0273abe54c88)
a41c76
Signed-off-by: Ján Tomko <jtomko@redhat.com>
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1694166
a41c76
Message-Id: <966ad0eebcb1ae5f20f59fc6cc84008bbfa6426f.1583322090.git.jtomko@redhat.com>
a41c76
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
a41c76
---
a41c76
 src/conf/domain_conf.c | 16 ++++++----------
a41c76
 1 file changed, 6 insertions(+), 10 deletions(-)
a41c76
a41c76
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
a41c76
index 8a5f14d6cb..88117187c8 100644
a41c76
--- a/src/conf/domain_conf.c
a41c76
+++ b/src/conf/domain_conf.c
a41c76
@@ -24991,7 +24991,7 @@ virDomainFSDefFormat(virBufferPtr buf,
a41c76
     const char *fsdriver = virDomainFSDriverTypeToString(def->fsdriver);
a41c76
     const char *wrpolicy = virDomainFSWrpolicyTypeToString(def->wrpolicy);
a41c76
     const char *src = def->src->path;
a41c76
-    g_auto(virBuffer) driverBuf = VIR_BUFFER_INITIALIZER;
a41c76
+    g_auto(virBuffer) driverAttrBuf = VIR_BUFFER_INITIALIZER;
a41c76
 
a41c76
     if (!type) {
a41c76
         virReportError(VIR_ERR_INTERNAL_ERROR,
a41c76
@@ -25016,25 +25016,21 @@ virDomainFSDefFormat(virBufferPtr buf,
a41c76
 
a41c76
     virBufferAdjustIndent(buf, 2);
a41c76
     if (def->fsdriver) {
a41c76
-        virBufferAsprintf(&driverBuf, " type='%s'", fsdriver);
a41c76
+        virBufferAsprintf(&driverAttrBuf, " type='%s'", fsdriver);
a41c76
 
a41c76
         if (def->format)
a41c76
-            virBufferAsprintf(&driverBuf, " format='%s'",
a41c76
+            virBufferAsprintf(&driverAttrBuf, " format='%s'",
a41c76
                               virStorageFileFormatTypeToString(def->format));
a41c76
 
a41c76
         /* Don't generate anything if wrpolicy is set to default */
a41c76
         if (def->wrpolicy)
a41c76
-            virBufferAsprintf(&driverBuf, " wrpolicy='%s'", wrpolicy);
a41c76
+            virBufferAsprintf(&driverAttrBuf, " wrpolicy='%s'", wrpolicy);
a41c76
 
a41c76
     }
a41c76
 
a41c76
-    virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
a41c76
+    virDomainVirtioOptionsFormat(&driverAttrBuf, def->virtio);
a41c76
 
a41c76
-    if (virBufferUse(&driverBuf)) {
a41c76
-        virBufferAddLit(buf, "
a41c76
-        virBufferAddBuffer(buf, &driverBuf);
a41c76
-        virBufferAddLit(buf, "/>\n");
a41c76
-    }
a41c76
+    virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL);
a41c76
 
a41c76
     switch (def->type) {
a41c76
     case VIR_DOMAIN_FS_TYPE_MOUNT:
a41c76
-- 
a41c76
2.25.1
a41c76