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

Ján Tomko posted 4 patches 7 years, 8 months ago
[libvirt] [PATCH 2/4] conf: use virXMLFormatElement for <iommu>
Posted by Ján Tomko 7 years, 8 months ago
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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/4] conf: use virXMLFormatElement for <iommu>
Posted by John Ferlan 7 years, 8 months ago

On 08/29/2017 12:48 PM, Ján Tomko wrote:
> Simplify the formatting function even further.
> ---
>  src/conf/domain_conf.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

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