From nobody Sat Feb 7 10:44:30 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 1495799960609972.9739494860842; Fri, 26 May 2017 04:59:20 -0700 (PDT) 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 E28D6448D93; Fri, 26 May 2017 11:59: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 B622A7DFE7; Fri, 26 May 2017 11:59: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 3EA2B4A48C; Fri, 26 May 2017 11:59:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4QBxFcS008682 for ; Fri, 26 May 2017 07:59:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 05BB17DFE7; Fri, 26 May 2017 11:59:15 +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 B14127DFDE for ; Fri, 26 May 2017 11:59:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E28D6448D93 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 E28D6448D93 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 26 May 2017 07:59:02 -0400 Message-Id: <20170526115910.3977-4-jferlan@redhat.com> In-Reply-To: <20170526115910.3977-1-jferlan@redhat.com> References: <20170526115910.3977-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 03/11] interface: Use virInterfaceDefPtr rather than deref from virInterfaceObjPtr 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]); Fri, 26 May 2017 11:59:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We're about to make the obj much more private, so make it easier to see future changes which will require accessors for the obj->def This also includes modifying some interfaces->objs[i]->X references to be obj =3D interfaces->objs[i]; and then def =3D obj->def Signed-off-by: John Ferlan --- src/conf/virinterfaceobj.c | 32 +++++++++++++++++++++----------- src/test/test_driver.c | 12 +++++++++--- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c index 62c3735..ead9512 100644 --- a/src/conf/virinterfaceobj.c +++ b/src/conf/virinterfaceobj.c @@ -72,18 +72,21 @@ virInterfaceObjFindByMACString(virInterfaceObjListPtr i= nterfaces, unsigned int matchct =3D 0; =20 for (i =3D 0; i < interfaces->count; i++) { + virInterfaceObjPtr obj =3D interfaces->objs[i]; + virInterfaceDefPtr def; =20 - virInterfaceObjLock(interfaces->objs[i]); - if (STRCASEEQ(interfaces->objs[i]->def->mac, mac)) { + virInterfaceObjLock(obj); + def =3D obj->def; + if (STRCASEEQ(def->mac, mac)) { matchct++; if (matchct <=3D maxmatches) { - matches[matchct - 1] =3D interfaces->objs[i]; + matches[matchct - 1] =3D obj; /* keep the lock if we're returning object to caller */ /* it is the caller's responsibility to unlock *all* match= es */ continue; } } - virInterfaceObjUnlock(interfaces->objs[i]); + virInterfaceObjUnlock(obj); =20 } return matchct; @@ -97,10 +100,14 @@ virInterfaceObjFindByName(virInterfaceObjListPtr inter= faces, size_t i; =20 for (i =3D 0; i < interfaces->count; i++) { - virInterfaceObjLock(interfaces->objs[i]); - if (STREQ(interfaces->objs[i]->def->name, name)) - return interfaces->objs[i]; - virInterfaceObjUnlock(interfaces->objs[i]); + virInterfaceObjPtr obj =3D interfaces->objs[i]; + virInterfaceDefPtr def; + + virInterfaceObjLock(obj); + def =3D obj->def; + if (STREQ(def->name, name)) + return obj; + virInterfaceObjUnlock(obj); } =20 return NULL; @@ -134,10 +141,10 @@ virInterfaceObjListClone(virInterfaceObjListPtr src, virInterfaceObjListFree(dest); /* start with an empty list */ cnt =3D src->count; for (i =3D 0; i < cnt; i++) { - virInterfaceDefPtr def =3D src->objs[i]->def; + virInterfaceObjPtr srcobj =3D src->objs[i]; virInterfaceDefPtr backup; virInterfaceObjPtr obj; - char *xml =3D virInterfaceDefFormat(def); + char *xml =3D virInterfaceDefFormat(srcobj->def); =20 if (!xml) goto cleanup; @@ -247,9 +254,12 @@ virInterfaceObjGetNames(virInterfaceObjListPtr interfa= ces, =20 for (i =3D 0; i < interfaces->count && nnames < maxnames; i++) { virInterfaceObjPtr obj =3D interfaces->objs[i]; + virInterfaceDefPtr def; + virInterfaceObjLock(obj); + def =3D obj->def; if (wantActive =3D=3D virInterfaceObjIsActive(obj)) { - if (VIR_STRDUP(names[nnames], obj->def->name) < 0) { + if (VIR_STRDUP(names[nnames], def->name) < 0) { virInterfaceObjUnlock(obj); goto failure; } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index da45542..6ff4657 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -3706,12 +3706,14 @@ testInterfaceLookupByName(virConnectPtr conn, { testDriverPtr privconn =3D conn->privateData; virInterfaceObjPtr obj; + virInterfaceDefPtr def; virInterfacePtr ret =3D NULL; =20 if (!(obj =3D testInterfaceObjFindByName(privconn, name))) return NULL; + def =3D obj->def; =20 - ret =3D virGetInterface(conn, obj->def->name, obj->def->mac); + ret =3D virGetInterface(conn, def->name, def->mac); =20 virInterfaceObjUnlock(obj); return ret; @@ -3724,6 +3726,7 @@ testInterfaceLookupByMACString(virConnectPtr conn, { testDriverPtr privconn =3D conn->privateData; virInterfaceObjPtr obj; + virInterfaceDefPtr def; int ifacect; virInterfacePtr ret =3D NULL; =20 @@ -3741,7 +3744,8 @@ testInterfaceLookupByMACString(virConnectPtr conn, goto cleanup; } =20 - ret =3D virGetInterface(conn, obj->def->name, obj->def->mac); + def =3D obj->def; + ret =3D virGetInterface(conn, def->name, def->mac); =20 cleanup: if (obj) @@ -3888,6 +3892,7 @@ testInterfaceDefineXML(virConnectPtr conn, testDriverPtr privconn =3D conn->privateData; virInterfaceDefPtr def; virInterfaceObjPtr obj =3D NULL; + virInterfaceDefPtr objdef; virInterfacePtr ret =3D NULL; =20 virCheckFlags(0, NULL); @@ -3899,8 +3904,9 @@ testInterfaceDefineXML(virConnectPtr conn, if ((obj =3D virInterfaceObjAssignDef(&privconn->ifaces, def)) =3D=3D = NULL) goto cleanup; def =3D NULL; + objdef =3D obj->def; =20 - ret =3D virGetInterface(conn, obj->def->name, obj->def->mac); + ret =3D virGetInterface(conn, objdef->name, objdef->mac); =20 cleanup: virInterfaceDefFree(def); --=20 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list