提交 bb74c66e 编写于 作者: J Ján Tomko

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 c1c4d0d5
where we would format an empty pair tag.
上级 5b96f37f
...@@ -21477,7 +21477,6 @@ virDomainControllerDefFormat(virBufferPtr buf, ...@@ -21477,7 +21477,6 @@ virDomainControllerDefFormat(virBufferPtr buf,
def->queues || def->cmd_per_lun || def->max_sectors || def->ioeventfd || def->queues || def->cmd_per_lun || def->max_sectors || def->ioeventfd ||
def->iothread || def->iothread ||
virDomainDeviceInfoNeedsFormat(&def->info, flags) || pcihole64) { virDomainDeviceInfoNeedsFormat(&def->info, flags) || pcihole64) {
virBufferAddLit(buf, ">\n");
if (pciModel) { if (pciModel) {
modelName = virDomainControllerPCIModelNameTypeToString(def->opts.pciopts.modelName); modelName = virDomainControllerPCIModelNameTypeToString(def->opts.pciopts.modelName);
...@@ -21526,7 +21525,10 @@ virDomainControllerDefFormat(virBufferPtr buf, ...@@ -21526,7 +21525,10 @@ virDomainControllerDefFormat(virBufferPtr buf,
virBufferAsprintf(&childBuf, "<pcihole64 unit='KiB'>%lu</" virBufferAsprintf(&childBuf, "<pcihole64 unit='KiB'>%lu</"
"pcihole64>\n", def->opts.pciopts.pcihole64size); "pcihole64>\n", def->opts.pciopts.pcihole64size);
} }
}
if (virBufferUse(&childBuf)) {
virBufferAddLit(buf, ">\n");
virBufferAddBuffer(buf, &childBuf); virBufferAddBuffer(buf, &childBuf);
virBufferAddLit(buf, "</controller>\n"); virBufferAddLit(buf, "</controller>\n");
} else { } else {
......
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
<on_crash>destroy</on_crash> <on_crash>destroy</on_crash>
<devices> <devices>
<emulator>/usr/bin/qemu-system-s390x</emulator> <emulator>/usr/bin/qemu-system-s390x</emulator>
<controller type='virtio-serial' index='0'> <controller type='virtio-serial' index='0'/>
</controller>
<console type='pty'> <console type='pty'>
<target type='virtio' port='0'/> <target type='virtio' port='0'/>
</console> </console>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册