From nobody Thu May 15 01:48:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 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