From nobody Sun May 19 00:17:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643364017; cv=none; d=zohomail.com; s=zohoarc; b=FB7UC0HnltXjD+kJ9YZrSynHXNrF+lH0UI59VG0jpP+lCQCdJmVYv2oGXpFq8oHgzAmxSTz6O6lVi8HTl6nJW/pS6oP6CWO6CinrJZRKK6517s5PHyNhbtseQdDWXh4U8q3LskY69Uv1Y7rvEEgDLCDKLdl853VFud/BQZoyoYo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643364017; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1TnR3AZozRK0rusJ3jkkZrvehF82VxbUk2ZnKWX3Nng=; b=RQyfgWjk1jFJY41FWDSD1AnJ/RD5r3YytP1/4tdPXac8NepKswU+9OxGhQUlzbqwAnHrAZgVwPNmxcgTF/9qtwS+w9Ee8HD00JhsvAV0qIesd7u8dfyDdBHuEHwtgA5PYW+vemeSPVVSvpcp0ZavtAiKJ9grEbT+Xu37jInzJIA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 16433640177251.548473958455702; Fri, 28 Jan 2022 02:00:17 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-316-n-VIT0hUMb--ymOsDGlqtQ-1; Fri, 28 Jan 2022 05:00:13 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 14111EB6D6; Fri, 28 Jan 2022 09:59: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 C1A40752B2; Fri, 28 Jan 2022 09:59:45 +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 7C1601809CB8; Fri, 28 Jan 2022 09:59:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20S9xgdJ031717 for ; Fri, 28 Jan 2022 04:59:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id BE0EB7243E; Fri, 28 Jan 2022 09:59:41 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.194.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9CCBC72415; Fri, 28 Jan 2022 09:59:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643364017; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=1TnR3AZozRK0rusJ3jkkZrvehF82VxbUk2ZnKWX3Nng=; b=Sl7U68hiqObXAODBlznXdPmU0PnRAWwX+zvuSqf4qriLWtusVNTv5AgRR/EbWxUCJ7egQ3 C9ua6uMpCxKsbpKr2kV5jONzqEtmx3pMaem/luJ5yPmPFbDLKTe73YbnAhY1ViifyH8vGL Oj4rlnGwfw3NMqYPJ723CTP14KM87zE= X-MC-Unique: n-VIT0hUMb--ymOsDGlqtQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v4 1/9] internal: Add CONCAT macro Date: Fri, 28 Jan 2022 10:59:14 +0100 Message-Id: <20220128095922.17782-2-twiederh@redhat.com> In-Reply-To: <20220128095922.17782-1-twiederh@redhat.com> References: <20220128095922.17782-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643364020860100001 Content-Type: text/plain; charset="utf-8" Using the two-step idiom to force resolution of other macros, e.g.: #define bar BAR CONCAT_(foo, bar) // foobar CONCAT(foo, bar) // fooBAR Signed-off-by: Tim Wiederhake --- src/internal.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/internal.h b/src/internal.h index b6e4332542..4cfb022b41 100644 --- a/src/internal.h +++ b/src/internal.h @@ -100,6 +100,9 @@ #define STREQ_NULLABLE(a, b) (g_strcmp0(a, b) =3D=3D 0) #define STRNEQ_NULLABLE(a, b) (g_strcmp0(a, b) !=3D 0) =20 +#define CONCAT_(a, b) a ## b +#define CONCAT(a, b) CONCAT_(a, b) + #ifdef WIN32 # ifndef O_CLOEXEC # define O_CLOEXEC _O_NOINHERIT --=20 2.31.1 From nobody Sun May 19 00:17:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643364050; cv=none; d=zohomail.com; s=zohoarc; b=RykJ0QKqbEMfkdjMqxzZemO/PQgYubs1nbrIedCDMIiHK2sjBHeZd9dvyWkLyMzDD08uf8Mcz363qOrRb4vQDI8xUZe1KtR8oyWhVjvYJ5wXQzcDIEao1t81j1+3YF6xBiLa3+6rkxW1czJcFICFJ4YNex/pm/3+QCucGE1Usns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643364050; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ji9Sx08DerxLEEdo28X+dDZj5Dzv/1jx8c0qzs4vidU=; b=ZnfefJPi/XkeaGqF576luMhO6J5GK2p0u0/fafkPY8hw3D6+0OZUlZ87DR17HJjmuKETozh0gtgm2FLbClK0zGDzwFmJGX0xbFsi+64TLU7KFKkKIvK5G1Pz9XrPf4xifpU7virQQlP3yxJSNKBNK14DsMJCzy621Ew9NC5h+tk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1643364050089716.953340370783; Fri, 28 Jan 2022 02:00:50 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-589-gAfuxYQ2N9masOpZPXlm3Q-1; Fri, 28 Jan 2022 05:00:25 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 44A908C7195; Fri, 28 Jan 2022 09:59:54 +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 23C416D033; Fri, 28 Jan 2022 09:59:54 +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 E4D644A7C8; Fri, 28 Jan 2022 09:59:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20S9xg0x031724 for ; Fri, 28 Jan 2022 04:59:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id A874A708C9; Fri, 28 Jan 2022 09:59:42 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.194.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9F9574E8F; Fri, 28 Jan 2022 09:59:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643364049; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ji9Sx08DerxLEEdo28X+dDZj5Dzv/1jx8c0qzs4vidU=; b=UUJaukHhOlmm/vyIPqieccl2XkCfDU4FetyyzZdIMHW1A++vKZLxhbAYquEVkHzWrKrXO1 fz4ec1Wu3LBf5dvLC6E89ywAnM2mVz0U7h/ezJnNVpcXEN+UqOuK1CIoexPh2QrxCCy2+D FihupzC1D3GE5SfTXjXmx1DblXqZDl4= X-MC-Unique: gAfuxYQ2N9masOpZPXlm3Q-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v4 2/9] virthread: Introduce virLockGuard Date: Fri, 28 Jan 2022 10:59:15 +0100 Message-Id: <20220128095922.17782-3-twiederh@redhat.com> In-Reply-To: <20220128095922.17782-1-twiederh@redhat.com> References: <20220128095922.17782-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643364051960100001 Content-Type: text/plain; charset="utf-8" Locks a virMutex on creation and unlocks it in its destructor. The VIR_LOCK_GUARD macro is used instead of "g_auto(virLockGuard)" to work around a clang issue (see https://bugs.llvm.org/show_bug.cgi?id=3D3888 and https://bugs.llvm.org/show_bug.cgi?id=3D43482). Typical usage: void function(virMutex *m) { VIR_LOCK_GUARD lock =3D virLockGuardLock(m); /* `m` is locked, and released automatically on scope exit */ ... while (expression) { VIR_LOCK_GUARD lock2 =3D virLockGuardLock(...); /* similar */ } } Signed-off-by: Tim Wiederhake --- src/libvirt_private.syms | 2 ++ src/util/virthread.c | 15 +++++++++++++++ src/util/virthread.h | 10 ++++++++++ 3 files changed, 27 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ba3462d849..4cfe6c17eb 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3376,6 +3376,8 @@ virCondInit; virCondSignal; virCondWait; virCondWaitUntil; +virLockGuardLock; +virLockGuardUnlock; virMutexDestroy; virMutexInit; virMutexInitRecursive; diff --git a/src/util/virthread.c b/src/util/virthread.c index e89c1a09fb..5422bb74fd 100644 --- a/src/util/virthread.c +++ b/src/util/virthread.c @@ -96,6 +96,21 @@ void virMutexUnlock(virMutex *m) pthread_mutex_unlock(&m->lock); } =20 +virLockGuard virLockGuardLock(virMutex *m) +{ + virLockGuard l =3D { m }; + virMutexLock(m); + return l; +} + +void virLockGuardUnlock(virLockGuard *l) +{ + if (!l || !l->mutex) + return; + + virMutexUnlock(g_steal_pointer(&l->mutex)); +} + =20 int virRWLockInit(virRWLock *m) { diff --git a/src/util/virthread.h b/src/util/virthread.h index 55c8263ae6..6cdaf2820e 100644 --- a/src/util/virthread.h +++ b/src/util/virthread.h @@ -31,6 +31,11 @@ struct virMutex { pthread_mutex_t lock; }; =20 +typedef struct virLockGuard virLockGuard; +struct virLockGuard { + virMutex *mutex; +}; + typedef struct virRWLock virRWLock; struct virRWLock { pthread_rwlock_t lock; @@ -121,6 +126,11 @@ void virMutexLock(virMutex *m); void virMutexUnlock(virMutex *m); =20 =20 +virLockGuard virLockGuardLock(virMutex *m); +void virLockGuardUnlock(virLockGuard *l); +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virLockGuard, virLockGuardUnlock); +#define VIR_LOCK_GUARD g_auto(virLockGuard) G_GNUC_UNUSED + int virRWLockInit(virRWLock *m) G_GNUC_WARN_UNUSED_RESULT; void virRWLockDestroy(virRWLock *m); =20 --=20 2.31.1 From nobody Sun May 19 00:17:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643364020; cv=none; d=zohomail.com; s=zohoarc; b=mB4/T2QaHobAgDM0PO0NSqKWgWQzmwV2zjNJS3IZjtij2124JEShhM5UQ8b6L83K8Eb7ozpYtU2EfSopZKrdBmr0DyDhnqvhwvAOkC169fVB5VViFV61be/dNzyc1zH3KXrfbQvEckHXIHr6Eldjq8/46ZoVRv2bJ06rMB6mTcc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643364020; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9h3ofOmdp9yfmFIt1hagMHMWlAf7WnMD2o+Rm5ckrls=; b=YUmfZ1vFPkVRQPG0GdHeA0V+2vC01idGFQnO+j5dUeq5NEyJ/LU6Tkshwn+HQZE2WL7rCcXU4tTcXNsUlmvcgHOvN++2tDGmTKja3SVwDvxMxQsON/pVVwQHLV61tsChp4pQbUR2pwkPezl5Noe9wUJZoKfqAPyFZXwKHB06SOY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1643364020237221.701400601944; Fri, 28 Jan 2022 02:00:20 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-668-B_IjkWenME-nIzeQTOJ2Xg-1; Fri, 28 Jan 2022 05:00:15 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E97D1098256; Fri, 28 Jan 2022 09:59:47 +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 2917B7B6D8; Fri, 28 Jan 2022 09:59:47 +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 B33CC1809CB8; Fri, 28 Jan 2022 09:59:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20S9xi8U031734 for ; Fri, 28 Jan 2022 04:59:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 12F6F74EAE; Fri, 28 Jan 2022 09:59:44 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.194.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 109A0703B6; Fri, 28 Jan 2022 09:59:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643364019; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9h3ofOmdp9yfmFIt1hagMHMWlAf7WnMD2o+Rm5ckrls=; b=T89zJOp8IyxccnrMowndhxnc4zG3OQXkcFpXIelWl0jbj6lyRZN2EOaWpGnI7c70R3hKdQ XiWhyKtC6yC6X3Cgt7PPxmqLB+EJXbrY0uTVQt1bSDTNLlGeD2wZqwJA92Oib55UuoWfKp vy5wotECqDy8/QFyxkCc/P8FReLiqOA= X-MC-Unique: B_IjkWenME-nIzeQTOJ2Xg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v4 3/9] virthread: Introduce VIR_WITH_MUTEX_LOCK_GUARD Date: Fri, 28 Jan 2022 10:59:16 +0100 Message-Id: <20220128095922.17782-4-twiederh@redhat.com> In-Reply-To: <20220128095922.17782-1-twiederh@redhat.com> References: <20220128095922.17782-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643364021489100003 Content-Type: text/plain; charset="utf-8" Modeled after "WITH_QEMU_LOCK_GUARD" (see qemu's include/qemu/lockable.h). Uses "__LINE__" instead of "__COUNTER__", as the latter is a GNU extension. See comment for typical usage. Signed-off-by: Tim Wiederhake --- src/util/virthread.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/util/virthread.h b/src/util/virthread.h index 6cdaf2820e..da17780908 100644 --- a/src/util/virthread.h +++ b/src/util/virthread.h @@ -209,3 +209,23 @@ int virThreadLocalSet(virThreadLocal *l, void*) G_GNUC= _WARN_UNUSED_RESULT; return 0; \ } \ struct classname ## EatSemicolon + +/** + * VIR_WITH_MUTEX_LOCK_GUARD: + * + * This macro defines a lock scope such that entering the scope takes the = lock + * and leaving the scope releases the lock. Return statements are allowed + * within the scope and release the lock. Break and continue statements le= ave + * the scope early and release the lock. + * + * virMutex *mutex =3D ...; + * + * VIR_WITH_MUTEX_LOCK_GUARD(mutex) { + * // `mutex` is locked, and released automatically on scope exit + * ... + * } + */ +#define VIR_WITH_MUTEX_LOCK_GUARD(m) \ + for (g_auto(virLockGuard) CONCAT(var, __LINE__) =3D virLockGuardLock(m= ); \ + CONCAT(var, __LINE__).mutex; \ + CONCAT(var, __LINE__).mutex =3D (virLockGuardUnlock(& CONCAT(var,= __LINE__)), NULL)) --=20 2.31.1 From nobody Sun May 19 00:17:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643364033; cv=none; d=zohomail.com; s=zohoarc; b=HQe6Ski2EoSDxXM5/OE4OybJxsRMpbaspnbA2rGWhxGRa/VDGdxDUAWDxiB7PQuZOjRjyrCLV5vIQEwgSxjCBjZvtVEGGgqeB9H0EP2cc7YX+zNBQkWBBBGHE1Sdl7GXlddemEjovt5oLFL3T1BZ7QDxQcYzbho/cV1veklofk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643364033; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=V5C5TSlaszbRgzjG4qxLU2HpDAgD0+fEyNdy9vFfRJQ=; b=k/BCCBUpGXBaGNLKShSk/pi0KzCGGYKZPP1Mbb3kwgIbvsK9QKzLKkVIDY4rPiBufIvTfJGTa+d67brKVVupTeJn1kksrDUPxXBt3qk7y4sJWFQAcg/slkglmY+PxIjGfSlf4jKmKJcItXNSAG25TxBNIyyR3zZsUqFRJ5V4YrU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1643364033980431.6947064314015; Fri, 28 Jan 2022 02:00:33 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-260-Z_2QuG_cPWWOEu9yEzNVJA-1; Fri, 28 Jan 2022 05:00:28 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3F052100CCC5; Fri, 28 Jan 2022 09:59:54 +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 208A360C5A; Fri, 28 Jan 2022 09:59:54 +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 DE4DB4CA9B; Fri, 28 Jan 2022 09:59:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20S9xj9t031742 for ; Fri, 28 Jan 2022 04:59:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4AE576F169; Fri, 28 Jan 2022 09:59:45 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.194.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5356A6F12C; Fri, 28 Jan 2022 09:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643364033; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=V5C5TSlaszbRgzjG4qxLU2HpDAgD0+fEyNdy9vFfRJQ=; b=G4LwEKItvkVAKmvYImfZwiK1VZrQoVJJNJx0oi3of/OBBNenksOQUll6BGWp3pQassoXK9 5fnbOd/O6C3ZG9OV4NUEyMtLR82pirOxORdRnQ8EklAD/q7WpfrFNszyB7Yh0z2D0K4zcH 1N3+Dwkev6T/1iUyaSh9mxMXfN5w624= X-MC-Unique: Z_2QuG_cPWWOEu9yEzNVJA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v4 4/9] virobject: Introduce virObjectLockGuard Date: Fri, 28 Jan 2022 10:59:17 +0100 Message-Id: <20220128095922.17782-5-twiederh@redhat.com> In-Reply-To: <20220128095922.17782-1-twiederh@redhat.com> References: <20220128095922.17782-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643364036350100003 Content-Type: text/plain; charset="utf-8" Typical usage: void foobar(virObjectLockable *obj) { VIR_LOCK_GUARD lock =3D virObjectLockGuard(obj); /* `obj` is locked, and released automatically on scope exit */ ... } Signed-off-by: Tim Wiederhake --- src/libvirt_private.syms | 1 + src/util/virobject.c | 16 ++++++++++++++++ src/util/virobject.h | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4cfe6c17eb..463bb39de3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2944,6 +2944,7 @@ virObjectListFree; virObjectListFreeCount; virObjectLock; virObjectLockableNew; +virObjectLockGuard; virObjectNew; virObjectRef; virObjectRWLockableNew; diff --git a/src/util/virobject.c b/src/util/virobject.c index 588b41802c..74cc84205e 100644 --- a/src/util/virobject.c +++ b/src/util/virobject.c @@ -426,6 +426,22 @@ virObjectGetRWLockableObj(void *anyobj) } =20 =20 +/** + * virObjectLockGuard: + * @anyobj: any instance of virObjectLockable + * + * Acquire a lock on @anyobj that will be managed by the virLockGuard obje= ct + * returned to the caller. + */ +virLockGuard +virObjectLockGuard(void *anyobj) +{ + virObjectLockable *obj =3D virObjectGetLockableObj(anyobj); + + return virLockGuardLock(&obj->lock); +} + + /** * virObjectLock: * @anyobj: any instance of virObjectLockable diff --git a/src/util/virobject.h b/src/util/virobject.h index 1e34c77744..dc1ce66a4f 100644 --- a/src/util/virobject.h +++ b/src/util/virobject.h @@ -118,6 +118,10 @@ void * virObjectRWLockableNew(virClass *klass) ATTRIBUTE_NONNULL(1); =20 +virLockGuard +virObjectLockGuard(void *lockableobj) + ATTRIBUTE_NONNULL(1); + void virObjectLock(void *lockableobj) ATTRIBUTE_NONNULL(1); --=20 2.31.1 From nobody Sun May 19 00:17:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643364062; cv=none; d=zohomail.com; s=zohoarc; b=mjlHKKVgDvQHdz4uPtbs5rlhGO0tl+41s09Vwtfz8F0w9SpcrwwiZ8h6CYJnBkN6ZtNs1UeBRPybYe+yjfp6F+SAfjQiQGHJ/bhfVA4cek9421u0zPYZBnGt6vDFDQDyxXJz4Gt304DGrtL5vVOjx6yLfffOu2P3uiJ2gmA48ks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643364062; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WjekiYQFlo2oOSEmMZCQHEZYlQ3z7txUboQKz2v7T/Y=; b=krVhwTmuP7rbWBVI2aCjQeYR4+62JwZWJXyf5W44yNJgVkBPP7BecjGRhP1zd2GLp1fBaNtdOFyEwcwO6XH/oWJeilgXj2BdIWpBma9VnsxzMBCTyUNG6+ZqszkVjyJmNc/PPUMVHaF/5SDnnOJVoNzA4pAAPLjEcyBzyxJNQII= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1643364062814377.3797992739169; Fri, 28 Jan 2022 02:01:02 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-Vry1RB16MGeAewk_ZtrLcg-1; Fri, 28 Jan 2022 05:00:35 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D71018749BA; Fri, 28 Jan 2022 09:59:59 +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 B161866E03; Fri, 28 Jan 2022 09:59:59 +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 831A94BB7C; Fri, 28 Jan 2022 09:59:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20S9xkDL031749 for ; Fri, 28 Jan 2022 04:59:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id C43416F116; Fri, 28 Jan 2022 09:59:46 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.194.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id B70D579414; Fri, 28 Jan 2022 09:59:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643364062; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=WjekiYQFlo2oOSEmMZCQHEZYlQ3z7txUboQKz2v7T/Y=; b=IvQl+4ots1LG4T+KoG8D9iNkeC3uKzfzc4fQRFLtjr/dr2wPgH1nfWskfX5lI0HZsaMp2i 9BRPD00RTJ7I1upCV7Oo1XHvdV+hRRrZuLU1Dcg8JdL/j4A2/CUXw3q6bcfD9FAXvZIPqM 1PbVNx++K2EmykWlTmXBUgsumYyzJgo= X-MC-Unique: Vry1RB16MGeAewk_ZtrLcg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v4 5/9] virobject: Introduce VIR_WITH_OBJECT_LOCK_GUARD Date: Fri, 28 Jan 2022 10:59:18 +0100 Message-Id: <20220128095922.17782-6-twiederh@redhat.com> In-Reply-To: <20220128095922.17782-1-twiederh@redhat.com> References: <20220128095922.17782-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643364064892100001 Content-Type: text/plain; charset="utf-8" Modeled after "WITH_QEMU_LOCK_GUARD" (see qemu's include/qemu/lockable.h). Uses "__LINE__" instead of "__COUNTER__", as the latter is a GNU extension. See comment for typical usage. Signed-off-by: Tim Wiederhake --- src/util/virobject.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/util/virobject.h b/src/util/virobject.h index dc1ce66a4f..595076bda7 100644 --- a/src/util/virobject.h +++ b/src/util/virobject.h @@ -148,3 +148,23 @@ virObjectListFree(void *list); void virObjectListFreeCount(void *list, size_t count); + +/** + * VIR_WITH_OBJECT_LOCK_GUARD: + * + * This macro defines a lock scope such that entering the scope takes the = lock + * and leaving the scope releases the lock. Return statements are allowed + * within the scope and release the lock. Break and continue statements le= ave + * the scope early and release the lock. + * + * virObjectLockable *lockable =3D ...; + * + * VIR_WITH_OBJECT_LOCK_GUARD(lockable) { + * // `lockable` is locked, and released automatically on scope ex= it + * ... + * } + */ +#define VIR_WITH_OBJECT_LOCK_GUARD(o) \ + for (g_auto(virLockGuard) CONCAT(var, __LINE__) =3D virObjectLockGuard= (o); \ + CONCAT(var, __LINE__).mutex; \ + CONCAT(var, __LINE__).mutex =3D (virLockGuardUnlock(& CONCAT(var,= __LINE__)), NULL)) --=20 2.31.1 From nobody Sun May 19 00:17:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643364037; cv=none; d=zohomail.com; s=zohoarc; b=YMkXBn78WzLA2Zs6WRes/Bb/k0NYEfwhQU/on5NyC6UEWYW43lBpcClMRLY+Vu/IwVCO1D/euSfu2rJDAHBr2QMHSRz5txBkpib186vnBqyGvU/188XBKa03riLlpYMZBy/VjizadVvy8gFjNgwcV/yD+IZ98puQuZ7gb9vgga0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643364037; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Qq+y7/oL5CaNpujY98WOcbYlnxQ5/DhxA4/q9hlh7sw=; b=ZCKq+tHPIvR/N53joPk2+GMZ0uYutEUaUIwyPHkJ9BXl3rVQLH3UHcUOKYu1uNgHfqBn9Ic/PX0Rrp32XDpnoUYmF38KEMN+eYHmd/0yBsr57G0PQuV5Hg7NX1d14Yl2lHOXjI+ovX3AxBUbzLVVRhcmgdffpfdJkPwPlQKAZso= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1643364037388519.8906695336615; Fri, 28 Jan 2022 02:00:37 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-494-mDtj2N1oO1Ok2EygkP71qw-1; Fri, 28 Jan 2022 05:00:32 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5DFA5190B2D4; Fri, 28 Jan 2022 09:59:57 +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 3957B66E02; Fri, 28 Jan 2022 09:59:57 +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 076EB1809CB9; Fri, 28 Jan 2022 09:59:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20S9xmbF031754 for ; Fri, 28 Jan 2022 04:59:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6FF316D033; Fri, 28 Jan 2022 09:59:48 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.194.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 576D06D032; Fri, 28 Jan 2022 09:59:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643364036; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Qq+y7/oL5CaNpujY98WOcbYlnxQ5/DhxA4/q9hlh7sw=; b=GQe1OCXPZ313umCIUUXI2CkNRGIM0bKJbIXQRSkDH1fWCCLX+3zpNzQbdneGxzPiuALkOl +HAzuJ5KDxMerv/4mIeqSRpOZXWvT+ZQ8cxPlzKM1g+xZfgbs2Ie0uC5+IjxDDaldbR57Q 1xONW262MCjrRRn73gh/oYO6V+ngeOw= X-MC-Unique: mDtj2N1oO1Ok2EygkP71qw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v4 6/9] virChrdevFDStreamCloseCb: Use virLockGuardLock Date: Fri, 28 Jan 2022 10:59:19 +0100 Message-Id: <20220128095922.17782-7-twiederh@redhat.com> In-Reply-To: <20220128095922.17782-1-twiederh@redhat.com> References: <20220128095922.17782-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643364039830100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake --- src/conf/virchrdev.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c index b5477b03d5..c9b2134e3b 100644 --- a/src/conf/virchrdev.c +++ b/src/conf/virchrdev.c @@ -237,12 +237,10 @@ static void virChrdevFDStreamCloseCb(virStreamPtr st = G_GNUC_UNUSED, void *opaque) { virChrdevStreamInfo *priv =3D opaque; - virMutexLock(&priv->devs->lock); + VIR_LOCK_GUARD lock =3D virLockGuardLock(&priv->devs->lock); =20 /* remove entry from hash */ virHashRemoveEntry(priv->devs->hash, priv->path); - - virMutexUnlock(&priv->devs->lock); } =20 /** --=20 2.31.1 From nobody Sun May 19 00:17:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643364036; cv=none; d=zohomail.com; s=zohoarc; b=nEUB9/4Mdr28DfcZvPRgDf55XVO/XolCxWbIftkFghHP31K/McG981cptFtiTbcv1jY9BLvj/2248WtbhxLg3xYqPbdKWI1Jf8QgDErCj+MV625oF0VMfhPeoCLN/XKR7i+peWBOocY+XkhUZqgWCtcWPNECaTBNS2Y2wukzn4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643364036; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6q2BwkSpg9KjkBdtWexaSoUiQYWpCU28HhqIEshNqXs=; b=HyvOv8lEJglPR8D9cgOASYcyCMX0mc5uFEfhkqgrNqS2KF4SAZ6yh3ccTN7h40lKClG3HXqOYGnpd3LnQWgCpqoSsfQPL9ksU6dcJ/H7H+NAdeHXseW1bljes2wokliTTs9+CT7lnWI3t5MZpt9NceOivWxdvMcqCucSNF+TMYQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1643364036754363.1187242461691; Fri, 28 Jan 2022 02:00:36 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-670-6nUFov76Mla4U_UdzEIZuA-1; Fri, 28 Jan 2022 05:00:32 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C9DC101873A; Fri, 28 Jan 2022 10:00:00 +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 EF8C673155; Fri, 28 Jan 2022 09:59:59 +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 BA0F24A7C9; Fri, 28 Jan 2022 09:59:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20S9xnFo031762 for ; Fri, 28 Jan 2022 04:59:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id AD6566D036; Fri, 28 Jan 2022 09:59:49 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.194.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id C59BA6D032; Fri, 28 Jan 2022 09:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643364035; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6q2BwkSpg9KjkBdtWexaSoUiQYWpCU28HhqIEshNqXs=; b=fYitDrfrMAcPqPeE2ZIrFdIJEXGJTsDM6NUvHIg17y3bf2ivsUT/FG6ZraXofa7i/rCYvv 26QKGNLW6z+yMOUICwBM2kdeRmNEaNSOLXitctD8fFYxzIytbWgFdTX97vErnosxTxqHsg 6gLuwOvw4uVfBfmCAGOvE3oXHht9tUw= X-MC-Unique: 6nUFov76Mla4U_UdzEIZuA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v4 7/9] virChrdevFree: Use VIR_WITH_MUTEX_LOCK Date: Fri, 28 Jan 2022 10:59:20 +0100 Message-Id: <20220128095922.17782-8-twiederh@redhat.com> In-Reply-To: <20220128095922.17782-1-twiederh@redhat.com> References: <20220128095922.17782-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643364039618100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake --- src/conf/virchrdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c index c9b2134e3b..8610f0ac5c 100644 --- a/src/conf/virchrdev.c +++ b/src/conf/virchrdev.c @@ -291,10 +291,10 @@ void virChrdevFree(virChrdevs *devs) if (!devs) return; =20 - virMutexLock(&devs->lock); - virHashForEachSafe(devs->hash, virChrdevFreeClearCallbacks, NULL); - g_clear_pointer(&devs->hash, g_hash_table_unref); - virMutexUnlock(&devs->lock); + VIR_WITH_MUTEX_LOCK_GUARD(&devs->lock) { + virHashForEachSafe(devs->hash, virChrdevFreeClearCallbacks, NULL); + g_clear_pointer(&devs->hash, g_hash_table_unref); + } virMutexDestroy(&devs->lock); =20 g_free(devs); --=20 2.31.1 From nobody Sun May 19 00:17:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643364039; cv=none; d=zohomail.com; s=zohoarc; b=G7krMN8YY2SOOTlJCccPxCKfOUkmfiCIQA+v+M1WqO9n4oVyfkiyKKupObYCpv00UxBEpgquYsPKkUg7qqMb8rW/zW9KFY8P45mD51VkYVSWndMdY3/xE719VbpoF8ai8zY03/YBteQkx+zAVGfrNPKL8kgkNq7DAU2mhLonxfg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643364039; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MGHdTbPPsEj42oQ72M6g+ZfNa0TuuB3EHoI+cE9d8EU=; b=h1+ykTyzRTShZ5yB28CO8YfzToz3iLAShcm7SJLP2AlgyfGz9Oxo+wUbWhdcsIasRjoaTfCdYTiYFYpWn2s13OItKJcsbaa/R7qAzuI4iuAsKU0fXZnGYdG5XTMiDavMc2bexQE55FsuFl+ai4Pgi+kFMB53f2G9qTB2NqHJGyY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1643364039961426.88428684415726; Fri, 28 Jan 2022 02:00:39 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-253-6dh9IYL5PPiQBzW7dA2zNQ-1; Fri, 28 Jan 2022 05:00:35 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B3A771015DA6; Fri, 28 Jan 2022 10:00:02 +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 794E6752B8; Fri, 28 Jan 2022 10:00:02 +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 41DDC4A7CB; Fri, 28 Jan 2022 10:00:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20S9xpY5031781 for ; Fri, 28 Jan 2022 04:59:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3EEB26D033; Fri, 28 Jan 2022 09:59:51 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.194.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2ED6D6D032; Fri, 28 Jan 2022 09:59:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643364039; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MGHdTbPPsEj42oQ72M6g+ZfNa0TuuB3EHoI+cE9d8EU=; b=JlbAH4O7wq8gvjtpQ+rf4ydnEimZeM9BodWIOUzd+AhKBxL7kxb+5Nhen+FOaWwcZG21EK vLp2llkCWaQU5D9Ya6a1ZR/c9FivpX9L7V2EGTRRGl7rAYHQNaTA1tkBY/VQk2vS/bIHpA BW9LnBkeyp3lZDjh7FiYNgJUZtywqMs= X-MC-Unique: 6dh9IYL5PPiQBzW7dA2zNQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v4 8/9] bhyveAutostartDomain: Use virObjectLockGuard Date: Fri, 28 Jan 2022 10:59:21 +0100 Message-Id: <20220128095922.17782-9-twiederh@redhat.com> In-Reply-To: <20220128095922.17782-1-twiederh@redhat.com> References: <20220128095922.17782-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643364042537100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake --- src/bhyve/bhyve_driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index f291f12e50..47ee98e650 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -87,7 +87,8 @@ bhyveAutostartDomain(virDomainObj *vm, void *opaque) { const struct bhyveAutostartData *data =3D opaque; int ret =3D 0; - virObjectLock(vm); + VIR_LOCK_GUARD lock =3D virObjectLockGuard(vm); + if (vm->autostart && !virDomainObjIsActive(vm)) { virResetLastError(); ret =3D virBhyveProcessStart(data->conn, vm, @@ -98,7 +99,6 @@ bhyveAutostartDomain(virDomainObj *vm, void *opaque) vm->def->name, virGetLastErrorMessage()); } } - virObjectUnlock(vm); return ret; } =20 --=20 2.31.1 From nobody Sun May 19 00:17:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643364033; cv=none; d=zohomail.com; s=zohoarc; b=jnbRy5mlYX4Kz5VVq3e6HkZIU79N/ocFVUIIi3nydLUEAs4T8nMpVKs2HRSdt/mKiU73iGrnqrDt0LC3YjMS9NydDXl0B7TnZQxU+dHkrKIgSYoIa/ePQTap5NXDPt/USkm2Eb7gB/4uL+GMqWhPdy/q00+8NX/7fySQ2Z3Yuao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643364033; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4/mEGk8bGDTECjETsrAbW4myVRIs6dakfiOfgv4xVrU=; b=Yrt36QWdbW8tNV6bqdK5O9rDnWuRosTVO5hy/05hSTWAKsuE1J0zCRBbpaDcuH6IE3hgqb12J/JsVpZrFv9/V4zocQOMaYjU7t+8/VE21uxMthQmL1gEK7XzMTwPOD3yi1diwIlFiX1qhNgBcZMoqqpedN+EeYP/WDFRGa0HFOg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1643364033382469.5321181059552; Fri, 28 Jan 2022 02:00:33 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-296-s33eJO9YPpS8k4o5EE5ubw-1; Fri, 28 Jan 2022 05:00:29 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33E96102C60E; Fri, 28 Jan 2022 09:59:56 +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 141456D032; Fri, 28 Jan 2022 09:59:56 +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 DA6494BB7C; Fri, 28 Jan 2022 09:59:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20S9xqXl031789 for ; Fri, 28 Jan 2022 04:59:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id CA11F6D033; Fri, 28 Jan 2022 09:59:52 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.194.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA4126D032; Fri, 28 Jan 2022 09:59:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643364032; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=4/mEGk8bGDTECjETsrAbW4myVRIs6dakfiOfgv4xVrU=; b=CTLf5OUODCcKF9tLy7eggQ9m5aw/MWG4OMUoKhW+4LTFjsWMgBeBDATCbQc/PkxoYv+1JC J0LmYgNWsvAd1tJ0hxQSA7SYTy8afIMWdfrF5/CUkE96AQHOya9UPNN67d6QjsCjbiCRuu 4Yk5Y/HHVHzhrme2ecdPLvCPgwazZGI= X-MC-Unique: s33eJO9YPpS8k4o5EE5ubw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v4 9/9] lxcDomainDetachDeviceHostdevUSBLive: Use VIR_WITH_OBJECT_LOCK_GUARD Date: Fri, 28 Jan 2022 10:59:22 +0100 Message-Id: <20220128095922.17782-10-twiederh@redhat.com> In-Reply-To: <20220128095922.17782-1-twiederh@redhat.com> References: <20220128095922.17782-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643364036016100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake --- src/lxc/lxc_driver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 7bc39120ee..42053de9c3 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -4045,9 +4045,9 @@ lxcDomainDetachDeviceHostdevUSBLive(virLXCDriver *dri= ver, VIR_WARN("cannot deny device %s for domain %s: %s", dst, vm->def->name, virGetLastErrorMessage()); =20 - virObjectLock(hostdev_mgr->activeUSBHostdevs); - virUSBDeviceListDel(hostdev_mgr->activeUSBHostdevs, usb); - virObjectUnlock(hostdev_mgr->activeUSBHostdevs); + VIR_WITH_OBJECT_LOCK_GUARD(hostdev_mgr->activeUSBHostdevs) { + virUSBDeviceListDel(hostdev_mgr->activeUSBHostdevs, usb); + } =20 virDomainHostdevRemove(vm->def, idx); virDomainHostdevDefFree(def); --=20 2.31.1