render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From d77f180068dab8747f5e2c098a9c59213ce19108 Mon Sep 17 00:00:00 2001
Message-Id: <d77f180068dab8747f5e2c098a9c59213ce19108@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Wed, 4 Mar 2020 12:42:29 +0100
Subject: [PATCH] conf: use virXMLFormatElement in virDomainFSDefFormat
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Use the virXMLFormatElement helper to format the driver element
to simplify adding further sub-elements.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
(cherry picked from commit 3efdbae5bf054d1a2bdc98fdccff0273abe54c88)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1694166
Message-Id: <966ad0eebcb1ae5f20f59fc6cc84008bbfa6426f.1583322090.git.jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/conf/domain_conf.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8a5f14d6cb..88117187c8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -24991,7 +24991,7 @@ virDomainFSDefFormat(virBufferPtr buf,
     const char *fsdriver = virDomainFSDriverTypeToString(def->fsdriver);
     const char *wrpolicy = virDomainFSWrpolicyTypeToString(def->wrpolicy);
     const char *src = def->src->path;
-    g_auto(virBuffer) driverBuf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) driverAttrBuf = VIR_BUFFER_INITIALIZER;
 
     if (!type) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -25016,25 +25016,21 @@ virDomainFSDefFormat(virBufferPtr buf,
 
     virBufferAdjustIndent(buf, 2);
     if (def->fsdriver) {
-        virBufferAsprintf(&driverBuf, " type='%s'", fsdriver);
+        virBufferAsprintf(&driverAttrBuf, " type='%s'", fsdriver);
 
         if (def->format)
-            virBufferAsprintf(&driverBuf, " format='%s'",
+            virBufferAsprintf(&driverAttrBuf, " format='%s'",
                               virStorageFileFormatTypeToString(def->format));
 
         /* Don't generate anything if wrpolicy is set to default */
         if (def->wrpolicy)
-            virBufferAsprintf(&driverBuf, " wrpolicy='%s'", wrpolicy);
+            virBufferAsprintf(&driverAttrBuf, " wrpolicy='%s'", wrpolicy);
 
     }
 
-    virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
+    virDomainVirtioOptionsFormat(&driverAttrBuf, def->virtio);
 
-    if (virBufferUse(&driverBuf)) {
-        virBufferAddLit(buf, "<driver");
-        virBufferAddBuffer(buf, &driverBuf);
-        virBufferAddLit(buf, "/>\n");
-    }
+    virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL);
 
     switch (def->type) {
     case VIR_DOMAIN_FS_TYPE_MOUNT:
-- 
2.25.1