From nobody Tue Apr 30 08:14:43 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 1512437955744345.10745526674066; Mon, 4 Dec 2017 17:39:15 -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 AFA46883AB; Tue, 5 Dec 2017 01:39:14 +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 49CB560FA3; Tue, 5 Dec 2017 01:39:14 +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 AC13E1800BDB; Tue, 5 Dec 2017 01:39:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dCQT029273 for ; Mon, 4 Dec 2017 20:39:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id 60FD861559; Tue, 5 Dec 2017 01:39:12 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 266F862A42 for ; Tue, 5 Dec 2017 01:39:12 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:38:51 -0500 Message-Id: <20171205013907.8563-2-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/17] qemu: Introduce qemuDomainDeviceDefValidateController 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.26]); Tue, 05 Dec 2017 01:39:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Introduce the bare bones helper to validate whether the controller definition is valid. Signed-off-by: John Ferlan --- src/qemu/qemu_domain.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e8e03134f..569bbd29e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3885,6 +3885,27 @@ qemuDomainDeviceDefValidateDisk(const virDomainDiskD= ef *disk) =20 =20 static int +qemuDomainDeviceDefValidateController(const virDomainControllerDef *contro= ller, + const virDomainDef *def ATTRIBUTE_UN= USED) +{ + switch ((virDomainControllerType) controller->type) { + case VIR_DOMAIN_CONTROLLER_TYPE_IDE: + case VIR_DOMAIN_CONTROLLER_TYPE_FDC: + case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: + 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; + } + + return 0; +} + + +static int qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, const virDomainDef *def, void *opaque ATTRIBUTE_UNUSED) @@ -3928,11 +3949,14 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDe= f *dev, ret =3D qemuDomainDeviceDefValidateDisk(dev->data.disk); break; =20 + case VIR_DOMAIN_DEVICE_CONTROLLER: + ret =3D qemuDomainDeviceDefValidateController(dev->data.controller= , def); + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: - case VIR_DOMAIN_DEVICE_CONTROLLER: case VIR_DOMAIN_DEVICE_GRAPHICS: case VIR_DOMAIN_DEVICE_HUB: case VIR_DOMAIN_DEVICE_MEMBALLOON: --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 08:14:43 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 1512437957061204.86901033703248; Mon, 4 Dec 2017 17:39:17 -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 CB05C13A53; Tue, 5 Dec 2017 01:39:15 +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 A81B61880D; Tue, 5 Dec 2017 01:39:15 +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 6C87E4A468; Tue, 5 Dec 2017 01:39:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dCgn029279 for ; Mon, 4 Dec 2017 20:39:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id C532261559; Tue, 5 Dec 2017 01:39:12 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8ACEB62464 for ; Tue, 5 Dec 2017 01:39:12 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:38:52 -0500 Message-Id: <20171205013907.8563-3-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/17] qemu: Introduce qemuDomainDeviceDefSkipController 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.29]); Tue, 05 Dec 2017 01:39:16 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In order to be able to reuse some code for both controller def validation and command line building, create a convenience helper that will perform the "skip" avoidance checks. It will also set some flags to allow the caller to specifically skip (or fail) depending on the result of the flag (as opposed to building up some ever growing list of variables). Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 61 +++++------------------------------ src/qemu/qemu_domain.c | 84 +++++++++++++++++++++++++++++++++++++++++++++= +++- src/qemu/qemu_domain.h | 12 +++++++ 3 files changed, 102 insertions(+), 55 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6a8da1d58..5a6a671a1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3180,8 +3180,8 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd, virQEMUCapsPtr qemuCaps) { size_t i, j; + unsigned int flags =3D 0; int usbcontroller =3D 0; - bool usblegacy =3D false; int contOrder[] =3D { /* * List of controller types that we add commandline args for, @@ -3216,61 +3216,14 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd, if (cont->type !=3D contOrder[j]) continue; =20 - /* skip USB controllers with type none.*/ - if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB && - cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) { - usbcontroller =3D -1; /* mark we don't want a controller */ - continue; - } - - /* skip pcie-root */ - if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI && - cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) { - continue; - } + if (qemuDomainDeviceDefSkipController(cont, def, &flags)) { + /* mark we don't want a controller */ + if (flags & QEMU_DOMAIN_DEVICE_SKIP_USB_CONTROLLER_FLAG) + usbcontroller =3D -1; =20 - /* Skip pci-root, except for pSeries guests (which actually - * support more than one PCI Host Bridge per guest) */ - if (!qemuDomainIsPSeries(def) && - cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI && - cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) { - continue; - } - - /* first SATA controller on Q35 machines is implicit */ - if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SATA && - cont->idx =3D=3D 0 && qemuDomainIsQ35(def)) - continue; - - /* first IDE controller is implicit on various machines */ - if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_IDE && - cont->idx =3D=3D 0 && qemuDomainHasBuiltinIDE(def)) - continue; - - if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB && - cont->model =3D=3D -1 && - !qemuDomainIsQ35(def) && - !qemuDomainIsVirt(def)) { - - /* An appropriate default USB controller model should alre= ady - * have been selected in qemuDomainDeviceDefPostParse(); if - * we still have no model by now, we have to fall back to = the - * legacy USB controller. - * - * Note that we *don't* want to end up with the legacy USB - * controller for q35 and virt machines, so we go ahead and - * fail in qemuBuildControllerDevStr(); on the other hand, - * for s390 machines we want to ignore any USB controller - * (see 548ba43028 for the full story), so we skip - * qemuBuildControllerDevStr() but we don't ultimately end - * up adding the legacy USB controller */ - if (usblegacy) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Multiple legacy USB controllers are " - "not supported")); + if (flags & QEMU_DOMAIN_DEVICE_SKIP_USB_LEGACY_FAIL_FLAG) goto cleanup; - } - usblegacy =3D true; + continue; } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 569bbd29e..d4c7674c0 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3884,10 +3884,92 @@ qemuDomainDeviceDefValidateDisk(const virDomainDisk= Def *disk) } =20 =20 +/** + * qemuDomainDeviceDefSkipController: + * @controller: Controller to check + * @def: Domain definition + * @flags: qemuDomainDeviceSkipFlags to set if specific condition found + * + * Returns true if this controller can be skipped for command line generat= ion + * or device validation + */ +bool +qemuDomainDeviceDefSkipController(const virDomainControllerDef *controller, + const virDomainDef *def, + unsigned int *flags) +{ + /* skip USB controllers with type none.*/ + if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB && + controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) { + *flags |=3D QEMU_DOMAIN_DEVICE_SKIP_USB_CONTROLLER_FLAG; + return true; + } + + /* skip pcie-root */ + if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI && + controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) + return true; + + /* Skip pci-root, except for pSeries guests (which actually + * support more than one PCI Host Bridge per guest) */ + if (!qemuDomainIsPSeries(def) && + controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI && + controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) + return true; + + /* first SATA controller on Q35 machines is implicit */ + if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SATA && + controller->idx =3D=3D 0 && qemuDomainIsQ35(def)) + return true; + + /* first IDE controller is implicit on various machines */ + if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_IDE && + controller->idx =3D=3D 0 && qemuDomainHasBuiltinIDE(def)) + return true; + + if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB && + controller->model =3D=3D -1 && + !qemuDomainIsQ35(def) && + !qemuDomainIsVirt(def)) { + + /* An appropriate default USB controller model should already + * have been selected in qemuDomainDeviceDefPostParse(); if + * we still have no model by now, we have to fall back to the + * legacy USB controller. + * + * Note that we *don't* want to end up with the legacy USB + * controller for q35 and virt machines, so we go ahead and + * fail in qemuBuildControllerDevStr(); on the other hand, + * for s390 machines we want to ignore any USB controller + * (see 548ba43028 for the full story), so we skip + * qemuBuildControllerDevStr() but we don't ultimately end + * up adding the legacy USB controller */ + if (*flags & QEMU_DOMAIN_DEVICE_SKIP_USB_LEGACY_FLAG) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Multiple legacy USB controllers are " + "not supported")); + *flags |=3D QEMU_DOMAIN_DEVICE_SKIP_USB_LEGACY_FAIL_FLAG; + } + *flags |=3D QEMU_DOMAIN_DEVICE_SKIP_USB_LEGACY_FLAG; + return true; + } + + return false; +} + + static int qemuDomainDeviceDefValidateController(const virDomainControllerDef *contro= ller, - const virDomainDef *def ATTRIBUTE_UN= USED) + const virDomainDef *def) { + unsigned int flags =3D 0; + + if (qemuDomainDeviceDefSkipController(controller, def, &flags)) + return 0; + + if (flags & QEMU_DOMAIN_DEVICE_SKIP_USB_LEGACY_FAIL_FLAG) + return -1; + switch ((virDomainControllerType) controller->type) { case VIR_DOMAIN_CONTROLLER_TYPE_IDE: case VIR_DOMAIN_CONTROLLER_TYPE_FDC: diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index c33af3671..5c9c55d38 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -999,4 +999,16 @@ qemuDomainPrepareDiskSource(virConnectPtr conn, qemuDomainObjPrivatePtr priv, virQEMUDriverConfigPtr cfg); =20 +typedef enum { + QEMU_DOMAIN_DEVICE_SKIP_USB_CONTROLLER_FLAG =3D (1 << 0), + QEMU_DOMAIN_DEVICE_SKIP_USB_LEGACY_FLAG =3D (1 << 1), + QEMU_DOMAIN_DEVICE_SKIP_USB_LEGACY_FAIL_FLAG =3D (1 << 2), +} qemuDomainDeviceSkipFlags; + +bool +qemuDomainDeviceDefSkipController(const virDomainControllerDef *controller, + const virDomainDef *def, + unsigned int *flags); + + #endif /* __QEMU_DOMAIN_H__ */ --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 08:14:43 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 1512437961499629.7830873983287; Mon, 4 Dec 2017 17:39:21 -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 B95F361D22; Tue, 5 Dec 2017 01:39:19 +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 8ECBD5DA69; Tue, 5 Dec 2017 01:39:19 +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 503D6410B1; Tue, 5 Dec 2017 01:39:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dDvx029293 for ; Mon, 4 Dec 2017 20:39:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3139261559; Tue, 5 Dec 2017 01:39:13 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9CE962461 for ; Tue, 5 Dec 2017 01:39:12 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:38:53 -0500 Message-Id: <20171205013907.8563-4-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/17] qemu: Use virDomainControllerType in qemuBuildControllerDevStr switch 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]); Tue, 05 Dec 2017 01:39:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make sure all types of virDomainControllerType are handled in the switch statement. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5a6a671a1..818a057bc 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2695,7 +2695,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, } } =20 - switch (def->type) { + switch ((virDomainControllerType) def->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: switch (model) { case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: @@ -3140,7 +3140,8 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, "this QEMU binary or machine type")); goto error; =20 - default: + case VIR_DOMAIN_CONTROLLER_TYPE_FDC: + case VIR_DOMAIN_CONTROLLER_TYPE_LAST: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported controller type: %s"), virDomainControllerTypeToString(def->type)); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 08:14:43 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 1512437964126589.4296615572405; Mon, 4 Dec 2017 17:39:24 -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 4661CC014182; Tue, 5 Dec 2017 01:39:22 +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 1C8AA183C3; Tue, 5 Dec 2017 01:39:22 +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 D8D4C3D3D4; Tue, 5 Dec 2017 01:39:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dD1a029298 for ; Mon, 4 Dec 2017 20:39:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8DDBB61559; Tue, 5 Dec 2017 01:39:13 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53C7562461 for ; Tue, 5 Dec 2017 01:39:13 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:38:54 -0500 Message-Id: <20171205013907.8563-5-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/17] qemu: Move CCW S390 Address 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 05 Dec 2017 01:39:22 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move the call to qemuDomainCheckCCWS390AddressSupport from qemuBuildControllerDevStr to qemuDomainDeviceDefValidateController. This means we will get the qemuCaps from the driver opaque variable passed to qemuDomainDeviceDefValidate. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 4 ---- src/qemu/qemu_domain.c | 18 +++++++++++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 818a057bc..15d9209c6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2662,10 +2662,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, =20 *devstr =3D NULL; =20 - if (!qemuDomainCheckCCWS390AddressSupport(domainDef, def->info, qemuCa= ps, - "controller")) - return -1; - if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { if ((qemuDomainSetSCSIControllerModel(domainDef, qemuCaps, &model)= ) < 0) return -1; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d4c7674c0..1fc360af9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3960,7 +3960,8 @@ qemuDomainDeviceDefSkipController(const virDomainCont= rollerDef *controller, =20 static int qemuDomainDeviceDefValidateController(const virDomainControllerDef *contro= ller, - const virDomainDef *def) + const virDomainDef *def, + virQEMUCapsPtr qemuCaps) { unsigned int flags =3D 0; =20 @@ -3970,6 +3971,10 @@ qemuDomainDeviceDefValidateController(const virDomai= nControllerDef *controller, if (flags & QEMU_DOMAIN_DEVICE_SKIP_USB_LEGACY_FAIL_FLAG) return -1; =20 + if (!qemuDomainCheckCCWS390AddressSupport(def, controller->info, qemuC= aps, + "controller")) + return -1; + switch ((virDomainControllerType) controller->type) { case VIR_DOMAIN_CONTROLLER_TYPE_IDE: case VIR_DOMAIN_CONTROLLER_TYPE_FDC: @@ -3990,9 +3995,15 @@ qemuDomainDeviceDefValidateController(const virDomai= nControllerDef *controller, static int qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, const virDomainDef *def, - void *opaque ATTRIBUTE_UNUSED) + void *opaque) { int ret =3D 0; + virQEMUDriverPtr driver =3D opaque; + virQEMUCapsPtr qemuCaps =3D NULL; + + if (!(qemuCaps =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, + def->emulator))) + return -1; =20 switch ((virDomainDeviceType) dev->type) { case VIR_DOMAIN_DEVICE_NET: @@ -4032,7 +4043,8 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef = *dev, break; =20 case VIR_DOMAIN_DEVICE_CONTROLLER: - ret =3D qemuDomainDeviceDefValidateController(dev->data.controller= , def); + ret =3D qemuDomainDeviceDefValidateController(dev->data.controller= , def, + qemuCaps); break; =20 case VIR_DOMAIN_DEVICE_LEASE: --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 08:14:43 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 151243796070038.5971734701119; Mon, 4 Dec 2017 17:39:20 -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 A9AF4C059B75; Tue, 5 Dec 2017 01:39:19 +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 865AF62465; Tue, 5 Dec 2017 01:39:19 +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 4CA60389C; Tue, 5 Dec 2017 01:39:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dDwR029303 for ; Mon, 4 Dec 2017 20:39:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id EE81117D3C; Tue, 5 Dec 2017 01:39:13 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2BDD61559 for ; Tue, 5 Dec 2017 01:39:13 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:38:55 -0500 Message-Id: <20171205013907.8563-6-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/17] tests: Remove use of IDE disk for pseries floppy test 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.32]); Tue, 05 Dec 2017 01:39:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Lin Ma Adding an IDE controller for a machinetype that has no built-in IDE controller, libvirt will log an error. Currently the machinetype list which returns by qemuDomainMachineHasBuiltinIDE only includes 440fx, malta, sun4u and g3beige. Remove the disk and the .args file since the expectation is the test will fail in qemuxml2argvtest because floppy is not supported on pseries and thus no disk is necessary and no .args file would be created to compare against. Signed-off-by: Lin Ma Signed-off-by: John Ferlan --- .../qemuxml2argv-disk-floppy-pseries.args | 24 ------------------= ---- .../qemuxml2argv-disk-floppy-pseries.xml | 7 ------- 2 files changed, 31 deletions(-) delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-floppy-pseries= .args diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy-pseries.args b= /tests/qemuxml2argvdata/qemuxml2argv-disk-floppy-pseries.args deleted file mode 100644 index 72a418302..000000000 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy-pseries.args +++ /dev/null @@ -1,24 +0,0 @@ -LC_ALL=3DC \ -PATH=3D/bin \ -HOME=3D/home/test \ -USER=3Dtest \ -LOGNAME=3Dtest \ -QEMU_AUDIO_DRV=3Dnone \ -/usr/bin/qemu-system-ppc64 \ --name QEMUGuest1 \ --S \ --M pseries \ --m 214 \ --smp 1 \ --uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --nographic \ --monitor unix:/tmp/test-monitor,server,nowait \ --no-acpi \ --boot c \ --usb \ --drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dide,bus=3D0,unit=3D= 0 \ --drive file=3D/dev/fd0,format=3Draw,if=3Dfloppy,unit=3D0 \ --drive file=3D/tmp/firmware.img,format=3Draw,if=3Dfloppy,unit=3D1 \ --net none \ --serial none \ --parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy-pseries.xml b/= tests/qemuxml2argvdata/qemuxml2argv-disk-floppy-pseries.xml index be0ede6bd..a4191abe1 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy-pseries.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy-pseries.xml @@ -14,12 +14,6 @@ destroy /usr/bin/qemu-system-ppc64 - - - - -
- @@ -34,7 +28,6 @@ - --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 08:14:43 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 1512437960651295.6351737897837; Mon, 4 Dec 2017 17:39:20 -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 AB26A745; Tue, 5 Dec 2017 01:39:19 +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 8488218253; Tue, 5 Dec 2017 01:39:19 +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 4CE6B1800C87; Tue, 5 Dec 2017 01:39:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dETq029312 for ; Mon, 4 Dec 2017 20:39:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 58B0B17D3A; Tue, 5 Dec 2017 01:39:14 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DC0962461 for ; Tue, 5 Dec 2017 01:39:14 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:38:56 -0500 Message-Id: <20171205013907.8563-7-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/17] tests: Drop IDE controller in CCW 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.29]); Tue, 05 Dec 2017 01:39:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Lin Ma Adding an IDE controller for a machinetype that has no built-in IDE controller, libvirt will log an error. Currently the machinetype list which returns by qemuDomainMachineHasBuiltinIDE only includes 440fx, malta, sun4u and g3beige. Signed-off-by: Lin Ma Signed-off-by: John Ferlan --- tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml | 4 = ---- ...uhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit.xml | 4 = ---- ...muhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml | 4 = ---- .../qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml | 4 = ---- ...emuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml | 4 = ---- .../qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml | 4 = ---- .../qemuhotplug-base-ccw-live-with-ccw-virtio.xml | 4 = ---- tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml | 4 = ---- 8 files changed, 32 deletions(-) diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-vir= tio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio= .xml index cd03d0e09..75948f324 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml @@ -33,10 +33,6 @@
- - -
-
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-= ccw-virtio+ccw-virtio-1-explicit.xml b/tests/qemuhotplugtestdomains/qemuhot= plug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit.xml index 519d8161f..301658178 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-vir= tio+ccw-virtio-1-explicit.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-vir= tio+ccw-virtio-1-explicit.xml @@ -43,10 +43,6 @@
- - -
-
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-= ccw-virtio+ccw-virtio-1-reverse.xml b/tests/qemuhotplugtestdomains/qemuhotp= lug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml index 7be75f977..bb9d427c2 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-vir= tio+ccw-virtio-1-reverse.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-vir= tio+ccw-virtio-1-reverse.xml @@ -43,10 +43,6 @@
- - -
-
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-= ccw-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-wit= h-2-ccw-virtio.xml index a83f1b5d7..c41f5affd 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-vir= tio.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-vir= tio.xml @@ -33,10 +33,6 @@
- - -
-
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-cc= w-virtio+ccw-virtio-2-explicit.xml b/tests/qemuhotplugtestdomains/qemuhotpl= ug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml index 3e9020751..b1114dba9 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virti= o+ccw-virtio-2-explicit.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virti= o+ccw-virtio-2-explicit.xml @@ -42,10 +42,6 @@
- - -
-
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-cc= w-virtio+ccw-virtio-2.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-c= cw-live-with-ccw-virtio+ccw-virtio-2.xml index 3e9020751..b1114dba9 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virti= o+ccw-virtio-2.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virti= o+ccw-virtio-2.xml @@ -42,10 +42,6 @@
- - -
-
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-cc= w-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-= ccw-virtio.xml index 0fa8d036b..3476f61db 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virti= o.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virti= o.xml @@ -32,10 +32,6 @@
- - -
-
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml b/t= ests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml index d4434a18c..3a202d069 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml @@ -23,10 +23,6 @@
- - -
-
--=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 08:14:43 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 1512437968483992.4791174023746; Mon, 4 Dec 2017 17:39:28 -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 D3672624DF; Tue, 5 Dec 2017 01:39: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 ADA1C5DA71; Tue, 5 Dec 2017 01:39:24 +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 74A1C1802122; Tue, 5 Dec 2017 01:39:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dEVt029327 for ; Mon, 4 Dec 2017 20:39:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id BAF9B61559; Tue, 5 Dec 2017 01:39:14 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D4D162461 for ; Tue, 5 Dec 2017 01:39:14 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:38:57 -0500 Message-Id: <20171205013907.8563-8-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/17] qemu: Introduce qemuDomainDeviceDefValidateControllerIDE 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]); Tue, 05 Dec 2017 01:39:25 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Lin Ma Move the IDE controller check from command line building to controller def validation. Cause the IDE case for command line building to generate a failure if called to add an IDE since that shouldn't happen if the Validate code did the right thing. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 16 ---------------- src/qemu/qemu_domain.c | 27 ++++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 15d9209c6..8af30a8ca 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3120,22 +3120,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, break; =20 case VIR_DOMAIN_CONTROLLER_TYPE_IDE: - /* Since we currently only support the integrated IDE - * controller on various boards, if we ever get to here, it's - * because some other machinetype had an IDE controller - * specified, or one with a single IDE contraller had multiple - * ide controllers specified. - */ - if (qemuDomainHasBuiltinIDE(domainDef)) - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Only a single IDE controller is supported " - "for this machine type")); - else - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("IDE controllers are unsupported for " - "this QEMU binary or machine type")); - goto error; - case VIR_DOMAIN_CONTROLLER_TYPE_FDC: case VIR_DOMAIN_CONTROLLER_TYPE_LAST: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 1fc360af9..d2412154a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3959,10 +3959,32 @@ qemuDomainDeviceDefSkipController(const virDomainCo= ntrollerDef *controller, =20 =20 static int +qemuDomainDeviceDefValidateControllerIDE(const virDomainDef *def) +{ + /* Since we currently only support the integrated IDE + * controller on various boards, if we ever get to here, it's + * because some other machinetype had an IDE controller + * specified, or one with a single IDE controller had multiple + * IDE controllers specified. + */ + if (qemuDomainHasBuiltinIDE(def)) + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Only a single IDE controller is supported " + "for this machine type")); + else + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("IDE controllers are unsupported for " + "this QEMU binary or machine type")); + return -1; +} + + +static int qemuDomainDeviceDefValidateController(const virDomainControllerDef *contro= ller, const virDomainDef *def, virQEMUCapsPtr qemuCaps) { + int ret =3D 0; unsigned int flags =3D 0; =20 if (qemuDomainDeviceDefSkipController(controller, def, &flags)) @@ -3977,6 +3999,9 @@ qemuDomainDeviceDefValidateController(const virDomain= ControllerDef *controller, =20 switch ((virDomainControllerType) controller->type) { case VIR_DOMAIN_CONTROLLER_TYPE_IDE: + ret =3D qemuDomainDeviceDefValidateControllerIDE(def); + break; + case VIR_DOMAIN_CONTROLLER_TYPE_FDC: case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: case VIR_DOMAIN_CONTROLLER_TYPE_SATA: @@ -3988,7 +4013,7 @@ qemuDomainDeviceDefValidateController(const virDomain= ControllerDef *controller, break; } =20 - return 0; + return ret; } =20 =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 08:14:43 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 1512437963216320.8847762551371; Mon, 4 Dec 2017 17:39:23 -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 4910680481; Tue, 5 Dec 2017 01:39:22 +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 1974017106; Tue, 5 Dec 2017 01:39:22 +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 D5A9D180474F; Tue, 5 Dec 2017 01:39:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dFb0029334 for ; Mon, 4 Dec 2017 20:39:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 23CF817D2C; Tue, 5 Dec 2017 01:39:15 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDA9D61559 for ; Tue, 5 Dec 2017 01:39:14 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:38:58 -0500 Message-Id: <20171205013907.8563-9-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/17] 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 05 Dec 2017 01:39:22 +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. This includes the @model reset/check when the controller model hasn't yet been set. While at it modify the switch to account for all virDomainControllerModelSCSI types rather than using the default label. Rename/reorder the args in qemuCheckSCSIControllerIOThreads to match the caller and also remove the unnecessary model check as well as fixing up the comments to remove the previously removed qemuCaps arg. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 94 +++++----------------------------------------= -- src/qemu/qemu_domain.c | 98 +++++++++++++++++++++++++++++++++++++++++++++= +++- 2 files changed, 106 insertions(+), 86 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8af30a8ca..158f73690 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2583,52 +2583,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->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", - _("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 @@ -2662,47 +2616,17 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, =20 *devstr =3D NULL; =20 - if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { - if ((qemuDomainSetSCSIControllerModel(domainDef, qemuCaps, &model)= ) < 0) - return -1; - } - - if (!(def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI && - 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 (model) { + if ((qemuDomainSetSCSIControllerModel(domainDef, qemuCaps, &model)= ) < 0) + return -1; + switch ((virDomainControllerModelSCSI) 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"); - 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"); @@ -2711,12 +2635,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; @@ -2733,7 +2654,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)); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d2412154a..ce9904d55 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3979,6 +3979,97 @@ qemuDomainDeviceDefValidateControllerIDE(const virDo= mainDef *def) } =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, + virQEMUCapsPtr qemuCaps) +{ + int model =3D controller->model; + + if ((qemuDomainSetSCSIControllerModel(def, qemuCaps, &model)) < 0) + return -1; + + if (model !=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; + } + } + + switch ((virDomainControllerModelSCSI) 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, @@ -4002,8 +4093,12 @@ qemuDomainDeviceDefValidateController(const virDomai= nControllerDef *controller, ret =3D qemuDomainDeviceDefValidateControllerIDE(def); break; =20 - case VIR_DOMAIN_CONTROLLER_TYPE_FDC: case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: + ret =3D qemuDomainDeviceDefValidateControllerSCSI(controller, def, + qemuCaps); + 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: @@ -4090,6 +4185,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef = *dev, break; } =20 + virObjectUnref(qemuCaps); return ret; } =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 08:14:43 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 1512437965701509.38040758425575; Mon, 4 Dec 2017 17:39: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 DC319624CB; Tue, 5 Dec 2017 01:39:22 +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 B9F26189D6; Tue, 5 Dec 2017 01:39:22 +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 803831804751; Tue, 5 Dec 2017 01:39:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dF2n029339 for ; Mon, 4 Dec 2017 20:39:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8351D17D2C; Tue, 5 Dec 2017 01:39:15 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47AA261559 for ; Tue, 5 Dec 2017 01:39:15 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:38:59 -0500 Message-Id: <20171205013907.8563-10-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/17] 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 05 Dec 2017 01:39:23 +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 check in qemuBuildControllerDevCommandLine to skip the pcie-root and pci-root tests for not pseries guests. Next we'll move the controller index check switch. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 20 -------------------- src/qemu/qemu_domain.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 158f73690..0089f1bf6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2719,26 +2719,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 ce9904d55..c49a11119 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4071,6 +4071,37 @@ qemuDomainDeviceDefValidateControllerSCSI(const virD= omainControllerDef *controll =20 =20 static int +qemuDomainDeviceDefValidateControllerPCI(const virDomainControllerDef *con= troller) +{ + virDomainControllerModelPCI model =3D controller->model; + + 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) @@ -4098,12 +4129,15 @@ qemuDomainDeviceDefValidateController(const virDoma= inControllerDef *controller, qemuCaps); break; =20 + case VIR_DOMAIN_CONTROLLER_TYPE_PCI: + ret =3D qemuDomainDeviceDefValidateControllerPCI(controller); + 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 Tue Apr 30 08:14:43 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 1512437966100562.9960777809226; Mon, 4 Dec 2017 17:39:26 -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 EBED612B20; Tue, 5 Dec 2017 01:39: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 C54AB62465; Tue, 5 Dec 2017 01:39:24 +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 8C2AC3D380; Tue, 5 Dec 2017 01:39:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dGPF029347 for ; Mon, 4 Dec 2017 20:39:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id F38AE61559; Tue, 5 Dec 2017 01:39:15 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id A740A62464 for ; Tue, 5 Dec 2017 01:39:15 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:39:00 -0500 Message-Id: <20171205013907.8563-11-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/17] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 05 Dec 2017 01:39:25 +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 | 115 +++++++++++++++++++++++++-------------------= ---- 1 file changed, 59 insertions(+), 56 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0089f1bf6..94bf21803 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2612,6 +2612,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, { virBuffer buf =3D VIR_BUFFER_INITIALIZER; int model =3D def->model; + const virDomainPCIControllerOpts *pciopts; const char *modelName =3D NULL; =20 *devstr =3D NULL; @@ -2717,24 +2718,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' " @@ -2749,26 +2752,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' " @@ -2783,28 +2786,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' " @@ -2821,22 +2824,22 @@ 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) { 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' " @@ -2844,7 +2847,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", @@ -2852,7 +2855,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", @@ -2862,24 +2865,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' " @@ -2897,24 +2900,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' " @@ -2930,26 +2933,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' " @@ -2964,32 +2967,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); @@ -3002,17 +3005,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 Tue Apr 30 08:14:43 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 1512437967015659.6176242833186; Mon, 4 Dec 2017 17:39:27 -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 8F9382CE92F; Tue, 5 Dec 2017 01:39:25 +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 6A99517D2E; Tue, 5 Dec 2017 01:39:25 +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 35E843D386; Tue, 5 Dec 2017 01:39:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dGhh029362 for ; Mon, 4 Dec 2017 20:39:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5C0E517D2C; Tue, 5 Dec 2017 01:39:16 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 225BB61559 for ; Tue, 5 Dec 2017 01:39:16 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:39:01 -0500 Message-Id: <20171205013907.8563-12-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/17] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 05 Dec 2017 01:39:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move the various modelName =3D=3D NAME_NONE from the command line generation into domain controller validation. Also rather than have multiple cases with the same check, let's make the code more generic, but also note that it was the modelName option that caused the failure. We also have to be sure not to check the PCI models that we don't care about. For the remaining checks in command line building, we can use the field name in the error message to be more specific about what causes the failure. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 52 ++++++++++++---------------------------------= ---- src/qemu/qemu_domain.c | 12 ++++++++++++ 2 files changed, 24 insertions(+), 40 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 94bf21803..9f8a1bc33 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2722,11 +2722,9 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, =20 switch ((virDomainControllerModelPCI) def->model) { case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: - if (pciopts->modelName - =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE || - pciopts->chassisNr =3D=3D -1) { + if (pciopts->chassisNr =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pci-bridge options not set= ")); + _("autogenerated pci-bridge option chassisN= r not set")); goto error; } =20 @@ -2756,12 +2754,9 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, def->info.alias); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: - if (pciopts->modelName - =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE || - pciopts->busNr =3D=3D -1) { + if (pciopts->busNr =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pci-expander-bus options n= ot set")); - goto error; + _("autogenerated pci-expander-bus option bu= sNr not set")); } =20 modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); @@ -2793,13 +2788,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, pciopts->numaNode); break; case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: - if (pciopts->modelName - =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated dmi-to-pci-bridge options = not set")); - goto error; - } - modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); if (!modelName) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2824,12 +2812,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, virBufferAsprintf(&buf, "%s,id=3D%s", modelName, def->info.ali= as); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: - if (pciopts->modelName - =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pcie-root-port options not= set")); - goto error; - } modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); if (!modelName) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2869,12 +2851,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, pciopts->chassis, def->info.alias); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: - if (pciopts->modelName - =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pcie-switch-upstream-port = options not set")); - goto error; - } modelName =3D virDomainControllerPCIModelNameTypeToString(pcio= pts->modelName); if (!modelName) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2900,13 +2876,12 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, virBufferAsprintf(&buf, "%s,id=3D%s", modelName, def->info.ali= as); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: - if (pciopts->modelName - =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE || - pciopts->chassis =3D=3D -1 || + if (pciopts->chassis =3D=3D -1 || pciopts->port =3D=3D -1) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INTERNAL_ERROR, _("autogenerated pcie-switch-downstream-por= t " - "options not set")); + "options chassis=3D%d or port=3D%d not se= t"), + pciopts->chassis, pciopts->port); goto error; } =20 @@ -2937,11 +2912,9 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, pciopts->chassis, def->info.alias); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: - if (pciopts->modelName - =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE || - pciopts->busNr =3D=3D -1) { + if (pciopts->busNr =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pcie-expander-bus options = not set")); + _("autogenerated pcie-expander-bus option b= usNr not set")); goto error; } =20 @@ -2974,10 +2947,9 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, pciopts->numaNode); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: - if (pciopts->modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_= NAME_NONE || - pciopts->targetIndex =3D=3D -1) { + if (pciopts->targetIndex =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("autogenerated pci-root options not set")= ); + _("autogenerated pci-root option targetInde= x not set")); goto error; } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c49a11119..eb7941f10 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4074,6 +4074,7 @@ static int qemuDomainDeviceDefValidateControllerPCI(const virDomainControllerDef *con= troller) { virDomainControllerModelPCI model =3D controller->model; + const virDomainPCIControllerOpts *pciopts; =20 switch (model) { case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: @@ -4097,6 +4098,17 @@ qemuDomainDeviceDefValidateControllerPCI(const virDo= mainControllerDef *controlle break; } =20 + pciopts =3D &controller->opts.pciopts; + if (controller->model !=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT && + controller->model !=3D VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST) { + if (pciopts->modelName =3D=3D VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME= _NONE) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("autogenerated %s option modelName not set"), + virDomainControllerModelPCITypeToString(control= ler->model)); + return -1; + } + } + return 0; } =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 08:14:43 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 1512437971480304.3395118028251; Mon, 4 Dec 2017 17:39:31 -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 A89E861B8F; Tue, 5 Dec 2017 01:39: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 811194D7; Tue, 5 Dec 2017 01:39: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 36C6C3D389; Tue, 5 Dec 2017 01:39:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dG4c029369 for ; Mon, 4 Dec 2017 20:39:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id BA13C61559; Tue, 5 Dec 2017 01:39:16 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8001362461 for ; Tue, 5 Dec 2017 01:39:16 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:39:02 -0500 Message-Id: <20171205013907.8563-13-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/17] 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.39]); Tue, 05 Dec 2017 01:39:28 +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 9f8a1bc33..7a9b68604 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2719,6 +2719,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: @@ -2728,13 +2731,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, @@ -2759,13 +2755,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, _("autogenerated pci-expander-bus option bu= sNr not set")); } =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, @@ -2788,13 +2777,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, virBufferAsprintf(&buf, "%s,id=3D%s", modelName, def->info.ali= as); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: - 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, @@ -2885,13 +2853,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, @@ -2918,13 +2879,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, @@ -2957,13 +2911,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 eb7941f10..65487880e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4075,6 +4075,7 @@ qemuDomainDeviceDefValidateControllerPCI(const virDom= ainControllerDef *controlle { virDomainControllerModelPCI model =3D controller->model; const virDomainPCIControllerOpts *pciopts; + const char *modelName =3D NULL; =20 switch (model) { case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: @@ -4107,6 +4108,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 Tue Apr 30 08:14:43 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 1512437969296893.0227131873144; Mon, 4 Dec 2017 17:39:29 -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 13C2E60153; Tue, 5 Dec 2017 01:39:28 +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 E0F541825B; Tue, 5 Dec 2017 01:39: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 AD0A83D38C; Tue, 5 Dec 2017 01:39:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dHjN029374 for ; Mon, 4 Dec 2017 20:39:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 25E7317D2C; Tue, 5 Dec 2017 01:39:17 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE1F661559 for ; Tue, 5 Dec 2017 01:39:16 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:39:03 -0500 Message-Id: <20171205013907.8563-14-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 13/17] 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.25]); Tue, 05 Dec 2017 01:39:28 +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 | 96 ---------------------------------- src/qemu/qemu_domain.c | 134 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 134 insertions(+), 96 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7a9b68604..e722bb46b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2725,20 +2725,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 option chassisN= r 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 " @@ -2750,19 +2736,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 option bu= sNr not set")); - } - - 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 " @@ -2777,14 +2750,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)= " @@ -2794,16 +2759,6 @@ qemuBuildControllerDevStr(const virDomainDef *domain= Def, virBufferAsprintf(&buf, "%s,id=3D%s", modelName, def->info.ali= as); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: - if ((pciopts->modelName !=3D - 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 +2781,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,23 +2791,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, - _("autogenerated pcie-switch-downstream-por= t " - "options chassis=3D%d or port=3D%d not se= t"), - pciopts->chassis, pciopts->port); - 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 " @@ -2873,20 +2803,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 option b= usNr 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 " @@ -2901,22 +2817,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 option targetInde= x 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 65487880e..86e6d5573 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4077,6 +4077,8 @@ qemuDomainDeviceDefValidateControllerPCI(const virDom= ainControllerDef *controlle const virDomainPCIControllerOpts *pciopts; const char *modelName =3D NULL; =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: @@ -4119,6 +4121,138 @@ 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 option chassisNr no= t 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 option busNr = not set")); + 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->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, + _("autogenerated pcie-switch-downstream-port " + "options chassis=3D%d or port=3D%d not set"), + pciopts->chassis, pciopts->port); + 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 option busNr= 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 option targetIndex no= t 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 Tue Apr 30 08:14:43 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 1512437972332326.45212259415257; Mon, 4 Dec 2017 17:39:32 -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 9B38CC05FFCD; Tue, 5 Dec 2017 01:39:30 +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 7136A17998; Tue, 5 Dec 2017 01:39: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 394131802126; Tue, 5 Dec 2017 01:39:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dH3i029379 for ; Mon, 4 Dec 2017 20:39:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 830E261559; Tue, 5 Dec 2017 01:39:17 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4757962461 for ; Tue, 5 Dec 2017 01:39:17 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:39:04 -0500 Message-Id: <20171205013907.8563-15-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/17] 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 05 Dec 2017 01:39:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move the qemuCaps checks over to qemuDomainControllerDefValidatePCI and add empty lines between cases so it's a bit easier on the eyes to read. 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 | 78 ++++++---------------------------------------= --- src/qemu/qemu_domain.c | 79 +++++++++++++++++++++++++++++++++++++++++++++= ++-- tests/qemumemlocktest.c | 14 +++++++++ tests/qemuxml2xmltest.c | 5 +++- 4 files changed, 104 insertions(+), 72 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e722bb46b..837339d23 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2725,23 +2725,12 @@ 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); @@ -2749,66 +2738,28 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, virBufferAsprintf(&buf, ",numa_node=3D%d", 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; - } =20 + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: 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; - } =20 + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: 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); @@ -2816,31 +2767,20 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, virBufferAsprintf(&buf, ",numa_node=3D%d", pciopts->numaNode); break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: /* Skip the implicit one */ 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: virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 86e6d5573..0aed767d2 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4071,7 +4071,8 @@ qemuDomainDeviceDefValidateControllerSCSI(const virDo= mainControllerDef *controll =20 =20 static int -qemuDomainDeviceDefValidateControllerPCI(const virDomainControllerDef *con= troller) +qemuDomainDeviceDefValidateControllerPCI(const virDomainControllerDef *con= troller, + virQEMUCapsPtr qemuCaps) { virDomainControllerModelPCI model =3D controller->model; const virDomainPCIControllerOpts *pciopts; @@ -4138,6 +4139,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: @@ -4155,6 +4163,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: @@ -4166,6 +4181,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: @@ -4178,6 +4200,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: @@ -4189,6 +4227,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: @@ -4208,6 +4253,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: @@ -4225,6 +4278,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: @@ -4246,6 +4306,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: @@ -4286,7 +4361,7 @@ qemuDomainDeviceDefValidateController(const virDomain= ControllerDef *controller, break; =20 case VIR_DOMAIN_CONTROLLER_TYPE_PCI: - ret =3D qemuDomainDeviceDefValidateControllerPCI(controller); + ret =3D qemuDomainDeviceDefValidateControllerPCI(controller, qemuC= aps); 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 146a67ee2..790d976f4 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1310,7 +1310,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 Tue Apr 30 08:14:43 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 1512437971463899.745532260195; Mon, 4 Dec 2017 17:39:31 -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 795F260177; Tue, 5 Dec 2017 01:39:30 +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 F07D44DD; Tue, 5 Dec 2017 01:39:29 +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 BA0921802124; Tue, 5 Dec 2017 01:39:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dHFn029385 for ; Mon, 4 Dec 2017 20:39:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id DFF7917D3A; Tue, 5 Dec 2017 01:39:17 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4B3861559 for ; Tue, 5 Dec 2017 01:39:17 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:39:05 -0500 Message-Id: <20171205013907.8563-16-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 15/17] 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 05 Dec 2017 01:39:30 +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. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 6 ------ src/qemu/qemu_domain.c | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 837339d23..56030c482 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2699,12 +2699,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 0aed767d2..2e82df4ff 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4333,6 +4333,18 @@ qemuDomainDeviceDefValidateControllerPCI(const virDo= mainControllerDef *controlle =20 =20 static int +qemuDomainDeviceDefValidateControllerSATA(virQEMUCapsPtr qemuCaps) +{ + 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) @@ -4364,8 +4376,11 @@ qemuDomainDeviceDefValidateController(const virDomai= nControllerDef *controller, ret =3D qemuDomainDeviceDefValidateControllerPCI(controller, qemuC= aps); break; =20 - case VIR_DOMAIN_CONTROLLER_TYPE_FDC: case VIR_DOMAIN_CONTROLLER_TYPE_SATA: + ret =3D qemuDomainDeviceDefValidateControllerSATA(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 Tue Apr 30 08:14:43 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 151243797453119.108110362662273; Mon, 4 Dec 2017 17:39:34 -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 9EFF65FD40; Tue, 5 Dec 2017 01:39:33 +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 6B51D61984; Tue, 5 Dec 2017 01:39:33 +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 325FC3D38D; Tue, 5 Dec 2017 01:39:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dJsC029418 for ; Mon, 4 Dec 2017 20:39:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id C0A8117D2C; Tue, 5 Dec 2017 01:39:19 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8696F6266C for ; Tue, 5 Dec 2017 01:39:17 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:39:06 -0500 Message-Id: <20171205013907.8563-17-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 16/17] qemu: Introduce qemuDomainDeviceDefValidateControllerUSB 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.25]); Tue, 05 Dec 2017 01:39:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move the USB controller validation checs out of qemu_command and into the proper qemu_domain validation helper. We will start slowly and also modity the xml2argv test to change from a RUN to PARSE failure check when the QEMU_CAPS_PIIX3_USB_UHCI is removed. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 6 ------ src/qemu/qemu_domain.c | 18 +++++++++++++++++- tests/qemuxml2argvtest.c | 8 ++++---- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 56030c482..7ea01e008 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2542,12 +2542,6 @@ qemuBuildUSBControllerDevStr(virDomainControllerDefP= tr def, =20 model =3D def->model; =20 - if (model =3D=3D -1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("no model provided for USB controller")); - return -1; - } - smodel =3D qemuControllerModelUSBTypeToString(model); flags =3D qemuControllerModelUSBToCaps(model); =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2e82df4ff..3ab3aa181 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4345,6 +4345,19 @@ qemuDomainDeviceDefValidateControllerSATA(virQEMUCap= sPtr qemuCaps) =20 =20 static int +qemuDomainDeviceDefValidateControllerUSB(const virDomainControllerDef *con= troller) +{ + if (controller->model =3D=3D -1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("no model provided for USB controller")); + return -1; + } + + return 0; +} + + +static int qemuDomainDeviceDefValidateController(const virDomainControllerDef *contro= ller, const virDomainDef *def, virQEMUCapsPtr qemuCaps) @@ -4380,10 +4393,13 @@ qemuDomainDeviceDefValidateController(const virDoma= inControllerDef *controller, ret =3D qemuDomainDeviceDefValidateControllerSATA(qemuCaps); break; =20 + case VIR_DOMAIN_CONTROLLER_TYPE_USB: + ret =3D qemuDomainDeviceDefValidateControllerUSB(controller); + 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: case VIR_DOMAIN_CONTROLLER_TYPE_LAST: break; } diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 385a54615..3fcc76baa 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1508,10 +1508,10 @@ mymain(void) QEMU_CAPS_PCI_OHCI, QEMU_CAPS_PIIX3_USB_UHCI, QEMU_CAPS_NEC_USB_XHCI); - DO_TEST_FAILURE("usb-controller-default-unavailable-q35", - QEMU_CAPS_DEVICE_IOH3420, - QEMU_CAPS_PCI_OHCI, - QEMU_CAPS_NEC_USB_XHCI); + DO_TEST_PARSE_ERROR("usb-controller-default-unavailable-q35", + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_PCI_OHCI, + QEMU_CAPS_NEC_USB_XHCI); DO_TEST("usb-controller-explicit-q35", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_PCI_OHCI, --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 08:14:43 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 1512437977122999.4781571201295; Mon, 4 Dec 2017 17:39:37 -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 2FF9178EC1; Tue, 5 Dec 2017 01:39:36 +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 099424D8; Tue, 5 Dec 2017 01:39:36 +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 C4E01180212A; Tue, 5 Dec 2017 01:39:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB51dLKD029435 for ; Mon, 4 Dec 2017 20:39:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id B80B017D41; Tue, 5 Dec 2017 01:39:21 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A8E562464 for ; Tue, 5 Dec 2017 01:39:19 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 4 Dec 2017 20:39:07 -0500 Message-Id: <20171205013907.8563-18-jferlan@redhat.com> In-Reply-To: <20171205013907.8563-1-jferlan@redhat.com> References: <20171205013907.8563-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 17/17] qemu: Complete move USB 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 05 Dec 2017 01:39:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move the remainder of the qemuBuildUSBControllerDevStr checks over to qemuDomainDeviceDefValidateControllerUSB. This also allows the command code to shorten up a bit and become a void procedure. This also requires modifying the xml2xml test a bit in order to include the correct capability bit and modifying the xml2argv test in order to use the PARSE_ERROR macro. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 64 +++-----------------------------------------= ---- src/qemu/qemu_command.h | 2 ++ src/qemu/qemu_domain.c | 55 +++++++++++++++++++++++++++++++++++++++-- tests/qemuxml2argvtest.c | 10 ++++---- tests/qemuxml2xmltest.c | 17 ++++++++----- 5 files changed, 74 insertions(+), 74 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7ea01e008..0d4355abc 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -142,8 +142,6 @@ VIR_ENUM_IMPL(qemuSoundCodec, VIR_DOMAIN_SOUND_CODEC_TY= PE_LAST, "hda-duplex", "hda-micro"); =20 -VIR_ENUM_DECL(qemuControllerModelUSB) - VIR_ENUM_IMPL(qemuControllerModelUSB, VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST, "piix3-usb-uhci", "piix4-usb-uhci", @@ -2503,66 +2501,13 @@ qemuBuildFSDevCommandLine(virCommandPtr cmd, } =20 =20 -static int -qemuControllerModelUSBToCaps(int model) -{ - switch (model) { - case VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI: - return QEMU_CAPS_PIIX3_USB_UHCI; - case VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX4_UHCI: - return QEMU_CAPS_PIIX4_USB_UHCI; - case VIR_DOMAIN_CONTROLLER_MODEL_USB_EHCI: - return QEMU_CAPS_USB_EHCI; - case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_EHCI1: - case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI1: - case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI2: - case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI3: - return QEMU_CAPS_ICH9_USB_EHCI1; - case VIR_DOMAIN_CONTROLLER_MODEL_USB_VT82C686B_UHCI: - return QEMU_CAPS_VT82C686B_USB_UHCI; - case VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI: - return QEMU_CAPS_PCI_OHCI; - case VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI: - return QEMU_CAPS_NEC_USB_XHCI; - case VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI: - return QEMU_CAPS_DEVICE_QEMU_XHCI; - default: - return -1; - } -} - - -static int +static void qemuBuildUSBControllerDevStr(virDomainControllerDefPtr def, - virQEMUCapsPtr qemuCaps, virBuffer *buf) { - const char *smodel; - int model, flags; - - model =3D def->model; - - smodel =3D qemuControllerModelUSBTypeToString(model); - flags =3D qemuControllerModelUSBToCaps(model); - - if (flags =3D=3D -1 || !virQEMUCapsGet(qemuCaps, flags)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("%s not supported in this QEMU binary"), smodel); - return -1; - } - - virBufferAsprintf(buf, "%s", smodel); + virBufferAsprintf(buf, "%s", qemuControllerModelUSBTypeToString(def->m= odel)); =20 if (def->opts.usbopts.ports !=3D -1) { - if ((model !=3D VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI || - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI_PORTS)) && - model !=3D VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("usb controller type %s doesn't support 'port= s' " - "with this QEMU binary"), smodel); - return -1; - } - virBufferAsprintf(buf, ",p2=3D%d,p3=3D%d", def->opts.usbopts.ports, def->opts.usbopts.ports= ); } @@ -2572,8 +2517,6 @@ qemuBuildUSBControllerDevStr(virDomainControllerDefPt= r def, def->info.alias, def->info.master.usb.startport); else virBufferAsprintf(buf, ",id=3D%s", def->info.alias); - - return 0; } =20 =20 @@ -2697,8 +2640,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, break; =20 case VIR_DOMAIN_CONTROLLER_TYPE_USB: - if (qemuBuildUSBControllerDevStr(def, qemuCaps, &buf) =3D=3D -1) - goto error; + qemuBuildUSBControllerDevStr(def, &buf); =20 if (nusbcontroller) *nusbcontroller +=3D 1; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index bdde6f918..3551b8cfb 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -43,6 +43,8 @@ =20 VIR_ENUM_DECL(qemuVideo) =20 +VIR_ENUM_DECL(qemuControllerModelUSB) + virCommandPtr qemuBuildCommandLine(virQEMUDriverPtr driver, virLogManagerPtr logManager, virDomainObjPtr vm, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3ab3aa181..118216d84 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4344,15 +4344,66 @@ qemuDomainDeviceDefValidateControllerSATA(virQEMUCa= psPtr qemuCaps) } =20 =20 +static unsigned int +qemuDomainControllerModelUSBToCaps(int model) +{ + switch (model) { + case VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI: + return QEMU_CAPS_PIIX3_USB_UHCI; + case VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX4_UHCI: + return QEMU_CAPS_PIIX4_USB_UHCI; + case VIR_DOMAIN_CONTROLLER_MODEL_USB_EHCI: + return QEMU_CAPS_USB_EHCI; + case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_EHCI1: + case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI1: + case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI2: + case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI3: + return QEMU_CAPS_ICH9_USB_EHCI1; + case VIR_DOMAIN_CONTROLLER_MODEL_USB_VT82C686B_UHCI: + return QEMU_CAPS_VT82C686B_USB_UHCI; + case VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI: + return QEMU_CAPS_PCI_OHCI; + case VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI: + return QEMU_CAPS_NEC_USB_XHCI; + case VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI: + return QEMU_CAPS_DEVICE_QEMU_XHCI; + default: + return -1; + } +} + + static int -qemuDomainDeviceDefValidateControllerUSB(const virDomainControllerDef *con= troller) +qemuDomainDeviceDefValidateControllerUSB(const virDomainControllerDef *con= troller, + virQEMUCapsPtr qemuCaps) { + unsigned int flags; + if (controller->model =3D=3D -1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("no model provided for USB controller")); return -1; } =20 + flags =3D qemuDomainControllerModelUSBToCaps(controller->model); + if (flags =3D=3D -1 || !virQEMUCapsGet(qemuCaps, flags)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("%s not supported in this QEMU binary"), + qemuControllerModelUSBTypeToString(controller->mode= l)); + return -1; + } + + if (controller->opts.usbopts.ports !=3D -1 && + (controller->model !=3D VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI || + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI_PORTS)) && + controller->model !=3D VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("usb controller type %s doesn't support 'ports' " + "with this QEMU binary"), + qemuControllerModelUSBTypeToString(controller->mode= l)); + return -1; + } + return 0; } =20 @@ -4394,7 +4445,7 @@ qemuDomainDeviceDefValidateController(const virDomain= ControllerDef *controller, break; =20 case VIR_DOMAIN_CONTROLLER_TYPE_USB: - ret =3D qemuDomainDeviceDefValidateControllerUSB(controller); + ret =3D qemuDomainDeviceDefValidateControllerUSB(controller, qemuC= aps); break; =20 case VIR_DOMAIN_CONTROLLER_TYPE_FDC: diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3fcc76baa..439d570d8 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1517,10 +1517,10 @@ mymain(void) QEMU_CAPS_PCI_OHCI, QEMU_CAPS_PIIX3_USB_UHCI, QEMU_CAPS_NEC_USB_XHCI); - DO_TEST_FAILURE("usb-controller-explicit-unavailable-q35", - QEMU_CAPS_DEVICE_IOH3420, - QEMU_CAPS_PCI_OHCI, - QEMU_CAPS_PIIX3_USB_UHCI); + DO_TEST_PARSE_ERROR("usb-controller-explicit-unavailable-q35", + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_PCI_OHCI, + QEMU_CAPS_PIIX3_USB_UHCI); DO_TEST("usb-controller-xhci", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PIIX3_USB_UHCI, @@ -1538,7 +1538,7 @@ mymain(void) QEMU_CAPS_NEC_USB_XHCI, QEMU_CAPS_NEC_USB_XHCI_PORTS); DO_TEST("usb-controller-qemu-xhci", QEMU_CAPS_DEVICE_QEMU_XHCI); - DO_TEST_FAILURE("usb-controller-qemu-xhci-unavailable", NONE); + DO_TEST_PARSE_ERROR("usb-controller-qemu-xhci-unavailable", NONE); DO_TEST_PARSE_ERROR("usb-controller-qemu-xhci-limit", QEMU_CAPS_DEVICE_QEMU_XHCI); =20 diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 790d976f4..d4f599a99 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -678,15 +678,18 @@ mymain(void) DO_TEST("ppc64-usb-controller-legacy", QEMU_CAPS_PIIX3_USB_UHCI); DO_TEST("usb-port-missing", NONE); - DO_TEST("usb-redir", NONE); - DO_TEST("usb-redir-filter", NONE); + DO_TEST("usb-redir", + QEMU_CAPS_ICH9_USB_EHCI1); + DO_TEST("usb-redir-filter", + QEMU_CAPS_ICH9_USB_EHCI1); DO_TEST("usb-redir-filter-version", NONE); DO_TEST("blkdeviotune", NONE); DO_TEST("blkdeviotune-max", NONE); DO_TEST("blkdeviotune-group-num", NONE); DO_TEST("blkdeviotune-max-length", NONE); - DO_TEST("controller-usb-order", NONE); - + DO_TEST("controller-usb-order", + QEMU_CAPS_NEC_USB_XHCI, + QEMU_CAPS_ICH9_USB_EHCI1); DO_TEST_FULL("seclabel-dynamic-baselabel", WHEN_INACTIVE, GIC_NONE, NO= NE); DO_TEST_FULL("seclabel-dynamic-override", WHEN_INACTIVE, GIC_NONE, NON= E); DO_TEST_FULL("seclabel-dynamic-labelskip", WHEN_INACTIVE, GIC_NONE, NO= NE); @@ -829,7 +832,8 @@ mymain(void) DO_TEST("numad-auto-vcpu-no-numatune", NONE); DO_TEST("numad-auto-memory-vcpu-no-cpuset-and-placement", NONE); DO_TEST("numad-auto-memory-vcpu-cpuset", NONE); - DO_TEST("usb-ich9-ehci-addr", NONE); + DO_TEST("usb-ich9-ehci-addr", + QEMU_CAPS_ICH9_USB_EHCI1); DO_TEST("disk-copy_on_read", NONE); DO_TEST("tpm-passthrough", NONE); =20 @@ -1313,7 +1317,8 @@ mymain(void) DO_TEST("intel-iommu-caching-mode", QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, - QEMU_CAPS_DEVICE_IOH3420); + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_ICH9_USB_EHCI1); 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