Signed-off-by: Shi Lei <shi_lei@xxxxxxxxxxxxxx> --- src/conf/network_conf.c | 14 +++----------- src/conf/network_conf.h | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 90b1e0ee..ba67eab1 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -2095,7 +2095,7 @@ static int virNetworkDNSDefFormat(virBuffer *buf, const virNetworkDNSDef *def) { - size_t i, j; + size_t i; if (!(def->enable || def->forwardPlainNames || def->nfwds || def->nhosts || def->nsrvs || def->ntxts)) @@ -2164,16 +2164,8 @@ virNetworkDNSDefFormat(virBuffer *buf, if (def->nhosts) { for (i = 0; i < def->nhosts; i++) { - g_autofree 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"); + if (virNetworkDNSHostDefFormatBuf(buf, "host", &def->hosts[i], def, NULL) < 0) + return -1; } } virBufferAdjustIndent(buf, -2); diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index 998411be..836d088d 100644 --- a/src/conf/network_conf.h +++ b/src/conf/network_conf.h @@ -142,7 +142,7 @@ struct _virNetworkDNSSrvDef { /* genparse, genformat */ }; typedef struct _virNetworkDNSHostDef virNetworkDNSHostDef; -struct _virNetworkDNSHostDef { /* genparse */ +struct _virNetworkDNSHostDef { /* genparse, genformat */ virSocketAddr ip; /* xmlattr */ size_t nnames; char **names; /* xmlelem:hostname, array */ -- 2.25.1