From nobody Fri May 10 10:26:13 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=1643721810; cv=none; d=zohomail.com; s=zohoarc; b=G3+bcXi50z8UuBMKO32uUJ44oH86hOgzZrLR5zyGyBU/FS4hPduchRFyQmV3grMpQIq9I6LFA1oiZ6puPH+WGxL7Loq6c6tk3iG8OdyhbAUwF9yO9UdjIVaHxuRIjQRE5wQCYQLRNLHEUYiJ7h//DvKtcERSCarXNI+Z03lYnqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643721810; 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=RIVcfkUG8IUrCGaThU5/A8AEIQUxSE2pMWbBffhDoHsykJc0Xzh56P3CS9qdpanZCJk6QIkmMEDAKy3KBn156QQ6Hww1PlWMNBVad0vfSQtWWREAtBsPxEgpa17WRDyIYBbDedqnsdG4QlXi8MTvVZWaAkX5935BgN+sDMFHWXI= 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 1643721810139742.146550123023; Tue, 1 Feb 2022 05:23:30 -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-167-ux_zHvqAN_WsUA_1i0LXUA-1; Tue, 01 Feb 2022 08:23:28 -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 1FA0510B7463; Tue, 1 Feb 2022 13:23:23 +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 F18DE7D712; Tue, 1 Feb 2022 13:23:22 +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 C3D7B1809CB9; Tue, 1 Feb 2022 13:23:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 211DKKJr007414 for ; Tue, 1 Feb 2022 08:20:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6A39110A48AF; Tue, 1 Feb 2022 13:20:20 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.195.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id B59ED10A48AC; Tue, 1 Feb 2022 13:20:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643721809; 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=aRpq4/mqfAI5F56fmlJTZpNyCbI+tRU3oV72ukrC4hRh1ivZJ/G37RjABJnwIenHRrSoDE 1HV2fDsB4CWH0nkHvOZS/4YdZOoKDpQ/+Pj50mX4XqNxI/vom+4700TU9DOV9qlRlsvQmu 37qqxZf9CRdqkMRUS/SkuycGJe0IUnM= X-MC-Unique: ux_zHvqAN_WsUA_1i0LXUA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v5 1/9] internal: Add CONCAT macro Date: Tue, 1 Feb 2022 14:20:09 +0100 Message-Id: <20220201132017.53963-2-twiederh@redhat.com> In-Reply-To: <20220201132017.53963-1-twiederh@redhat.com> References: <20220201132017.53963-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1643721812602100001 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 Fri May 10 10:26:13 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=1643721637; cv=none; d=zohomail.com; s=zohoarc; b=m2EbPDBtSW3gWLQjsLMZo/vLT26F+kFGq3iFRNWHkzaje17asHcDLouV31XIjRg8WNQP/yXiTh2wamyKxufhNcmRidYQ/gt9AjY+EhgSBm47sZaBPpxJ30sjukLX7GPbBTb6ZwvwxfsLDdSapkPq83pDVI5s6LroWRU6fSWPolE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643721637; 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=4veDpEMBBTQapZH2eh1sylOGYs5B8+vyN/Fs9d8E8cY=; b=g5sQZnWm7I+n2e2+yAFJv5nfD7qECdE0ihBNn8YAN05j8cch+bUnQj4LgyrXOa2IacrA2+aIZv6cnKVa7gGmGVxeLk3VsGk8MrHz6WezICZ7dTMe38jgAV2TnVD4iSq1MMLvyz/LACVpp9CuP/fzoh91TIRYIa+6uq4ZP+Hf688= 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 1643721637078936.8113197087844; Tue, 1 Feb 2022 05:20: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-214-sXZe_CVOOuSK_qIdfXgOJQ-1; Tue, 01 Feb 2022 08:20:33 -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 62FF884B9A4; Tue, 1 Feb 2022 13:20:27 +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 B805E6E209; Tue, 1 Feb 2022 13:20:25 +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 A2F494BB7C; Tue, 1 Feb 2022 13:20:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 211DKL0k007424 for ; Tue, 1 Feb 2022 08:20:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 72BBE10A48B6; Tue, 1 Feb 2022 13:20:21 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.195.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDE8610A48B3; Tue, 1 Feb 2022 13:20:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643721636; 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=4veDpEMBBTQapZH2eh1sylOGYs5B8+vyN/Fs9d8E8cY=; b=fVlqftDOp7BjESSWWOHEmMyOELOVXyN79717VBkAEuqXQwSaoLjWz0m7PR12DythlYbADb 9gUvjQINuUoDQOED1RQxNsluMtkLbVJXhmw6dowfOZeUq3jhrQhbIpWnqhnhcXgQpNMRtd 1BzPZhu+QmGmgURrDgMjy73mCqEK21U= X-MC-Unique: sXZe_CVOOuSK_qIdfXgOJQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v5 2/9] virthread: Introduce virLockGuard Date: Tue, 1 Feb 2022 14:20:10 +0100 Message-Id: <20220201132017.53963-3-twiederh@redhat.com> In-Reply-To: <20220201132017.53963-1-twiederh@redhat.com> References: <20220201132017.53963-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1643721638334100001 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 Reviewed-by: Daniel P. Berrang=C3=A9 --- 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 bc6fa191bf..5da9874e17 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3388,6 +3388,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 Fri May 10 10:26:13 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=1643721713; cv=none; d=zohomail.com; s=zohoarc; b=e3hlibnkqUuUmgh7knOgDaYYX+FaCIladzgyEaHtlGYcW7sXeQIXSzXnrXZrUrPnhMm0Q3VhxOuvozdCqaLPPZPNjwA/22uIpfxOH946cD6tZGg74F/iLusZwxDVicMHGuLtZY137sUxTgSXszxnDnleLgpHCzu9geQS/5s/+J8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643721713; 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=rptmcNEuVAzzgCPDV3PvNXABhiXyHvasK3dyKCDf75o=; b=Fh5qZmstzThRYckn6+ZHfmIz0+ZXvp7Dt8jMmaUy7qa0CplfpNgVwUW/AiJESypz/jAyiB7C81h02bUocblrxvnjgHRNtClsBuNcj0mQho6glBOlsSkequGkLR06v4pcSMa+MoI7mdpKFkGEntetJBX1Aq2KSyG0t1I3v5u0qQY= 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 1643721713248173.3830810287567; Tue, 1 Feb 2022 05:21:53 -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-580-b6JLFUI6PtKQRYvk3G_XHg-1; Tue, 01 Feb 2022 08:21:51 -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 EE8D58145E2; Tue, 1 Feb 2022 13:21:45 +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 C980F7DE21; Tue, 1 Feb 2022 13:21: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 958301809C88; Tue, 1 Feb 2022 13:21:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 211DKMxM007435 for ; Tue, 1 Feb 2022 08:20:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7E8FC10A48B6; Tue, 1 Feb 2022 13:20:22 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.195.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id C965310A48B3; Tue, 1 Feb 2022 13:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643721712; 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=rptmcNEuVAzzgCPDV3PvNXABhiXyHvasK3dyKCDf75o=; b=KztDq90vy/gyMNlE5MkoTG2mujrSO5L2tYw2hOgSdQw+AM5O5Ytcgi2OBmtt6CFXKjQXOl AGNWNiW3qTi0GMWFwzGNKPNwCejtuCCiUKHwk3lPzkAqezd7F6CLiZ/3/hhT9AcTha48We 0za9yCs8LfwTmMQPqIxXVUWlmkfIXo8= X-MC-Unique: b6JLFUI6PtKQRYvk3G_XHg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v5 3/9] virthread: Introduce VIR_WITH_MUTEX_LOCK_GUARD Date: Tue, 1 Feb 2022 14:20:11 +0100 Message-Id: <20220201132017.53963-4-twiederh@redhat.com> In-Reply-To: <20220201132017.53963-1-twiederh@redhat.com> References: <20220201132017.53963-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1643721716081100001 Content-Type: text/plain; charset="utf-8" Modeled after "WITH_QEMU_LOCK_GUARD" (see qemu's include/qemu/lockable.h). See comment for typical usage. Signed-off-by: Tim Wiederhake Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virthread.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/util/virthread.h b/src/util/virthread.h index 6cdaf2820e..23abe0b6c9 100644 --- a/src/util/virthread.h +++ b/src/util/virthread.h @@ -209,3 +209,24 @@ int virThreadLocalSet(virThreadLocal *l, void*) G_GNUC= _WARN_UNUSED_RESULT; return 0; \ } \ struct classname ## EatSemicolon + +#define VIR_WITH_MUTEX_LOCK_GUARD_(m, name) \ + for (g_auto(virLockGuard) name =3D virLockGuardLock(m); name.mutex; \ + name.mutex =3D (virLockGuardUnlock(&name), NULL)) +/** + * 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) \ + VIR_WITH_MUTEX_LOCK_GUARD_(m, CONCAT(var, __COUNTER__)) --=20 2.31.1 From nobody Fri May 10 10:26:13 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=1643721657; cv=none; d=zohomail.com; s=zohoarc; b=Ull0aJYxBkFx6nsUHejbs+gUttBDUFI6TBtygmVCFKaWH4hV3Hq4F2IxwCmx7PwFGy1WPxprFhxoUn2yzIGNdLIQ52eJfBr0+qx8CUkntIwvKN7TURjPhDpRJJ1Xf+l0VJWdlnYIaEV7OJNscNdavCz38BSMdRkIApOGVgK44fI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643721657; 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=ghYMZVzFXr3zu5BJJIxUHGWCLCfaR71vE3jMtTzsKBM=; b=mcIRsE/XaekARlGgjQL6dHyP0YIQ7CHZRy5raQKvXHnkliqT14iyHX1Dlao+P9UUOdZqspDN+vELHvnRfE0lpZlqfTda/pk5LohqDbSb2Tr2gKZHSvpkE9zeaidKG+wHPgy6DeGzhfxEiz0PKxLVtNNPQV7Imn6UCFxC6Tr+81c= 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 1643721657005681.5271519685648; Tue, 1 Feb 2022 05:20:57 -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-18-M_gAnKqTO8agcHC78ByVog-1; Tue, 01 Feb 2022 08:20:52 -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 E02B48519E4; Tue, 1 Feb 2022 13:20:47 +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 BB78C7D716; Tue, 1 Feb 2022 13:20: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 6B70D4A7C8; Tue, 1 Feb 2022 13:20:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 211DKNQo007445 for ; Tue, 1 Feb 2022 08:20:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8A0ED10A48B3; Tue, 1 Feb 2022 13:20:23 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.195.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id D44CC10A48AC; Tue, 1 Feb 2022 13:20:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643721656; 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=ghYMZVzFXr3zu5BJJIxUHGWCLCfaR71vE3jMtTzsKBM=; b=JAD4HaWjQuUXyvrCNRvvpfV242o95l3mxEsQjP5HGL9mE54ProIUOM4ygUhN96Owo6t1QZ 0t1dh93wu0xYC9bpZzddnajI4H+wp3iDAoyHiQLR+PC2vaQ2XoPIXg2VlkXg2tnebjOMNN iowvqEVc/Ko13fkKluRwIpnBzJIC3CE= X-MC-Unique: M_gAnKqTO8agcHC78ByVog-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v5 4/9] virobject: Introduce virObjectLockGuard Date: Tue, 1 Feb 2022 14:20:12 +0100 Message-Id: <20220201132017.53963-5-twiederh@redhat.com> In-Reply-To: <20220201132017.53963-1-twiederh@redhat.com> References: <20220201132017.53963-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1643721660467100001 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 Reviewed-by: Daniel P. Berrang=C3=A9 --- 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 5da9874e17..9bc3d9530b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2956,6 +2956,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 Fri May 10 10:26:13 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=1643721815; cv=none; d=zohomail.com; s=zohoarc; b=fdJ6yyMuCSp7MQzf/uD/3T0o8CQcsfZFpd9rvqJERcYRKJx7fUnl6RZOu6vvistAuW8+DOpDrrUMrt56yQpruxgvO/ywv7jX6YWdvbK7XOWGnHMleSxoqsofpC7zFz324kcvERa2MLO65gQU9S+e7/frUJl1CDONDxeQk7qd1WU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643721815; 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=vxpLRa/wFN+8yLIR/vK2WQTowPrxzSVgDvFumXduO/o=; b=ll2ED+BmKoNitDUbgaKNWN/RCkiRgeji3bIKMlA1BSQrx9FBCRwjUv3UEGpuWvfLYQg45fhRtYv1noHP4WNdSOnTXFsBi2NickpBni4iu5L0eZnMqhBoJXsCWdw11aA8rxxAjZtCBXKeleuQjMMtuBOV72OuLkBZxf/3sYixJKU= 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 1643721815667110.12215267177623; Tue, 1 Feb 2022 05:23:35 -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-631-X5qAQEK4OcisPTG0NzrExg-1; Tue, 01 Feb 2022 08:23:31 -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 A48CC1091DBD; Tue, 1 Feb 2022 13:23:26 +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 53ABE6E204; Tue, 1 Feb 2022 13:23:26 +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 282071809CBF; Tue, 1 Feb 2022 13:23:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 211DKONE007455 for ; Tue, 1 Feb 2022 08:20:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id B4D9510A48B6; Tue, 1 Feb 2022 13:20:24 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.195.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE30F10A48AF; Tue, 1 Feb 2022 13:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643721815; 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=vxpLRa/wFN+8yLIR/vK2WQTowPrxzSVgDvFumXduO/o=; b=YiyIWla1iHf9nsQObaa3k1VMFBPgazjOgpdyG3PogrYFlg3A69rGtpqqHQu65R4vx1RptH KPTGo6dNAL4FKOvYZNJK6+oONBNM3G9y+QCJecW+Gj34usMttBPHlQn7Q2tAfqyuRRgQt6 nXszbLDCmtAvACdAn4DQxgdKNjNQ4lA= X-MC-Unique: X5qAQEK4OcisPTG0NzrExg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v5 5/9] virobject: Introduce VIR_WITH_OBJECT_LOCK_GUARD Date: Tue, 1 Feb 2022 14:20:13 +0100 Message-Id: <20220201132017.53963-6-twiederh@redhat.com> In-Reply-To: <20220201132017.53963-1-twiederh@redhat.com> References: <20220201132017.53963-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1643721817921100001 Content-Type: text/plain; charset="utf-8" Modeled after "WITH_QEMU_LOCK_GUARD" (see qemu's include/qemu/lockable.h). See comment for typical usage. Signed-off-by: Tim Wiederhake Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virobject.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/util/virobject.h b/src/util/virobject.h index dc1ce66a4f..a1e16aee77 100644 --- a/src/util/virobject.h +++ b/src/util/virobject.h @@ -148,3 +148,25 @@ virObjectListFree(void *list); void virObjectListFreeCount(void *list, size_t count); + +#define VIR_WITH_OBJECT_LOCK_GUARD_(o, name) \ + for (g_auto(virLockGuard) name =3D virObjectLockGuard(o); name.mutex; \ + name.mutex =3D (virLockGuardUnlock(&name), NULL)) + +/** + * 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) \ + VIR_WITH_OBJECT_LOCK_GUARD_(o, CONCAT(var, __COUNTER__)) --=20 2.31.1 From nobody Fri May 10 10:26:13 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=1643721819; cv=none; d=zohomail.com; s=zohoarc; b=fAM7p8v5a0mjekSCzOgJxVRnRpbL6piOv0xhbnak/TK5jYCnwTrIxCp9YG3Hm+urJS4sD6ln/EgQdQhviaxjkN8VihzpSzyy6rJrcHj/4mUtHDPV+K28+Q52TaivFDAS6+3pq9eE4yEsGdQhFCDUyWMDL1OQuKPEgDvVfAuP05A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643721819; 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=Ji82/28FyF5q+5lVjyQsQHKfp8JOYlxiqAcjFjmXkRHfI0ZM2vg7Q/kBfd9nMTZXShCKVuUuDRJ4LmalzMax7SMExm1lINpNzGJpW57Tbu9tk5ShOZLLd+F1eO8DNUQogyGjgSmOHZglo3iW5F4rYbQB/y49YN/QAJim++SExUA= 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 1643721819267434.0173960242573; Tue, 1 Feb 2022 05:23: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-613-r6U-sVpaNBeM3wz2aI2FYA-1; Tue, 01 Feb 2022 08:23: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 AFAEA1124C5E; Tue, 1 Feb 2022 13:23:29 +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 8963A6E209; Tue, 1 Feb 2022 13:23:29 +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 2DD394CA93; Tue, 1 Feb 2022 13:23:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 211DKPkA007465 for ; Tue, 1 Feb 2022 08:20:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id BE7AB10A48B7; Tue, 1 Feb 2022 13:20:25 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.195.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1457A10A48AF; Tue, 1 Feb 2022 13:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643721818; 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=eTkUtx7bDwTaj47hC3U97vYOHWr9vqnMC1lYUDzg0siSWDJCNq24WzYkvCzsMGmymU+Tow WUilQn08OBY3ACyYHAD0hyMY8XaE4yFH2R5lkkteNrgrgn6oF8ZUzKBOgv+5G3B9WEskgQ 0z1xev3HqTbVhC4npFd77E8xt0lqb/I= X-MC-Unique: r6U-sVpaNBeM3wz2aI2FYA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v5 6/9] virChrdevFDStreamCloseCb: Use virLockGuardLock Date: Tue, 1 Feb 2022 14:20:14 +0100 Message-Id: <20220201132017.53963-7-twiederh@redhat.com> In-Reply-To: <20220201132017.53963-1-twiederh@redhat.com> References: <20220201132017.53963-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1643721820800100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Daniel P. Berrang=C3=A9 --- 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 Fri May 10 10:26:13 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=1643721824; cv=none; d=zohomail.com; s=zohoarc; b=Snb0/R7/tloOJusjETXgcj/e3H0Va1Cnm0FR68kIi8M3weCUTx5vg/smA62uosfNGnmthTkAlHjloG7yLyqbERNl+wHwX/zYvEX9JimGIiahvcVROaxWknNLpzZSe1kAWMp5qtbyZPfjtTYPT7oiQFjF+Pje/hrxkr8jpV7IKYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643721824; 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=YrJH3nB2gpqVtf6qKU6AOGuMae4uqs5GMuF/o+THAuqgGnOECrdM6fbee8ZVVATWGhG8Lt1hUWMLn1XLPyUOYPCBQ0kXZmCu7KGKQNwfDUjhLORDk5vW6cuzEQ5sMU6vfLFqsdkfr0svL0onFZAB0YOarBuQmIhskpb/Oams/+Q= 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 1643721824272340.14893815537596; Tue, 1 Feb 2022 05:23:44 -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-440-VMYAgAf_PP2Vag6WnUkC8Q-1; Tue, 01 Feb 2022 08:23:39 -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 A041C84E20F; Tue, 1 Feb 2022 13:23:34 +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 7FB67752AE; Tue, 1 Feb 2022 13:23: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 4A9B71809CBF; Tue, 1 Feb 2022 13:23:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 211DKQ35007475 for ; Tue, 1 Feb 2022 08:20:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id C708E10A48B8; Tue, 1 Feb 2022 13:20:26 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.195.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E29B10A48B6; Tue, 1 Feb 2022 13:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643721823; 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=Fvozch0TwwVXV2iwbOSjURUxx+TkqyYHZFMOSsn+1m150VQJvVm1VFipB+eRzWM9rbcFyb Eo0IvcIfY5QL2SNiZINruPfnHHdHxK14QVWSDUATsNbkUdzxLv4f2AIpzcM/NfiWWgD/JC xprdADd8dLYrmuUjMmQynm0Z9Q3+eIo= X-MC-Unique: VMYAgAf_PP2Vag6WnUkC8Q-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v5 7/9] virChrdevFree: Use VIR_WITH_MUTEX_LOCK Date: Tue, 1 Feb 2022 14:20:15 +0100 Message-Id: <20220201132017.53963-8-twiederh@redhat.com> In-Reply-To: <20220201132017.53963-1-twiederh@redhat.com> References: <20220201132017.53963-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1643721826178100001 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 Fri May 10 10:26:13 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=1643721825; cv=none; d=zohomail.com; s=zohoarc; b=Pul2MChqItLQEsU67RhpgnVCvbazPa0rq1/GrU17oUkQmj8hI+zM70z9hQKrD+qcxjyDu9YZeMdYS9+FRgLOsCUQlVWLPJcBdqNLF8P6LBEP66ZLN8nV4rU44wlZYsRmbYochheKxXYjZJQJtzb5wvXEHb1/Z7JBCs31KGW0TmQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643721825; 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=KhvS5zmVqbvbF9cXdCTZP0lJz5UMF7bKPWHU9AXKKOt39gCBgJdt7UPF2Qg4Gk8ilHVrEwBrsHm1op/kSL0xGFJQVu5EJCSFK4LR9O+qkIYQEYy9tupKz3H+r3HtqgYU6ZoHHS2MG41yXJdkPqYI2UoFr83Y5gy0tEmn94xWH8s= 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 16437218255001001.0746774840645; Tue, 1 Feb 2022 05:23:45 -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-353-bLKzJhQ4OYu-1G2D6RZcIQ-1; Tue, 01 Feb 2022 08:23:43 -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 BB73B46871; Tue, 1 Feb 2022 13:23:37 +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 8FC3F7D71B; Tue, 1 Feb 2022 13:23:37 +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 5DEDD1809CBF; Tue, 1 Feb 2022 13:23:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 211DKRGs007486 for ; Tue, 1 Feb 2022 08:20:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id CFCA110A48AF; Tue, 1 Feb 2022 13:20:27 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.195.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26C9F10A48AC; Tue, 1 Feb 2022 13:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643721824; 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=JaSxJAlY9g+0EpahWVmkXgy2jEKqkb3+TtE/o4ooSgl13tcjiInv16cQ1v+qLHsSCeakbB lDOpV/6nrTSVKXLpMiqSAeIQ9olYY93BYmF5MhCBLQ8sf2yDBl0wiSDARkFZ25JoxpWI8X wqWKySnCjUuMuUaq5Ca2Ww9DtsYLsqo= X-MC-Unique: bLKzJhQ4OYu-1G2D6RZcIQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v5 8/9] bhyveAutostartDomain: Use virObjectLockGuard Date: Tue, 1 Feb 2022 14:20:16 +0100 Message-Id: <20220201132017.53963-9-twiederh@redhat.com> In-Reply-To: <20220201132017.53963-1-twiederh@redhat.com> References: <20220201132017.53963-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1643721828241100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Daniel P. Berrang=C3=A9 --- 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 Fri May 10 10:26:13 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=1643721662; cv=none; d=zohomail.com; s=zohoarc; b=fyigzlpckX1LYKe1LhW77ohhcfvMn1ewY3W5kZGqLXbfqZ6VeKGMGsTz34Iyo9qjrynCPWS0OfGQKNsuU3Ox0KQdAcEAVTyZ/LA+3338XB9uMO7/2qmI5oSYBtEVCQSCVXRhWm+VXkcpo9/cAHnNeX+ypqyD0QbUhlNgKaWUfD8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643721662; 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=Els3mhaAsyOVSCYNQ27EkgrypQaMsXoTzkfU1qIZZGVAEz4ajy8Myd+2rLpDy645ldqozP3mbDSyT0nflificBci7L3DwmhTjaBjJISqrdaQJGA5swIbEPO2v13nDHgx6RXQMxeI0kw2KO7DCRnrEaUv883gNvH1QUV74TF7T5E= 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 1643721662047251.27017915030422; Tue, 1 Feb 2022 05:21: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-150-QCv-n2hhNYCtH0lBvxXs5Q-1; Tue, 01 Feb 2022 08:20:59 -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 7EB1746863; Tue, 1 Feb 2022 13:20: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 5649B7D712; Tue, 1 Feb 2022 13:20: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 238AC4A7CA; Tue, 1 Feb 2022 13:20:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 211DKSU2007496 for ; Tue, 1 Feb 2022 08:20:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id D7E2810A48B2; Tue, 1 Feb 2022 13:20:28 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.195.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2ECE610A48AC; Tue, 1 Feb 2022 13:20:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643721661; 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=AWq8YnkVM7/8wtekM5o/yejbJj0Q5SSH5fb0m7jM/WWMCOUvVFTiitIVrLXBBWR4SxX3Ik 6cz6E83xUuGPNT/j1b+v3oZk/xvjCCNf0zJP71rqulHTKzkjaDtfAGaLhk19E6B3+o9auk eccdL5yPCj4Rv849gYMwNTmcQ97oobc= X-MC-Unique: QCv-n2hhNYCtH0lBvxXs5Q-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v5 9/9] lxcDomainDetachDeviceHostdevUSBLive: Use VIR_WITH_OBJECT_LOCK_GUARD Date: Tue, 1 Feb 2022 14:20:17 +0100 Message-Id: <20220201132017.53963-10-twiederh@redhat.com> In-Reply-To: <20220201132017.53963-1-twiederh@redhat.com> References: <20220201132017.53963-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1643721663713100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Daniel P. Berrang=C3=A9 --- 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