From nobody Sun Feb 8 14:11:47 2026 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 149574225211153.58852260135882; Thu, 25 May 2017 12:57:32 -0700 (PDT) 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 EB7DD448D6F; Thu, 25 May 2017 19:57:29 +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 AD4B718B41; Thu, 25 May 2017 19:57: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 612594A48E; Thu, 25 May 2017 19:57:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4PJvRaH016870 for ; Thu, 25 May 2017 15:57:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id E16D77F8DC; Thu, 25 May 2017 19:57:27 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-108.phx2.redhat.com [10.3.116.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B41817DF6 for ; Thu, 25 May 2017 19:57:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EB7DD448D6F Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.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 EB7DD448D6F From: John Ferlan To: libvir-list@redhat.com Date: Thu, 25 May 2017 15:57:02 -0400 Message-Id: <20170525195711.27087-6-jferlan@redhat.com> In-Reply-To: <20170525195711.27087-1-jferlan@redhat.com> References: <20170525195711.27087-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 05/14] nodedev: Use common naming for virnodedeviceobj 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.29]); Thu, 25 May 2017 19:57:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" A virNodeDeviceObjPtr is an @obj A virNodeDeviceObjListPtr is an @devs Signed-off-by: John Ferlan --- src/conf/virnodedeviceobj.c | 130 ++++++++++++++++++++++------------------= ---- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index 913cdda..a2d09ad 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -34,10 +34,10 @@ VIR_LOG_INIT("conf.virnodedeviceobj"); =20 =20 static int -virNodeDeviceObjHasCap(const virNodeDeviceObj *dev, +virNodeDeviceObjHasCap(const virNodeDeviceObj *obj, const char *cap) { - virNodeDevCapsDefPtr caps =3D dev->def->caps; + virNodeDevCapsDefPtr caps =3D obj->def->caps; const char *fc_host_cap =3D virNodeDevCapTypeToString(VIR_NODE_DEV_CAP_FC_HOST); const char *vports_cap =3D @@ -100,9 +100,9 @@ virNodeDeviceObjHasCap(const virNodeDeviceObj *dev, * Pointer to the caps or NULL if not found */ static virNodeDevCapsDefPtr -virNodeDeviceFindFCCapDef(const virNodeDeviceObj *dev) +virNodeDeviceFindFCCapDef(const virNodeDeviceObj *obj) { - virNodeDevCapsDefPtr caps =3D dev->def->caps; + virNodeDevCapsDefPtr caps =3D obj->def->caps; =20 while (caps) { if (caps->data.type =3D=3D VIR_NODE_DEV_CAP_SCSI_HOST && @@ -124,9 +124,9 @@ virNodeDeviceFindFCCapDef(const virNodeDeviceObj *dev) * Pointer to the caps or NULL if not found */ static virNodeDevCapsDefPtr -virNodeDeviceFindVPORTCapDef(const virNodeDeviceObj *dev) +virNodeDeviceFindVPORTCapDef(const virNodeDeviceObj *obj) { - virNodeDevCapsDefPtr caps =3D dev->def->caps; + virNodeDevCapsDefPtr caps =3D obj->def->caps; =20 while (caps) { if (caps->data.type =3D=3D VIR_NODE_DEV_CAP_SCSI_HOST && @@ -235,18 +235,18 @@ virNodeDeviceFindByCap(virNodeDeviceObjListPtr devs, =20 =20 void -virNodeDeviceObjFree(virNodeDeviceObjPtr dev) +virNodeDeviceObjFree(virNodeDeviceObjPtr obj) { - if (!dev) + if (!obj) return; =20 - virNodeDeviceDefFree(dev->def); - if (dev->privateFree) - (*dev->privateFree)(dev->privateData); + virNodeDeviceDefFree(obj->def); + if (obj->privateFree) + (*obj->privateFree)(obj->privateData); =20 - virMutexDestroy(&dev->lock); + virMutexDestroy(&obj->lock); =20 - VIR_FREE(dev); + VIR_FREE(obj); } =20 =20 @@ -265,51 +265,51 @@ virNodeDeviceObjPtr virNodeDeviceObjAssignDef(virNodeDeviceObjListPtr devs, virNodeDeviceDefPtr def) { - virNodeDeviceObjPtr device; + virNodeDeviceObjPtr obj; =20 - if ((device =3D virNodeDeviceObjFindByName(devs, def->name))) { - virNodeDeviceDefFree(device->def); - device->def =3D def; - return device; + if ((obj =3D virNodeDeviceObjFindByName(devs, def->name))) { + virNodeDeviceDefFree(obj->def); + obj->def =3D def; + return obj; } =20 - if (VIR_ALLOC(device) < 0) + if (VIR_ALLOC(obj) < 0) return NULL; =20 - if (virMutexInit(&device->lock) < 0) { + if (virMutexInit(&obj->lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot initialize mutex")); - VIR_FREE(device); + VIR_FREE(obj); return NULL; } - virNodeDeviceObjLock(device); + virNodeDeviceObjLock(obj); =20 - if (VIR_APPEND_ELEMENT_COPY(devs->objs, devs->count, device) < 0) { - virNodeDeviceObjUnlock(device); - virNodeDeviceObjFree(device); + if (VIR_APPEND_ELEMENT_COPY(devs->objs, devs->count, obj) < 0) { + virNodeDeviceObjUnlock(obj); + virNodeDeviceObjFree(obj); return NULL; } - device->def =3D def; + obj->def =3D def; =20 - return device; + return obj; =20 } =20 =20 void virNodeDeviceObjRemove(virNodeDeviceObjListPtr devs, - virNodeDeviceObjPtr *dev) + virNodeDeviceObjPtr *obj) { size_t i; =20 - virNodeDeviceObjUnlock(*dev); + virNodeDeviceObjUnlock(*obj); =20 for (i =3D 0; i < devs->count; i++) { virNodeDeviceObjLock(devs->objs[i]); - if (devs->objs[i] =3D=3D *dev) { + if (devs->objs[i] =3D=3D *obj) { virNodeDeviceObjUnlock(devs->objs[i]); virNodeDeviceObjFree(devs->objs[i]); - *dev =3D NULL; + *obj =3D NULL; =20 VIR_DELETE_ELEMENT(devs->objs, i, devs->count); break; @@ -332,15 +332,15 @@ virNodeDeviceObjRemove(virNodeDeviceObjListPtr devs, * parent_host value on success (>=3D 0), -1 otherwise. */ static int -virNodeDeviceFindFCParentHost(virNodeDeviceObjPtr parent) +virNodeDeviceFindFCParentHost(virNodeDeviceObjPtr obj) { - virNodeDevCapsDefPtr cap =3D virNodeDeviceFindVPORTCapDef(parent); + virNodeDevCapsDefPtr cap =3D virNodeDeviceFindVPORTCapDef(obj); =20 if (!cap) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Parent device %s is not capable " "of vport operations"), - parent->def->name); + obj->def->name); return -1; } =20 @@ -353,19 +353,19 @@ virNodeDeviceGetParentHostByParent(virNodeDeviceObjLi= stPtr devs, const char *dev_name, const char *parent_name) { - virNodeDeviceObjPtr parent =3D NULL; + virNodeDeviceObjPtr obj =3D NULL; int ret; =20 - if (!(parent =3D virNodeDeviceObjFindByName(devs, parent_name))) { + if (!(obj =3D virNodeDeviceObjFindByName(devs, parent_name))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not find parent device for '%s'"), dev_name); return -1; } =20 - ret =3D virNodeDeviceFindFCParentHost(parent); + ret =3D virNodeDeviceFindFCParentHost(obj); =20 - virNodeDeviceObjUnlock(parent); + virNodeDeviceObjUnlock(obj); =20 return ret; } @@ -377,19 +377,19 @@ virNodeDeviceGetParentHostByWWNs(virNodeDeviceObjList= Ptr devs, const char *parent_wwnn, const char *parent_wwpn) { - virNodeDeviceObjPtr parent =3D NULL; + virNodeDeviceObjPtr obj =3D NULL; int ret; =20 - if (!(parent =3D virNodeDeviceFindByWWNs(devs, parent_wwnn, parent_wwp= n))) { + if (!(obj =3D virNodeDeviceFindByWWNs(devs, parent_wwnn, parent_wwpn))= ) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not find parent device for '%s'"), dev_name); return -1; } =20 - ret =3D virNodeDeviceFindFCParentHost(parent); + ret =3D virNodeDeviceFindFCParentHost(obj); =20 - virNodeDeviceObjUnlock(parent); + virNodeDeviceObjUnlock(obj); =20 return ret; } @@ -400,19 +400,19 @@ virNodeDeviceGetParentHostByFabricWWN(virNodeDeviceOb= jListPtr devs, const char *dev_name, const char *parent_fabric_wwn) { - virNodeDeviceObjPtr parent =3D NULL; + virNodeDeviceObjPtr obj =3D NULL; int ret; =20 - if (!(parent =3D virNodeDeviceFindByFabricWWN(devs, parent_fabric_wwn)= )) { + if (!(obj =3D virNodeDeviceFindByFabricWWN(devs, parent_fabric_wwn))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not find parent device for '%s'"), dev_name); return -1; } =20 - ret =3D virNodeDeviceFindFCParentHost(parent); + ret =3D virNodeDeviceFindFCParentHost(obj); =20 - virNodeDeviceObjUnlock(parent); + virNodeDeviceObjUnlock(obj); =20 return ret; } @@ -421,19 +421,19 @@ virNodeDeviceGetParentHostByFabricWWN(virNodeDeviceOb= jListPtr devs, static int virNodeDeviceFindVportParentHost(virNodeDeviceObjListPtr devs) { - virNodeDeviceObjPtr parent =3D NULL; + virNodeDeviceObjPtr obj =3D NULL; const char *cap =3D virNodeDevCapTypeToString(VIR_NODE_DEV_CAP_VPORTS); int ret; =20 - if (!(parent =3D virNodeDeviceFindByCap(devs, cap))) { + if (!(obj =3D virNodeDeviceFindByCap(devs, cap))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not find any vport capable device")); return -1; } =20 - ret =3D virNodeDeviceFindFCParentHost(parent); + ret =3D virNodeDeviceFindFCParentHost(obj); =20 - virNodeDeviceObjUnlock(parent); + virNodeDeviceObjUnlock(obj); =20 return ret; } @@ -481,12 +481,12 @@ virNodeDeviceObjUnlock(virNodeDeviceObjPtr obj) =20 =20 static bool -virNodeDeviceCapMatch(virNodeDeviceObjPtr devobj, +virNodeDeviceCapMatch(virNodeDeviceObjPtr obj, int type) { virNodeDevCapsDefPtr cap =3D NULL; =20 - for (cap =3D devobj->def->caps; cap; cap =3D cap->next) { + for (cap =3D obj->def->caps; cap; cap =3D cap->next) { if (type =3D=3D cap->data.type) return true; =20 @@ -589,9 +589,9 @@ virNodeDeviceObjGetNames(virNodeDeviceObjListPtr devs, =20 =20 #define MATCH(FLAG) ((flags & (VIR_CONNECT_LIST_NODE_DEVICES_CAP_ ## FLAG)= ) && \ - virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_ ## FL= AG)) + virNodeDeviceCapMatch(obj, VIR_NODE_DEV_CAP_ ## FLAG)) static bool -virNodeDeviceMatch(virNodeDeviceObjPtr devobj, +virNodeDeviceMatch(virNodeDeviceObjPtr obj, unsigned int flags) { /* filter by cap type */ @@ -621,7 +621,7 @@ virNodeDeviceMatch(virNodeDeviceObjPtr devobj, =20 int virNodeDeviceObjListExport(virConnectPtr conn, - virNodeDeviceObjListPtr devobjs, + virNodeDeviceObjListPtr devs, virNodeDevicePtr **devices, virNodeDeviceObjListFilter filter, unsigned int flags) @@ -632,26 +632,26 @@ virNodeDeviceObjListExport(virConnectPtr conn, int ret =3D -1; size_t i; =20 - if (devices && VIR_ALLOC_N(tmp_devices, devobjs->count + 1) < 0) + if (devices && VIR_ALLOC_N(tmp_devices, devs->count + 1) < 0) goto cleanup; =20 - for (i =3D 0; i < devobjs->count; i++) { - virNodeDeviceObjPtr devobj =3D devobjs->objs[i]; - virNodeDeviceObjLock(devobj); - if ((!filter || filter(conn, devobj->def)) && - virNodeDeviceMatch(devobj, flags)) { + for (i =3D 0; i < devs->count; i++) { + virNodeDeviceObjPtr obj =3D devs->objs[i]; + virNodeDeviceObjLock(obj); + if ((!filter || filter(conn, obj->def)) && + virNodeDeviceMatch(obj, flags)) { if (devices) { - if (!(device =3D virGetNodeDevice(conn, devobj->def->name)= ) || - VIR_STRDUP(device->parent, devobj->def->parent) < 0) { + if (!(device =3D virGetNodeDevice(conn, obj->def->name)) || + VIR_STRDUP(device->parent, obj->def->parent) < 0) { virObjectUnref(device); - virNodeDeviceObjUnlock(devobj); + virNodeDeviceObjUnlock(obj); goto cleanup; } tmp_devices[ndevices] =3D device; } ndevices++; } - virNodeDeviceObjUnlock(devobj); + virNodeDeviceObjUnlock(obj); } =20 if (tmp_devices) { --=20 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list