From nobody Mon Feb 9 23:09:44 2026 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 1496148783921814.6238541123781; Tue, 30 May 2017 05:53:03 -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 DB706C0B39C0; 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 A8CD25B81B; 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 ABF414BB7F; Tue, 30 May 2017 12:53:00 +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 v4UCqwr1013136 for ; Tue, 30 May 2017 08:52:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id B33D519C98; Tue, 30 May 2017 12:52:58 +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 156A95B80E; Tue, 30 May 2017 12:52:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DB706C0B39C0 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.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 DB706C0B39C0 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 30 May 2017 14:50:25 +0200 Message-Id: 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 02/18] conf: use a separate buffer for the subelements of 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.32]); Tue, 30 May 2017 12:53:02 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We need to decide whether to format as a single tag or if it has any subelements. Rewrite the function to use a separate buffer for subelements, to make adding new options easier. --- src/conf/domain_conf.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 318e254..fe0eaf2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21397,6 +21397,9 @@ virDomainControllerDefFormat(virBufferPtr buf, const char *model =3D NULL; const char *modelName =3D NULL; bool pcihole64 =3D false, pciModel =3D false, pciTarget =3D false; + virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; + + virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); =20 if (!type) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -21462,7 +21465,6 @@ virDomainControllerDefFormat(virBufferPtr buf, def->iothread || virDomainDeviceInfoNeedsFormat(&def->info, flags) || pcihole64) { virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); =20 if (pciModel) { modelName =3D virDomainControllerPCIModelNameTypeToString(def-= >opts.pciopts.modelName); @@ -21472,47 +21474,47 @@ virDomainControllerDefFormat(virBufferPtr buf, def->opts.pciopts.modelName); return -1; } - virBufferAsprintf(buf, "\n", modelName); + virBufferAsprintf(&childBuf, "\n", modelNa= me); } =20 if (pciTarget) { - virBufferAddLit(buf, "opts.pciopts.chassisNr !=3D -1) - virBufferAsprintf(buf, " chassisNr=3D'%d'", + virBufferAsprintf(&childBuf, " chassisNr=3D'%d'", def->opts.pciopts.chassisNr); if (def->opts.pciopts.chassis !=3D -1) - virBufferAsprintf(buf, " chassis=3D'%d'", + virBufferAsprintf(&childBuf, " chassis=3D'%d'", def->opts.pciopts.chassis); if (def->opts.pciopts.port !=3D -1) - virBufferAsprintf(buf, " port=3D'0x%x'", + virBufferAsprintf(&childBuf, " port=3D'0x%x'", def->opts.pciopts.port); if (def->opts.pciopts.busNr !=3D -1) - virBufferAsprintf(buf, " busNr=3D'%d'", + virBufferAsprintf(&childBuf, " busNr=3D'%d'", def->opts.pciopts.busNr); if (def->opts.pciopts.numaNode =3D=3D -1) { - virBufferAddLit(buf, "/>\n"); + virBufferAddLit(&childBuf, "/>\n"); } else { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - virBufferAsprintf(buf, "%d\n", + virBufferAddLit(&childBuf, ">\n"); + virBufferAdjustIndent(&childBuf, 2); + virBufferAsprintf(&childBuf, "%d\n", def->opts.pciopts.numaNode); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(&childBuf, -2); + virBufferAddLit(&childBuf, "\n"); } } =20 - virDomainControllerDriverFormat(buf, def); + virDomainControllerDriverFormat(&childBuf, def); =20 if (virDomainDeviceInfoNeedsFormat(&def->info, flags) && - virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0) return -1; =20 if (pcihole64) { - virBufferAsprintf(buf, "%lu%lu\n", def->opts.pciopts.pcihole64s= ize); } =20 - virBufferAdjustIndent(buf, -2); + virBufferAddBuffer(buf, &childBuf); virBufferAddLit(buf, "\n"); } else { virBufferAddLit(buf, "/>\n"); --=20 2.10.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list