conf: Sanitize formatting of UDP chardev source

Use much simpler logic to determine parts of the code to print.
This commit is contained in:
Peter Krempa 2016-09-26 17:15:00 +02:00
parent c7d3cf2e3b
commit 4a0da345d0

View File

@ -21394,32 +21394,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.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) {
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.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;