From nobody Fri May 16 08:39:43 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 14967491938201021.3705097466727; Tue, 6 Jun 2017 04:39:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 78CA013A68; Tue, 6 Jun 2017 11:39:49 +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 4F2FE5C888; Tue, 6 Jun 2017 11:39:49 +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 E4FF34BB7F; Tue, 6 Jun 2017 11:39:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v56BcjFk001883 for ; Tue, 6 Jun 2017 07:38:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id BF869756BF; Tue, 6 Jun 2017 11:38:45 +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 473F47EBD3 for ; Tue, 6 Jun 2017 11:38:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 78CA013A68 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.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 78CA013A68 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 6 Jun 2017 13:36:16 +0200 Message-Id: <3871f4545cb57650aa2b20ac2a8a4d1a643acb84.1496748930.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 02/15] virDomainControllerDefFormat: do not mix attributes and subelements 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 06 Jun 2017 11:39:50 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move out the PCI controller's subelements formatting out of the switch handling attributes. This removes the need for a few bool variables. --- src/conf/domain_conf.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 02b2e49..e50628f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21409,7 +21409,6 @@ virDomainControllerDefFormat(virBufferPtr buf, const char *type =3D virDomainControllerTypeToString(def->type); 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; =20 virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); @@ -21456,25 +21455,12 @@ virDomainControllerDefFormat(virBufferPtr buf, } break; =20 - case VIR_DOMAIN_CONTROLLER_TYPE_PCI: - if (def->opts.pciopts.pcihole64) - pcihole64 =3D true; - if (def->opts.pciopts.modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MOD= EL_NAME_NONE) - pciModel =3D true; - if (def->opts.pciopts.chassisNr !=3D -1 || - def->opts.pciopts.chassis !=3D -1 || - def->opts.pciopts.port !=3D -1 || - def->opts.pciopts.busNr !=3D -1 || - def->opts.pciopts.numaNode !=3D -1) - pciTarget =3D true; - break; - default: break; } =20 - if (pciModel || pciTarget) { - if (pciModel) { + if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { + if (def->opts.pciopts.modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MOD= EL_NAME_NONE) { modelName =3D virDomainControllerPCIModelNameTypeToString(def-= >opts.pciopts.modelName); if (!modelName) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -21485,7 +21471,11 @@ virDomainControllerDefFormat(virBufferPtr buf, virBufferAsprintf(&childBuf, "\n", modelNa= me); } =20 - if (pciTarget) { + if (def->opts.pciopts.chassisNr !=3D -1 || + def->opts.pciopts.chassis !=3D -1 || + def->opts.pciopts.port !=3D -1 || + def->opts.pciopts.busNr !=3D -1 || + def->opts.pciopts.numaNode !=3D -1) { virBufferAddLit(&childBuf, "opts.pciopts.chassisNr !=3D -1) virBufferAsprintf(&childBuf, " chassisNr=3D'%d'", @@ -21518,7 +21508,8 @@ virDomainControllerDefFormat(virBufferPtr buf, virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0) return -1; =20 - if (pcihole64) { + if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI && + def->opts.pciopts.pcihole64) { virBufferAsprintf(&childBuf, "%lu\n", def->opts.pciopts.pcihole64size); } --=20 2.10.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list