From nobody Sun May 5 11:50:11 2024 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 1517454145408122.30058092166735; Wed, 31 Jan 2018 19:02:25 -0800 (PST) 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 2881D3A9F2; Thu, 1 Feb 2018 03:02:24 +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 DF6665C20B; Thu, 1 Feb 2018 03:02:23 +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 82DA018033D9; Thu, 1 Feb 2018 03:02:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w112w0gP031273 for ; Wed, 31 Jan 2018 21:58:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id 127C960A9A; Thu, 1 Feb 2018 02:58:00 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id C295E608F1 for ; Thu, 1 Feb 2018 02:57:59 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 31 Jan 2018 21:57:40 -0500 Message-Id: <20180201025753.10651-2-jferlan@redhat.com> In-Reply-To: <20180201025753.10651-1-jferlan@redhat.com> References: <20180201025753.10651-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v6 01/14] qemu: Introduce qemuDomainDeviceDefValidateControllerAttributes 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.38]); Thu, 01 Feb 2018 03:02:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move the checks that various attributes are not set on any controller other than SCSI controller using virtio-scsi model into the common controller validate checks. Need to also add a qemuDomainResetSCSIControllerModel call in order to ensure we get the "right" SCSI model if it's not set by default since it wouldn't be set during post parse processing. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 24 ------------------------ src/qemu/qemu_domain.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 899f0cbbb..7b2f4cd13 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2725,30 +2725,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, return -1; } =20 - if (!(def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI && - def->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI))= { - if (def->queues) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'queues' is only supported by virtio-scsi co= ntroller")); - return -1; - } - if (def->cmd_per_lun) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'cmd_per_lun' is only supported by virtio-sc= si controller")); - return -1; - } - if (def->max_sectors) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'max_sectors' is only supported by virtio-sc= si controller")); - return -1; - } - if (def->ioeventfd) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'ioeventfd' is only supported by virtio-scsi= controller")); - return -1; - } - } - switch ((virDomainControllerType) def->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: switch (def->model) { diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c8123ce59..324805282 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3923,6 +3923,37 @@ qemuDomainDeviceDefValidateDisk(const virDomainDiskD= ef *disk) =20 =20 static int +qemuDomainDeviceDefValidateControllerAttributes(const virDomainControllerD= ef *controller) +{ + if (!(controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI && + controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO= _SCSI)) { + if (controller->queues) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'queues' is only supported by virtio-scsi co= ntroller")); + return -1; + } + if (controller->cmd_per_lun) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'cmd_per_lun' is only supported by virtio-sc= si controller")); + return -1; + } + if (controller->max_sectors) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'max_sectors' is only supported by virtio-sc= si controller")); + return -1; + } + if (controller->ioeventfd) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'ioeventfd' is only supported by virtio-scsi= controller")); + return -1; + } + } + + return 0; +} + + +static int qemuDomainDeviceDefValidateControllerIDE(const virDomainControllerDef *con= troller, const virDomainDef *def) { @@ -3959,6 +3990,9 @@ qemuDomainDeviceDefValidateController(const virDomain= ControllerDef *controller, "controller")) return -1; =20 + if (qemuDomainDeviceDefValidateControllerAttributes(controller) < 0) + return -1; + switch ((virDomainControllerType) controller->type) { case VIR_DOMAIN_CONTROLLER_TYPE_IDE: ret =3D qemuDomainDeviceDefValidateControllerIDE(controller, def); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 11:50:11 2024 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 1517454149916561.9066511998699; Wed, 31 Jan 2018 19:02:29 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A368025BB2; Thu, 1 Feb 2018 03:02:28 +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 7499162671; Thu, 1 Feb 2018 03:02:28 +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 3504918033DC; Thu, 1 Feb 2018 03:02:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w112w0us031279 for ; Wed, 31 Jan 2018 21:58:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7FFBA6090B; Thu, 1 Feb 2018 02:58:00 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A3C0608F1 for ; Thu, 1 Feb 2018 02:58:00 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 31 Jan 2018 21:57:41 -0500 Message-Id: <20180201025753.10651-3-jferlan@redhat.com> In-Reply-To: <20180201025753.10651-1-jferlan@redhat.com> References: <20180201025753.10651-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v6 02/14] qemu: Move and rename qemuBuildCheckSCSIControllerModel 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 01 Feb 2018 03:02:29 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move to qemu_domain during the validation of controller options and rename qemuDomainCheckSCSIControllerModel. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 67 ---------------------------------------------= ---- src/qemu/qemu_domain.c | 66 +++++++++++++++++++++++++++++++++++++++++++++= +++ 2 files changed, 66 insertions(+), 67 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7b2f4cd13..1efaec2d3 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1888,68 +1888,6 @@ qemuCheckIOThreads(const virDomainDef *def, } =20 =20 -/** - * @qemuCaps: QEMU capabilities - * @model: SCSI model to check - * - * Using the @qemuCaps, let's ensure the provided @model can be supported - * - * Returns true if acceptible, false otherwise with error message set. - */ -static bool -qemuBuildCheckSCSIControllerModel(virQEMUCapsPtr qemuCaps, - int model) -{ - switch ((virDomainControllerModelSCSI) model) { - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("This QEMU doesn't support " - "the LSI 53C895A SCSI controller")); - return false; - } - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("This QEMU doesn't support " - "virtio scsi controller")); - return false; - } - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI: - /*TODO: need checking work here if necessary */ - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_MPTSAS1068)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("This QEMU doesn't support " - "the LSI SAS1068 (MPT Fusion) controller")); - return false; - } - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_MEGASAS)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("This QEMU doesn't support " - "the LSI SAS1078 (MegaRAID) controller")); - return false; - } - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unsupported controller model: %s"), - virDomainControllerModelSCSITypeToString(model)); - return false; - } - - return true; -} - - char * qemuBuildDriveDevStr(const virDomainDef *def, virDomainDiskDefPtr disk, @@ -2720,11 +2658,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, =20 *devstr =3D NULL; =20 - if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { - if (!qemuBuildCheckSCSIControllerModel(qemuCaps, def->model)) - return -1; - } - switch ((virDomainControllerType) def->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: switch (def->model) { diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 324805282..152718c0d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3953,6 +3953,68 @@ qemuDomainDeviceDefValidateControllerAttributes(cons= t virDomainControllerDef *co } =20 =20 +/** + * @qemuCaps: QEMU capabilities + * @model: SCSI model to check + * + * Using the @qemuCaps, let's ensure the provided @model can be supported + * + * Returns true if acceptible, false otherwise with error message set. + */ +static bool +qemuDomainCheckSCSIControllerModel(virQEMUCapsPtr qemuCaps, + int model) +{ + switch ((virDomainControllerModelSCSI) model) { + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("This QEMU doesn't support " + "the LSI 53C895A SCSI controller")); + return false; + } + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("This QEMU doesn't support " + "virtio scsi controller")); + return false; + } + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI: + /*TODO: need checking work here if necessary */ + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_MPTSAS1068)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("This QEMU doesn't support " + "the LSI SAS1068 (MPT Fusion) controller")); + return false; + } + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_MEGASAS)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("This QEMU doesn't support " + "the LSI SAS1078 (MegaRAID) controller")); + return false; + } + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unsupported controller model: %s"), + virDomainControllerModelSCSITypeToString(model)); + return false; + } + + return true; +} + + static int qemuDomainDeviceDefValidateControllerIDE(const virDomainControllerDef *con= troller, const virDomainDef *def) @@ -3990,6 +4052,10 @@ qemuDomainDeviceDefValidateController(const virDomai= nControllerDef *controller, "controller")) return -1; =20 + if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI && + !qemuDomainCheckSCSIControllerModel(qemuCaps, controller->model)) + return -1; + if (qemuDomainDeviceDefValidateControllerAttributes(controller) < 0) return -1; =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 11:50:11 2024 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 1517454153282829.4702199118681; Wed, 31 Jan 2018 19:02:33 -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 0C445776FD; Thu, 1 Feb 2018 03:02:32 +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 AC8EC60621; Thu, 1 Feb 2018 03:02:31 +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 5B37518033DE; Thu, 1 Feb 2018 03:02:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w112w0vT031294 for ; Wed, 31 Jan 2018 21:58:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id EBF336090B; Thu, 1 Feb 2018 02:58:00 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id A83F6608F1 for ; Thu, 1 Feb 2018 02:58:00 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 31 Jan 2018 21:57:42 -0500 Message-Id: <20180201025753.10651-4-jferlan@redhat.com> In-Reply-To: <20180201025753.10651-1-jferlan@redhat.com> References: <20180201025753.10651-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v6 03/14] qemu: Adjust SCSI controller switch in qemuBuildControllerDevStr 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.27]); Thu, 01 Feb 2018 03:02:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Modify the SCSI controller switch during command line building to account for all virDomainControllerModelSCSI types rather than using the default label. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1efaec2d3..d9fa3742a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2660,7 +2660,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, =20 switch ((virDomainControllerType) def->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: - switch (def->model) { + switch ((virDomainControllerModelSCSI) def->model) { case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: if (def->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { virBufferAddLit(&buf, "virtio-scsi-ccw"); @@ -2700,7 +2700,10 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078: virBufferAddLit(&buf, "megasas"); break; - default: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported controller model: %s"), virDomainControllerModelSCSITypeToString(def->m= odel)); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 11:50:11 2024 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 15174539026551006.4644664664072; Wed, 31 Jan 2018 18:58:22 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1567E61460; Thu, 1 Feb 2018 02:58:21 +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 CECB15D968; Thu, 1 Feb 2018 02:58:20 +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 8AA6E1806104; Thu, 1 Feb 2018 02:58:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w112w1HL031302 for ; Wed, 31 Jan 2018 21:58:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6A7286090B; Thu, 1 Feb 2018 02:58:01 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F3E8608F1 for ; Thu, 1 Feb 2018 02:58:01 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 31 Jan 2018 21:57:43 -0500 Message-Id: <20180201025753.10651-5-jferlan@redhat.com> In-Reply-To: <20180201025753.10651-1-jferlan@redhat.com> References: <20180201025753.10651-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v6 04/14] qemu: Add check for iothread attribute in validate controller 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 01 Feb 2018 02:58:21 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Let's make sure that non SCSI virtio-scsi isn't used for any type other than a virtio-scsi controller. This includes removing the check from qemuCheckSCSIControllerIOThreads which is a very suble difference because although def->model was used in the original comparison and just @model is used in the new comparison, the comparison is the same. This is because qemuDomainSetSCSIControllerModel doesn't change the def->model, thus we know that the resultant @model would result in either the same as input or if not set, whatever the default model is when def->model =3D=3D -1. In this second case, virtio-scsi is the last default chosen. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 8 -------- src/qemu/qemu_domain.c | 5 +++++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d9fa3742a..007d689ec 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2598,14 +2598,6 @@ qemuCheckSCSIControllerIOThreads(const virDomainDef = *domainDef, if (!def->iothread) return true; =20 - if (def->model !=3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("IOThreads only supported for virtio-scsi " - "controllers model is '%s'"), - virDomainControllerModelSCSITypeToString(def->model= )); - return false; - } - if (def->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && def->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 152718c0d..0a9f92031 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3947,6 +3947,11 @@ qemuDomainDeviceDefValidateControllerAttributes(cons= t virDomainControllerDef *co _("'ioeventfd' is only supported by virtio-scsi= controller")); return -1; } + if (controller->iothread) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'iothread' is only supported for virtio-scsi= controller")); + return -1; + } } =20 return 0; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 11:50:11 2024 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 1517453887087540.2578095009327; Wed, 31 Jan 2018 18:58:07 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4CA4D552C7; Thu, 1 Feb 2018 02:58:05 +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 A2DB66266F; Thu, 1 Feb 2018 02:58:04 +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 35B51180BAE2; Thu, 1 Feb 2018 02:58:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w112w1nu031307 for ; Wed, 31 Jan 2018 21:58:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id D87746090B; Thu, 1 Feb 2018 02:58:01 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 93BD3608F1 for ; Thu, 1 Feb 2018 02:58:01 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 31 Jan 2018 21:57:44 -0500 Message-Id: <20180201025753.10651-6-jferlan@redhat.com> In-Reply-To: <20180201025753.10651-1-jferlan@redhat.com> References: <20180201025753.10651-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v6 05/14] qemu: Introduce qemuDomainDeviceDefValidateControllerSCSI 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 01 Feb 2018 02:58:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move SCSI validation from qemu_command into qemu_domain. Rename/reorder the args in qemuCheckSCSIControllerIOThreads to match the caller as well as fixing up the comments to remove the previously removed qemuCaps arg. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 48 ++--------------------------------- src/qemu/qemu_domain.c | 67 +++++++++++++++++++++++++++++++++++++++++++++= +++- 2 files changed, 68 insertions(+), 47 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 007d689ec..b4daf90d4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2580,44 +2580,6 @@ qemuBuildUSBControllerDevStr(virDomainControllerDefP= tr def, } =20 =20 -/* qemuCheckSCSIControllerIOThreads: - * @domainDef: Pointer to domain def - * @def: Pointer to controller def - * @qemuCaps: Capabilities - * - * If this controller definition has iothreads set, let's make sure the - * configuration is right before adding to the command line - * - * Returns true if either supported or there are no iothreads for controll= er; - * otherwise, returns false if configuration is not quite right. - */ -static bool -qemuCheckSCSIControllerIOThreads(const virDomainDef *domainDef, - virDomainControllerDefPtr def) -{ - if (!def->iothread) - return true; - - if (def->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && - def->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("IOThreads only available for virtio pci and " - "virtio ccw controllers")); - return false; - } - - /* Can we find the controller iothread in the iothreadid list? */ - if (!virDomainIOThreadIDFind(domainDef, def->iothread)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("controller iothread '%u' not defined in iothread= id"), - def->iothread); - return false; - } - - return true; -} - - /** * qemuBuildControllerDevStr: * @domainDef: domain definition @@ -2656,12 +2618,9 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: if (def->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { virBufferAddLit(&buf, "virtio-scsi-ccw"); - if (def->iothread) { - if (!qemuCheckSCSIControllerIOThreads(domainDef, def)) - goto error; + if (def->iothread) virBufferAsprintf(&buf, ",iothread=3Diothread%u", def->iothread); - } } else if (def->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) { virBufferAddLit(&buf, "virtio-scsi-s390"); @@ -2670,12 +2629,9 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, virBufferAddLit(&buf, "virtio-scsi-device"); } else { virBufferAddLit(&buf, "virtio-scsi-pci"); - if (def->iothread) { - if (!qemuCheckSCSIControllerIOThreads(domainDef, def)) - goto error; + if (def->iothread) virBufferAsprintf(&buf, ",iothread=3Diothread%u", def->iothread); - } } if (qemuBuildVirtioOptionsStr(&buf, def->virtio, qemuCaps) < 0) goto error; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0a9f92031..88d56b0b9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4046,6 +4046,68 @@ qemuDomainDeviceDefValidateControllerIDE(const virDo= mainControllerDef *controlle } =20 =20 +/* qemuDomainCheckSCSIControllerIOThreads: + * @controller: Pointer to controller def + * @def: Pointer to domain def + * + * If this controller definition has iothreads set, let's make sure the + * configuration is right before adding to the command line + * + * Returns true if either supported or there are no iothreads for controll= er; + * otherwise, returns false if configuration is not quite right. + */ +static bool +qemuDomainCheckSCSIControllerIOThreads(const virDomainControllerDef *contr= oller, + const virDomainDef *def) +{ + if (!controller->iothread) + return true; + + if (controller->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && + controller->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("IOThreads only available for virtio pci and " + "virtio ccw controllers")); + return false; + } + + /* Can we find the controller iothread in the iothreadid list? */ + if (!virDomainIOThreadIDFind(def, controller->iothread)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("controller iothread '%u' not defined in iothread= id"), + controller->iothread); + return false; + } + + return true; +} + + +static int +qemuDomainDeviceDefValidateControllerSCSI(const virDomainControllerDef *co= ntroller, + const virDomainDef *def) +{ + switch ((virDomainControllerModelSCSI) controller->model) { + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: + if (!qemuDomainCheckSCSIControllerIOThreads(controller, def)) + return -1; + break; + + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST: + break; + } + + return 0; +} + + static int qemuDomainDeviceDefValidateController(const virDomainControllerDef *contro= ller, const virDomainDef *def, @@ -4069,8 +4131,11 @@ qemuDomainDeviceDefValidateController(const virDomai= nControllerDef *controller, ret =3D qemuDomainDeviceDefValidateControllerIDE(controller, def); break; =20 - case VIR_DOMAIN_CONTROLLER_TYPE_FDC: case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: + ret =3D qemuDomainDeviceDefValidateControllerSCSI(controller, def); + break; + + case VIR_DOMAIN_CONTROLLER_TYPE_FDC: case VIR_DOMAIN_CONTROLLER_TYPE_SATA: case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: case VIR_DOMAIN_CONTROLLER_TYPE_CCID: --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 11:50:11 2024 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 1517453905983453.6205303534697; Wed, 31 Jan 2018 18:58:25 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 318C628121; Thu, 1 Feb 2018 02:58:24 +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 EACED60BE7; Thu, 1 Feb 2018 02:58:23 +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 B0BCC4EEEF; Thu, 1 Feb 2018 02:58:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w112w2jE031322 for ; Wed, 31 Jan 2018 21:58:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id 515F76090B; Thu, 1 Feb 2018 02:58:02 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E801608F1 for ; Thu, 1 Feb 2018 02:58:01 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 31 Jan 2018 21:57:45 -0500 Message-Id: <20180201025753.10651-7-jferlan@redhat.com> In-Reply-To: <20180201025753.10651-1-jferlan@redhat.com> References: <20180201025753.10651-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v6 06/14] qemu: Introduce qemuDomainDeviceDefValidateControllerPCI 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 01 Feb 2018 02:58:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move PCI validation checks out of qemu_command into the proper qemu_domain validation helper. Since there's a lot to move, we'll start slow by replicating the pcie-root and pci-root avoidance from qemuBuildSkipController and the first switch found in qemuBuildControllerDevStr. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 20 -------------------- src/qemu/qemu_domain.c | 47 +++++++++++++++++++++++++++++++++++++++++++++= +- 2 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b4daf90d4..c2c1ae9b6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2713,26 +2713,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, case VIR_DOMAIN_CONTROLLER_TYPE_PCI: switch ((virDomainControllerModelPCI) def->model) { case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: - case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: - case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: - if (def->idx =3D=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("index for pci controllers of model '%s' = must be > 0"), - virDomainControllerModelPCITypeToString(def= ->model)); - goto error; - } - break; - case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: - case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: - break; - } - switch ((virDomainControllerModelPCI) def->model) { - case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: if (def->opts.pciopts.modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE || def->opts.pciopts.chassisNr =3D=3D -1) { diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 88d56b0b9..179ff0ec8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4109,6 +4109,48 @@ qemuDomainDeviceDefValidateControllerSCSI(const virD= omainControllerDef *controll =20 =20 static int +qemuDomainDeviceDefValidateControllerPCI(const virDomainControllerDef *con= troller, + const virDomainDef *def) +{ + virDomainControllerModelPCI model =3D controller->model; + + /* skip pcie-root */ + if (controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) + return 0; + + /* Skip pci-root, except for pSeries guests (which actually + * support more than one PCI Host Bridge per guest) */ + if (!qemuDomainIsPSeries(def) && + controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) + return 0; + + switch (model) { + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: + case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: + if (controller->idx =3D=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("index for pci controllers of model '%s' must= be > 0"), + virDomainControllerModelPCITypeToString(model)); + return -1; + } + break; + + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: + break; + } + + return 0; +} + + +static int qemuDomainDeviceDefValidateController(const virDomainControllerDef *contro= ller, const virDomainDef *def, virQEMUCapsPtr qemuCaps) @@ -4135,12 +4177,15 @@ qemuDomainDeviceDefValidateController(const virDoma= inControllerDef *controller, ret =3D qemuDomainDeviceDefValidateControllerSCSI(controller, def); break; =20 + case VIR_DOMAIN_CONTROLLER_TYPE_PCI: + ret =3D qemuDomainDeviceDefValidateControllerPCI(controller, def); + break; + case VIR_DOMAIN_CONTROLLER_TYPE_FDC: case VIR_DOMAIN_CONTROLLER_TYPE_SATA: case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: case VIR_DOMAIN_CONTROLLER_TYPE_CCID: case VIR_DOMAIN_CONTROLLER_TYPE_USB: - case VIR_DOMAIN_CONTROLLER_TYPE_PCI: case VIR_DOMAIN_CONTROLLER_TYPE_LAST: break; } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 11:50:11 2024 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 1517454156041328.7077160399672; Wed, 31 Jan 2018 19:02:36 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D73F7A3433; Thu, 1 Feb 2018 03:02:34 +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 ADAF462699; Thu, 1 Feb 2018 03:02:34 +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 767203FB1F; Thu, 1 Feb 2018 03:02:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w112w3LI031328 for ; Wed, 31 Jan 2018 21:58:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id F15436090B; Thu, 1 Feb 2018 02:58:02 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id A56BB608F1 for ; Thu, 1 Feb 2018 02:58:02 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 31 Jan 2018 21:57:46 -0500 Message-Id: <20180201025753.10651-8-jferlan@redhat.com> In-Reply-To: <20180201025753.10651-1-jferlan@redhat.com> References: <20180201025753.10651-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v6 07/14] qemu: Add missing checks for pcie-root-port options 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 01 Feb 2018 03:02:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Andrea Bolognani We format the 'chassis' and 'port' properties on the QEMU command line later on, so we should make sure they've been set. Signed-off-by: Andrea Bolognani Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c2c1ae9b6..abff1049b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2816,7 +2816,9 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: if (def->opts.pciopts.modelName - =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) { + =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE || + def->opts.pciopts.chassis =3D=3D -1 || + def->opts.pciopts.port =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("autogenerated pcie-root-port options not= set")); goto error; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 11:50:11 2024 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 1517453909124767.401603525536; Wed, 31 Jan 2018 18:58:29 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 98462550D5; Thu, 1 Feb 2018 02:58:27 +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 697745D9CA; Thu, 1 Feb 2018 02:58:27 +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 2ADDF3FC71; Thu, 1 Feb 2018 02:58:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w112w3O0031337 for ; Wed, 31 Jan 2018 21:58:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id 77E846090B; Thu, 1 Feb 2018 02:58:03 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F0EB608F1 for ; Thu, 1 Feb 2018 02:58:03 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 31 Jan 2018 21:57:47 -0500 Message-Id: <20180201025753.10651-9-jferlan@redhat.com> In-Reply-To: <20180201025753.10651-1-jferlan@redhat.com> References: <20180201025753.10651-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v6 08/14] qemu: Use virDomainPCIControllerOpts in qemuBuildControllerDevStr 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 01 Feb 2018 02:58:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Shorten up a few characters and reference the pciopts pointer Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 118 ++++++++++++++++++++++++--------------------= ---- 1 file changed, 60 insertions(+), 58 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index abff1049b..518a867d5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2608,6 +2608,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, int *nusbcontroller) { virBuffer buf =3D VIR_BUFFER_INITIALIZER; + const virDomainPCIControllerOpts *pciopts; const char *modelName =3D NULL; =20 *devstr =3D NULL; @@ -2711,24 +2712,26 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, break; =20 case VIR_DOMAIN_CONTROLLER_TYPE_PCI: + pciopts =3D &def->opts.pciopts; + switch ((virDomainControllerModelPCI) def->model) { case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: - if (def->opts.pciopts.modelName + if (pciopts->modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE || - def->opts.pciopts.chassisNr =3D=3D -1) { + pciopts->chassisNr =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("autogenerated pci-bridge options not set= ")); goto error; } =20 - modelName =3D virDomainControllerPCIModelNameTypeToString(def-= >opts.pciopts.modelName); + modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); if (!modelName) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown pci-bridge model name value %d"), - def->opts.pciopts.modelName); + pciopts->modelName); goto error; } - if (def->opts.pciopts.modelName + if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("PCI controller model name '%s' " @@ -2743,26 +2746,26 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, goto error; } virBufferAsprintf(&buf, "%s,chassis_nr=3D%d,id=3D%s", - modelName, def->opts.pciopts.chassisNr, + modelName, pciopts->chassisNr, def->info.alias); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: - if (def->opts.pciopts.modelName + if (pciopts->modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE || - def->opts.pciopts.busNr =3D=3D -1) { + pciopts->busNr =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("autogenerated pci-expander-bus options n= ot set")); goto error; } =20 - modelName =3D virDomainControllerPCIModelNameTypeToString(def-= >opts.pciopts.modelName); + modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); if (!modelName) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown pci-expander-bus model name valu= e %d"), - def->opts.pciopts.modelName); + pciopts->modelName); goto error; } - if (def->opts.pciopts.modelName + if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("PCI controller model name '%s' " @@ -2777,28 +2780,28 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, goto error; } virBufferAsprintf(&buf, "%s,bus_nr=3D%d,id=3D%s", - modelName, def->opts.pciopts.busNr, + modelName, pciopts->busNr, def->info.alias); - if (def->opts.pciopts.numaNode !=3D -1) + if (pciopts->numaNode !=3D -1) virBufferAsprintf(&buf, ",numa_node=3D%d", - def->opts.pciopts.numaNode); + pciopts->numaNode); break; case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: - if (def->opts.pciopts.modelName + 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; } =20 - modelName =3D virDomainControllerPCIModelNameTypeToString(def-= >opts.pciopts.modelName); + modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); if (!modelName) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown dmi-to-pci-bridge model name val= ue %d"), - def->opts.pciopts.modelName); + pciopts->modelName); goto error; } - if (def->opts.pciopts.modelName + if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE= ) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("PCI controller model name '%s' " @@ -2815,24 +2818,23 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, virBufferAsprintf(&buf, "%s,id=3D%s", modelName, def->info.ali= as); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: - if (def->opts.pciopts.modelName + if (pciopts->modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE || - def->opts.pciopts.chassis =3D=3D -1 || - def->opts.pciopts.port =3D=3D -1) { + pciopts->chassis =3D=3D -1 || pciopts->port =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("autogenerated pcie-root-port options not= set")); goto error; } - modelName =3D virDomainControllerPCIModelNameTypeToString(def-= >opts.pciopts.modelName); + modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); if (!modelName) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown pcie-root-port model name value = %d"), - def->opts.pciopts.modelName); + pciopts->modelName); goto error; } - if ((def->opts.pciopts.modelName !=3D + if ((pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420) && - (def->opts.pciopts.modelName !=3D + (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("PCI controller model name '%s' " @@ -2840,7 +2842,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, modelName); goto error; } - if ((def->opts.pciopts.modelName =3D=3D + if ((pciopts->modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420) && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_IOH3420)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -2848,7 +2850,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, "controller is not supported in this QEMU= binary")); goto error; } - if ((def->opts.pciopts.modelName =3D=3D + if ((pciopts->modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT) && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT)= ) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -2858,24 +2860,24 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, } =20 virBufferAsprintf(&buf, "%s,port=3D0x%x,chassis=3D%d,id=3D%s", - modelName, def->opts.pciopts.port, - def->opts.pciopts.chassis, def->info.alias); + modelName, pciopts->port, + pciopts->chassis, def->info.alias); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: - if (def->opts.pciopts.modelName + 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(def-= >opts.pciopts.modelName); + modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); if (!modelName) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown pcie-switch-upstream-port model = name value %d"), - def->opts.pciopts.modelName); + pciopts->modelName); goto error; } - if (def->opts.pciopts.modelName + if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("PCI controller model name '%s' " @@ -2893,24 +2895,24 @@ 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 (def->opts.pciopts.modelName + if (pciopts->modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE || - def->opts.pciopts.chassis =3D=3D -1 || - def->opts.pciopts.port =3D=3D -1) { + pciopts->chassis =3D=3D -1 || + pciopts->port =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("autogenerated pcie-switch-downstream-por= t " "options not set")); goto error; } =20 - modelName =3D virDomainControllerPCIModelNameTypeToString(def-= >opts.pciopts.modelName); + modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); if (!modelName) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown pcie-switch-downstream-port mode= l name value %d"), - def->opts.pciopts.modelName); + pciopts->modelName); goto error; } - if (def->opts.pciopts.modelName + if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_XIO3130_DOWNSTRE= AM) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("PCI controller model name '%s' " @@ -2926,26 +2928,26 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, goto error; } virBufferAsprintf(&buf, "%s,port=3D0x%x,chassis=3D%d,id=3D%s", - modelName, def->opts.pciopts.port, - def->opts.pciopts.chassis, def->info.alias); + modelName, pciopts->port, + pciopts->chassis, def->info.alias); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: - if (def->opts.pciopts.modelName + if (pciopts->modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE || - def->opts.pciopts.busNr =3D=3D -1) { + pciopts->busNr =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("autogenerated pcie-expander-bus options = not set")); goto error; } =20 - modelName =3D virDomainControllerPCIModelNameTypeToString(def-= >opts.pciopts.modelName); + modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); if (!modelName) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown pcie-expander-bus model name val= ue %d"), - def->opts.pciopts.modelName); + pciopts->modelName); goto error; } - if (def->opts.pciopts.modelName + if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB_PCIE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("PCI controller model name '%s' " @@ -2960,32 +2962,32 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, goto error; } virBufferAsprintf(&buf, "%s,bus_nr=3D%d,id=3D%s", - modelName, def->opts.pciopts.busNr, + modelName, pciopts->busNr, def->info.alias); - if (def->opts.pciopts.numaNode !=3D -1) + if (pciopts->numaNode !=3D -1) virBufferAsprintf(&buf, ",numa_node=3D%d", - def->opts.pciopts.numaNode); + pciopts->numaNode); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: - if (def->opts.pciopts.modelName =3D=3D VIR_DOMAIN_CONTROLLER_P= CI_MODEL_NAME_NONE || - def->opts.pciopts.targetIndex =3D=3D -1) { + if (pciopts->modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_= NAME_NONE || + pciopts->targetIndex =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("autogenerated pci-root options not set")= ); goto error; } =20 /* Skip the implicit one */ - if (def->opts.pciopts.targetIndex =3D=3D 0) + if (pciopts->targetIndex =3D=3D 0) goto done; =20 - modelName =3D virDomainControllerPCIModelNameTypeToString(def-= >opts.pciopts.modelName); + modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); if (!modelName) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown pci-root model name value %d"), - def->opts.pciopts.modelName); + pciopts->modelName); goto error; } - if (def->opts.pciopts.modelName !=3D VIR_DOMAIN_CONTROLLER_PCI= _MODEL_NAME_SPAPR_PCI_HOST_BRIDGE) { + if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NA= ME_SPAPR_PCI_HOST_BRIDGE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("PCI controller model name '%s' is not va= lid for a pci-root"), modelName); @@ -2998,17 +3000,17 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, goto error; } virBufferAsprintf(&buf, "%s,index=3D%d,id=3D%s", - modelName, def->opts.pciopts.targetIndex, + modelName, pciopts->targetIndex, def->info.alias); =20 - if (def->opts.pciopts.numaNode !=3D -1) { + if (pciopts->numaNode !=3D -1) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPAPR_PCI_HOST_BRI= DGE_NUMA_NODE)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("the spapr-pci-host-bridge controller= " "doesn't support numa_node on this QE= MU binary")); goto error; } - virBufferAsprintf(&buf, ",numa_node=3D%d", def->opts.pciop= ts.numaNode); + virBufferAsprintf(&buf, ",numa_node=3D%d", pciopts->numaNo= de); } break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 11:50:11 2024 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 1517453905307178.755268626168; Wed, 31 Jan 2018 18:58:25 -0800 (PST) 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 BDF692823D; Thu, 1 Feb 2018 02:58:23 +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 9778760473; Thu, 1 Feb 2018 02:58:23 +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 3338918033DA; Thu, 1 Feb 2018 02:58:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w112w3aR031354 for ; Wed, 31 Jan 2018 21:58:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id E4F266090B; Thu, 1 Feb 2018 02:58:03 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1377608F1 for ; Thu, 1 Feb 2018 02:58:03 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 31 Jan 2018 21:57:48 -0500 Message-Id: <20180201025753.10651-10-jferlan@redhat.com> In-Reply-To: <20180201025753.10651-1-jferlan@redhat.com> References: <20180201025753.10651-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v6 09/14] 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 01 Feb 2018 02:58:24 +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 | 36 ++++++------------------------------ src/qemu/qemu_domain.c | 12 ++++++++++++ 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 518a867d5..ccd141c55 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2716,9 +2716,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, =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= ")); goto error; @@ -2750,9 +2748,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, 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; @@ -2787,13 +2783,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, @@ -2818,9 +2807,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, 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 || - pciopts->chassis =3D=3D -1 || pciopts->port =3D=3D -1) { + if (pciopts->chassis =3D=3D -1 || pciopts->port =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("autogenerated pcie-root-port options not= set")); goto error; @@ -2864,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, @@ -2895,9 +2876,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, 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", _("autogenerated pcie-switch-downstream-por= t " @@ -2932,9 +2911,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, 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")); goto error; @@ -2969,8 +2946,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, 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")= ); goto error; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 179ff0ec8..a40d5ba55 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4113,6 +4113,7 @@ qemuDomainDeviceDefValidateControllerPCI(const virDom= ainControllerDef *controlle const virDomainDef *def) { virDomainControllerModelPCI model =3D controller->model; + const virDomainPCIControllerOpts *pciopts; =20 /* skip pcie-root */ if (controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) @@ -4146,6 +4147,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 options 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 From nobody Sun May 5 11:50:11 2024 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 1517453908570986.9986503266059; Wed, 31 Jan 2018 18:58:28 -0800 (PST) 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 4B1CD28144; Thu, 1 Feb 2018 02:58:27 +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 1F2415C89A; Thu, 1 Feb 2018 02:58:27 +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 B973F18033DE; Thu, 1 Feb 2018 02:58:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w112w4tv031361 for ; Wed, 31 Jan 2018 21:58:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5D5DF6090B; Thu, 1 Feb 2018 02:58:04 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 192F3608F1 for ; Thu, 1 Feb 2018 02:58:04 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 31 Jan 2018 21:57:49 -0500 Message-Id: <20180201025753.10651-11-jferlan@redhat.com> In-Reply-To: <20180201025753.10651-1-jferlan@redhat.com> References: <20180201025753.10651-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v6 10/14] qemu: Move PCI command modelName TypeToString 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 01 Feb 2018 02:58:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Similar to the checking the modelName vs. NAME_NONE, let's make the ModelNameTypeToString check more generic too within the checking done in controller validation (with the same ignore certain models. NB: We need to keep the ModelNameTypeToString fetch in command line validation since we use it, but at least we can assume it returns something valid now. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 59 +++------------------------------------------= ---- src/qemu/qemu_domain.c | 10 +++++++++ 2 files changed, 13 insertions(+), 56 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ccd141c55..9a4ad0531 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2713,6 +2713,9 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, =20 case VIR_DOMAIN_CONTROLLER_TYPE_PCI: pciopts =3D &def->opts.pciopts; + if (def->model !=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT && + def->model !=3D VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST) + modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); =20 switch ((virDomainControllerModelPCI) def->model) { case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: @@ -2722,13 +2725,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, goto error; } =20 - modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); - if (!modelName) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown pci-bridge model name value %d"), - pciopts->modelName); - goto error; - } if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -2754,13 +2750,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, goto error; } =20 - modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); - if (!modelName) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown pci-expander-bus model name valu= e %d"), - pciopts->modelName); - goto error; - } if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -2783,13 +2772,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, pciopts->numaNode); break; case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: - modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); - if (!modelName) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown dmi-to-pci-bridge model name val= ue %d"), - pciopts->modelName); - goto error; - } if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE= ) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -2812,13 +2794,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, _("autogenerated pcie-root-port options not= set")); goto error; } - modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); - if (!modelName) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown pcie-root-port model name value = %d"), - pciopts->modelName); - goto error; - } if ((pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420) && (pciopts->modelName !=3D @@ -2851,13 +2826,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, pciopts->chassis, def->info.alias); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: - modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); - if (!modelName) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown pcie-switch-upstream-port model = name value %d"), - pciopts->modelName); - goto error; - } if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -2884,13 +2852,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, goto error; } =20 - modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); - if (!modelName) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown pcie-switch-downstream-port mode= l name value %d"), - pciopts->modelName); - goto error; - } if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_XIO3130_DOWNSTRE= AM) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -2917,13 +2878,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, goto error; } =20 - modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); - if (!modelName) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown pcie-expander-bus model name val= ue %d"), - pciopts->modelName); - goto error; - } if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB_PCIE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -2956,13 +2910,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, if (pciopts->targetIndex =3D=3D 0) goto done; =20 - modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); - if (!modelName) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown pci-root model name value %d"), - pciopts->modelName); - goto error; - } if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NA= ME_SPAPR_PCI_HOST_BRIDGE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("PCI controller model name '%s' is not va= lid for a pci-root"), diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a40d5ba55..302e3ee49 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4114,6 +4114,7 @@ qemuDomainDeviceDefValidateControllerPCI(const virDom= ainControllerDef *controlle { virDomainControllerModelPCI model =3D controller->model; const virDomainPCIControllerOpts *pciopts; + const char *modelName =3D NULL; =20 /* skip pcie-root */ if (controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) @@ -4156,6 +4157,15 @@ qemuDomainDeviceDefValidateControllerPCI(const virDo= mainControllerDef *controlle virDomainControllerModelPCITypeToString(control= ler->model)); return -1; } + + modelName =3D virDomainControllerPCIModelNameTypeToString(pciopts-= >modelName); + if (!modelName) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown %s modelName value %d"), + virDomainControllerModelPCITypeToString(control= ler->model), + pciopts->modelName); + return -1; + } } =20 return 0; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 11:50:11 2024 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 151745415927777.46076637882959; Wed, 31 Jan 2018 19:02:39 -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 E7DF3A343A; Thu, 1 Feb 2018 03:02:37 +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 C066760A9A; Thu, 1 Feb 2018 03:02:37 +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 824193FC73; Thu, 1 Feb 2018 03:02:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w112w4Yg031366 for ; Wed, 31 Jan 2018 21:58:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id CF6C2608F1; Thu, 1 Feb 2018 02:58:04 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8830D6090B for ; Thu, 1 Feb 2018 02:58:04 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 31 Jan 2018 21:57:50 -0500 Message-Id: <20180201025753.10651-12-jferlan@redhat.com> In-Reply-To: <20180201025753.10651-1-jferlan@redhat.com> References: <20180201025753.10651-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v6 11/14] qemu: Move PCI more command checks 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.39]); Thu, 01 Feb 2018 03:02:38 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Excluding the qemuCaps checks, move the remainder of the checks that validate whether the PCI definition is valid or not into qemuDomainControllerDefValidatePCI. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 101 ----------------------------------- src/qemu/qemu_domain.c | 139 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 139 insertions(+), 101 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9a4ad0531..e0bd6c6bf 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2719,20 +2719,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, =20 switch ((virDomainControllerModelPCI) def->model) { case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: - if (pciopts->chassisNr =3D=3D -1) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pci-bridge options not set= ")); - goto error; - } - - if (pciopts->modelName - !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("PCI controller model name '%s' " - "is not valid for a pci-bridge"), - modelName); - goto error; - } if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCI_BRIDGE)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("the pci-bridge controller " @@ -2744,20 +2730,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, def->info.alias); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: - if (pciopts->busNr =3D=3D -1) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pci-expander-bus options n= ot set")); - goto error; - } - - if (pciopts->modelName - !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("PCI controller model name '%s' " - "is not valid for a pci-expander-bus"), - modelName); - goto error; - } if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PXB)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("the pxb controller " @@ -2772,14 +2744,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, pciopts->numaNode); break; case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: - if (pciopts->modelName - !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE= ) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("PCI controller model name '%s' " - "is not valid for a dmi-to-pci-bridge"), - modelName); - goto error; - } if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRID= GE)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("the dmi-to-pci-bridge (i82801b11-bridge)= " @@ -2789,21 +2753,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->chassis =3D=3D -1 || pciopts->port =3D=3D -1) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pcie-root-port options not= set")); - goto error; - } - if ((pciopts->modelName !=3D - VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420) && - (pciopts->modelName !=3D - VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("PCI controller model name '%s' " - "is not valid for a pcie-root-port"), - modelName); - goto error; - } if ((pciopts->modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420) && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_IOH3420)) { @@ -2826,14 +2775,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 VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("PCI controller model name '%s' " - "is not valid for a pcie-switch-upstream-= port"), - modelName); - goto error; - } if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_X3130_UPSTREAM)= ) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("the pcie-switch-upstream-port (x3130-ups= tream) " @@ -2844,22 +2785,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, virBufferAsprintf(&buf, "%s,id=3D%s", modelName, def->info.ali= as); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: - if (pciopts->chassis =3D=3D -1 || - pciopts->port =3D=3D -1) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pcie-switch-downstream-por= t " - "options not set")); - goto error; - } - - if (pciopts->modelName - !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_XIO3130_DOWNSTRE= AM) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("PCI controller model name '%s' " - "is not valid for a pcie-switch-downstrea= m-port"), - modelName); - goto error; - } if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_XIO3130_DOWNSTR= EAM)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("The pcie-switch-downstream-port " @@ -2872,20 +2797,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, pciopts->chassis, def->info.alias); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: - if (pciopts->busNr =3D=3D -1) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pcie-expander-bus options = not set")); - goto error; - } - - if (pciopts->modelName - !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB_PCIE) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("PCI controller model name '%s' " - "is not valid for a pcie-expander-bus"), - modelName); - goto error; - } if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PXB_PCIE)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("the pxb-pcie controller " @@ -2900,22 +2811,10 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, pciopts->numaNode); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: - if (pciopts->targetIndex =3D=3D -1) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pci-root options not set")= ); - goto error; - } - /* Skip the implicit one */ if (pciopts->targetIndex =3D=3D 0) goto done; =20 - if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NA= ME_SPAPR_PCI_HOST_BRIDGE) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("PCI controller model name '%s' is not va= lid for a pci-root"), - modelName); - goto error; - } if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_= BRIDGE)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("the spapr-pci-host-bridge controller " diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 302e3ee49..c76fdee23 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4126,6 +4126,8 @@ qemuDomainDeviceDefValidateControllerPCI(const virDom= ainControllerDef *controlle controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) return 0; =20 + /* First pass - just check the controller index for the model's + * that we care to check... */ switch (model) { case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: @@ -4168,6 +4170,143 @@ qemuDomainDeviceDefValidateControllerPCI(const virD= omainControllerDef *controlle } } =20 + /* Second pass - now the model specific checks */ + switch (model) { + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: + if (pciopts->chassisNr =3D=3D -1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("autogenerated pci-bridge options not set")); + return -1; + } + + if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_P= CI_BRIDGE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller model name '%s' is not valid " + "for a pci-bridge"), + modelName); + return -1; + } + + break; + + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: + if (pciopts->busNr =3D=3D -1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("autogenerated pci-expander-bus options not s= et")); + return -1; + } + + if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_P= XB) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller model name '%s' is not valid " + "for a pci-expander-bus"), + modelName); + return -1; + } + + break; + + case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: + if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I= 82801B11_BRIDGE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller model name '%s' is not valid " + "for a dmi-to-pci-bridge"), + modelName); + return -1; + } + + break; + + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: + if (pciopts->chassis =3D=3D -1 || pciopts->port =3D=3D -1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("autogenerated pcie-root-port options not set= ")); + return -1; + } + + if ((pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_= IOH3420) && + (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_= PCIE_ROOT_PORT)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller model name '%s' is not valid " + "for a pcie-root-port"), + modelName); + return -1; + } + + break; + + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: + if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X= 3130_UPSTREAM) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller model name '%s' is not valid " + "for a pcie-switch-upstream-port"), + modelName); + return -1; + } + + break; + + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: + if (pciopts->chassis =3D=3D -1 || pciopts->port =3D=3D -1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("autogenerated pcie-switch-downstream-port " + "options not set")); + return -1; + } + + if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X= IO3130_DOWNSTREAM) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller model name '%s' is not valid " + "for a pcie-switch-downstream-port"), + modelName); + return -1; + } + + break; + + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: + if (pciopts->busNr =3D=3D -1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("autogenerated pcie-expander-bus options not = set")); + return -1; + } + + if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_P= XB_PCIE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller model name '%s' is not valid " + "for a pcie-expander-bus"), + modelName); + return -1; + } + + break; + + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: + if (pciopts->targetIndex =3D=3D -1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("autogenerated pci-root options not set")); + return -1; + } + + /* Skip the implicit one */ + if (pciopts->targetIndex =3D=3D 0) + return 0; + + if (pciopts->modelName !=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_S= PAPR_PCI_HOST_BRIDGE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller model name '%s' is not valid " + "for a pci-root"), + modelName); + return 0; + } + + break; + + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: + break; + } + return 0; } =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 11:50:11 2024 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 1517454162729762.5627736842878; Wed, 31 Jan 2018 19:02:42 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 64D1980476; Thu, 1 Feb 2018 03:02:41 +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 372665D968; Thu, 1 Feb 2018 03:02:41 +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 E4D593FC75; Thu, 1 Feb 2018 03:02:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w112w5PJ031371 for ; Wed, 31 Jan 2018 21:58:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 450E1608F1; Thu, 1 Feb 2018 02:58:05 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0261460621 for ; Thu, 1 Feb 2018 02:58:04 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 31 Jan 2018 21:57:51 -0500 Message-Id: <20180201025753.10651-13-jferlan@redhat.com> In-Reply-To: <20180201025753.10651-1-jferlan@redhat.com> References: <20180201025753.10651-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v6 12/14] qemu: Complete PCI command checks 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 01 Feb 2018 03:02:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move the qemuCaps checks over to qemuDomainControllerDefValidatePCI. This requires two test updates in order to set the correct capability bit for an xml2xml test as well as setting up the similar capability for the pseries memlocktest. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 70 +------------------------------------------ src/qemu/qemu_domain.c | 80 +++++++++++++++++++++++++++++++++++++++++++++= ++-- tests/qemumemlocktest.c | 14 +++++++++ tests/qemuxml2xmltest.c | 5 +++- 4 files changed, 97 insertions(+), 72 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e0bd6c6bf..093aa263a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2719,23 +2719,11 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, =20 switch ((virDomainControllerModelPCI) def->model) { case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCI_BRIDGE)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("the pci-bridge controller " - "is not supported in this QEMU binary")); - goto error; - } virBufferAsprintf(&buf, "%s,chassis_nr=3D%d,id=3D%s", modelName, pciopts->chassisNr, def->info.alias); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PXB)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("the pxb controller " - "is not supported in this QEMU binary")); - goto error; - } virBufferAsprintf(&buf, "%s,bus_nr=3D%d,id=3D%s", modelName, pciopts->busNr, def->info.alias); @@ -2744,65 +2732,22 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, pciopts->numaNode); break; case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRID= GE)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("the dmi-to-pci-bridge (i82801b11-bridge)= " - "controller is not supported in this QEMU= binary")); - goto error; - } 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_IOH3420) && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_IOH3420)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("the pcie-root-port (ioh3420) " - "controller is not supported in this QEMU= binary")); - goto error; - } - if ((pciopts->modelName =3D=3D - VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT) && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT)= ) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("the pcie-root-port (pcie-root-port) " - "controller is not supported in this QEMU= binary")); - goto error; - } - virBufferAsprintf(&buf, "%s,port=3D0x%x,chassis=3D%d,id=3D%s", modelName, pciopts->port, pciopts->chassis, def->info.alias); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_X3130_UPSTREAM)= ) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("the pcie-switch-upstream-port (x3130-ups= tream) " - "controller is not supported in this QEMU= binary")); - goto error; - } - virBufferAsprintf(&buf, "%s,id=3D%s", modelName, def->info.ali= as); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_XIO3130_DOWNSTR= EAM)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("The pcie-switch-downstream-port " - "(xio3130-downstream) controller " - "is not supported in this QEMU binary")); - goto error; - } virBufferAsprintf(&buf, "%s,port=3D0x%x,chassis=3D%d,id=3D%s", modelName, pciopts->port, pciopts->chassis, def->info.alias); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PXB_PCIE)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("the pxb-pcie controller " - "is not supported in this QEMU binary")); - goto error; - } virBufferAsprintf(&buf, "%s,bus_nr=3D%d,id=3D%s", modelName, pciopts->busNr, def->info.alias); @@ -2815,25 +2760,12 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, if (pciopts->targetIndex =3D=3D 0) goto done; =20 - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_= BRIDGE)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("the spapr-pci-host-bridge controller " - "is not supported in this QEMU binary")); - goto error; - } virBufferAsprintf(&buf, "%s,index=3D%d,id=3D%s", modelName, pciopts->targetIndex, def->info.alias); =20 - if (pciopts->numaNode !=3D -1) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPAPR_PCI_HOST_BRI= DGE_NUMA_NODE)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("the spapr-pci-host-bridge controller= " - "doesn't support numa_node on this QE= MU binary")); - goto error; - } + if (pciopts->numaNode !=3D -1) virBufferAsprintf(&buf, ",numa_node=3D%d", pciopts->numaNo= de); - } break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c76fdee23..fe3f9bfe1 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4110,7 +4110,8 @@ qemuDomainDeviceDefValidateControllerSCSI(const virDo= mainControllerDef *controll =20 static int qemuDomainDeviceDefValidateControllerPCI(const virDomainControllerDef *con= troller, - const virDomainDef *def) + const virDomainDef *def, + virQEMUCapsPtr qemuCaps) { virDomainControllerModelPCI model =3D controller->model; const virDomainPCIControllerOpts *pciopts; @@ -4187,6 +4188,13 @@ qemuDomainDeviceDefValidateControllerPCI(const virDo= mainControllerDef *controlle return -1; } =20 + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCI_BRIDGE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("the pci-bridge controller is not supported " + "in this QEMU binary")); + return -1; + } + break; =20 case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: @@ -4204,6 +4212,13 @@ qemuDomainDeviceDefValidateControllerPCI(const virDo= mainControllerDef *controlle return -1; } =20 + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PXB)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("the pxb controller is not supported in this " + "QEMU binary")); + return -1; + } + break; =20 case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: @@ -4215,6 +4230,13 @@ qemuDomainDeviceDefValidateControllerPCI(const virDo= mainControllerDef *controlle return -1; } =20 + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE))= { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("the dmi-to-pci-bridge (i82801b11-bridge) " + "controller is not supported in this QEMU bin= ary")); + return -1; + } + break; =20 case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: @@ -4233,6 +4255,22 @@ qemuDomainDeviceDefValidateControllerPCI(const virDo= mainControllerDef *controlle return -1; } =20 + if ((pciopts->modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAM= E_IOH3420) && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_IOH3420)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("the pcie-root-port (ioh3420) controller " + "is not supported in this QEMU binary")); + return -1; + } + + if ((pciopts->modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAM= E_PCIE_ROOT_PORT) && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("the pcie-root-port (pcie-root-port) controll= er " + "is not supported in this QEMU binary")); + return -1; + } + break; =20 case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: @@ -4244,6 +4282,13 @@ qemuDomainDeviceDefValidateControllerPCI(const virDo= mainControllerDef *controlle return -1; } =20 + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_X3130_UPSTREAM)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("the pcie-switch-upstream-port (x3130-upstrea= m) " + "controller is not supported in this QEMU bin= ary")); + return -1; + } + break; =20 case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: @@ -4262,6 +4307,14 @@ qemuDomainDeviceDefValidateControllerPCI(const virDo= mainControllerDef *controlle return -1; } =20 + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM)= ) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("The pcie-switch-downstream-port " + "(xio3130-downstream) controller is not " + "supported in this QEMU binary")); + return -1; + } + break; =20 case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: @@ -4279,6 +4332,13 @@ qemuDomainDeviceDefValidateControllerPCI(const virDo= mainControllerDef *controlle return -1; } =20 + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PXB_PCIE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("the pxb-pcie controller is not supported " + "in this QEMU binary")); + return -1; + } + break; =20 case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: @@ -4300,6 +4360,21 @@ qemuDomainDeviceDefValidateControllerPCI(const virDo= mainControllerDef *controlle return 0; } =20 + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRID= GE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("the spapr-pci-host-bridge controller is not " + "supported in this QEMU binary")); + return -1; + } + + if (pciopts->numaNode !=3D -1 && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPAPR_PCI_HOST_BRIDGE_NUMA= _NODE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("the spapr-pci-host-bridge controller doe= sn't " + "support numa_node in this QEMU binary")); + return -1; + } + break; =20 case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: @@ -4339,7 +4414,8 @@ qemuDomainDeviceDefValidateController(const virDomain= ControllerDef *controller, break; =20 case VIR_DOMAIN_CONTROLLER_TYPE_PCI: - ret =3D qemuDomainDeviceDefValidateControllerPCI(controller, def); + ret =3D qemuDomainDeviceDefValidateControllerPCI(controller, def, + qemuCaps); break; =20 case VIR_DOMAIN_CONTROLLER_TYPE_FDC: diff --git a/tests/qemumemlocktest.c b/tests/qemumemlocktest.c index 62bd25450..bc0b53e6f 100644 --- a/tests/qemumemlocktest.c +++ b/tests/qemumemlocktest.c @@ -63,6 +63,7 @@ mymain(void) { int ret =3D 0; char *fakerootdir; + virQEMUCapsPtr qemuCaps =3D NULL; =20 if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) { fprintf(stderr, "Out of memory\n"); @@ -127,6 +128,16 @@ mymain(void) DO_TEST("pc-locked+hostdev", VIR_DOMAIN_MEMORY_PARAM_UNLIMITED); =20 qemuTestSetHostArch(driver.caps, VIR_ARCH_PPC64); + if (!(qemuCaps =3D virQEMUCapsNew())) { + ret =3D -1; + goto cleanup; + } + + virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE); + if (qemuTestCapsCacheInsert(driver.qemuCapsCache, qemuCaps) < 0) { + ret =3D -1; + goto cleanup; + }; =20 DO_TEST("pseries-kvm", 20971520); DO_TEST("pseries-tcg", 0); @@ -140,6 +151,9 @@ mymain(void) DO_TEST("pseries-hardlimit+locked+hostdev", 2147483648); DO_TEST("pseries-locked+hostdev", VIR_DOMAIN_MEMORY_PARAM_UNLIMITED); =20 + cleanup: + virObjectUnref(qemuCaps); + if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) virFileDeleteTree(fakerootdir); =20 diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 78519f509..d3544a1ef 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1317,7 +1317,10 @@ mymain(void) DO_TEST("intel-iommu-machine", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MACHINE_IOMMU); - DO_TEST("intel-iommu-caching-mode", NONE); + DO_TEST("intel-iommu-caching-mode", + QEMU_CAPS_DEVICE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, + QEMU_CAPS_DEVICE_IOH3420); DO_TEST("intel-iommu-eim", NONE); DO_TEST("intel-iommu-device-iotlb", NONE); =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 11:50:11 2024 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 1517453912270492.9514755141872; Wed, 31 Jan 2018 18:58:32 -0800 (PST) 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 C1B2ABE28C; Thu, 1 Feb 2018 02:58:30 +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 9D9D3620A5; Thu, 1 Feb 2018 02:58:30 +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 612123FB20; Thu, 1 Feb 2018 02:58:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w112w53T031376 for ; Wed, 31 Jan 2018 21:58:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id AFC1E6090B; Thu, 1 Feb 2018 02:58:05 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E38F608F1 for ; Thu, 1 Feb 2018 02:58:05 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 31 Jan 2018 21:57:52 -0500 Message-Id: <20180201025753.10651-14-jferlan@redhat.com> In-Reply-To: <20180201025753.10651-1-jferlan@redhat.com> References: <20180201025753.10651-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v6 13/14] qemu: Introduce qemuDomainDeviceDefValidateControllerSATA 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.27]); Thu, 01 Feb 2018 02:58:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move the SATA controller check from command line building to controller def validation. This includes copying the SATA skip check found in qemuBuildSkipController. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 6 ------ src/qemu/qemu_domain.c | 24 +++++++++++++++++++++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 093aa263a..85d88ff9b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2693,12 +2693,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, break; =20 case VIR_DOMAIN_CONTROLLER_TYPE_SATA: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_AHCI)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("SATA is not supported with this " - "QEMU binary")); - goto error; - } virBufferAsprintf(&buf, "ahci,id=3D%s", def->info.alias); break; =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index fe3f9bfe1..9b5907848 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4387,6 +4387,24 @@ qemuDomainDeviceDefValidateControllerPCI(const virDo= mainControllerDef *controlle =20 =20 static int +qemuDomainDeviceDefValidateControllerSATA(const virDomainControllerDef *co= ntroller, + const virDomainDef *def, + virQEMUCapsPtr qemuCaps) +{ + /* first SATA controller on Q35 machines is implicit */ + if (controller->idx =3D=3D 0 && qemuDomainIsQ35(def)) + return 0; + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_AHCI)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("SATA is not supported with this QEMU binary")); + return -1; + } + return 0; +} + + +static int qemuDomainDeviceDefValidateController(const virDomainControllerDef *contro= ller, const virDomainDef *def, virQEMUCapsPtr qemuCaps) @@ -4418,8 +4436,12 @@ qemuDomainDeviceDefValidateController(const virDomai= nControllerDef *controller, qemuCaps); break; =20 - case VIR_DOMAIN_CONTROLLER_TYPE_FDC: case VIR_DOMAIN_CONTROLLER_TYPE_SATA: + ret =3D qemuDomainDeviceDefValidateControllerSATA(controller, def, + qemuCaps); + break; + + case VIR_DOMAIN_CONTROLLER_TYPE_FDC: case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: case VIR_DOMAIN_CONTROLLER_TYPE_CCID: case VIR_DOMAIN_CONTROLLER_TYPE_USB: --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 11:50:11 2024 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 151745391542236.75692654810757; Wed, 31 Jan 2018 18:58:35 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 38438C0586A2; Thu, 1 Feb 2018 02:58:34 +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 097EF60BEC; Thu, 1 Feb 2018 02:58:34 +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 8439A18033E0; Thu, 1 Feb 2018 02:58:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w112w6tj031384 for ; Wed, 31 Jan 2018 21:58:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2BD856090B; Thu, 1 Feb 2018 02:58:06 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id DAFA7608F1 for ; Thu, 1 Feb 2018 02:58:05 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 31 Jan 2018 21:57:53 -0500 Message-Id: <20180201025753.10651-15-jferlan@redhat.com> In-Reply-To: <20180201025753.10651-1-jferlan@redhat.com> References: <20180201025753.10651-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v6 14/14] qemu: Use switch statement for address types in qemuBuildControllerDevStr 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 01 Feb 2018 02:58:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Marc Hartmayer Use a switch statement instead of if-else-if statements. Move the command line building of the iothread attribute into the common path as the SCSI controller attributes are already validated. Signed-off-by: Marc Hartmayer Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 85d88ff9b..d0771487d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2608,6 +2608,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, int *nusbcontroller) { virBuffer buf =3D VIR_BUFFER_INITIALIZER; + int address_type =3D def->info.type; const virDomainPCIControllerOpts *pciopts; const char *modelName =3D NULL; =20 @@ -2617,23 +2618,25 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: switch ((virDomainControllerModelSCSI) def->model) { case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: - if (def->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + switch ((virDomainDeviceAddressType) address_type) { + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: virBufferAddLit(&buf, "virtio-scsi-ccw"); - if (def->iothread) - virBufferAsprintf(&buf, ",iothread=3Diothread%u", - def->iothread); - } else if (def->info.type =3D=3D - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) { + break; + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: virBufferAddLit(&buf, "virtio-scsi-s390"); - } else if (def->info.type =3D=3D - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO) { + break; + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: virBufferAddLit(&buf, "virtio-scsi-device"); - } else { + break; + default: virBufferAddLit(&buf, "virtio-scsi-pci"); - if (def->iothread) - virBufferAsprintf(&buf, ",iothread=3Diothread%u", - def->iothread); } + + if (def->iothread) { + virBufferAsprintf(&buf, ",iothread=3Diothread%u", + def->iothread); + } + if (qemuBuildVirtioOptionsStr(&buf, def->virtio, qemuCaps) < 0) goto error; break; @@ -2661,18 +2664,20 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, break; =20 case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: - if (def->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + switch ((virDomainDeviceAddressType) address_type) { + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: virBufferAddLit(&buf, "virtio-serial-pci"); - } else if (def->info.type =3D=3D - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + break; + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: virBufferAddLit(&buf, "virtio-serial-ccw"); - } else if (def->info.type =3D=3D - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) { + break; + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: virBufferAddLit(&buf, "virtio-serial-s390"); - } else if (def->info.type =3D=3D - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO) { + break; + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: virBufferAddLit(&buf, "virtio-serial-device"); - } else { + break; + default: virBufferAddLit(&buf, "virtio-serial"); } virBufferAsprintf(&buf, ",id=3D%s", def->info.alias); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list