[PATCH 7/7] virDomainNetDefFormat: Modernize <mac/> formatting

Michal Privoznik mprivozn at redhat.com
Tue Jan 31 16:44:21 UTC 2023


The <source/> child element of <mac/> is formatted the old way.
Switch to virXMLFormatElement().

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/conf/domain_conf.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b991a01af3..1cf2bf84bc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23685,6 +23685,7 @@ virDomainNetDefFormat(virBuffer *buf,
     virDomainHostdevDef *hostdef = NULL;
     char macstr[VIR_MAC_STRING_BUFLEN];
     g_auto(virBuffer) targetAttrBuf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) macAttrBuf = VIR_BUFFER_INITIALIZER;
     const char *prefix = xmlopt ? xmlopt->config.netPrefix : NULL;
 
     /* publicActual is true if we should report the current state in
@@ -23725,13 +23726,13 @@ virDomainNetDefFormat(virBuffer *buf,
     virBufferAddLit(buf, ">\n");
 
     virBufferAdjustIndent(buf, 2);
-    virBufferAsprintf(buf, "<mac address='%s'",
+    virBufferAsprintf(&macAttrBuf, " address='%s'",
                       virMacAddrFormat(&def->mac, macstr));
     if (def->mac_type)
-        virBufferAsprintf(buf, " type='%s'", virDomainNetMacTypeTypeToString(def->mac_type));
+        virBufferAsprintf(&macAttrBuf, " type='%s'", virDomainNetMacTypeTypeToString(def->mac_type));
     if (def->mac_check != VIR_TRISTATE_BOOL_ABSENT)
-        virBufferAsprintf(buf, " check='%s'", virTristateBoolTypeToString(def->mac_check));
-    virBufferAddLit(buf, "/>\n");
+        virBufferAsprintf(&macAttrBuf, " check='%s'", virTristateBoolTypeToString(def->mac_check));
+    virXMLFormatElement(buf, "mac", &macAttrBuf, NULL);
 
     if (publicActual) {
         /* when there is a virDomainActualNetDef, and we haven't been
-- 
2.39.1



More information about the libvir-list mailing list