[RFC 15/21] conf: Generate virNetworkDNSHostDefFormatBuf

[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 | 15 +++------------
 src/conf/network_conf.h |  2 +-
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 29ef3cf..1fea580 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2176,7 +2176,7 @@ static int
 virNetworkDNSDefFormat(virBufferPtr buf,
                        const virNetworkDNSDef *def)
 {
-    size_t i, j;
+    size_t i;
 
     if (!(def->enable || def->forwardPlainNames || def->nfwds || def->nhosts ||
           def->nsrvs || def->ntxts))
@@ -2246,17 +2246,8 @@ virNetworkDNSDefFormat(virBufferPtr buf,
 
     if (def->nhosts) {
         for (i = 0; i < def->nhosts; i++) {
-            char *ip = virSocketAddrFormat(&def->hosts[i].ip);
-
-            virBufferAsprintf(buf, "<host ip='%s'>\n", ip);
-            virBufferAdjustIndent(buf, 2);
-            for (j = 0; j < def->hosts[i].nnames; j++)
-                virBufferEscapeString(buf, "<hostname>%s</hostname>\n",
-                                      def->hosts[i].names[j]);
-
-            virBufferAdjustIndent(buf, -2);
-            virBufferAddLit(buf, "</host>\n");
-            VIR_FREE(ip);
+            if (virNetworkDNSHostDefFormatBuf(buf, "host", &def->hosts[i], NULL) < 0)
+                return -1;
         }
     }
     virBufferAdjustIndent(buf, -2);
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index b715dc3..a5a4939 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -149,7 +149,7 @@ struct _virNetworkDNSSrvDef {   /* genparse:withhook, genformat */
 
 typedef struct _virNetworkDNSHostDef virNetworkDNSHostDef;
 typedef virNetworkDNSHostDef *virNetworkDNSHostDefPtr;
-struct _virNetworkDNSHostDef {  /* genparse:withhook */
+struct _virNetworkDNSHostDef {  /* genparse:withhook, genformat */
     virSocketAddr ip;           /* xmlattr */
     size_t nnames;
     char **names;               /* xmlelem:hostname, array */
-- 
2.17.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