From nobody Mon Feb 9 13:01:46 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 1493159829347833.4809862465164; Tue, 25 Apr 2017 15:37:09 -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 4BF1F3DBD5; Tue, 25 Apr 2017 22:37:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1F5BD19EE3; Tue, 25 Apr 2017 22:37:07 +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 AFF114E9BD; Tue, 25 Apr 2017 22:37:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3PMb33K029194 for ; Tue, 25 Apr 2017 18:37:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id AB1A01811B; Tue, 25 Apr 2017 22:37:03 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-16.phx2.redhat.com [10.3.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6643760E3E for ; Tue, 25 Apr 2017 22:37:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4BF1F3DBD5 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.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 4BF1F3DBD5 From: John Ferlan To: libvir-list@redhat.com Date: Tue, 25 Apr 2017 18:36:51 -0400 Message-Id: <20170425223656.20740-4-jferlan@redhat.com> In-Reply-To: <20170425223656.20740-1-jferlan@redhat.com> References: <20170425223656.20740-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/8] 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 25 Apr 2017 22:37:08 +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 | 33 +++++++++++++++++++++------------ src/test/test_driver.c | 12 +++++++++--- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c index 62c3735..36131af 100644 --- a/src/conf/virinterfaceobj.c +++ b/src/conf/virinterfaceobj.c @@ -55,7 +55,6 @@ virInterfaceObjFree(virInterfaceObjPtr obj) { if (!obj) return; - virInterfaceDefFree(obj->def); virMutexDestroy(&obj->lock); VIR_FREE(obj); @@ -72,18 +71,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 +99,14 @@ virInterfaceObjFindByName(virInterfaceObjListPtr interf= aces, 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 +140,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 +253,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.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list