conf: only format <controller> as a pair tag when needed

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.
This commit is contained in:
Ján Tomko 2017-05-26 18:10:11 +02:00
parent 5b96f37ff4
commit bb74c66e67
2 changed files with 4 additions and 3 deletions

View 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 {

View 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>