From nobody Fri May 16 10:11:15 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.zoho.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 1496495534368990.6543120135294; Sat, 3 Jun 2017 06:12:14 -0700 (PDT) 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 410504E326; Sat, 3 Jun 2017 13:12:12 +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 130987B8FF; Sat, 3 Jun 2017 13:12:12 +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 B88321841C84; Sat, 3 Jun 2017 13:12:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v53DCAHr005805 for ; Sat, 3 Jun 2017 09:12:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 43CCF7B8D9; Sat, 3 Jun 2017 13:12:10 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-124.phx2.redhat.com [10.3.116.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0330A179C2 for ; Sat, 3 Jun 2017 13:12:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 410504E326 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 410504E326 From: John Ferlan To: libvir-list@redhat.com Date: Sat, 3 Jun 2017 09:12:00 -0400 Message-Id: <20170603131202.17611-11-jferlan@redhat.com> In-Reply-To: <20170603131202.17611-1-jferlan@redhat.com> References: <20170603131202.17611-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 10/12] nodedev: Introduce virNodeDeviceObjListFindSCSIHostByWWNs 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.38]); Sat, 03 Jun 2017 13:12:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Alter the nodeDeviceLookupSCSIHostByWWN to use the new API in order to find what it's looking for. Signed-off-by: John Ferlan --- src/conf/virnodedeviceobj.c | 33 +++++++++++++++++++++ src/conf/virnodedeviceobj.h | 5 ++++ src/libvirt_private.syms | 1 + src/node_device/node_device_driver.c | 56 +++++++++++---------------------= ---- 4 files changed, 55 insertions(+), 40 deletions(-) diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index a9187be..fa61a2d 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -274,6 +274,39 @@ virNodeDeviceObjListFindByCap(virNodeDeviceObjListPtr = devs, } =20 =20 +virNodeDeviceObjPtr +virNodeDeviceObjListFindSCSIHostByWWNs(virNodeDeviceObjListPtr devs, + const char *wwnn, + const char *wwpn) +{ + size_t i; + + for (i =3D 0; i < devs->count; i++) { + virNodeDeviceObjPtr obj =3D devs->objs[i]; + virNodeDevCapsDefPtr cap; + + virNodeDeviceObjLock(obj); + cap =3D obj->def->caps; + + while (cap) { + if (cap->data.type =3D=3D VIR_NODE_DEV_CAP_SCSI_HOST) { + virNodeDeviceGetSCSIHostCaps(&cap->data.scsi_host); + if (cap->data.scsi_host.flags & + VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) { + if (STREQ(cap->data.scsi_host.wwnn, wwnn) && + STREQ(cap->data.scsi_host.wwpn, wwpn)) + return obj; + } + } + cap =3D cap->next; + } + virNodeDeviceObjUnlock(obj); + } + + return NULL; +} + + void virNodeDeviceObjFree(virNodeDeviceObjPtr obj) { diff --git a/src/conf/virnodedeviceobj.h b/src/conf/virnodedeviceobj.h index 6194c6c..6ec5ee7 100644 --- a/src/conf/virnodedeviceobj.h +++ b/src/conf/virnodedeviceobj.h @@ -53,6 +53,11 @@ virNodeDeviceObjListFindBySysfsPath(virNodeDeviceObjList= Ptr devs, ATTRIBUTE_NONNULL(2); =20 virNodeDeviceObjPtr +virNodeDeviceObjListFindSCSIHostByWWNs(virNodeDeviceObjListPtr devs, + const char *wwnn, + const char *wwpn); + +virNodeDeviceObjPtr virNodeDeviceObjListAssignDef(virNodeDeviceObjListPtr devs, virNodeDeviceDefPtr def); =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 33fc9fc..d415888 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -963,6 +963,7 @@ virNodeDeviceObjListAssignDef; virNodeDeviceObjListExport; virNodeDeviceObjListFindByName; virNodeDeviceObjListFindBySysfsPath; +virNodeDeviceObjListFindSCSIHostByWWNs; virNodeDeviceObjListFree; virNodeDeviceObjListGetNames; virNodeDeviceObjListGetParentHost; diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 348539f..4a5f168 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -288,9 +288,6 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn, const char *wwpn, unsigned int flags) { - size_t i; - virNodeDeviceObjListPtr devs =3D driver->devs; - virNodeDevCapsDefPtr cap =3D NULL; virNodeDeviceObjPtr obj =3D NULL; virNodeDeviceDefPtr def; virNodeDevicePtr device =3D NULL; @@ -298,48 +295,27 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn, virCheckFlags(0, NULL); =20 nodeDeviceLock(); + obj =3D virNodeDeviceObjListFindSCSIHostByWWNs(driver->devs, wwnn, wwp= n); + nodeDeviceUnlock(); =20 - for (i =3D 0; i < devs->count; i++) { - obj =3D devs->objs[i]; - virNodeDeviceObjLock(obj); - def =3D virNodeDeviceObjGetDef(obj); - cap =3D def->caps; - - while (cap) { - if (cap->data.type =3D=3D VIR_NODE_DEV_CAP_SCSI_HOST) { - nodeDeviceSysfsGetSCSIHostCaps(&cap->data.scsi_host); - if (cap->data.scsi_host.flags & - VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) { - if (STREQ(cap->data.scsi_host.wwnn, wwnn) && - STREQ(cap->data.scsi_host.wwpn, wwpn)) { - - if (virNodeDeviceLookupSCSIHostByWWNEnsureACL(conn= , def) < 0) - goto error; - - if ((device =3D virGetNodeDevice(conn, def->name))= ) { - if (VIR_STRDUP(device->parent, def->parent) < = 0) { - virObjectUnref(device); - device =3D NULL; - } - } - virNodeDeviceObjUnlock(obj); - goto out; - } - } - } - cap =3D cap->next; - } + if (!obj) + return NULL; =20 - virNodeDeviceObjUnlock(obj); - } + def =3D virNodeDeviceObjGetDef(obj); =20 - out: - nodeDeviceUnlock(); - return device; + if (virNodeDeviceLookupSCSIHostByWWNEnsureACL(conn, def) < 0) + goto cleanup; =20 - error: + if ((device =3D virGetNodeDevice(conn, def->name))) { + if (VIR_STRDUP(device->parent, def->parent) < 0) { + virObjectUnref(device); + device =3D NULL; + } + } + + cleanup: virNodeDeviceObjUnlock(obj); - goto out; + return device; } =20 =20 --=20 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list