From nobody Fri Jul 4 13:16:52 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 1496495549085523.1915342882152; Sat, 3 Jun 2017 06:12:29 -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 1F97C804EB; Sat, 3 Jun 2017 13:12:27 +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 ED9E17BAE9; Sat, 3 Jun 2017 13:12:26 +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 23E40180BAFF; Sat, 3 Jun 2017 13:12:26 +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 v53DC79X005746 for ; Sat, 3 Jun 2017 09:12:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 390B77B8D9; Sat, 3 Jun 2017 13:12:07 +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 ED331179C2 for ; Sat, 3 Jun 2017 13:12:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1F97C804EB Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.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 1F97C804EB From: John Ferlan To: libvir-list@redhat.com Date: Sat, 3 Jun 2017 09:11:53 -0400 Message-Id: <20170603131202.17611-4-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 03/12] 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sat, 03 Jun 2017 13:12:27 +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 | 124 ++++++++++++++++++++++------------------= ---- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index fa73de1..3aff5ca 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -41,10 +41,10 @@ virNodeDeviceObjGetDef(virNodeDeviceObjPtr obj) =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 @@ -105,9 +105,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 && @@ -129,9 +129,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 && @@ -240,16 +240,16 @@ virNodeDeviceFindByCap(virNodeDeviceObjListPtr devs, =20 =20 void -virNodeDeviceObjFree(virNodeDeviceObjPtr dev) +virNodeDeviceObjFree(virNodeDeviceObjPtr obj) { - if (!dev) + if (!obj) return; =20 - virNodeDeviceDefFree(dev->def); + virNodeDeviceDefFree(obj->def); =20 - virMutexDestroy(&dev->lock); + virMutexDestroy(&obj->lock); =20 - VIR_FREE(dev); + VIR_FREE(obj); } =20 =20 @@ -268,48 +268,48 @@ 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]); =20 VIR_DELETE_ELEMENT(devs->objs, i, devs->count); @@ -333,15 +333,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 @@ -354,19 +354,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; } @@ -378,19 +378,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; } @@ -401,19 +401,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; } @@ -422,19 +422,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; } @@ -482,12 +482,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 @@ -588,9 +588,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