]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: only format <controller> as a pair tag when needed
authorJán Tomko <jtomko@redhat.com>
Fri, 26 May 2017 16:10:11 +0000 (18:10 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 5 Jun 2017 14:13:50 +0000 (16:13 +0200)
Make the decision based on the usage of childBuf buffer.

This fixes the oddity in the test case introduced by commit c1c4d0d
where we would format an empty pair tag.

src/conf/domain_conf.c
tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml

index 08c8116e1ef079ee0bfd160fbe0548fad59e83b4..958a5b7cdf00cd501f6f0607000fee91cb0b8994 100644 (file)
@@ -21477,7 +21477,6 @@ virDomainControllerDefFormat(virBufferPtr buf,
         def->queues || def->cmd_per_lun || def->max_sectors || def->ioeventfd ||
         def->iothread ||
         virDomainDeviceInfoNeedsFormat(&def->info, flags) || pcihole64) {
-        virBufferAddLit(buf, ">\n");
 
         if (pciModel) {
             modelName = virDomainControllerPCIModelNameTypeToString(def->opts.pciopts.modelName);
@@ -21526,7 +21525,10 @@ virDomainControllerDefFormat(virBufferPtr buf,
             virBufferAsprintf(&childBuf, "<pcihole64 unit='KiB'>%lu</"
                               "pcihole64>\n", def->opts.pciopts.pcihole64size);
         }
+    }
 
+    if (virBufferUse(&childBuf)) {
+        virBufferAddLit(buf, ">\n");
         virBufferAddBuffer(buf, &childBuf);
         virBufferAddLit(buf, "</controller>\n");
     } else {
index 882d0054feef54fbd4ecdd7f734a3e83fe2f11ab..7eb1a765abda25bd53bb86de3bc8c52509fc7847 100644 (file)
@@ -14,8 +14,7 @@
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-s390x</emulator>
-    <controller type='virtio-serial' index='0'>
-    </controller>
+    <controller type='virtio-serial' index='0'/>
     <console type='pty'>
       <target type='virtio' port='0'/>
     </console>