From nobody Thu May 15 05:55:32 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.zohomail.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 1512609267299890.9547474048826; Wed, 6 Dec 2017 17:14:27 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 26F44C0587F3; Thu, 7 Dec 2017 01:14:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01E6F18C7C; Thu, 7 Dec 2017 01:14:26 +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 B22A31800BDF; Thu, 7 Dec 2017 01:14:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB71EMXp004473 for ; Wed, 6 Dec 2017 20:14:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id C97305C541; Thu, 7 Dec 2017 01:14:22 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BE2C5C3F7 for ; Thu, 7 Dec 2017 01:14:22 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 6 Dec 2017 20:14:04 -0500 Message-Id: <20171207011408.15091-9-jferlan@redhat.com> In-Reply-To: <20171207011408.15091-1-jferlan@redhat.com> References: <20171207011408.15091-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 08/12] qemu: Move PCI command modelName check to controller def validate 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 07 Dec 2017 01:14:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move the various modelName =3D=3D NAME_NONE from the command line generation into domain controller validation. Also rather than have multiple cases with the same check, let's make the code more generic, but also note that it was the modelName option that caused the failure. We also have to be sure not to check the PCI models that we don't care about. For the remaining checks in command line building, we can use the field name in the error message to be more specific about what causes the failure. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 52 ++++++++++++---------------------------------= ---- src/qemu/qemu_domain.c | 12 ++++++++++++ 2 files changed, 24 insertions(+), 40 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 4e292e446..45cbf5381 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2722,11 +2722,9 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, =20 switch ((virDomainControllerModelPCI) def->model) { case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: - if (pciopts->modelName - =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE || - pciopts->chassisNr =3D=3D -1) { + if (pciopts->chassisNr =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pci-bridge options not set= ")); + _("autogenerated pci-bridge option chassisN= r not set")); goto error; } =20 @@ -2756,12 +2754,9 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, def->info.alias); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: - if (pciopts->modelName - =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE || - pciopts->busNr =3D=3D -1) { + if (pciopts->busNr =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pci-expander-bus options n= ot set")); - goto error; + _("autogenerated pci-expander-bus option bu= sNr not set")); } =20 modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); @@ -2793,13 +2788,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, pciopts->numaNode); break; case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: - if (pciopts->modelName - =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated dmi-to-pci-bridge options = not set")); - goto error; - } - modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); if (!modelName) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2824,12 +2812,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, virBufferAsprintf(&buf, "%s,id=3D%s", modelName, def->info.ali= as); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: - if (pciopts->modelName - =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pcie-root-port options not= set")); - goto error; - } modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); if (!modelName) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2869,12 +2851,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, pciopts->chassis, def->info.alias); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: - if (pciopts->modelName - =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pcie-switch-upstream-port = options not set")); - goto error; - } modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); if (!modelName) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2900,13 +2876,12 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, virBufferAsprintf(&buf, "%s,id=3D%s", modelName, def->info.ali= as); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: - if (pciopts->modelName - =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE || - pciopts->chassis =3D=3D -1 || + if (pciopts->chassis =3D=3D -1 || pciopts->port =3D=3D -1) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INTERNAL_ERROR, _("autogenerated pcie-switch-downstream-por= t " - "options not set")); + "options chassis=3D%d or port=3D%d not se= t"), + pciopts->chassis, pciopts->port); goto error; } =20 @@ -2937,11 +2912,9 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, pciopts->chassis, def->info.alias); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: - if (pciopts->modelName - =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE || - pciopts->busNr =3D=3D -1) { + if (pciopts->busNr =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pcie-expander-bus options = not set")); + _("autogenerated pcie-expander-bus option b= usNr not set")); goto error; } =20 @@ -2974,10 +2947,9 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, pciopts->numaNode); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: - if (pciopts->modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_= NAME_NONE || - pciopts->targetIndex =3D=3D -1) { + if (pciopts->targetIndex =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pci-root options not set")= ); + _("autogenerated pci-root option targetInde= x not set")); goto error; } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ceb03a0cd..ecfff4209 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4014,6 +4014,7 @@ qemuDomainDeviceDefValidateControllerPCI(const virDom= ainControllerDef *controlle const virDomainDef *def) { virDomainControllerModelPCI model =3D controller->model; + const virDomainPCIControllerOpts *pciopts; =20 /* skip pcie-root */ if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI && @@ -4049,6 +4050,17 @@ qemuDomainDeviceDefValidateControllerPCI(const virDo= mainControllerDef *controlle break; } =20 + pciopts =3D &controller->opts.pciopts; + if (controller->model !=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT && + controller->model !=3D VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST) { + if (pciopts->modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME= _NONE) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("autogenerated %s option modelName not set"), + virDomainControllerModelPCITypeToString(control= ler->model)); + return -1; + } + } + return 0; } =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list