For VIR_DOMAIN_NET_TYPE_{SERVER,CLIENT,MCAST,UDP} we need to put
(optionally) 'address' attribute and 'port' attributes of
<source/> element. But the way we currently do that is
particularly verbose. It can be shortened using
virBufferEscapeString().
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/domain_conf.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fb2455840a..b991a01af3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23795,14 +23795,10 @@ virDomainNetDefFormat(virBuffer *buf,
case VIR_DOMAIN_NET_TYPE_CLIENT:
case VIR_DOMAIN_NET_TYPE_MCAST:
case VIR_DOMAIN_NET_TYPE_UDP:
- if (def->data.socket.address) {
- virBufferAsprintf(&sourceAttrBuf, " address='%s'
port='%d'",
- def->data.socket.address,
- def->data.socket.port);
- } else {
- virBufferAsprintf(&sourceAttrBuf, " port='%d'",
- def->data.socket.port);
- }
+ virBufferEscapeString(&sourceAttrBuf, " address='%s'",
+ def->data.socket.address);
+ virBufferAsprintf(&sourceAttrBuf, " port='%d'",
+ def->data.socket.port);
if (def->type != VIR_DOMAIN_NET_TYPE_UDP)
break;
--
2.39.1