From nobody Fri Jul 4 23:47:34 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1496148784102136.45509180619115; Tue, 30 May 2017 05:53:04 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F155D8046E; Tue, 30 May 2017 12:53:01 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB6C25B820; Tue, 30 May 2017 12:53:01 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5BB304A48C; Tue, 30 May 2017 12:53:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4UCqx6A013143 for ; Tue, 30 May 2017 08:52:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id D2EEC19E97; Tue, 30 May 2017 12:52:59 +0000 (UTC) Received: from icr.brq.redhat.com (dhcp129-58.brq.redhat.com [10.34.129.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30A005C7A5; Tue, 30 May 2017 12:52:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F155D8046E Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com F155D8046E From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 30 May 2017 14:50:26 +0200 Message-Id: <160447fa085ab8da66bf21947d11f58f539fd7c6.1496148357.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: jasowang@redhat.com Subject: [libvirt] [PATCH 03/18] conf: only format as a pair tag when needed X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 30 May 2017 12:53:02 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 +++- tests/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 fe0eaf2..57f52be 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21464,7 +21464,6 @@ virDomainControllerDefFormat(virBufferPtr buf, def->queues || def->cmd_per_lun || def->max_sectors || def->ioeven= tfd || def->iothread || virDomainDeviceInfoNeedsFormat(&def->info, flags) || pcihole64) { - virBufferAddLit(buf, ">\n"); =20 if (pciModel) { modelName =3D virDomainControllerPCIModelNameTypeToString(def-= >opts.pciopts.modelName); @@ -21513,7 +21512,10 @@ virDomainControllerDefFormat(virBufferPtr buf, virBufferAsprintf(&childBuf, "%lu\n", def->opts.pciopts.pcihole64s= ize); } + } =20 + if (virBufferUse(&childBuf)) { + virBufferAddLit(buf, ">\n"); virBufferAddBuffer(buf, &childBuf); virBufferAddLit(buf, "\n"); } else { diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xm= l b/tests/qemuxml2xmloutdata/qemuxml2xmlout-s390-defaultconsole.xml index 882d005..7eb1a76 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 - - + --=20 2.10.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list