From nobody Mon Apr 29 10:18:21 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 1517353520391413.10257842447686; Tue, 30 Jan 2018 15:05:20 -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 C36E128224; Tue, 30 Jan 2018 23:05:18 +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 83ED45C20B; Tue, 30 Jan 2018 23:05:18 +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 48AF05FBD8; Tue, 30 Jan 2018 23:05:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0UN5DoV006195 for ; Tue, 30 Jan 2018 18:05:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 582405E1B6; Tue, 30 Jan 2018 23:05:13 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF6505C20B for ; Tue, 30 Jan 2018 23:05:12 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 30 Jan 2018 18:04:55 -0500 Message-Id: <20180130230503.3820-2-jferlan@redhat.com> In-Reply-To: <20180130230503.3820-1-jferlan@redhat.com> References: <20180130230503.3820-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/9] qemu: Split qemuDomainSetSCSIControllerModel X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 30 Jan 2018 23:05:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than one function serving two purposes, let's split out the else condition which is checking whether the model can be used during command line building based on the capabilities. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 65 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_domain_address.c | 76 ++++++++++++--------------------------= ---- 2 files changed, 87 insertions(+), 54 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 96bd0ad8e..c66307ee0 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1888,6 +1888,68 @@ qemuCheckIOThreads(const virDomainDef *def, } =20 =20 +/** + * @qemuCaps: QEMU capabilities + * @model: SCSI model to check + * + * Using the @qemuCaps, let's ensure the provided @model can be supported + * + * Returns true if acceptible, false otherwise with error message set. + */ +static bool +qemuBuildCheckSCSIControllerModel(virQEMUCapsPtr qemuCaps, + int model) +{ + switch ((virDomainControllerModelSCSI) model) { + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("This QEMU doesn't support " + "the LSI 53C895A SCSI controller")); + return false; + } + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("This QEMU doesn't support " + "virtio scsi controller")); + return false; + } + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI: + /*TODO: need checking work here if necessary */ + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_MPTSAS1068)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("This QEMU doesn't support " + "the LSI SAS1068 (MPT Fusion) controller")); + return false; + } + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_MEGASAS)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("This QEMU doesn't support " + "the LSI SAS1078 (MegaRAID) controller")); + return false; + } + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unsupported controller model: %s"), + virDomainControllerModelSCSITypeToString(model)); + return false; + } + + return true; +} + + char * qemuBuildDriveDevStr(const virDomainDef *def, virDomainDiskDefPtr disk, @@ -2665,6 +2727,9 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { if ((qemuDomainSetSCSIControllerModel(domainDef, qemuCaps, &model)= ) < 0) return -1; + + if (!qemuBuildCheckSCSIControllerModel(qemuCaps, model)) + return -1; } =20 if (!(def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI && diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 600de85f8..86fe7ad11 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -40,66 +40,34 @@ VIR_LOG_INIT("qemu.qemu_domain_address"); #define VIO_ADDR_NVRAM 0x3000ul =20 =20 +/** + * @def: Domain definition + * @qemuCaps: qemu capabilities + * @model: model to either return or adjust + * + * If the @model is already defined, return it immediately; otherwise, + * based on the @qemuCaps set the @model value to the default value. + * + * Returns @model on success, -1 on failure with error set. + */ int qemuDomainSetSCSIControllerModel(const virDomainDef *def, virQEMUCapsPtr qemuCaps, int *model) { - if (*model > 0) { - switch (*model) { - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("This QEMU doesn't support " - "the LSI 53C895A SCSI controller")); - return -1; - } - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("This QEMU doesn't support " - "virtio scsi controller")); - return -1; - } - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI: - /*TODO: need checking work here if necessary */ - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_MPTSAS1068)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("This QEMU doesn't support " - "the LSI SAS1068 (MPT Fusion) controller"= )); - return -1; - } - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_MEGASAS)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("This QEMU doesn't support " - "the LSI SAS1078 (MegaRAID) controller")); - return -1; - } - break; - default: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unsupported controller model: %s"), - virDomainControllerModelSCSITypeToString(*model= )); - return -1; - } + if (*model > 0) + return 0; + + if (qemuDomainIsPSeries(def)) { + *model =3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI; + } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI)) { + *model =3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC; + } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI)) { + *model =3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI; } else { - if (qemuDomainIsPSeries(def)) { - *model =3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI; - } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI)) { - *model =3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC; - } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI)) { - *model =3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI; - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to determine model for scsi controlle= r")); - return -1; - } + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to determine model for scsi controller")); + return -1; } =20 return 0; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:18:21 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 1517353520225487.879121996982; Tue, 30 Jan 2018 15:05: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 B5DE1776D9; Tue, 30 Jan 2018 23:05:18 +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 3DAB05D755; Tue, 30 Jan 2018 23:05:18 +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 46D0118033D8; Tue, 30 Jan 2018 23:05:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0UN5Ekt006203 for ; Tue, 30 Jan 2018 18:05:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 653135C25E; Tue, 30 Jan 2018 23:05:14 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22CFD5C20B for ; Tue, 30 Jan 2018 23:05:13 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 30 Jan 2018 18:04:56 -0500 Message-Id: <20180130230503.3820-3-jferlan@redhat.com> In-Reply-To: <20180130230503.3820-1-jferlan@redhat.com> References: <20180130230503.3820-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/9] conf: Rework and rename virDomainDeviceFindControllerModel 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.27]); Tue, 30 Jan 2018 23:05:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" As it turns out virDomainDeviceFindControllerModel was only ever called for SCSI controllers using VIR_DOMAIN_CONTROLLER_TYPE_SCSI as a parameter. So rename to virDomainDeviceFindSCSIController and rather than return a model, let's return a virDomainControllerDefPtr to let the caller reference whatever it wants. Signed-off-by: John Ferlan --- src/conf/domain_conf.c | 24 +++++++++++------------- src/conf/domain_conf.h | 6 +++--- src/libvirt_private.syms | 2 +- src/qemu/qemu_alias.c | 8 +++++--- src/qemu/qemu_command.c | 13 ++++++++----- src/vbox/vbox_common.c | 8 ++++---- 6 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9c9e3334f..b39667952 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7821,21 +7821,20 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node ATT= RIBUTE_UNUSED, return ret; } =20 -int -virDomainDeviceFindControllerModel(const virDomainDef *def, - virDomainDeviceInfoPtr info, - int controllerType) + +virDomainControllerDefPtr +virDomainDeviceFindSCSIController(const virDomainDef *def, + virDomainDeviceInfoPtr info) { - int model =3D -1; size_t i; =20 for (i =3D 0; i < def->ncontrollers; i++) { - if (def->controllers[i]->type =3D=3D controllerType && + if (def->controllers[i]->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SC= SI && def->controllers[i]->idx =3D=3D info->addr.drive.controller) - model =3D def->controllers[i]->model; + return def->controllers[i]; } =20 - return model; + return NULL; } =20 virDomainDiskDefPtr @@ -17804,17 +17803,16 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDoma= inDefPtr def) hostdev =3D def->hostdevs[i]; if (virHostdevIsSCSIDevice(hostdev) && (int)hostdev->info->addr.drive.controller > maxController) { - int model =3D -1; + virDomainControllerDefPtr cont; =20 maxController =3D hostdev->info->addr.drive.controller; /* We may be creating a new controller because this one is ful= l. * So let's grab the model from it and update the model we're * going to add as long as this one isn't undefined. The premi= se * being keeping the same controller model for all SCSI hostde= vs. */ - model =3D virDomainDeviceFindControllerModel(def, hostdev->inf= o, - VIR_DOMAIN_CONTROLL= ER_TYPE_SCSI); - if (model !=3D -1) - newModel =3D model; + cont =3D virDomainDeviceFindSCSIController(def, hostdev->info); + if (cont && cont->model !=3D -1) + newModel =3D cont->model; } } =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ed8526092..21e004515 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2759,9 +2759,9 @@ int virDomainDiskSetDriver(virDomainDiskDefPtr def, c= onst char *name) ATTRIBUTE_RETURN_CHECK; int virDomainDiskGetFormat(virDomainDiskDefPtr def); void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format); -int virDomainDeviceFindControllerModel(const virDomainDef *def, - virDomainDeviceInfoPtr info, - int controllerType); +virDomainControllerDefPtr +virDomainDeviceFindSCSIController(const virDomainDef *def, + virDomainDeviceInfoPtr info); virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def, int bus, char *dst); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 792fb6056..68a1f496e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -298,7 +298,7 @@ virDomainDeviceAliasIsUserAlias; virDomainDeviceDefCopy; virDomainDeviceDefFree; virDomainDeviceDefParse; -virDomainDeviceFindControllerModel; +virDomainDeviceFindSCSIController; virDomainDeviceGetInfo; virDomainDeviceInfoIterate; virDomainDeviceTypeToString; diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 37fe2aa80..ed96f9f4c 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -190,9 +190,11 @@ qemuAssignDeviceDiskAlias(virDomainDefPtr def, =20 if (disk->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { if (disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_SCSI) { - controllerModel =3D - virDomainDeviceFindControllerModel(def, &disk->info, - VIR_DOMAIN_CONTROLLER_T= YPE_SCSI); + virDomainControllerDefPtr cont; + + cont =3D virDomainDeviceFindSCSIController(def, &disk->info); + if (cont) + controllerModel =3D cont->model; =20 if ((qemuDomainSetSCSIControllerModel(def, qemuCaps, &controllerModel)) < 0) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c66307ee0..113a2919b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1957,6 +1957,7 @@ qemuBuildDriveDevStr(const virDomainDef *def, virQEMUCapsPtr qemuCaps) { virBuffer opt =3D VIR_BUFFER_INITIALIZER; + virDomainControllerDefPtr cont; const char *bus =3D virDomainDiskQEMUBusTypeToString(disk->bus); const char *contAlias; char *drivealias; @@ -2042,9 +2043,9 @@ qemuBuildDriveDevStr(const virDomainDef *def, goto error; } =20 - controllerModel =3D - virDomainDeviceFindControllerModel(def, &disk->info, - VIR_DOMAIN_CONTROLLER_TYPE_= SCSI); + cont =3D virDomainDeviceFindSCSIController(def, &disk->info); + if (cont) + controllerModel =3D cont->model; if ((qemuDomainSetSCSIControllerModel(def, qemuCaps, &controllerModel)) < 0) goto error; @@ -5142,12 +5143,14 @@ qemuBuildSCSIHostdevDevStr(const virDomainDef *def, virQEMUCapsPtr qemuCaps) { virBuffer buf =3D VIR_BUFFER_INITIALIZER; + virDomainControllerDefPtr cont; int model =3D -1; char *driveAlias; const char *contAlias; =20 - model =3D virDomainDeviceFindControllerModel(def, dev->info, - VIR_DOMAIN_CONTROLLER_TYPE_= SCSI); + cont =3D virDomainDeviceFindSCSIController(def, dev->info); + if (cont) + model =3D cont->model; =20 if (qemuDomainSetSCSIControllerModel(def, qemuCaps, &model) < 0) goto error; diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 33aefabe5..6704772e6 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1047,10 +1047,11 @@ static int vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr data, IMachine *machin= e) { size_t i; - int type, ret =3D 0, model =3D -1; + int type, ret =3D 0; const char *src =3D NULL; nsresult rc =3D 0; virDomainDiskDefPtr disk =3D NULL; + virDomainControllerDefPtr cont; PRUnichar *storageCtlName =3D NULL; char *controllerName =3D NULL; IMedium *medium =3D NULL; @@ -1126,9 +1127,8 @@ vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr d= ata, IMachine *machine) case VIR_DOMAIN_DISK_BUS_SCSI: VBOX_UTF8_TO_UTF16(VBOX_CONTROLLER_SCSI_NAME, &storageCtlName); =20 - model =3D virDomainDeviceFindControllerModel(def, &disk->info, - VIR_DOMAIN_CONTROLL= ER_TYPE_SCSI); - if (model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068) { + cont =3D virDomainDeviceFindSCSIController(def, &disk->info); + if (cont && cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_SCS= I_LSISAS1068) { VBOX_UTF16_FREE(storageCtlName); VBOX_UTF8_TO_UTF16(VBOX_CONTROLLER_SAS_NAME, &storageCtlNa= me); } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:18:21 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 151735353845626.94313309383699; Tue, 30 Jan 2018 15:05:38 -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 499DD28226; Tue, 30 Jan 2018 23:05: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 1E353600D3; Tue, 30 Jan 2018 23:05: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 DC8BA18033DD; Tue, 30 Jan 2018 23:05:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0UN5FNn006217 for ; Tue, 30 Jan 2018 18:05:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6800B5C20B; Tue, 30 Jan 2018 23:05:15 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24DBA5C25E for ; Tue, 30 Jan 2018 23:05:14 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 30 Jan 2018 18:04:57 -0500 Message-Id: <20180130230503.3820-4-jferlan@redhat.com> In-Reply-To: <20180130230503.3820-1-jferlan@redhat.com> References: <20180130230503.3820-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/9] qemu: Introduce qemuDomainFindSCSIControllerModel X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 30 Jan 2018 23:05:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than repeat multiple steps in order to find the SCSI controller model, let's combine them into one helper that will return either the model from the definition or the default model based on the capabilities. This patch adds an extra check/error that the controller that's being found actually exists. This just clarifies that the error was because the controller doesn't exist rather than the more generic error that we were unable to determine the model from qemuDomainSetSCSIControllerModel when a -1 was passed in and the capabilities were unable to find one. Signed-off-by: John Ferlan --- src/qemu/qemu_alias.c | 12 ++++-------- src/qemu/qemu_command.c | 17 +++++------------ src/qemu/qemu_domain_address.c | 31 +++++++++++++++++++++++++++++++ src/qemu/qemu_domain_address.h | 4 ++++ 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index ed96f9f4c..ed3af04de 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -190,14 +190,10 @@ qemuAssignDeviceDiskAlias(virDomainDefPtr def, =20 if (disk->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { if (disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_SCSI) { - virDomainControllerDefPtr cont; - - cont =3D virDomainDeviceFindSCSIController(def, &disk->info); - if (cont) - controllerModel =3D cont->model; - - if ((qemuDomainSetSCSIControllerModel(def, qemuCaps, - &controllerModel)) < 0) + controllerModel =3D qemuDomainFindSCSIControllerModel(def, + &disk->inf= o, + qemuCaps); + if (controllerModel < 0) return -1; } =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 113a2919b..32ff385cf 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1957,7 +1957,6 @@ qemuBuildDriveDevStr(const virDomainDef *def, virQEMUCapsPtr qemuCaps) { virBuffer opt =3D VIR_BUFFER_INITIALIZER; - virDomainControllerDefPtr cont; const char *bus =3D virDomainDiskQEMUBusTypeToString(disk->bus); const char *contAlias; char *drivealias; @@ -2043,11 +2042,9 @@ qemuBuildDriveDevStr(const virDomainDef *def, goto error; } =20 - cont =3D virDomainDeviceFindSCSIController(def, &disk->info); - if (cont) - controllerModel =3D cont->model; - if ((qemuDomainSetSCSIControllerModel(def, qemuCaps, - &controllerModel)) < 0) + controllerModel =3D qemuDomainFindSCSIControllerModel(def, &disk->= info, + qemuCaps); + if (controllerModel < 0) goto error; =20 if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) { @@ -5143,16 +5140,12 @@ qemuBuildSCSIHostdevDevStr(const virDomainDef *def, virQEMUCapsPtr qemuCaps) { virBuffer buf =3D VIR_BUFFER_INITIALIZER; - virDomainControllerDefPtr cont; int model =3D -1; char *driveAlias; const char *contAlias; =20 - cont =3D virDomainDeviceFindSCSIController(def, dev->info); - if (cont) - model =3D cont->model; - - if (qemuDomainSetSCSIControllerModel(def, qemuCaps, &model) < 0) + model =3D qemuDomainFindSCSIControllerModel(def, dev->info, qemuCaps); + if (model < 0) goto error; =20 if (model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) { diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 86fe7ad11..74f7df205 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -74,6 +74,37 @@ qemuDomainSetSCSIControllerModel(const virDomainDef *def, } =20 =20 +/** + * @def: Domain definition + * @info: Domain device info + * @qemuCaps: QEMU capabilities + * + * Using the device info, find the controller related to the + * device by index and use that controller to return the model. + * + * Returns the model if found, -1 if not with an error message set + */ +int +qemuDomainFindSCSIControllerModel(const virDomainDef *def, + virDomainDeviceInfoPtr info, + virQEMUCapsPtr qemuCaps) +{ + virDomainControllerDefPtr cont; + int model; + + if (!(cont =3D virDomainDeviceFindSCSIController(def, info))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to find a SCSI controller for idx=3D%d"), + info->addr.drive.controller); + return -1; + } + + model =3D cont->model; + ignore_value(qemuDomainSetSCSIControllerModel(def, qemuCaps, &model)); + return model; +} + + static int qemuDomainAssignVirtioSerialAddresses(virDomainDefPtr def) { diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h index e951a4c88..8a4346892 100644 --- a/src/qemu/qemu_domain_address.h +++ b/src/qemu/qemu_domain_address.h @@ -32,6 +32,10 @@ int qemuDomainSetSCSIControllerModel(const virDomainDef = *def, virQEMUCapsPtr qemuCaps, int *model); =20 +int qemuDomainFindSCSIControllerModel(const virDomainDef *def, + virDomainDeviceInfoPtr info, + virQEMUCapsPtr qemuCaps); + int qemuDomainAssignAddresses(virDomainDefPtr def, virQEMUCapsPtr qemuCaps, virQEMUDriverPtr driver, --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:18:21 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 1517353536763913.329030290551; Tue, 30 Jan 2018 15:05:36 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C2F7146269; Tue, 30 Jan 2018 23:05:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 96B945D6B2; Tue, 30 Jan 2018 23:05:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4BF3A5FBDC; Tue, 30 Jan 2018 23:05:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0UN5Fjx006224 for ; Tue, 30 Jan 2018 18:05:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id D7ACA5C20B; Tue, 30 Jan 2018 23:05:15 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91EDF5C261 for ; Tue, 30 Jan 2018 23:05:15 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 30 Jan 2018 18:04:58 -0500 Message-Id: <20180130230503.3820-5-jferlan@redhat.com> In-Reply-To: <20180130230503.3820-1-jferlan@redhat.com> References: <20180130230503.3820-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/9] qemu: Introduce qemuDomainGetSCSIControllerModel 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, 30 Jan 2018 23:05:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rename and rework qemuDomainSetSCSIControllerModel since we're really not setting the SCSI controller model. Instead the code is either returning the existing SCSI controller model value, the default value based on the capabilities, or -1 with the error set. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 3 ++- src/qemu/qemu_domain_address.c | 51 +++++++++++++++++++-------------------= ---- src/qemu/qemu_domain_address.h | 6 ++--- 3 files changed, 28 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 32ff385cf..1142f302a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2723,7 +2723,8 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, *devstr =3D NULL; =20 if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { - if ((qemuDomainSetSCSIControllerModel(domainDef, qemuCaps, &model)= ) < 0) + model =3D qemuDomainGetSCSIControllerModel(domainDef, def, qemuCap= s); + if (model < 0) return -1; =20 if (!qemuBuildCheckSCSIControllerModel(qemuCaps, model)) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 74f7df205..5211b4f8a 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -42,35 +42,33 @@ VIR_LOG_INIT("qemu.qemu_domain_address"); =20 /** * @def: Domain definition + * @cont: Domain controller def * @qemuCaps: qemu capabilities - * @model: model to either return or adjust * - * If the @model is already defined, return it immediately; otherwise, - * based on the @qemuCaps set the @model value to the default value. + * If the controller model is already defined, return it immediately; + * otherwise, based on the @qemuCaps return a default model value. * - * Returns @model on success, -1 on failure with error set. + * Returns model on success, -1 on failure with error set. */ int -qemuDomainSetSCSIControllerModel(const virDomainDef *def, - virQEMUCapsPtr qemuCaps, - int *model) +qemuDomainGetSCSIControllerModel(const virDomainDef *def, + const virDomainControllerDef *cont, + virQEMUCapsPtr qemuCaps) { - if (*model > 0) - return 0; - - if (qemuDomainIsPSeries(def)) { - *model =3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI; - } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI)) { - *model =3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC; - } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI)) { - *model =3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI; - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to determine model for scsi controller")); - return -1; - } + if (cont->model > 0) + return cont->model; =20 - return 0; + if (qemuDomainIsPSeries(def)) + return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI; + else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI)) + return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC; + else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI)) + return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI; + + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to determine model for SCSI controller idx=3D= %d"), + cont->idx); + return -1; } =20 =20 @@ -90,7 +88,6 @@ qemuDomainFindSCSIControllerModel(const virDomainDef *def, virQEMUCapsPtr qemuCaps) { virDomainControllerDefPtr cont; - int model; =20 if (!(cont =3D virDomainDeviceFindSCSIController(def, info))) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -99,9 +96,7 @@ qemuDomainFindSCSIControllerModel(const virDomainDef *def, return -1; } =20 - model =3D cont->model; - ignore_value(qemuDomainSetSCSIControllerModel(def, qemuCaps, &model)); - return model; + return qemuDomainGetSCSIControllerModel(def, cont, qemuCaps); } =20 =20 @@ -227,9 +222,9 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def, for (i =3D 0; i < def->ncontrollers; i++) { virDomainControllerDefPtr cont =3D def->controllers[i]; =20 - model =3D cont->model; if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { - if (qemuDomainSetSCSIControllerModel(def, qemuCaps, &model) < = 0) + model =3D qemuDomainGetSCSIControllerModel(def, cont, qemuCaps= ); + if (model < 0) goto cleanup; } =20 diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h index 8a4346892..209b59e0d 100644 --- a/src/qemu/qemu_domain_address.h +++ b/src/qemu/qemu_domain_address.h @@ -28,9 +28,9 @@ # include "qemu_conf.h" # include "qemu_capabilities.h" =20 -int qemuDomainSetSCSIControllerModel(const virDomainDef *def, - virQEMUCapsPtr qemuCaps, - int *model); +int qemuDomainGetSCSIControllerModel(const virDomainDef *def, + const virDomainControllerDef *cont, + virQEMUCapsPtr qemuCaps); =20 int qemuDomainFindSCSIControllerModel(const virDomainDef *def, virDomainDeviceInfoPtr info, --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:18:21 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 1517353543140554.8517775240084; Tue, 30 Jan 2018 15:05:43 -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 4BAC1776D0; Tue, 30 Jan 2018 23:05:39 +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 24B295D75F; Tue, 30 Jan 2018 23:05:39 +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 E0E5F5FBE2; Tue, 30 Jan 2018 23:05:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0UN5GeD006235 for ; Tue, 30 Jan 2018 18:05:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4F5F55C20B; Tue, 30 Jan 2018 23:05:16 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CFEA5C261 for ; Tue, 30 Jan 2018 23:05:15 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 30 Jan 2018 18:04:59 -0500 Message-Id: <20180130230503.3820-6-jferlan@redhat.com> In-Reply-To: <20180130230503.3820-1-jferlan@redhat.com> References: <20180130230503.3820-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/9] qemu: Fetch/save the default SCSI controller model during hotplug 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.27]); Tue, 30 Jan 2018 23:05:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If we're going to add a controller to the domain, let's set the default SCSI model value if we cannot find another SCSI controller already present. NB: Requires updating the live output test data since the model will now be formatted. Signed-off-by: John Ferlan --- src/qemu/qemu_hotplug.c | 8 ++++= ++-- .../qemuhotplug-base-with-scsi-controller-live.xml | 8 ++++= ---- .../qemuhotplug-base-without-scsi-controller-live+disk-scsi-2.xml | 8 ++++= ---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6b245bd6a..fccbc29a0 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -587,6 +587,7 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriverP= tr driver, { size_t i; virDomainControllerDefPtr cont; + qemuDomainObjPrivatePtr priv =3D vm->privateData; int model =3D -1; =20 for (i =3D 0; i < vm->def->ncontrollers; i++) { @@ -615,10 +616,13 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDrive= rPtr driver, return NULL; cont->type =3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI; cont->idx =3D controller; - cont->model =3D model; + if (model =3D=3D -1) + cont->model =3D qemuDomainGetSCSIControllerModel(vm->def, cont, pr= iv->qemuCaps); + else + cont->model =3D model; =20 VIR_INFO("No SCSI controller present, hotplugging one model=3D%s", - virDomainControllerModelSCSITypeToString(model)); + virDomainControllerModelSCSITypeToString(cont->model)); if (qemuDomainAttachControllerDevice(driver, vm, cont) < 0) { VIR_FREE(cont); return NULL; diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-with-scsi-contro= ller-live.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-with-scsi-con= troller-live.xml index 63eb77007..d23d3d483 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-with-scsi-controller-li= ve.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-with-scsi-controller-li= ve.xml @@ -26,19 +26,19 @@ - +
- +
- +
- +
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-without-scsi-con= troller-live+disk-scsi-2.xml b/tests/qemuhotplugtestdomains/qemuhotplug-bas= e-without-scsi-controller-live+disk-scsi-2.xml index c12d18f71..cceb678bb 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-without-scsi-controller= -live+disk-scsi-2.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-without-scsi-controller= -live+disk-scsi-2.xml @@ -36,19 +36,19 @@ - +
- +
- +
- +
--=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:18:21 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 1517353539611533.6078833237481; Tue, 30 Jan 2018 15:05:39 -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 43164780E5; Tue, 30 Jan 2018 23:05:38 +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 8122A5EDE2; Tue, 30 Jan 2018 23:05:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4854E5FBE1; Tue, 30 Jan 2018 23:05:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0UN5GpE006246 for ; Tue, 30 Jan 2018 18:05:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id BAF7B5C25E; Tue, 30 Jan 2018 23:05:16 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 78E7A5C20B for ; Tue, 30 Jan 2018 23:05:16 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 30 Jan 2018 18:05:00 -0500 Message-Id: <20180130230503.3820-7-jferlan@redhat.com> In-Reply-To: <20180130230503.3820-1-jferlan@redhat.com> References: <20180130230503.3820-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/9] qemu: Introduce qemuDomainSetSCSIControllerModel 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.27]); Tue, 30 Jan 2018 23:05:38 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" During post parse processing, let's force setting the controller model to default value if not already set for defined controllers (e.g. the non implicit ones). Signed-off-by: John Ferlan --- src/qemu/qemu_domain.c | 8 +++---- src/qemu/qemu_domain_address.c | 27 ++++++++++++++++++= ++++ src/qemu/qemu_domain_address.h | 4 ++++ .../hostdev-scsi-lsi-iscsi-auth.xml | 2 +- .../qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi.xml | 2 +- tests/qemuxml2xmloutdata/hostdev-scsi-lsi.xml | 2 +- 6 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6b4bd3cca..c8123ce59 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4251,11 +4251,9 @@ qemuDomainControllerDefPostParse(virDomainController= DefPtr cont, { switch ((virDomainControllerType)cont->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: - /* set the default SCSI controller model for S390 arches */ - if (cont->model =3D=3D -1 && - ARCH_IS_S390(def->os.arch)) { - cont->model =3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI; - } + /* Set the default SCSI controller model if not already set */ + if (qemuDomainSetSCSIControllerModel(def, cont, qemuCaps) < 0) + return -1; break; =20 case VIR_DOMAIN_CONTROLLER_TYPE_USB: diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 5211b4f8a..75c263015 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -60,6 +60,8 @@ qemuDomainGetSCSIControllerModel(const virDomainDef *def, =20 if (qemuDomainIsPSeries(def)) return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI; + else if (ARCH_IS_S390(def->os.arch)) + return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI; else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI)) return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC; else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI)) @@ -74,6 +76,31 @@ qemuDomainGetSCSIControllerModel(const virDomainDef *def, =20 /** * @def: Domain definition + * @cont: Domain controller def + * @qemuCaps: qemu capabilities + * + * Set the controller model based on the existing value and the + * capabilities if possible. + * + * Returns 0 on success, -1 on failure with error set. + */ +int +qemuDomainSetSCSIControllerModel(const virDomainDef *def, + virDomainControllerDefPtr cont, + virQEMUCapsPtr qemuCaps) +{ + int model =3D qemuDomainGetSCSIControllerModel(def, cont, qemuCaps); + + if (model < 0) + return -1; + + cont->model =3D model; + return 0; +} + + +/** + * @def: Domain definition * @info: Domain device info * @qemuCaps: QEMU capabilities * diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h index 209b59e0d..04fb2fc14 100644 --- a/src/qemu/qemu_domain_address.h +++ b/src/qemu/qemu_domain_address.h @@ -32,6 +32,10 @@ int qemuDomainGetSCSIControllerModel(const virDomainDef = *def, const virDomainControllerDef *cont, virQEMUCapsPtr qemuCaps); =20 +int qemuDomainSetSCSIControllerModel(const virDomainDef *def, + virDomainControllerDefPtr cont, + virQEMUCapsPtr qemuCaps); + int qemuDomainFindSCSIControllerModel(const virDomainDef *def, virDomainDeviceInfoPtr info, virQEMUCapsPtr qemuCaps); diff --git a/tests/qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi-auth.xml b/tes= ts/qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi-auth.xml index cad016129..3d0efdcaf 100644 --- a/tests/qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi-auth.xml +++ b/tests/qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi-auth.xml @@ -19,7 +19,7 @@
- +
diff --git a/tests/qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi.xml b/tests/qe= muxml2xmloutdata/hostdev-scsi-lsi-iscsi.xml index b7312ca4f..28b80a02b 100644 --- a/tests/qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi.xml +++ b/tests/qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi.xml @@ -19,7 +19,7 @@
- +
diff --git a/tests/qemuxml2xmloutdata/hostdev-scsi-lsi.xml b/tests/qemuxml2= xmloutdata/hostdev-scsi-lsi.xml index 54498aa5c..545ce3ba8 100644 --- a/tests/qemuxml2xmloutdata/hostdev-scsi-lsi.xml +++ b/tests/qemuxml2xmloutdata/hostdev-scsi-lsi.xml @@ -19,7 +19,7 @@
- +
--=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:18:21 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 1517353543540467.2893779867976; Tue, 30 Jan 2018 15:05:43 -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 3824D4A711; Tue, 30 Jan 2018 23:05:42 +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 1202760BE0; Tue, 30 Jan 2018 23:05:42 +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 C638A18033E4; Tue, 30 Jan 2018 23:05:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0UN5HxV006251 for ; Tue, 30 Jan 2018 18:05:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 375985C20B; Tue, 30 Jan 2018 23:05:17 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA5715C542 for ; Tue, 30 Jan 2018 23:05:16 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 30 Jan 2018 18:05:01 -0500 Message-Id: <20180130230503.3820-8-jferlan@redhat.com> In-Reply-To: <20180130230503.3820-1-jferlan@redhat.com> References: <20180130230503.3820-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/9] conf: Allow configuration of implicit controller model 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.38]); Tue, 30 Jan 2018 23:05:42 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When an implicit controller is added, the model is defined as -1 (IOW: undefined). So, if an implicit SCSI controller was added, can set the model to the default value if the underlying hypervisor supports it. Signed-off-by: John Ferlan --- src/conf/domain_conf.c | 17 +++++++++++++++++ tests/qemuargv2xmldata/nomachine-ppc64.xml | 2 +- tests/qemuargv2xmldata/pseries-disk.xml | 2 +- tests/qemuxml2xmloutdata/disk-scsi-device-auto.xml | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b39667952..8efe83489 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4924,6 +4924,8 @@ virDomainDefPostParseCommon(virDomainDefPtr def, struct virDomainDefPostParseDeviceIteratorData= *data, virHashTablePtr bootHash) { + size_t i; + /* verify init path for container based domains */ if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_EXE && !def->os.init) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -4991,6 +4993,21 @@ virDomainDefPostParseCommon(virDomainDefPtr def, return -1; } =20 + /* Implicit SCSI controllers without a defined model might have + * been added in AddImplicitDevices, after we've done the per-device + * post-parse. */ + for (i =3D 0; i < def->ncontrollers; i++) { + if (def->controllers[i]->model =3D=3D -1 && + def->controllers[i]->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SC= SI) { + virDomainDeviceDef device =3D { + .type =3D VIR_DOMAIN_DEVICE_CONTROLLER, + .data.controller =3D def->controllers[i], + }; + if (virDomainDefPostParseDeviceIterator(def, &device, NULL, da= ta) < 0) + return -1; + } + } + /* clean up possibly duplicated metadata entries */ virXMLNodeSanitizeNamespaces(def->metadata); =20 diff --git a/tests/qemuargv2xmldata/nomachine-ppc64.xml b/tests/qemuargv2xm= ldata/nomachine-ppc64.xml index fa41070cb..439f9e9ac 100644 --- a/tests/qemuargv2xmldata/nomachine-ppc64.xml +++ b/tests/qemuargv2xmldata/nomachine-ppc64.xml @@ -33,7 +33,7 @@ - +
diff --git a/tests/qemuargv2xmldata/pseries-disk.xml b/tests/qemuargv2xmlda= ta/pseries-disk.xml index 601d0f7f6..1f15a950e 100644 --- a/tests/qemuargv2xmldata/pseries-disk.xml +++ b/tests/qemuargv2xmldata/pseries-disk.xml @@ -34,7 +34,7 @@ - +
diff --git a/tests/qemuxml2xmloutdata/disk-scsi-device-auto.xml b/tests/qem= uxml2xmloutdata/disk-scsi-device-auto.xml index dde374590..a0db32b56 100644 --- a/tests/qemuxml2xmloutdata/disk-scsi-device-auto.xml +++ b/tests/qemuxml2xmloutdata/disk-scsi-device-auto.xml @@ -31,7 +31,7 @@
- +
--=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:18:21 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 1517353536679479.3231090411555; Tue, 30 Jan 2018 15:05:36 -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 BE094A342A; Tue, 30 Jan 2018 23:05:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9187B5C582; Tue, 30 Jan 2018 23:05:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4A82D5FBDB; Tue, 30 Jan 2018 23:05:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0UN5Ieu006261 for ; Tue, 30 Jan 2018 18:05:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id F377D5C20B; Tue, 30 Jan 2018 23:05:17 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF7295C25E for ; Tue, 30 Jan 2018 23:05:17 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 30 Jan 2018 18:05:02 -0500 Message-Id: <20180130230503.3820-9-jferlan@redhat.com> In-Reply-To: <20180130230503.3820-1-jferlan@redhat.com> References: <20180130230503.3820-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 8/9] qemu: Reduce need to call qemuDomainGetSCSIControllerModel 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, 30 Jan 2018 23:05:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now that post parse processing handles setting the SCSI controller model, there's no need to call qemuDomainGetSCSIControllerModel to get the "default controller" when building the command line controller string or when assigning the spaprvio address since the controller model value will already be filled in. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 11 +++-------- src/qemu/qemu_domain_address.c | 14 +++----------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1142f302a..f82a78155 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2717,22 +2717,17 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, int *nusbcontroller) { virBuffer buf =3D VIR_BUFFER_INITIALIZER; - int model =3D def->model; const char *modelName =3D NULL; =20 *devstr =3D NULL; =20 if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { - model =3D qemuDomainGetSCSIControllerModel(domainDef, def, qemuCap= s); - if (model < 0) - return -1; - - if (!qemuBuildCheckSCSIControllerModel(qemuCaps, model)) + if (!qemuBuildCheckSCSIControllerModel(qemuCaps, def->model)) return -1; } =20 if (!(def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI && - model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI)) { + def->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI))= { if (def->queues) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("'queues' is only supported by virtio-scsi co= ntroller")); @@ -2757,7 +2752,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, =20 switch ((virDomainControllerType) def->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: - switch (model) { + switch (def->model) { case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: if (def->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { virBufferAddLit(&buf, "virtio-scsi-ccw"); diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 75c263015..aa736131e 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -225,12 +225,10 @@ qemuDomainAssignSpaprVIOAddress(virDomainDefPtr def, =20 =20 static int -qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def, - virQEMUCapsPtr qemuCaps) +qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def) { size_t i; int ret =3D -1; - int model; =20 /* Default values match QEMU. See spapr_(llan|vscsi|vty).c */ =20 @@ -249,13 +247,7 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def, for (i =3D 0; i < def->ncontrollers; i++) { virDomainControllerDefPtr cont =3D def->controllers[i]; =20 - if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { - model =3D qemuDomainGetSCSIControllerModel(def, cont, qemuCaps= ); - if (model < 0) - goto cleanup; - } - - if (model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI && + if (cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI && cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { cont->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO; } @@ -2864,7 +2856,7 @@ qemuDomainAssignAddresses(virDomainDefPtr def, if (qemuDomainAssignVirtioSerialAddresses(def) < 0) return -1; =20 - if (qemuDomainAssignSpaprVIOAddresses(def, qemuCaps) < 0) + if (qemuDomainAssignSpaprVIOAddresses(def) < 0) return -1; =20 if (qemuDomainAssignS390Addresses(def, qemuCaps) < 0) --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:18:21 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 1517353542569938.3620437431106; Tue, 30 Jan 2018 15:05:42 -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 887C119D39D; Tue, 30 Jan 2018 23:05:40 +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 5C61A60A9A; Tue, 30 Jan 2018 23:05:40 +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 2286F5FBE6; Tue, 30 Jan 2018 23:05:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0UN5IcF006268 for ; Tue, 30 Jan 2018 18:05:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 692D15C261; Tue, 30 Jan 2018 23:05:18 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-232.phx2.redhat.com [10.3.116.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 272785C20B for ; Tue, 30 Jan 2018 23:05:18 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 30 Jan 2018 18:05:03 -0500 Message-Id: <20180130230503.3820-10-jferlan@redhat.com> In-Reply-To: <20180130230503.3820-1-jferlan@redhat.com> References: <20180130230503.3820-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 9/9] qemu: Update qemuDomainFindSCSIControllerModel return 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, 30 Jan 2018 23:05:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now that the controller model is updated during post parse callback, this code no longer needs to fetch the model based on the capabilities and can just return the model directly if the controller is found. Removal of @qemuCaps cascades through various callers which are now updated to not pass the capabilities. Signed-off-by: John Ferlan --- src/qemu/qemu_alias.c | 8 +++----- src/qemu/qemu_alias.h | 3 +-- src/qemu/qemu_command.c | 11 ++++------- src/qemu/qemu_command.h | 3 +-- src/qemu/qemu_domain_address.c | 6 ++---- src/qemu/qemu_domain_address.h | 3 +-- src/qemu/qemu_hotplug.c | 6 +++--- 7 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index ed3af04de..e8c1256b7 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -179,8 +179,7 @@ qemuAssignDeviceControllerAlias(virDomainDefPtr domainD= ef, /* Our custom -drive naming scheme used with id=3D */ int qemuAssignDeviceDiskAlias(virDomainDefPtr def, - virDomainDiskDefPtr disk, - virQEMUCapsPtr qemuCaps) + virDomainDiskDefPtr disk) { const char *prefix =3D virDomainDiskBusTypeToString(disk->bus); int controllerModel =3D -1; @@ -191,8 +190,7 @@ qemuAssignDeviceDiskAlias(virDomainDefPtr def, if (disk->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { if (disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_SCSI) { controllerModel =3D qemuDomainFindSCSIControllerModel(def, - &disk->inf= o, - qemuCaps); + &disk->inf= o); if (controllerModel < 0) return -1; } @@ -539,7 +537,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCap= sPtr qemuCaps) size_t i; =20 for (i =3D 0; i < def->ndisks; i++) { - if (qemuAssignDeviceDiskAlias(def, def->disks[i], qemuCaps) < 0) + if (qemuAssignDeviceDiskAlias(def, def->disks[i]) < 0) return -1; } for (i =3D 0; i < def->nnets; i++) { diff --git a/src/qemu/qemu_alias.h b/src/qemu/qemu_alias.h index 11bbc2860..2246e712f 100644 --- a/src/qemu/qemu_alias.h +++ b/src/qemu/qemu_alias.h @@ -39,8 +39,7 @@ int qemuAssignDeviceControllerAlias(virDomainDefPtr domai= nDef, virDomainControllerDefPtr controller); =20 int qemuAssignDeviceDiskAlias(virDomainDefPtr vmdef, - virDomainDiskDefPtr def, - virQEMUCapsPtr qemuCaps); + virDomainDiskDefPtr def); =20 int qemuAssignDeviceHostdevAlias(virDomainDefPtr def, char **alias, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f82a78155..899f0cbbb 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2042,8 +2042,7 @@ qemuBuildDriveDevStr(const virDomainDef *def, goto error; } =20 - controllerModel =3D qemuDomainFindSCSIControllerModel(def, &disk->= info, - qemuCaps); + controllerModel =3D qemuDomainFindSCSIControllerModel(def, &disk->= info); if (controllerModel < 0) goto error; =20 @@ -5132,15 +5131,14 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr d= ev, =20 char * qemuBuildSCSIHostdevDevStr(const virDomainDef *def, - virDomainHostdevDefPtr dev, - virQEMUCapsPtr qemuCaps) + virDomainHostdevDefPtr dev) { virBuffer buf =3D VIR_BUFFER_INITIALIZER; int model =3D -1; char *driveAlias; const char *contAlias; =20 - model =3D qemuDomainFindSCSIControllerModel(def, dev->info, qemuCaps); + model =3D qemuDomainFindSCSIControllerModel(def, dev->info); if (model < 0) goto error; =20 @@ -5623,8 +5621,7 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd, VIR_FREE(drvstr); =20 virCommandAddArg(cmd, "-device"); - if (!(devstr =3D qemuBuildSCSIHostdevDevStr(def, hostdev, - qemuCaps))) + if (!(devstr =3D qemuBuildSCSIHostdevDevStr(def, hostdev))) return -1; virCommandAddArg(cmd, devstr); VIR_FREE(devstr); diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index bdde6f918..31c9da673 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -154,8 +154,7 @@ char *qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr= dev, virQEMUCapsPtr qemuCaps); =20 char *qemuBuildSCSIHostdevDevStr(const virDomainDef *def, - virDomainHostdevDefPtr dev, - virQEMUCapsPtr qemuCaps); + virDomainHostdevDefPtr dev); char * qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def, virDomainHostdevDefPtr dev, diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index aa736131e..6272b1e91 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -102,7 +102,6 @@ qemuDomainSetSCSIControllerModel(const virDomainDef *de= f, /** * @def: Domain definition * @info: Domain device info - * @qemuCaps: QEMU capabilities * * Using the device info, find the controller related to the * device by index and use that controller to return the model. @@ -111,8 +110,7 @@ qemuDomainSetSCSIControllerModel(const virDomainDef *de= f, */ int qemuDomainFindSCSIControllerModel(const virDomainDef *def, - virDomainDeviceInfoPtr info, - virQEMUCapsPtr qemuCaps) + virDomainDeviceInfoPtr info) { virDomainControllerDefPtr cont; =20 @@ -123,7 +121,7 @@ qemuDomainFindSCSIControllerModel(const virDomainDef *d= ef, return -1; } =20 - return qemuDomainGetSCSIControllerModel(def, cont, qemuCaps); + return cont->model; } =20 =20 diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h index 04fb2fc14..83f8e81ca 100644 --- a/src/qemu/qemu_domain_address.h +++ b/src/qemu/qemu_domain_address.h @@ -37,8 +37,7 @@ int qemuDomainSetSCSIControllerModel(const virDomainDef *= def, virQEMUCapsPtr qemuCaps); =20 int qemuDomainFindSCSIControllerModel(const virDomainDef *def, - virDomainDeviceInfoPtr info, - virQEMUCapsPtr qemuCaps); + virDomainDeviceInfoPtr info); =20 int qemuDomainAssignAddresses(virDomainDefPtr def, virQEMUCapsPtr qemuCaps, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index fccbc29a0..2aa927e62 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -381,7 +381,7 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn, if (qemuHotplugPrepareDiskAccess(driver, vm, disk, NULL, false) < 0) goto cleanup; =20 - if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0) + if (qemuAssignDeviceDiskAlias(vm->def, disk) < 0) goto error; =20 if (qemuDomainPrepareDiskSource(conn, disk, priv, cfg) < 0) @@ -2405,7 +2405,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn, if (!(drivealias =3D qemuAliasFromHostdev(hostdev))) goto cleanup; =20 - if (!(devstr =3D qemuBuildSCSIHostdevDevStr(vm->def, hostdev, priv->qe= muCaps))) + if (!(devstr =3D qemuBuildSCSIHostdevDevStr(vm->def, hostdev))) goto cleanup; =20 if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0) @@ -4634,7 +4634,7 @@ qemuDomainDetachVirtioDiskDevice(virQEMUDriverPtr dri= ver, } =20 if (!detach->info.alias) { - if (qemuAssignDeviceDiskAlias(vm->def, detach, priv->qemuCaps) < 0) + if (qemuAssignDeviceDiskAlias(vm->def, detach) < 0) goto cleanup; } =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list