From nobody Sat May 4 23:55:43 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522674390384478.43722738178747; Mon, 2 Apr 2018 06:06:30 -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 554982F30B0; Mon, 2 Apr 2018 13:06:28 +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 67A315D9C8; Mon, 2 Apr 2018 13:06:27 +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 CFFF54CA97; Mon, 2 Apr 2018 13:06:24 +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 w32D6N1I007455 for ; Mon, 2 Apr 2018 09:06:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 338326046B; Mon, 2 Apr 2018 13:06:23 +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 EA1B4600C8 for ; Mon, 2 Apr 2018 13:06:22 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 2 Apr 2018 09:06:12 -0400 Message-Id: <20180402130616.25745-2-jferlan@redhat.com> In-Reply-To: <20180402130616.25745-1-jferlan@redhat.com> References: <20180402130616.25745-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/5] uml: Fix umlProcessAutoDestroyDom dom processing 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.29]); Mon, 02 Apr 2018 13:06:29 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There's no need to check if @dom exists before trying to call virDomainObjListRemove since it must exist due to prior checks. Additionally, if we do remove the @dom, then set it to NULL so that the virObjectUnlock isn't referencing something that is deleted. Signed-off-by: John Ferlan Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Marc Hartmayer --- src/uml/uml_driver.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index ab7fa7f273..ff2e7ac66b 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -747,8 +747,10 @@ static int umlProcessAutoDestroyDom(void *payload, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_DESTROYED); =20 - if (dom && !dom->persistent) + if (!dom->persistent) { virDomainObjListRemove(data->driver->domains, dom); + dom =3D NULL; + } =20 if (dom) virObjectUnlock(dom); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:55:43 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522674403887904.5540044706652; Mon, 2 Apr 2018 06:06:43 -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 C52B38046B; Mon, 2 Apr 2018 13:06:41 +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 9255260C80; Mon, 2 Apr 2018 13:06:41 +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 478F14CA9C; Mon, 2 Apr 2018 13:06:41 +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 w32D6NZV007471 for ; Mon, 2 Apr 2018 09:06:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 976656046B; Mon, 2 Apr 2018 13:06:23 +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 5AFFF600C8 for ; Mon, 2 Apr 2018 13:06:23 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 2 Apr 2018 09:06:13 -0400 Message-Id: <20180402130616.25745-3-jferlan@redhat.com> In-Reply-To: <20180402130616.25745-1-jferlan@redhat.com> References: <20180402130616.25745-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/5] uml: Fix umlInotifyEvent dom object handling 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.28]); Mon, 02 Apr 2018 13:06:42 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The virDomainObjListFindByName will return a locked and reffed object. If we call virDomainObjListRemove that will unlock the object upon return, thus we need to relock the object before making the call to virDomainObjEndAPI. Signed-off-by: John Ferlan Reviewed-by: Daniel P. Berrang=C3=A9 --- src/uml/uml_driver.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index ff2e7ac66b..b84585d728 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -346,8 +346,10 @@ umlInotifyEvent(int watch, event =3D virDomainEventLifecycleNewFromObj(dom, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_SHUT= DOWN); - if (!dom->persistent) + if (!dom->persistent) { virDomainObjListRemove(driver->domains, dom); + virObjectLock(dom); + } } else if (e.mask & (IN_CREATE | IN_MODIFY)) { VIR_DEBUG("Got inotify domain startup '%s'", name); if (virDomainObjIsActive(dom)) { @@ -377,8 +379,10 @@ umlInotifyEvent(int watch, event =3D virDomainEventLifecycleNewFromObj(dom, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_= FAILED); - if (!dom->persistent) + if (!dom->persistent) { virDomainObjListRemove(driver->domains, dom); + virObjectLock(dom); + } } else if (umlIdentifyChrPTY(driver, dom) < 0) { VIR_WARN("Could not identify character devices for new dom= ain"); umlShutdownVMDaemon(driver, dom, @@ -387,8 +391,10 @@ umlInotifyEvent(int watch, event =3D virDomainEventLifecycleNewFromObj(dom, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_= FAILED); - if (!dom->persistent) + if (!dom->persistent) { virDomainObjListRemove(driver->domains, dom); + virObjectLock(dom); + } } } virDomainObjEndAPI(&dom); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:55:43 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522674408715859.9233806935097; Mon, 2 Apr 2018 06:06:48 -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 E8FB98047E; Mon, 2 Apr 2018 13:06:46 +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 6BEE75D725; Mon, 2 Apr 2018 13:06: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 DEFEF4CAA1; Mon, 2 Apr 2018 13:06: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 w32D6Ocq007488 for ; Mon, 2 Apr 2018 09:06:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3D58F600C8; Mon, 2 Apr 2018 13:06:24 +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 EF30C6046B for ; Mon, 2 Apr 2018 13:06:23 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 2 Apr 2018 09:06:14 -0400 Message-Id: <20180402130616.25745-4-jferlan@redhat.com> In-Reply-To: <20180402130616.25745-1-jferlan@redhat.com> References: <20180402130616.25745-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 3/5] uml: Create accessors to virDomainObjListFindByUUID 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.28]); Mon, 02 Apr 2018 13:06:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than repeat code throughout, create and use a couple of accessors in order to lookup by UUID. This will also generate a common error message including the failed uuidstr for lookup rather than just returning nothing in some instances. Signed-off-by: John Ferlan Reviewed-by: Daniel P. Berrang=C3=A9 --- src/uml/uml_driver.c | 244 +++++++++++++++--------------------------------= ---- 1 file changed, 70 insertions(+), 174 deletions(-) diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index b84585d728..ad526a1e6b 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -163,6 +163,39 @@ umlVMDriverUnlock(void) umlDriverUnlock(uml_driver); } =20 + +static virDomainObjPtr +umlDomObjFromDomainLocked(struct uml_driver *driver, + const unsigned char *uuid) +{ + virDomainObjPtr vm; + char uuidstr[VIR_UUID_STRING_BUFLEN]; + + if (!(vm =3D virDomainObjListFindByUUID(driver->domains, uuid))) { + virUUIDFormat(uuid, uuidstr); + + virReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s'"), uuidstr); + return NULL; + } + + return vm; +} + + +static virDomainObjPtr +umlDomObjFromDomain(struct uml_driver *driver, + const unsigned char *uuid) +{ + virDomainObjPtr vm; + + umlDriverLock(driver); + vm =3D umlDomObjFromDomainLocked(driver, uuid); + umlDriverUnlock(driver); + return vm; +} + + static virNWFilterCallbackDriver umlCallbackDriver =3D { .name =3D "UML", .vmFilterRebuild =3D umlVMFilterRebuild, @@ -1376,20 +1409,14 @@ static virDomainPtr umlDomainLookupByID(virConnectP= tr conn, } =20 static virDomainPtr umlDomainLookupByUUID(virConnectPtr conn, - const unsigned char *uuid) + const unsigned char *uuid) { struct uml_driver *driver =3D (struct uml_driver *)conn->privateData; virDomainObjPtr vm; virDomainPtr dom =3D NULL; =20 - umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, uuid); - umlDriverUnlock(driver); - - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, NULL); - goto cleanup; - } + if (!(vm =3D umlDomObjFromDomain(driver, uuid))) + return NULL; =20 if (virDomainLookupByUUIDEnsureACL(conn, vm->def) < 0) goto cleanup; @@ -1435,13 +1462,8 @@ static int umlDomainIsActive(virDomainPtr dom) virDomainObjPtr obj; int ret =3D -1; =20 - umlDriverLock(driver); - obj =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - umlDriverUnlock(driver); - if (!obj) { - virReportError(VIR_ERR_NO_DOMAIN, NULL); - goto cleanup; - } + if (!(obj =3D umlDomObjFromDomain(driver, dom->uuid))) + return -1; =20 if (virDomainIsActiveEnsureACL(dom->conn, obj->def) < 0) goto cleanup; @@ -1461,13 +1483,8 @@ static int umlDomainIsPersistent(virDomainPtr dom) virDomainObjPtr obj; int ret =3D -1; =20 - umlDriverLock(driver); - obj =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - umlDriverUnlock(driver); - if (!obj) { - virReportError(VIR_ERR_NO_DOMAIN, NULL); - goto cleanup; - } + if (!(obj =3D umlDomObjFromDomain(driver, dom->uuid))) + return -1; =20 if (virDomainIsPersistentEnsureACL(dom->conn, obj->def) < 0) goto cleanup; @@ -1486,13 +1503,8 @@ static int umlDomainIsUpdated(virDomainPtr dom) virDomainObjPtr obj; int ret =3D -1; =20 - umlDriverLock(driver); - obj =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - umlDriverUnlock(driver); - if (!obj) { - virReportError(VIR_ERR_NO_DOMAIN, NULL); - goto cleanup; - } + if (!(obj =3D umlDomObjFromDomain(driver, dom->uuid))) + return -1; =20 if (virDomainIsUpdatedEnsureACL(dom->conn, obj->def) < 0) goto cleanup; @@ -1645,14 +1657,8 @@ static int umlDomainShutdownFlags(virDomainPtr dom, =20 virCheckFlags(0, -1); =20 - umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - umlDriverUnlock(driver); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, - _("no domain with matching id %d"), dom->id); - goto cleanup; - } + if (!(vm =3D umlDomObjFromDomain(driver, dom->uuid))) + return -1; =20 if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; @@ -1691,12 +1697,8 @@ umlDomainDestroyFlags(virDomainPtr dom, virCheckFlags(0, -1); =20 umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, - _("no domain with matching id %d"), dom->id); - goto cleanup; - } + if (!(vm =3D umlDomObjFromDomainLocked(driver, dom->uuid))) + return -1; =20 if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1734,14 +1736,8 @@ static char *umlDomainGetOSType(virDomainPtr dom) { virDomainObjPtr vm; char *type =3D NULL; =20 - umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - umlDriverUnlock(driver); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); - goto cleanup; - } + if (!(vm =3D umlDomObjFromDomain(driver, dom->uuid))) + return NULL; =20 if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1763,18 +1759,8 @@ umlDomainGetMaxMemory(virDomainPtr dom) virDomainObjPtr vm; unsigned long long ret =3D 0; =20 - umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - umlDriverUnlock(driver); - - if (!vm) { - char uuidstr[VIR_UUID_STRING_BUFLEN]; - - virUUIDFormat(dom->uuid, uuidstr); - virReportError(VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); - goto cleanup; - } + if (!(vm =3D umlDomObjFromDomain(driver, dom->uuid))) + return -1; =20 if (virDomainGetMaxMemoryEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1793,18 +1779,8 @@ static int umlDomainSetMaxMemory(virDomainPtr dom, u= nsigned long newmax) virDomainObjPtr vm; int ret =3D -1; =20 - umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - umlDriverUnlock(driver); - - if (!vm) { - char uuidstr[VIR_UUID_STRING_BUFLEN]; - - virUUIDFormat(dom->uuid, uuidstr); - virReportError(VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); - goto cleanup; - } + if (!(vm =3D umlDomObjFromDomain(driver, dom->uuid))) + return -1; =20 if (virDomainSetMaxMemoryEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1830,18 +1806,8 @@ static int umlDomainSetMemory(virDomainPtr dom, unsi= gned long newmem) virDomainObjPtr vm; int ret =3D -1; =20 - umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - umlDriverUnlock(driver); - - if (!vm) { - char uuidstr[VIR_UUID_STRING_BUFLEN]; - - virUUIDFormat(dom->uuid, uuidstr); - virReportError(VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); - goto cleanup; - } + if (!(vm =3D umlDomObjFromDomain(driver, dom->uuid))) + return -1; =20 if (virDomainSetMemoryEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1874,15 +1840,8 @@ static int umlDomainGetInfo(virDomainPtr dom, virDomainObjPtr vm; int ret =3D -1; =20 - umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - umlDriverUnlock(driver); - - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); - goto cleanup; - } + if (!(vm =3D umlDomObjFromDomain(driver, dom->uuid))) + return -1; =20 if (virDomainGetInfoEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1923,15 +1882,8 @@ umlDomainGetState(virDomainPtr dom, =20 virCheckFlags(0, -1); =20 - umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - umlDriverUnlock(driver); - - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); - goto cleanup; - } + if (!(vm =3D umlDomObjFromDomain(driver, dom->uuid))) + return -1; =20 if (virDomainGetStateEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -1956,14 +1908,8 @@ static char *umlDomainGetXMLDesc(virDomainPtr dom, /* Flags checked by virDomainDefFormat */ =20 umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - umlDriverUnlock(driver); - - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); + if (!(vm =3D umlDomObjFromDomainLocked(driver, dom->uuid))) goto cleanup; - } =20 if (virDomainGetXMLDescEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; @@ -2023,13 +1969,8 @@ static int umlDomainCreateWithFlags(virDomainPtr dom= , unsigned int flags) =20 virNWFilterReadLockFilterUpdates(); umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); + if (!(vm =3D umlDomObjFromDomainLocked(driver, dom->uuid))) goto cleanup; - } =20 if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -2123,12 +2064,8 @@ static int umlDomainUndefineFlags(virDomainPtr dom, virCheckFlags(0, -1); =20 umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); + if (!(vm =3D umlDomObjFromDomainLocked(driver, dom->uuid))) goto cleanup; - } =20 if (virDomainUndefineFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -2221,14 +2158,8 @@ static int umlDomainAttachDevice(virDomainPtr dom, c= onst char *xml) =20 umlDriverLock(driver); =20 - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - char uuidstr[VIR_UUID_STRING_BUFLEN]; - virUUIDFormat(dom->uuid, uuidstr); - virReportError(VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + if (!(vm =3D umlDomObjFromDomainLocked(driver, dom->uuid))) goto cleanup; - } =20 if (virDomainAttachDeviceEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -2341,14 +2272,8 @@ static int umlDomainDetachDevice(virDomainPtr dom, c= onst char *xml) int ret =3D -1; =20 umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - char uuidstr[VIR_UUID_STRING_BUFLEN]; - virUUIDFormat(dom->uuid, uuidstr); - virReportError(VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + if (!(vm =3D umlDomObjFromDomainLocked(driver, dom->uuid))) goto cleanup; - } =20 if (virDomainDetachDeviceEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -2411,13 +2336,8 @@ static int umlDomainGetAutostart(virDomainPtr dom, int ret =3D -1; =20 umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); + if (!(vm =3D umlDomObjFromDomainLocked(driver, dom->uuid))) goto cleanup; - } =20 if (virDomainGetAutostartEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -2441,13 +2361,8 @@ static int umlDomainSetAutostart(virDomainPtr dom, int ret =3D -1; =20 umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); + if (!(vm =3D umlDomObjFromDomainLocked(driver, dom->uuid))) goto cleanup; - } =20 if (virDomainSetAutostartEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -2517,15 +2432,8 @@ umlDomainBlockPeek(virDomainPtr dom, =20 virCheckFlags(0, -1); =20 - umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - umlDriverUnlock(driver); - - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); - goto cleanup; - } + if (!(vm =3D umlDomObjFromDomain(driver, dom->uuid))) + return -1; =20 if (virDomainBlockPeekEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -2581,7 +2489,6 @@ umlDomainOpenConsole(virDomainPtr dom, { struct uml_driver *driver =3D dom->conn->privateData; virDomainObjPtr vm =3D NULL; - char uuidstr[VIR_UUID_STRING_BUFLEN]; int ret =3D -1; virDomainChrDefPtr chr =3D NULL; size_t i; @@ -2589,13 +2496,8 @@ umlDomainOpenConsole(virDomainPtr dom, virCheckFlags(0, -1); =20 umlDriverLock(driver); - virUUIDFormat(dom->uuid, uuidstr); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + if (!(vm =3D umlDomObjFromDomainLocked(driver, dom->uuid))) goto cleanup; - } =20 if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -2932,14 +2834,8 @@ umlDomainHasManagedSaveImage(virDomainPtr dom, unsig= ned int flags) =20 virCheckFlags(0, -1); =20 - umlDriverLock(driver); - vm =3D virDomainObjListFindByUUID(driver->domains, dom->uuid); - umlDriverUnlock(driver); - - if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, NULL); - goto cleanup; - } + if (!(vm =3D umlDomObjFromDomain(driver, dom->uuid))) + return -1; =20 if (virDomainHasManagedSaveImageEnsureACL(dom->conn, vm->def) < 0) goto cleanup; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:55:43 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522674475257968.1406699411882; Mon, 2 Apr 2018 06:07:55 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B7D4AC058EA8; Mon, 2 Apr 2018 13:07:34 +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 86F737CA43; Mon, 2 Apr 2018 13:07:34 +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 204634CA99; Mon, 2 Apr 2018 13:07:34 +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 w32D6Osu007548 for ; Mon, 2 Apr 2018 09:06:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9D51B60637; Mon, 2 Apr 2018 13:06:24 +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 6003B600C8 for ; Mon, 2 Apr 2018 13:06:24 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 2 Apr 2018 09:06:15 -0400 Message-Id: <20180402130616.25745-5-jferlan@redhat.com> In-Reply-To: <20180402130616.25745-1-jferlan@redhat.com> References: <20180402130616.25745-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 4/5] uml: Add more specific error message on failed FindBy call 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 02 Apr 2018 13:07:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than an empty failed to find, let's provide a bit more knowledge about what we failed to find by using the name string or the id value. Signed-off-by: John Ferlan Reviewed-by: Daniel P. Berrang=C3=A9 --- src/uml/uml_driver.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index ad526a1e6b..b81da7cb2e 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -1393,7 +1393,8 @@ static virDomainPtr umlDomainLookupByID(virConnectPtr= conn, umlDriverUnlock(driver); =20 if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, NULL); + virReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching id '%d'"), id); goto cleanup; } =20 @@ -1441,7 +1442,8 @@ static virDomainPtr umlDomainLookupByName(virConnectP= tr conn, umlDriverUnlock(driver); =20 if (!vm) { - virReportError(VIR_ERR_NO_DOMAIN, NULL); + virReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching name '%s'"), name); goto cleanup; } =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:55:43 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152267441368056.83952121089112; Mon, 2 Apr 2018 06:06:53 -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 1107F83F3E; Mon, 2 Apr 2018 13:06:52 +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 CF30260F9A; Mon, 2 Apr 2018 13:06:51 +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 507FE1800CA0; Mon, 2 Apr 2018 13:06:51 +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 w32D6PKL007645 for ; Mon, 2 Apr 2018 09:06:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0E8AB6046B; Mon, 2 Apr 2018 13:06:25 +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 C3E47600C8 for ; Mon, 2 Apr 2018 13:06:24 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 2 Apr 2018 09:06:16 -0400 Message-Id: <20180402130616.25745-6-jferlan@redhat.com> In-Reply-To: <20180402130616.25745-1-jferlan@redhat.com> References: <20180402130616.25745-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 5/5] uml: 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 02 Apr 2018 13:06:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For umlDomObjFromDomainLocked and umlDomainLookupByID 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. This means for some consumers we need to relock the @dom after a virDomainObjListRemove, but before calling virDomainObjEndAPI. The LookupByName already returns the ref counted and locked object, so this will make things more consistent. Signed-off-by: John Ferlan Reviewed-by: Daniel P. Berrang=C3=A9 --- src/uml/uml_driver.c | 91 ++++++++++++++++++------------------------------= ---- 1 file changed, 32 insertions(+), 59 deletions(-) diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index b81da7cb2e..93d8a9f57c 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -171,7 +171,7 @@ umlDomObjFromDomainLocked(struct uml_driver *driver, virDomainObjPtr vm; char uuidstr[VIR_UUID_STRING_BUFLEN]; =20 - if (!(vm =3D virDomainObjListFindByUUID(driver->domains, uuid))) { + if (!(vm =3D virDomainObjListFindByUUIDRef(driver->domains, uuid))) { virUUIDFormat(uuid, uuidstr); =20 virReportError(VIR_ERR_NO_DOMAIN, @@ -773,8 +773,7 @@ static int umlProcessAutoDestroyDom(void *payload, return 0; } =20 - if (!(dom =3D virDomainObjListFindByUUID(data->driver->domains, - uuid))) { + if (!(dom =3D virDomainObjListFindByUUIDRef(data->driver->domains, uui= d))) { VIR_DEBUG("No domain object to kill"); return 0; } @@ -788,11 +787,10 @@ static int umlProcessAutoDestroyDom(void *payload, =20 if (!dom->persistent) { virDomainObjListRemove(data->driver->domains, dom); - dom =3D NULL; + virObjectLock(dom); } =20 - if (dom) - virObjectUnlock(dom); + virDomainObjEndAPI(&dom); if (event) umlDomainEventQueue(data->driver, event); virHashRemoveEntry(data->driver->autodestroy, uuidstr); @@ -1389,7 +1387,7 @@ static virDomainPtr umlDomainLookupByID(virConnectPtr= conn, virDomainPtr dom =3D NULL; =20 umlDriverLock(driver); - vm =3D virDomainObjListFindByID(driver->domains, id); + vm =3D virDomainObjListFindByIDRef(driver->domains, id); umlDriverUnlock(driver); =20 if (!vm) { @@ -1404,8 +1402,7 @@ static virDomainPtr umlDomainLookupByID(virConnectPtr= conn, dom =3D virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id); =20 cleanup: - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); return dom; } =20 @@ -1425,8 +1422,7 @@ static virDomainPtr umlDomainLookupByUUID(virConnectP= tr conn, dom =3D virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id); =20 cleanup: - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); return dom; } =20 @@ -1473,8 +1469,7 @@ static int umlDomainIsActive(virDomainPtr dom) ret =3D virDomainObjIsActive(obj); =20 cleanup: - if (obj) - virObjectUnlock(obj); + virDomainObjEndAPI(&obj); return ret; } =20 @@ -1494,8 +1489,7 @@ static int umlDomainIsPersistent(virDomainPtr dom) ret =3D obj->persistent; =20 cleanup: - if (obj) - virObjectUnlock(obj); + virDomainObjEndAPI(&obj); return ret; } =20 @@ -1514,8 +1508,7 @@ static int umlDomainIsUpdated(virDomainPtr dom) ret =3D obj->updated; =20 cleanup: - if (obj) - virObjectUnlock(obj); + virDomainObjEndAPI(&obj); return ret; } =20 @@ -1676,8 +1669,7 @@ static int umlDomainShutdownFlags(virDomainPtr dom, =20 cleanup: VIR_FREE(info); - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); return ret; } =20 @@ -1711,15 +1703,13 @@ umlDomainDestroyFlags(virDomainPtr dom, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_DESTROYED); if (!vm->persistent) { - virDomainObjListRemove(driver->domains, - vm); - vm =3D NULL; + virDomainObjListRemove(driver->domains, vm); + virObjectLock(vm); } ret =3D 0; =20 cleanup: - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); if (event) umlDomainEventQueue(driver, event); umlDriverUnlock(driver); @@ -1748,8 +1738,7 @@ static char *umlDomainGetOSType(virDomainPtr dom) { goto cleanup; =20 cleanup: - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); return type; } =20 @@ -1770,8 +1759,7 @@ umlDomainGetMaxMemory(virDomainPtr dom) ret =3D virDomainDefGetMemoryTotal(vm->def); =20 cleanup: - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); return ret; } =20 @@ -1797,8 +1785,7 @@ static int umlDomainSetMaxMemory(virDomainPtr dom, un= signed long newmax) ret =3D 0; =20 cleanup: - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); return ret; } =20 @@ -1830,8 +1817,7 @@ static int umlDomainSetMemory(virDomainPtr dom, unsig= ned long newmem) ret =3D 0; =20 cleanup: - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); return ret; } =20 @@ -1866,8 +1852,7 @@ static int umlDomainGetInfo(virDomainPtr dom, ret =3D 0; =20 cleanup: - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); return ret; } =20 @@ -1894,8 +1879,7 @@ umlDomainGetState(virDomainPtr dom, ret =3D 0; =20 cleanup: - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); return ret; } =20 @@ -1921,8 +1905,7 @@ static char *umlDomainGetXMLDesc(virDomainPtr dom, virDomainDefFormatConvertXMLFlags(flags)); =20 cleanup: - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); return ret; } =20 @@ -1986,8 +1969,7 @@ static int umlDomainCreateWithFlags(virDomainPtr dom,= unsigned int flags) VIR_DOMAIN_EVENT_STARTED_BOOTED); =20 cleanup: - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); if (event) umlDomainEventQueue(driver, event); umlDriverUnlock(driver); @@ -2034,8 +2016,7 @@ umlDomainDefineXMLFlags(virConnectPtr conn, const cha= r *xml, unsigned int flags) =20 if (virDomainSaveConfig(driver->configDir, driver->caps, vm->newDef ? vm->newDef : vm->def) < 0) { - virDomainObjListRemove(driver->domains, - vm); + virDomainObjListRemove(driver->domains, vm); vm =3D NULL; goto cleanup; } @@ -2085,14 +2066,13 @@ static int umlDomainUndefineFlags(virDomainPtr dom, vm->persistent =3D 0; } else { virDomainObjListRemove(driver->domains, vm); - vm =3D NULL; + virObjectLock(vm); } =20 ret =3D 0; =20 cleanup: - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); umlDriverUnlock(driver); return ret; } @@ -2198,8 +2178,7 @@ static int umlDomainAttachDevice(virDomainPtr dom, co= nst char *xml) cleanup: =20 virDomainDeviceDefFree(dev); - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); umlDriverUnlock(driver); return ret; } @@ -2306,8 +2285,7 @@ static int umlDomainDetachDevice(virDomainPtr dom, co= nst char *xml) =20 cleanup: virDomainDeviceDefFree(dev); - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); umlDriverUnlock(driver); return ret; } @@ -2348,8 +2326,7 @@ static int umlDomainGetAutostart(virDomainPtr dom, ret =3D 0; =20 cleanup: - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); umlDriverUnlock(driver); return ret; } @@ -2413,8 +2390,7 @@ static int umlDomainSetAutostart(virDomainPtr dom, cleanup: VIR_FREE(configFile); VIR_FREE(autostartLink); - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); umlDriverUnlock(driver); return ret; } @@ -2477,8 +2453,7 @@ umlDomainBlockPeek(virDomainPtr dom, =20 cleanup: VIR_FORCE_CLOSE(fd); - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); return ret; } =20 @@ -2545,8 +2520,7 @@ umlDomainOpenConsole(virDomainPtr dom, =20 ret =3D 0; cleanup: - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); umlDriverUnlock(driver); return ret; } @@ -2845,8 +2819,7 @@ umlDomainHasManagedSaveImage(virDomainPtr dom, unsign= ed int flags) ret =3D 0; =20 cleanup: - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); return ret; } =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list