Use much simpler logic to determine parts of the code to print.
---
src/conf/domain_conf.c | 42 ++++++++++++++++--------------------------
1 file changed, 16 insertions(+), 26 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a06da46..3f34540 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21431,32 +21431,22 @@ virDomainChrSourceDefFormat(virBufferPtr buf,
break;
case VIR_DOMAIN_CHR_TYPE_UDP:
- if (def->data.udp.bindService &&
- def->data.udp.bindHost) {
- virBufferEscapeString(buf, "<source mode='bind'
host='%s' ",
- def->data.udp.bindHost);
- virBufferEscapeString(buf, "service='%s'/>\n",
- def->data.udp.bindService);
- } else if (def->data.udp.bindHost) {
- virBufferEscapeString(buf, "<source mode='bind'
host='%s'/>\n",
- def->data.udp.bindHost);
- } else if (def->data.udp.bindService) {
- virBufferEscapeString(buf, "<source mode='bind'
service='%s'/>\n",
- def->data.udp.bindService);
- }
-
- if (def->data.udp.connectService &&
- def->data.udp.connectHost) {
- virBufferEscapeString(buf, "<source mode='connect'
host='%s' ",
- def->data.udp.connectHost);
- virBufferEscapeString(buf, "service='%s'/>\n",
- def->data.udp.connectService);
- } else if (def->data.udp.connectHost) {
- virBufferEscapeString(buf, "<source mode='connect'
host='%s'/>\n",
- def->data.udp.connectHost);
- } else if (def->data.udp.connectService) {
- virBufferEscapeString(buf, "<source mode='connect'
service='%s'/>\n",
- def->data.udp.connectService);
+ if (def->data.udp.bindService || def->data.udp.bindHost) {
+ virBufferAddLit(buf, "<source mode='bind'");
+ if (def->data.udp.bindService)
+ virBufferEscapeString(buf, " host='%s'",
def->data.udp.bindHost);
+ if (def->data.udp.bindService)
+ virBufferEscapeString(buf, " service='%s'",
def->data.udp.bindService);
+ virBufferAddLit(buf, "/>\n");
+ }
+
+ if (def->data.udp.connectService || def->data.udp.connectHost) {
+ virBufferAddLit(buf, "<source mode='connect'");
+ if (def->data.udp.connectService)
+ virBufferEscapeString(buf, " host='%s'",
def->data.udp.connectHost);
+ if (def->data.udp.connectService)
+ virBufferEscapeString(buf, " service='%s'",
def->data.udp.connectService);
+ virBufferAddLit(buf, "/>\n");
}
break;
--
2.10.0