From nobody Wed May 14 19:18:39 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.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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522675341916382.3407097187667; Mon, 2 Apr 2018 06:22:21 -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 5FCA92F30C3; Mon, 2 Apr 2018 13:22:20 +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 29BE35F7F3; Mon, 2 Apr 2018 13:22:20 +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 BCD6F1800CA0; Mon, 2 Apr 2018 13:22:19 +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 w32DLutE011834 for ; Mon, 2 Apr 2018 09:21:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3C0BD6046B; Mon, 2 Apr 2018 13:21:56 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-52.phx2.redhat.com [10.3.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id F410D600C8 for ; Mon, 2 Apr 2018 13:21:55 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 2 Apr 2018 09:21:49 -0400 Message-Id: <20180402132149.14529-3-jferlan@redhat.com> In-Reply-To: <20180402132149.14529-1-jferlan@redhat.com> References: <20180402132149.14529-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [REPOST PATCH 2/2] vz: Use virDomainObjListFindBy{UUID|ID}Ref 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]); Mon, 02 Apr 2018 13:22:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For vzDomainLookupByID and vzDomainLookupByUUID let's return a locked and referenced @vm object so that callers can then use the common and more consistent virDomainObjEndAPI in order to handle cleanup rather than needing to know that the returned object is locked and calling virObjectUnlock. The LookupByName already returns the ref counted and locked object, so this will make things more consistent. Also adjust the prlsdkHandle{VmState|VmRemoved|Perf}Event APIs in the same manner. Signed-off-by: John Ferlan Reviewed-by: Nikolay Shirokovskiy --- src/vz/vz_driver.c | 8 ++++---- src/vz/vz_sdk.c | 15 ++++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index bcbccf6cc8..736424897a 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -578,7 +578,7 @@ vzDomainLookupByID(virConnectPtr conn, int id) virDomainPtr ret =3D NULL; virDomainObjPtr dom; =20 - dom =3D virDomainObjListFindByID(privconn->driver->domains, id); + dom =3D virDomainObjListFindByIDRef(privconn->driver->domains, id); =20 if (dom =3D=3D NULL) { virReportError(VIR_ERR_NO_DOMAIN, NULL); @@ -591,7 +591,7 @@ vzDomainLookupByID(virConnectPtr conn, int id) ret =3D virGetDomain(conn, dom->def->name, dom->def->uuid, dom->def->i= d); =20 cleanup: - virObjectUnlock(dom); + virDomainObjEndAPI(&dom); return ret; } =20 @@ -602,7 +602,7 @@ vzDomainLookupByUUID(virConnectPtr conn, const unsigned= char *uuid) virDomainPtr ret =3D NULL; virDomainObjPtr dom; =20 - dom =3D virDomainObjListFindByUUID(privconn->driver->domains, uuid); + dom =3D virDomainObjListFindByUUIDRef(privconn->driver->domains, uuid); =20 if (dom =3D=3D NULL) { char uuidstr[VIR_UUID_STRING_BUFLEN]; @@ -618,7 +618,7 @@ vzDomainLookupByUUID(virConnectPtr conn, const unsigned= char *uuid) ret =3D virGetDomain(conn, dom->def->name, dom->def->uuid, dom->def->i= d); =20 cleanup: - virObjectUnlock(dom); + virDomainObjEndAPI(&dom); return ret; } =20 diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index a5b9f2da67..b8f13f88a7 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -2144,7 +2144,7 @@ prlsdkHandleVmStateEvent(vzDriverPtr driver, virDomainEventType lvEventType =3D 0; int lvEventTypeDetails =3D 0; =20 - dom =3D virDomainObjListFindByUUID(driver->domains, uuid); + dom =3D virDomainObjListFindByUUIDRef(driver->domains, uuid); if (dom =3D=3D NULL) return; =20 @@ -2166,7 +2166,7 @@ prlsdkHandleVmStateEvent(vzDriverPtr driver, =20 cleanup: PrlHandle_Free(eventParam); - virObjectUnlock(dom); + virObjectEndAPI(&dom); return; } =20 @@ -2225,7 +2225,7 @@ prlsdkHandleVmRemovedEvent(vzDriverPtr driver, { virDomainObjPtr dom =3D NULL; =20 - dom =3D virDomainObjListFindByUUID(driver->domains, uuid); + dom =3D virDomainObjListFindByUUIDRef(driver->domains, uuid); /* domain was removed from the list from the libvirt * API function in current connection */ if (dom =3D=3D NULL) @@ -2235,6 +2235,7 @@ prlsdkHandleVmRemovedEvent(vzDriverPtr driver, VIR_DOMAIN_EVENT_UNDEFINED_REMOVED); =20 virDomainObjListRemove(driver->domains, dom); + virDomainObjEndAPI(&dom); return; } =20 @@ -2246,7 +2247,7 @@ prlsdkHandlePerfEvent(vzDriverPtr driver, virDomainObjPtr dom =3D NULL; vzDomObjPtr privdom =3D NULL; =20 - if (!(dom =3D virDomainObjListFindByUUID(driver->domains, uuid))) { + if (!(dom =3D virDomainObjListFindByUUIDRef(driver->domains, uuid))) { PrlHandle_Free(event); return; } @@ -2255,7 +2256,7 @@ prlsdkHandlePerfEvent(vzDriverPtr driver, PrlHandle_Free(privdom->stats); privdom->stats =3D event; =20 - virObjectUnlock(dom); + virDomainObjEndAPI(&dom); } =20 static void @@ -2269,7 +2270,7 @@ prlsdkHandleMigrationProgress(vzDriverPtr driver, PRL_HANDLE param =3D PRL_INVALID_HANDLE; PRL_RESULT pret; =20 - if (!(dom =3D virDomainObjListFindByUUID(driver->domains, uuid))) + if (!(dom =3D virDomainObjListFindByUUIDRef(driver->domains, uuid))) return; =20 pret =3D PrlEvent_GetParam(event, 0, ¶m); @@ -2283,7 +2284,7 @@ prlsdkHandleMigrationProgress(vzDriverPtr driver, =20 cleanup: PrlHandle_Free(param); - virObjectUnlock(dom); + virDomainObjEndAPI(&dom); } =20 static PRL_RESULT --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list