From nobody Mon Feb 9 03:12:00 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 1496144314401331.45330128840385; Tue, 30 May 2017 04:38:34 -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 6E4178123F; Tue, 30 May 2017 11:38:32 +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 4623018402; Tue, 30 May 2017 11:38:32 +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 F1A90180BAF8; Tue, 30 May 2017 11:38:31 +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 v4UBcT0G002935 for ; Tue, 30 May 2017 07:38:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 17F737E5C8; Tue, 30 May 2017 11:38:29 +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 C7C4C7E2EE for ; Tue, 30 May 2017 11:38:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6E4178123F Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.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 6E4178123F From: John Ferlan To: libvir-list@redhat.com Date: Tue, 30 May 2017 07:38:17 -0400 Message-Id: <20170530113821.32540-6-jferlan@redhat.com> In-Reply-To: <20170530113821.32540-1-jferlan@redhat.com> References: <20170530113821.32540-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/9] util: Introduce virObjectLockableRecursiveNew 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.25]); Tue, 30 May 2017 11:38:33 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Introduce a recursive option for the lockable object which calls virMutexInitRecursive instead of virMutexInit. Signed-off-by: John Ferlan --- src/libvirt_private.syms | 1 + src/util/virobject.c | 26 ++++++++++++++++++++++++++ src/util/virobject.h | 4 ++++ 3 files changed, 31 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 429b095..9693dc4 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2268,6 +2268,7 @@ virObjectListFree; virObjectListFreeCount; virObjectLock; virObjectLockableNew; +virObjectLockableRecursiveNew; virObjectNew; virObjectRef; virObjectUnlock; diff --git a/src/util/virobject.c b/src/util/virobject.c index a1934941..b1fabd7 100644 --- a/src/util/virobject.c +++ b/src/util/virobject.c @@ -250,6 +250,32 @@ virObjectLockableNew(virClassPtr klass) } =20 =20 +void * +virObjectLockableRecursiveNew(virClassPtr klass) +{ + virObjectLockablePtr obj; + + if (!virClassIsDerivedFrom(klass, virClassForObjectLockable())) { + virReportInvalidArg(klass, + _("Class %s must derive from virObjectLockable= "), + virClassName(klass)); + return NULL; + } + + if (!(obj =3D virObjectNew(klass))) + return NULL; + + if (virMutexInitRecursive(&obj->lock) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to initialize recursive mutex")); + virObjectUnref(obj); + return NULL; + } + + return obj; +} + + static void virObjectLockableDispose(void *anyobj) { diff --git a/src/util/virobject.h b/src/util/virobject.h index 89f8050..7df9b47 100644 --- a/src/util/virobject.h +++ b/src/util/virobject.h @@ -109,6 +109,10 @@ void * virObjectLockableNew(virClassPtr klass) ATTRIBUTE_NONNULL(1); =20 +void * +virObjectLockableRecursiveNew(virClassPtr klass) + ATTRIBUTE_NONNULL(1); + void virObjectLock(void *lockableobj) ATTRIBUTE_NONNULL(1); --=20 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list