[RFCv2 18/46] conf: Generate virNetworkDNSForwarderFormatBuf

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

 



Signed-off-by: Shi Lei <shi_lei@xxxxxxxxxxxxxx>
---
 src/conf/network_conf.c | 18 +++---------------
 src/conf/network_conf.h |  4 ++--
 2 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 608843d..437c2c6 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2155,21 +2155,9 @@ virNetworkDNSDefFormat(virBufferPtr buf,
     virBufferAdjustIndent(buf, 2);
 
     for (i = 0; i < def->nfwds; i++) {
-
-        virBufferAddLit(buf, "<forwarder");
-        if (def->forwarders[i].domain) {
-            virBufferEscapeString(buf, " domain='%s'",
-                                  def->forwarders[i].domain);
-        }
-        if (VIR_SOCKET_ADDR_VALID(&def->forwarders[i].addr)) {
-            g_autofree char *addr = virSocketAddrFormat(&def->forwarders[i].addr);
-
-            if (!addr)
-                return -1;
-
-            virBufferAsprintf(buf, " addr='%s'", addr);
-        }
-        virBufferAddLit(buf, "/>\n");
+        if (virNetworkDNSForwarderFormatBuf(buf, "forwarder",
+                                            &def->forwarders[i], def, NULL) < 0)
+            return -1;
     }
 
     for (i = 0; i < def->ntxts; i++) {
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 881a9f2..84b636e 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -158,9 +158,9 @@ struct _virNetworkDNSHostDef {  /* genparse:withhook, genformat */
 
 typedef struct _virNetworkDNSForwarder virNetworkDNSForwarder;
 typedef virNetworkDNSForwarder *virNetworkDNSForwarderPtr;
-struct _virNetworkDNSForwarder {    /* genparse:withhook */
-    virSocketAddr addr;             /* xmlattr */
+struct _virNetworkDNSForwarder {    /* genparse:withhook, genformat */
     char *domain;                   /* xmlattr */
+    virSocketAddr addr;             /* xmlattr */
 };
 
 typedef struct _virNetworkDNSDef virNetworkDNSDef;
-- 
2.25.1





[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