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

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



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


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