From bb74c66e67485e12c239c13ea1be38ec6e0081ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Fri, 26 May 2017 18:10:11 +0200 Subject: [PATCH] conf: only format 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. --- src/conf/domain_conf.c | 4 +++- .../qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 08c8116e1e..958a5b7cdf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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, "%lu\n", def->opts.pciopts.pcihole64size); } + } + if (virBufferUse(&childBuf)) { + virBufferAddLit(buf, ">\n"); virBufferAddBuffer(buf, &childBuf); virBufferAddLit(buf, "\n"); } else { diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml index 882d0054fe..7eb1a765ab 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml @@ -14,8 +14,7 @@ destroy /usr/bin/qemu-system-s390x - - + -- GitLab