[PATCH 2/4] conf: use virXMLFormatElement for <iommu>

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Simplify the formatting function even further.
---
 src/conf/domain_conf.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8e555ad9d..a26731e75 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -25061,6 +25061,7 @@ virDomainIOMMUDefFormat(virBufferPtr buf,
                         const virDomainIOMMUDef *iommu)
 {
     virBuffer childBuf = VIR_BUFFER_INITIALIZER;
+    virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
     virBuffer driverAttrBuf = VIR_BUFFER_INITIALIZER;
     int ret = -1;
 
@@ -25086,16 +25087,11 @@ virDomainIOMMUDefFormat(virBufferPtr buf,
     if (virXMLFormatElement(&childBuf, "driver", &driverAttrBuf, NULL) < 0)
         goto cleanup;
 
-    virBufferAsprintf(buf, "<iommu model='%s'",
+    virBufferAsprintf(&attrBuf, " model='%s'",
                       virDomainIOMMUModelTypeToString(iommu->model));
 
-    if (virBufferError(&childBuf) != 0 || virBufferUse(&childBuf)) {
-        virBufferAddLit(buf, ">\n");
-        virBufferAddBuffer(buf, &childBuf);
-        virBufferAddLit(buf, "</iommu>\n");
-    } else {
-        virBufferAddLit(buf, "/>\n");
-    }
+    if (virXMLFormatElement(buf, "iommu", &attrBuf, &childBuf) < 0)
+        goto cleanup;
 
     ret = 0;
 
-- 
2.13.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux