From nobody Sun Apr 28 08:22:51 2024 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521647634641533.493169266945; Wed, 21 Mar 2018 08:53:54 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 30691C0587E5; Wed, 21 Mar 2018 15:53:53 +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 CE91B611A0; Wed, 21 Mar 2018 15:53:52 +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 8A80A4CA9B; Wed, 21 Mar 2018 15:53:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2LFrfA4008255 for ; Wed, 21 Mar 2018 11:53:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7B4B38474F; Wed, 21 Mar 2018 15:53:41 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-18.phx2.redhat.com [10.3.116.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C7E48474D for ; Wed, 21 Mar 2018 15:53:41 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 21 Mar 2018 11:53:32 -0400 Message-Id: <20180321155335.17203-2-jferlan@redhat.com> In-Reply-To: <20180321155335.17203-1-jferlan@redhat.com> References: <20180321155335.17203-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/4] secret: Return with locked obj from virSecretObjListRemove 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 21 Mar 2018 15:53:53 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than unlock the object that was expected to be locked on input, let the caller perform the unlock or more succinctly a virSecretObjEndAPI on the object which will perform the Unref and Unlock and clear the @obj. Also clean up the virSecretObjListRemove function comments. Signed-off-by: John Ferlan --- src/conf/virsecretobj.c | 15 ++++++++------- src/secret/secret_driver.c | 4 ---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index 47e0b28968..49c341484b 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -284,11 +284,14 @@ virSecretObjListFindByUsage(virSecretObjListPtr secre= ts, /* * virSecretObjListRemove: * @secrets: list of secret objects - * @secret: a secret object + * @obj: a secret object * - * Remove the object from the hash table. The caller must hold the lock - * on the driver owning @secrets and must have also locked @secret to - * ensure no one else is either waiting for @secret or still using it. + * Remove @obj from the secret obj list hash table. The caller must hold + * the lock on @obj to ensure no one else is either waiting for @obj or + * still using it. + * + * Upon return the @obj remains locked with at least 1 reference and + * the caller is expected to use virSecretObjEndAPI on it. */ void virSecretObjListRemove(virSecretObjListPtr secrets, @@ -308,7 +311,6 @@ virSecretObjListRemove(virSecretObjListPtr secrets, virObjectRWLockWrite(secrets); virObjectLock(obj); virHashRemoveEntry(secrets->objs, uuidstr); - virObjectUnlock(obj); virObjectUnref(obj); virObjectRWUnlock(secrets); } @@ -927,8 +929,7 @@ virSecretLoad(virSecretObjListPtr secrets, =20 if (virSecretLoadValue(obj) < 0) { virSecretObjListRemove(secrets, obj); - virObjectUnref(obj); - obj =3D NULL; + virSecretObjEndAPI(&obj); /* clears obj */ } =20 cleanup: diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index 23a3c9bdad..7c611253aa 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -271,8 +271,6 @@ secretDefineXML(virConnectPtr conn, VIR_STEAL_PTR(def, objDef); } else { virSecretObjListRemove(driver->secrets, obj); - virObjectUnref(obj); - obj =3D NULL; } =20 cleanup: @@ -413,8 +411,6 @@ secretUndefine(virSecretPtr secret) virSecretObjDeleteData(obj); =20 virSecretObjListRemove(driver->secrets, obj); - virObjectUnref(obj); - obj =3D NULL; =20 ret =3D 0; =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 08:22:51 2024 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152164762767418.710658334352843; Wed, 21 Mar 2018 08:53:47 -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 4913481255; Wed, 21 Mar 2018 15:53:46 +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 219E584748; Wed, 21 Mar 2018 15:53:46 +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 AA96D181BA03; Wed, 21 Mar 2018 15:53:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2LFrgja008265 for ; Wed, 21 Mar 2018 11:53:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4B54584742; Wed, 21 Mar 2018 15:53:42 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-18.phx2.redhat.com [10.3.116.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 065828474C for ; Wed, 21 Mar 2018 15:53:41 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 21 Mar 2018 11:53:33 -0400 Message-Id: <20180321155335.17203-3-jferlan@redhat.com> In-Reply-To: <20180321155335.17203-1-jferlan@redhat.com> References: <20180321155335.17203-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/4] interface: Return with locked obj from virInterfaceObjListRemove 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.25]); Wed, 21 Mar 2018 15:53:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than unlock the object that was expected to be locked on input, let the caller perform the unlock or more succinctly a virInterfaceObjEndAPI on the object which will perform the Unref and Unlock and clear the @obj. Also add comments to the virInterfaceObjListRemove. Signed-off-by: John Ferlan --- src/conf/virinterfaceobj.c | 13 ++++++++++++- src/test/test_driver.c | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c index f90c0bd9c4..28fbbaa08b 100644 --- a/src/conf/virinterfaceobj.c +++ b/src/conf/virinterfaceobj.c @@ -358,6 +358,18 @@ virInterfaceObjListAssignDef(virInterfaceObjListPtr in= terfaces, } =20 =20 +/* + * virInterfaceObjListRemove: + * @interfaces: list of interface objects + * @obj: an interface object + * + * Remove @obj from the interface obj list hash table. The caller must hold + * the lock on @obj to ensure no one else is either waiting for @obj or + * still using it. + * + * Upon return the @obj remains locked with at least 1 reference and + * the caller is expected to use virInterfaceObjEndAPI on it. + */ void virInterfaceObjListRemove(virInterfaceObjListPtr interfaces, virInterfaceObjPtr obj) @@ -370,7 +382,6 @@ virInterfaceObjListRemove(virInterfaceObjListPtr interf= aces, virObjectRWLockWrite(interfaces); virObjectLock(obj); virHashRemoveEntry(interfaces->objsName, obj->def->name); - virObjectUnlock(obj); virObjectUnref(obj); virObjectRWUnlock(interfaces); } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 4de0cc5333..b0aa350d95 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4085,7 +4085,7 @@ testInterfaceUndefine(virInterfacePtr iface) return -1; =20 virInterfaceObjListRemove(privconn->ifaces, obj); - virObjectUnref(obj); + virInterfaceObjEndAPI(&obj); =20 return 0; } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 08:22:51 2024 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521647634600787.222454385373; Wed, 21 Mar 2018 08:53:54 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E71055D697; Wed, 21 Mar 2018 15:53:52 +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 B88E78272B; Wed, 21 Mar 2018 15:53:52 +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 6B9D24CA99; Wed, 21 Mar 2018 15:53:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2LFrgbH008271 for ; Wed, 21 Mar 2018 11:53:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id AA41F84740; Wed, 21 Mar 2018 15:53:42 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-18.phx2.redhat.com [10.3.116.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BBE684747 for ; Wed, 21 Mar 2018 15:53:42 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 21 Mar 2018 11:53:34 -0400 Message-Id: <20180321155335.17203-4-jferlan@redhat.com> In-Reply-To: <20180321155335.17203-1-jferlan@redhat.com> References: <20180321155335.17203-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/4] nodedev: Return with locked obj from virNodeDeviceObjListRemove 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 21 Mar 2018 15:53:53 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than unlock the object that was expected to be locked on input, let the caller perform the unlock or more succinctly a virNodeDeviceObjEndAPI on the object which will perform the Unref and Unlock and clear the @obj. Also add comments for virNodeDeviceObjListRemove. Signed-off-by: John Ferlan --- src/conf/virnodedeviceobj.c | 13 ++++++++++++- src/node_device/node_device_hal.c | 4 ++-- src/node_device/node_device_udev.c | 2 +- src/test/test_driver.c | 4 +--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index ad0f27ee47..a5939c5de5 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -470,6 +470,18 @@ virNodeDeviceObjListAssignDef(virNodeDeviceObjListPtr = devs, } =20 =20 +/* + * virNodeDeviceObjListRemove: + * @devs: list of node device objects + * @obj: a node device object + * + * Remove @obj from the node device obj list hash table. The caller must h= old + * the lock on @obj to ensure no one else is either waiting for @obj or + * still using it. + * + * Upon return the @obj remains locked with at least 1 reference and + * the caller is expected to use virNodeDeviceObjEndAPI on it. + */ void virNodeDeviceObjListRemove(virNodeDeviceObjListPtr devs, virNodeDeviceObjPtr obj) @@ -485,7 +497,6 @@ virNodeDeviceObjListRemove(virNodeDeviceObjListPtr devs, virObjectRWLockWrite(devs); virObjectLock(obj); virHashRemoveEntry(devs->objs, def->name); - virObjectUnlock(obj); virObjectUnref(obj); virObjectRWUnlock(devs); } diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_devic= e_hal.c index 6ad56f4166..8aac806a64 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -512,7 +512,7 @@ dev_refresh(const char *udi) * to sub-capabilities (like net.80203) is nasty ... so avoid it. */ virNodeDeviceObjListRemove(driver->devs, obj); - virObjectUnref(obj); + virNodeDeviceObjEndAPI(&obj); dev_create(udi); } else { VIR_DEBUG("no device named %s", name); @@ -541,7 +541,7 @@ device_removed(LibHalContext *ctx ATTRIBUTE_UNUSED, virNodeDeviceObjListRemove(driver->devs, obj); else VIR_DEBUG("no device named %s", name); - virObjectUnref(obj); + virNodeDeviceObjEndAPI(&obj); } =20 =20 diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index e87eb32a85..1151b04ecb 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1298,7 +1298,7 @@ udevRemoveOneDevice(struct udev_device *device) VIR_DEBUG("Removing device '%s' with sysfs path '%s'", def->name, name); virNodeDeviceObjListRemove(driver->devs, obj); - virObjectUnref(obj); + virNodeDeviceObjEndAPI(&obj); =20 if (event) virObjectEventStateQueue(driver->nodeDeviceEventState, event); diff --git a/src/test/test_driver.c b/src/test/test_driver.c index b0aa350d95..a7aaabe09b 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4716,7 +4716,7 @@ testDestroyVport(testDriverPtr privconn, 0); =20 virNodeDeviceObjListRemove(privconn->devs, obj); - virObjectUnref(obj); + virNodeDeviceObjEndAPI(&obj); =20 testObjectEventQueue(privconn, event); return 0; @@ -5695,8 +5695,6 @@ testNodeDeviceDestroy(virNodeDevicePtr dev) =20 virObjectLock(obj); virNodeDeviceObjListRemove(driver->devs, obj); - virObjectUnref(obj); - obj =3D NULL; =20 cleanup: virNodeDeviceObjEndAPI(&obj); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 08:22:51 2024 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152164763746146.641006783678904; Wed, 21 Mar 2018 08:53:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3616C550CD; Wed, 21 Mar 2018 15:53:56 +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 EFD09608F2; Wed, 21 Mar 2018 15:53:55 +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 A56D3181BA04; Wed, 21 Mar 2018 15:53:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2LFrhDR008282 for ; Wed, 21 Mar 2018 11:53:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1BC1484742; Wed, 21 Mar 2018 15:53:43 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-18.phx2.redhat.com [10.3.116.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id D103084740 for ; Wed, 21 Mar 2018 15:53:42 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 21 Mar 2018 11:53:35 -0400 Message-Id: <20180321155335.17203-5-jferlan@redhat.com> In-Reply-To: <20180321155335.17203-1-jferlan@redhat.com> References: <20180321155335.17203-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/4] storagepool: Return with locked obj from virStoragePoolObjRemove 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 21 Mar 2018 15:53:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than unlock the object that was expected to be locked on input, let the caller perform the unlock or more succinctly a virStoragePoolObjEndAPI on the object which will perform the Unref and Unlock and clear the @obj. Also add comments for virStoragePoolObjRemove. Signed-off-by: John Ferlan --- src/conf/virstorageobj.c | 17 ++++++++++++++--- src/storage/storage_driver.c | 12 +----------- src/test/test_driver.c | 14 +++----------- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 799b8c9fa3..c057c6b3ed 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -517,6 +517,18 @@ virStoragePoolObjListSearch(virStoragePoolObjListPtr p= ools, } =20 =20 +/* + * virStoragePoolObjRemove: + * @pools: list of storage pool objects + * @obj: a storage pool object + * + * Remove @obj from the storage pool obj list hash tables. The caller must + * hold the lock on @obj to ensure no one else is either waiting for @obj = or + * still using it. + * + * Upon return the @obj remains locked with at least 1 reference and + * the caller is expected to use virStoragePoolObjEndAPI on it. + */ void virStoragePoolObjRemove(virStoragePoolObjListPtr pools, virStoragePoolObjPtr obj) @@ -530,7 +542,6 @@ virStoragePoolObjRemove(virStoragePoolObjListPtr pools, virObjectLock(obj); virHashRemoveEntry(pools->objs, uuidstr); virHashRemoveEntry(pools->objsName, obj->def->name); - virObjectUnlock(obj); virObjectUnref(obj); virObjectRWUnlock(pools); } @@ -1138,13 +1149,13 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pool= s, VIR_FREE(obj->configFile); /* for driver reload */ if (VIR_STRDUP(obj->configFile, path) < 0) { virStoragePoolObjRemove(pools, obj); - virObjectUnref(obj); + virStoragePoolObjEndAPI(&obj); return NULL; } VIR_FREE(obj->autostartLink); /* for driver reload */ if (VIR_STRDUP(obj->autostartLink, autostartLink) < 0) { virStoragePoolObjRemove(pools, obj); - virObjectUnref(obj); + virStoragePoolObjEndAPI(&obj); return NULL; } =20 diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index d5e38af5aa..b2946d0509 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -94,7 +94,7 @@ virStoragePoolUpdateInactive(virStoragePoolObjPtr *objptr) =20 if (!virStoragePoolObjGetConfigFile(obj)) { virStoragePoolObjRemove(driver->pools, obj); - virObjectUnref(obj); + virStoragePoolObjEndAPI(&obj); *objptr =3D NULL; } else if (virStoragePoolObjGetNewDef(obj)) { virStoragePoolObjDefUseNewDef(obj); @@ -746,8 +746,6 @@ storagePoolCreateXML(virConnectPtr conn, (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD)) { if (backend->buildPool(obj, build_flags) < 0) { virStoragePoolObjRemove(driver->pools, obj); - virObjectUnref(obj); - obj =3D NULL; goto cleanup; } } @@ -756,8 +754,6 @@ storagePoolCreateXML(virConnectPtr conn, if (backend->startPool && backend->startPool(obj) < 0) { virStoragePoolObjRemove(driver->pools, obj); - virObjectUnref(obj); - obj =3D NULL; goto cleanup; } =20 @@ -771,8 +767,6 @@ storagePoolCreateXML(virConnectPtr conn, if (backend->stopPool) backend->stopPool(obj); virStoragePoolObjRemove(driver->pools, obj); - virObjectUnref(obj); - obj =3D NULL; goto cleanup; } =20 @@ -833,8 +827,6 @@ storagePoolDefineXML(virConnectPtr conn, =20 if (virStoragePoolObjSaveDef(driver, obj, def) < 0) { virStoragePoolObjRemove(driver->pools, obj); - virObjectUnref(obj); - obj =3D NULL; goto cleanup; } =20 @@ -901,8 +893,6 @@ storagePoolUndefine(virStoragePoolPtr pool) =20 VIR_INFO("Undefining storage pool '%s'", def->name); virStoragePoolObjRemove(driver->pools, obj); - virObjectUnref(obj); - obj =3D NULL; ret =3D 0; =20 cleanup: diff --git a/src/test/test_driver.c b/src/test/test_driver.c index a7aaabe09b..4b7f8c4244 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4556,16 +4556,12 @@ testStoragePoolCreateXML(virConnectPtr conn, def->source.adapter.data.fchost.wwnn, def->source.adapter.data.fchost.wwpn) < 0) { virStoragePoolObjRemove(privconn->pools, obj); - virObjectUnref(obj); - obj =3D NULL; goto cleanup; } } =20 if (testStoragePoolObjSetDefaults(obj) =3D=3D -1) { virStoragePoolObjRemove(privconn->pools, obj); - virObjectUnref(obj); - obj =3D NULL; goto cleanup; } =20 @@ -4627,8 +4623,6 @@ testStoragePoolDefineXML(virConnectPtr conn, =20 if (testStoragePoolObjSetDefaults(obj) =3D=3D -1) { virStoragePoolObjRemove(privconn->pools, obj); - virObjectUnref(obj); - obj =3D NULL; goto cleanup; } =20 @@ -4658,7 +4652,7 @@ testStoragePoolUndefine(virStoragePoolPtr pool) 0); =20 virStoragePoolObjRemove(privconn->pools, obj); - virObjectUnref(obj); + virStoragePoolObjEndAPI(&obj); =20 testObjectEventQueue(privconn, event); return 0; @@ -4750,11 +4744,9 @@ testStoragePoolDestroy(virStoragePoolPtr pool) VIR_STORAGE_POOL_EVENT_STOPPED, 0); =20 - if (!(virStoragePoolObjGetConfigFile(obj))) { + if (!(virStoragePoolObjGetConfigFile(obj))) virStoragePoolObjRemove(privconn->pools, obj); - virObjectUnref(obj); - obj =3D NULL; - } + ret =3D 0; =20 cleanup: --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list