]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: fix formatting of udp chardev attributes
authorJán Tomko <jtomko@redhat.com>
Tue, 26 Sep 2017 11:30:10 +0000 (13:30 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 26 Sep 2017 11:36:51 +0000 (13:36 +0200)
It is possible (although possibly not very useful) to leave out
the service attribute when using <source mode='bind'/>

Fix the formatter bug introduced by commit 4a0da34 and format
the host when its present (checked for non-NULL inside
virBufferEscapeString) instead of basing it on the presence
of the service attribute.

https://bugzilla.redhat.com/show_bug.cgi?id=1455825

src/conf/domain_conf.c
tests/genericxml2xmloutdata/generic-chardev-udp.xml

index 44cfb52b43136ee2e12f3f2eed803d615a87e682..3c3db7291387587f68cffabea2d6a2c6a142350a 100644 (file)
@@ -23307,19 +23307,15 @@ virDomainChrSourceDefFormat(virBufferPtr buf,
     case VIR_DOMAIN_CHR_TYPE_UDP:
         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);
+            virBufferEscapeString(buf, " host='%s'", def->data.udp.bindHost);
+            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);
+            virBufferEscapeString(buf, " host='%s'", def->data.udp.connectHost);
+            virBufferEscapeString(buf, " service='%s'", def->data.udp.connectService);
             virBufferAddLit(buf, "/>\n");
         }
         break;
index c4a719f2f6d0aed27ad42cad73141b1d13b8ff2c..c9b3e5550c1ebbe16925e0febfdfd1bd1d8faf50 100644 (file)
@@ -29,7 +29,7 @@
       <target type='virtio' name='test3'/>
     </channel>
     <channel type='udp'>
-      <source mode='bind'/>
+      <source mode='bind' host='localhost'/>
       <source mode='connect' service='5678'/>
       <target type='virtio' name='test4'/>
     </channel>