[PATCH 3/7] virDomainNetDefFormat: Modernize <tune/> formatting

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


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

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/conf/domain_conf.c             | 10 +++++-----
 tests/qemuxml2argvdata/net-mtu.xml |  3 +++
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 382c32db67..4c6f79efe3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23993,11 +23993,11 @@ virDomainNetDefFormat(virBuffer *buf,
     }
 
     if (def->tune.sndbuf_specified) {
-        virBufferAddLit(buf,   "<tune>\n");
-        virBufferAdjustIndent(buf, 2);
-        virBufferAsprintf(buf, "<sndbuf>%llu</sndbuf>\n", def->tune.sndbuf);
-        virBufferAdjustIndent(buf, -2);
-        virBufferAddLit(buf,   "</tune>\n");
+        g_auto(virBuffer) sndChildBuf = VIR_BUFFER_INIT_CHILD(buf);
+
+        virBufferAsprintf(&sndChildBuf, "<sndbuf>%llu</sndbuf>\n", def->tune.sndbuf);
+
+        virXMLFormatElement(buf, "tune", NULL, &sndChildBuf);
     }
 
     virDomainNetTeamingInfoFormat(def->teaming, buf);
diff --git a/tests/qemuxml2argvdata/net-mtu.xml b/tests/qemuxml2argvdata/net-mtu.xml
index 900548b465..092978bea0 100644
--- a/tests/qemuxml2argvdata/net-mtu.xml
+++ b/tests/qemuxml2argvdata/net-mtu.xml
@@ -50,6 +50,9 @@
       <mac address='52:54:00:e5:48:59'/>
       <source network='default'/>
       <model type='virtio'/>
+      <tune>
+        <sndbuf>1600</sndbuf>
+      </tune>
       <mtu size='9000'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
     </interface>
-- 
2.39.1



More information about the libvir-list mailing list