render / rpms / libvirt

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