From nobody Sun May 19 07:16:11 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=1633001133; cv=none; d=zohomail.com; s=zohoarc; b=ENYvrs+RRTORxWELE1eZYRI1gxP2UOxR+gIlgc91imdy1paxFqSaDwNlDgrllbzbgmzbcRFsYojGtokjeyX+sVK5yO+eVGffui+UUynbVjRKN/pjXu3UkkNNIa3KDmcjnDJGKSM1FdsPuwRO52hYe5D90jhsHlhXTUFlXisZvWA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633001133; 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=HP6usu7N2FX5tMF3v/szJ6cYGIF+Y9qGcYkvbq2TWWo=; b=VShcgG4J/mllm6l5ppe7REKO4SHazr2j2Um1uZB6Ukvxyvx7pqVh6loYCWuP1lpwLA+LaNdj7c6sjuyQiNv5ijDvmRN0oOMvzNWIer/UcOsmgJ+sGIDmr+iIJ6lgLzK79aAbm0RxVI9PHyOC74U12nP6aEot0mKip03JGHIBclU= 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 1633001133577717.24332059047; Thu, 30 Sep 2021 04:25:33 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-394-A_4_g_HsMZm4w8M9oGcuMg-1; Thu, 30 Sep 2021 07:25:30 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0CCBA1923761; Thu, 30 Sep 2021 11:25: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 DA20F60FFD; Thu, 30 Sep 2021 11:25: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 A47B51806D00; Thu, 30 Sep 2021 11:25:25 +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 18UBPDDV021097 for ; Thu, 30 Sep 2021 07:25:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 97B855F4EB; Thu, 30 Sep 2021 11:25:13 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.194.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id E118F5F4EF; Thu, 30 Sep 2021 11:25:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633001132; 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=HP6usu7N2FX5tMF3v/szJ6cYGIF+Y9qGcYkvbq2TWWo=; b=RXjl/pezETJlA4BSDtdPJ5jK+tBcZGXt9/mk2a64wBct+3m/q7EJ7nIn10nvkIFBt3grUt R4dLpdOQjUkvbWkXpcOM89odhRz3U9iRF9eLPxTrxtqOBX6DmekENyvPdUvVQzpLHT/KcK tSCxLrG8th/7k/ZV/57UXn9ZOBmKx5Y= X-MC-Unique: A_4_g_HsMZm4w8M9oGcuMg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v3 1/9] internal: Add CONCAT macro Date: Thu, 30 Sep 2021 13:24:51 +0200 Message-Id: <20210930112459.11429-2-twiederh@redhat.com> In-Reply-To: <20210930112459.11429-1-twiederh@redhat.com> References: <20210930112459.11429-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.12 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: 1633001135901100005 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 e1250a59fe..48188e6fa3 100644 --- a/src/internal.h +++ b/src/internal.h @@ -93,6 +93,9 @@ =20 #define NUL_TERMINATE(buf) do { (buf)[sizeof(buf)-1] =3D '\0'; } while (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 07:16:11 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=1633001174; cv=none; d=zohomail.com; s=zohoarc; b=l/yQ/IStZLltXWc/pxpwCI2ltOJgT5mwSGncXM8KuAPXtSYUJMJqLWDeAowZtZhq2Nbp86fmENajNUkY6k5vt/7wUyyo3ZE3G/hZKWs/CFeIaNnL+3mbtKYRhONOwC6F5lRphI7+hbKN7CLRO7Xyxs4mBu7T0gPMGcBK3/c+UqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633001174; 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=8eJCprshXhLHW2OLi5ag6K9HgZhoDa6Aas5JTkpvveA=; b=lhINgnEgQn2QbJypucUf8mhpKItPtpL7Ki37i85zswKBvgG0mdKt9YmYTrw1OUG1DDhrc6jhOGCRhPGfTxtZ+ec6mtgPgilwmCNRyojmu9wE9JqFlHMrM0bWZLD+W/Tu349aiYfIkLPoXk7r+pqMc+7hYD/8xnD7UAAYBxGXEmo= 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 1633001174709847.5773096725175; Thu, 30 Sep 2021 04:26:14 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-372-vks17SP0PfuUMzIvfRxlYQ-1; Thu, 30 Sep 2021 07:26:11 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA551A0CAB; Thu, 30 Sep 2021 11:26:06 +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 CB1C360C82; Thu, 30 Sep 2021 11:26:06 +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 9920E1806D02; Thu, 30 Sep 2021 11:26:06 +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 18UBPEuJ021104 for ; Thu, 30 Sep 2021 07:25:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id A351A5F4EC; Thu, 30 Sep 2021 11:25:14 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.194.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id EACC45F4EB; Thu, 30 Sep 2021 11:25:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633001173; 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=8eJCprshXhLHW2OLi5ag6K9HgZhoDa6Aas5JTkpvveA=; b=SNlx90O7wH4J9SAzmPmzIVToNj+h79AURrIrK9PfN+oysgw7S13aglYimqCiexbZkeDmd0 668npTO1xSy52k3orQsCb7FwuKHk/vSrShiucnStTSVfnzn7/jp5iCvzNxKJBPJTxZ+Vzb t89XZtVTTPI+YNWAI3Jt8hRoCY3kq10= X-MC-Unique: vks17SP0PfuUMzIvfRxlYQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v3 2/9] virthread: Introduce virLockGuard Date: Thu, 30 Sep 2021 13:24:52 +0200 Message-Id: <20210930112459.11429-3-twiederh@redhat.com> In-Reply-To: <20210930112459.11429-1-twiederh@redhat.com> References: <20210930112459.11429-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.12 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: 1633001175531100001 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_autoptr(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 virLockGuardNew(m); /* `m` is locked, and released automatically on scope exit */ ... while (expression) { VIR_LOCK_GUARD lock2 =3D virLockGuardNew(...); /* similar */ } } Signed-off-by: Tim Wiederhake --- src/libvirt_private.syms | 3 +++ src/util/virthread.c | 26 ++++++++++++++++++++++++++ src/util/virthread.h | 11 +++++++++++ 3 files changed, 40 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6de9d9aef1..f41674781d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3373,6 +3373,9 @@ virCondInit; virCondSignal; virCondWait; virCondWaitUntil; +virLockGuardFree; +virLockGuardNew; +virLockGuardUnlock; virMutexDestroy; virMutexInit; virMutexInitRecursive; diff --git a/src/util/virthread.c b/src/util/virthread.c index e89c1a09fb..a5a948985f 100644 --- a/src/util/virthread.c +++ b/src/util/virthread.c @@ -96,6 +96,32 @@ void virMutexUnlock(virMutex *m) pthread_mutex_unlock(&m->lock); } =20 +virLockGuard *virLockGuardNew(virMutex *m) +{ + virLockGuard *l =3D g_new0(virLockGuard, 1); + l->mutex =3D m; + + virMutexLock(l->mutex); + return l; +} + +void virLockGuardFree(virLockGuard *l) +{ + if (!l) + return; + + virLockGuardUnlock(l); + g_free(l); +} + +void virLockGuardUnlock(virLockGuard *l) +{ + if (!l) + 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..d896a6ad3a 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,12 @@ void virMutexLock(virMutex *m); void virMutexUnlock(virMutex *m); =20 =20 +virLockGuard *virLockGuardNew(virMutex *m); +void virLockGuardFree(virLockGuard *l); +void virLockGuardUnlock(virLockGuard *l); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virLockGuard, virLockGuardFree); +#define VIR_LOCK_GUARD g_autoptr(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 07:16:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1633001139; cv=none; d=zohomail.com; s=zohoarc; b=YF6r/25/tXCAHZhyI1Da12ySp77mRZoBsI1Be12vsbYC9J+1zQLMR/MyinitOFr+fFzgOLlqrYiHkJq3laEnvGXBY0VfCWzwXgs8fQt99Mp3EkoHPOAA9Uv368pAhGybJkpKyx6YH+ADHf/d4pblQEqvwHm9Kh+WfdbHim7uOtw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633001139; 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=iMGfn4z541KxA5MA5UKsDfLwlcIDQxK+R6eLoeuIh40=; b=YPVzCMp10PKA8cX060DnM9zWfIJdsYoz5TOPa7+LRcRY+0Vz2nxhsM8vFxapy3JEEGTjs1gXSa4+fNtUGsPhrDH9eI7BW6LSJ9SguS5JzyTmrkvSb6R0f5776iN2Vw5iLE715KtmYwPhUM/DtW9aShb1W+qlSmzg3eit3WGWbuc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1633001139525854.8471788084574; Thu, 30 Sep 2021 04:25:39 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-439-jpyrUhiuOMetHtW-eWHXbA-1; Thu, 30 Sep 2021 07:25:36 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2480F1923784; Thu, 30 Sep 2021 11:25: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 C521960259; Thu, 30 Sep 2021 11:25:28 +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 695024EA37; Thu, 30 Sep 2021 11:25:28 +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 18UBPFOG021109 for ; Thu, 30 Sep 2021 07:25:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id AF8A35F4EC; Thu, 30 Sep 2021 11:25:15 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.194.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05B065F4EB; Thu, 30 Sep 2021 11:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633001137; 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=iMGfn4z541KxA5MA5UKsDfLwlcIDQxK+R6eLoeuIh40=; b=FO4UXpWq0bRQGqI8t7t8AV2AWEZvySO6FgTLdLE8P0WTwTBI/dEGCZF8ba0TZ1lzA1oqI7 jsCMOGy5eY6vzjQ+u1d7cYncqDLREH4CurO4sCwxix18azetM6fc168XjnBJzW3isRrVWf r90fBiOgKr2DrsRu4dQTl3CjubPuwoA= X-MC-Unique: jpyrUhiuOMetHtW-eWHXbA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v3 3/9] virthread: Introduce VIR_WITH_MUTEX_LOCK_GUARD Date: Thu, 30 Sep 2021 13:24:53 +0200 Message-Id: <20210930112459.11429-4-twiederh@redhat.com> In-Reply-To: <20210930112459.11429-1-twiederh@redhat.com> References: <20210930112459.11429-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.12 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: 1633001140670100002 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 d896a6ad3a..78b3684193 100644 --- a/src/util/virthread.h +++ b/src/util/virthread.h @@ -210,3 +210,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_autoptr(virLockGuard) CONCAT(var, __LINE__) =3D virLockGuardNew= (m); \ + CONCAT(var, __LINE__); \ + CONCAT(var, __LINE__) =3D (virLockGuardFree(CONCAT(var, __LINE__)= ), NULL)) --=20 2.31.1 From nobody Sun May 19 07:16:11 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=1633001177; cv=none; d=zohomail.com; s=zohoarc; b=FgDRD3Ds5JNIfTAKvNnDUEE84eit3SyRL3e1fbEU0K9DLwbPU2FwTsvDkNApwpFqKyJ/YNpOxgEEUPEkTrvmxu5E3jkJ3ZDIaTh3GoXs7eYmwsRsGZh+N8LwqGA2+EFXRVsF7nx9XxdZfhqitxYN2X+/DggI5JIRnU5HXIoFh9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633001177; 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=AV3qCwfv94riAz0CRB9s3RXDsATUEXVxn/f6eSZQlvg=; b=DUC/gLiWe8yHaj5PT4Oyi/Sw8u0Gr2goLq12alWbAIAm48gay21iaVA2KvpQMfQHO96yZ7KmCcUjkse9o2es6QZTPJndriE3WDzRMt/LV5SjufadnaNOAjpyDueV0z3OmrHEmFZs/kSBb1BBKnM8WF4mcoRx0sBtyZTKrW+YmNE= 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 1633001177662629.9902256442049; Thu, 30 Sep 2021 04:26:17 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-300-O51HvBbFOpW16oernNZDyA-1; Thu, 30 Sep 2021 07:26:14 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A0B651923762; Thu, 30 Sep 2021 11:26:09 +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 847CF60C9F; Thu, 30 Sep 2021 11:26:09 +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 286B64EA3A; Thu, 30 Sep 2021 11:26:09 +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 18UBPG0S021117 for ; Thu, 30 Sep 2021 07:25:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id BA6EC5F4F0; Thu, 30 Sep 2021 11:25:16 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.194.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F70D5F4EB; Thu, 30 Sep 2021 11:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633001176; 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=AV3qCwfv94riAz0CRB9s3RXDsATUEXVxn/f6eSZQlvg=; b=FyDJ+dRVUB51cYPJRxATD6OIm62EyEs0T/W+bSw64Qt6fIxMkeBvK1TPuyMvTbG/mXc4Dw tMS4dz4P99LeKsTZ4WckhFN3OJnFzkySxe/k1b9gGLC4HviIkL5SoibSsux33fiKDvMmnZ NAvSsRMQK1ed5GYtaxrWdisFRDXRPgU= X-MC-Unique: O51HvBbFOpW16oernNZDyA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v3 4/9] virobject: Introduce virObjectLockGuard Date: Thu, 30 Sep 2021 13:24:54 +0200 Message-Id: <20210930112459.11429-5-twiederh@redhat.com> In-Reply-To: <20210930112459.11429-1-twiederh@redhat.com> References: <20210930112459.11429-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.12 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: 1633001179716100003 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 f41674781d..733e40384e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2947,6 +2947,7 @@ virObjectListFree; virObjectListFreeCount; virObjectLock; virObjectLockableNew; +virObjectLockGuard; virObjectNew; virObjectRef; virObjectRWLockableNew; diff --git a/src/util/virobject.c b/src/util/virobject.c index 3412985b79..4812b79d56 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 virLockGuardNew(&obj->lock); +} + + /** * virObjectLock: * @anyobj: any instance of virObjectLockable diff --git a/src/util/virobject.h b/src/util/virobject.h index 1e34c77744..0c9cbea726 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 07:16:11 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=1633001166; cv=none; d=zohomail.com; s=zohoarc; b=PObFR1PMFZP0CfcNbsHR4XF8AhdvoshZgVC3w5Sfz4uETb0qRrZKlQ9uyApJyDW+pJIrSjEkgnMwmuPcGRjwrQdZ8BSkq/zA59e5uTTOKp1gkLWxY7NEe4fujwN5A/q7tmyIA4FNKbevZR14HuqJ4Pqbnyac1Dzf93mt42h7yM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633001166; 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=qaisCUo2jE+O6YLh3N9Rh5nWfT5Y7BfqnVHJPRr3hk8=; b=LewSeCeXiHi7sRGEuuRlnnJ2lkQoI3LfkqKafs1PSnvwbOZPxnPtcuZgE5P2e2+dccHlLpuAtA7pQbE9unsjW0TqbowDqNsnOm6XYiyB+5ultTCHG4uuVaSIfOUdoxsa2vKyygGjazyyqMzBMijmm1Kv79Nx872XmfI6PmL17ko= 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 1633001166600247.76120126109004; Thu, 30 Sep 2021 04:26:06 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-530-ZmTBNQANOy6hmZc0x-LCsw-1; Thu, 30 Sep 2021 07:25:38 -0400 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 2B3EB9128E; Thu, 30 Sep 2021 11:25:32 +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 DDEC65C23A; Thu, 30 Sep 2021 11:25:31 +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 893CC4EA39; Thu, 30 Sep 2021 11:25:31 +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 18UBPHb0021127 for ; Thu, 30 Sep 2021 07:25:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id C556A5F4FD; Thu, 30 Sep 2021 11:25:17 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.194.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A3425F4EB; Thu, 30 Sep 2021 11:25:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633001165; 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=qaisCUo2jE+O6YLh3N9Rh5nWfT5Y7BfqnVHJPRr3hk8=; b=QdC66egLaZ4D/0D3P2HnOhBDoQhlFA/aJnCC5IN4uhJ+LJIo24n3I5kFFTF1icnMwqYcYW kq3p6AO6SxRlADrEonYRuwz7cUijKbuhr+o93vlGzC5rcC9GAPgicG9epgK/v0ln2t0yqB 8A0m/PVEKhdrOQa1LIFwPUFgYpDrIHc= X-MC-Unique: ZmTBNQANOy6hmZc0x-LCsw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v3 5/9] virobject: Introduce VIR_WITH_OBJECT_LOCK_GUARD Date: Thu, 30 Sep 2021 13:24:55 +0200 Message-Id: <20210930112459.11429-6-twiederh@redhat.com> In-Reply-To: <20210930112459.11429-1-twiederh@redhat.com> References: <20210930112459.11429-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: 1633001166865100001 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 0c9cbea726..a95985b69a 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_autoptr(virLockGuard) CONCAT(var, __LINE__) =3D virObjectLockGu= ard(o); \ + CONCAT(var, __LINE__); \ + CONCAT(var, __LINE__) =3D (virLockGuardFree(CONCAT(var, __LINE__)= ), NULL)) --=20 2.31.1 From nobody Sun May 19 07:16:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1633001184; cv=none; d=zohomail.com; s=zohoarc; b=bnstrdAGuIJR8W2DXKdK2BGiSNsXuKrqE/cPgcjp3BRUDCh+BlKdxJ8h1PJKkLmA53nCb6XKVTWEYD1NEHTTpbDm84z6seoBo2Hi3C/PIau42Isot2ZQN/br1PflmyjQLz5rcIeJAIpWCIPuTEdp1wbvM1VPxUTwLtziMy+cY3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633001184; 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=PeS0o4fZ4qJy5QhcGLO15mMRS8H2jrD1ygEJBu4UqtE=; b=km5u6ZJg7cqKSGH4xTI8qtLrj+W2/66JevcOVeu2nxsMkqDgju/sedYb2Dr22nk59p5NuU8VAqeMZzGxZPrYvnIwBx8q3oGNRWc+jEJJ775AU4o229SepUjfy/8cuY83Zly6rvg0x80moWFUqiHfwJXZwEg3YCG73qeaIPm3QDw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1633001184749217.11470378001263; Thu, 30 Sep 2021 04:26:24 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-563-KJhWuHirNoCJx4tQom4YXw-1; Thu, 30 Sep 2021 07:26:21 -0400 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 3324F100C669; Thu, 30 Sep 2021 11:26:13 +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 1685A5C23A; Thu, 30 Sep 2021 11:26:13 +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 DBD4E180BAD1; Thu, 30 Sep 2021 11:26:12 +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 18UBPLbn021150 for ; Thu, 30 Sep 2021 07:25:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5770B5F4FC; Thu, 30 Sep 2021 11:25:21 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.194.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id A19855F4F7; Thu, 30 Sep 2021 11:25:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633001183; 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=PeS0o4fZ4qJy5QhcGLO15mMRS8H2jrD1ygEJBu4UqtE=; b=ayUjgR5sm20/q2wCurqq1vjSjR31qoyr/qNtnVb2Erixkb1LhstPbxWd4SpdEauEL5vyus qgbkGMI3ion7a+pdoDlZ0gvGNYNFA3/dUxz36/v/yMJiR+8SQWC1466hSGqFovgTEhJ4qc ZKHsKHb25ZTwmrvkTYk7MDG9OJQZYZY= X-MC-Unique: KJhWuHirNoCJx4tQom4YXw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v3 6/9] virChrdevFDStreamCloseCb: Use virLockGuardNew Date: Thu, 30 Sep 2021 13:24:56 +0200 Message-Id: <20210930112459.11429-7-twiederh@redhat.com> In-Reply-To: <20210930112459.11429-1-twiederh@redhat.com> References: <20210930112459.11429-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: 1633001186426100001 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 5d6de68427..0184a1ae10 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 virLockGuardNew(&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 07:16:11 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=1633001185; cv=none; d=zohomail.com; s=zohoarc; b=BBG+rC/7aE5ss5oZ4wjhFyFBFUHHWhMzScYJ0C3RXEa715mfMQl2ck9A+wrHX694XiYK/eTXrTVuhIlA5Qk6e/4pz6HX4VZqrqee0ruTffGQ2TMT2Ni21tKtA4Aprl+Ltqw34y28PFz5RzkNlC8zCo+oGcIC+p2myMjHfBN+/A8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633001185; 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=K+sU1q/ASlkk0532z1gQI1CQ8DxOxixzhe3c4GBEDmY=; b=b/nyUVR4gBG5yl+1IRhDs7PIbacK3euucb30NhGCc+aZy1tH0q/t5jODgTae9/efLgj9FZmXtWRWZ/T+dqGLM9SKvOZn0B9KVFfgXF321Jw7qPQJX5TeQP31Wk2WxH/+QT+V+jXY7s7CddyxXf6dwUHullOUVK3GKu5pINyVxGw= 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 1633001185249659.2788319838527; Thu, 30 Sep 2021 04:26:25 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-33-zYkXnc2wMb-jfbENgi7BxQ-1; Thu, 30 Sep 2021 07:26:22 -0400 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 759591923783; Thu, 30 Sep 2021 11:26:16 +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 1D0A6838D6; Thu, 30 Sep 2021 11:26:16 +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 C1F3A4EA3C; Thu, 30 Sep 2021 11:26:15 +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 18UBPMAU021155 for ; Thu, 30 Sep 2021 07:25:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 630225F4FB; Thu, 30 Sep 2021 11:25:22 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.194.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA1075F4F7; Thu, 30 Sep 2021 11:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633001184; 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=K+sU1q/ASlkk0532z1gQI1CQ8DxOxixzhe3c4GBEDmY=; b=B65F9yZuQmSQt1JXDO/RxcSmB1YkQ3ZT2O6Ai7bua8rqlufIJ9RlkhwHbNfIlLJBRtW4wm rbtV+kc3dttDpGWWE8jj21qpKM62LYujm1CypPB1ZlDW0NvZ/eLXrVITXrn1PXOpDZioQs DGEVoHu7naL0406AaPwlcBQjxwUU2VQ= X-MC-Unique: zYkXnc2wMb-jfbENgi7BxQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v3 7/9] virChrdevFree: Use VIR_WITH_MUTEX_LOCK Date: Thu, 30 Sep 2021 13:24:57 +0200 Message-Id: <20210930112459.11429-8-twiederh@redhat.com> In-Reply-To: <20210930112459.11429-1-twiederh@redhat.com> References: <20210930112459.11429-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: 1633001186495100002 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 0184a1ae10..1cf727d46e 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); - virHashFree(devs->hash); - virMutexUnlock(&devs->lock); + VIR_WITH_MUTEX_LOCK_GUARD(&devs->lock) { + virHashForEachSafe(devs->hash, virChrdevFreeClearCallbacks, NULL); + virHashFree(devs->hash); + } virMutexDestroy(&devs->lock); =20 g_free(devs); --=20 2.31.1 From nobody Sun May 19 07:16:11 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=1633001134; cv=none; d=zohomail.com; s=zohoarc; b=XmmgUk088npNw4tAUhympaDXBOPCFiAPL5WhfMZojqDPi6fXuV/atiZATS3rGiw5clRyzRPrz1KwIQGubmPEv+6aUSv1vjHGboFBLdAMe+sIG4lhDRCbqHw3iUcO20NTfn8CgJyJqrtYzuKJOQ95lL80xIZkVotkpVdLZ4ChFzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633001134; 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=vJrgy6AmepKmK9CREwswzOOk35IWU92hTXh4671gHtU=; b=BwKkr6BkxtyfyUM4GrdwwwQoMBv64z0rGxdK6COGG05vupPsyaEko/aI6UBtfYaLp83uTnNYzs5sJ0NFVfPVIxCwB2SgG8UubWbCwsFc6PNqRW4Og9fgncSguFW8NNB1mLr6Aj3ti70zwBf6BWrjD/T22t8KpKxa67/CGdzZI2k= 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 1633001134223560.1020716839502; Thu, 30 Sep 2021 04:25:34 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-356-Ss7rJGQpPp265S6A3PeG1g-1; Thu, 30 Sep 2021 07:25:30 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B3A711084686; Thu, 30 Sep 2021 11:25:25 +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 95CD260BE5; Thu, 30 Sep 2021 11:25: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 659A24EA2A; Thu, 30 Sep 2021 11:25:25 +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 18UBPNfg021164 for ; Thu, 30 Sep 2021 07:25:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 69FEC5F4F7; Thu, 30 Sep 2021 11:25:23 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.194.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3A2F5F4FE; Thu, 30 Sep 2021 11:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633001133; 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=vJrgy6AmepKmK9CREwswzOOk35IWU92hTXh4671gHtU=; b=XcZx6Ye7gl8ZKuqeIwsa15Bnf8QzvQF8/kLI/IOHUXVilRlCaiYmya/DCbvrbIPavQnqQQ Mxf65CtqCEd/AkkaqCqOSkmPDR0+SGsxZgaBczEUCkhRjnUM1UEsxrX5UprlmGERL1Q2ec n8LWN9dz+ra/nd5+GHjkCGayboXKkqc= X-MC-Unique: Ss7rJGQpPp265S6A3PeG1g-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v3 8/9] bhyveAutostartDomain: Use virObjectLockGuard Date: Thu, 30 Sep 2021 13:24:58 +0200 Message-Id: <20210930112459.11429-9-twiederh@redhat.com> In-Reply-To: <20210930112459.11429-1-twiederh@redhat.com> References: <20210930112459.11429-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.12 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: 1633002037329100001 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 516490f6cd..c41de30be9 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 07:16:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1633001164; cv=none; d=zohomail.com; s=zohoarc; b=UuodnSpsLUTn8YqGcdKUbmgi+1wbFZHiyZj+BivMQFPmWbnRnjhbOLaEV5hdAcm/eoAGuFXHBTNal9q2pNYtBJxyyXVrVa2z1/IQpdfk0/5RNYcu8Sp/AUk+LbFjJEc73ri2VGbBM5YXQaYSRkxzBvyLAcWDJuAVA9ZLFfASNxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633001164; 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=KgMRrtQofiRmzgzeeJPAqzDYZm0uw6TKrxh6PpEqAbY=; b=aJI33BbRoxHHl5GArd/1CRyF0WU8MQoN/5cnp3aI/tOgGYXo6mA/brO7Er5WrhbUL16BYjC1XdCdUxhKVdDTDzuyfyUeMFrKdJ6rWMaJdC+xLtQHOY0gK2W2Jg/147mrUM58L02CTXLfMKt/Du7/S+6z8xusobWul5UDau4ZPno= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1633001164001551.4476670135589; Thu, 30 Sep 2021 04:26:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-481-8Lk22GsLP262zdc6EIFnrg-1; Thu, 30 Sep 2021 07:25:34 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E519F835DF8; Thu, 30 Sep 2021 11:25:28 +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 95A8A60FB8; Thu, 30 Sep 2021 11:25:28 +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 4BF6C1806D03; Thu, 30 Sep 2021 11:25:28 +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 18UBPOwm021171 for ; Thu, 30 Sep 2021 07:25:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 72EF45F4FC; Thu, 30 Sep 2021 11:25:24 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.194.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD7975F4F7; Thu, 30 Sep 2021 11:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633001163; 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=KgMRrtQofiRmzgzeeJPAqzDYZm0uw6TKrxh6PpEqAbY=; b=Cyh+G3/Irr5rmxjtOJuUkeoeU2jS1RxdnzfFAz/8rgAwfgLlE/Jbd44SGDrDpmqaTJKOM8 F1L8dhNYy4385D8RvqBLYUkt3ZYoSbtS6lKRVqW6+uqA3QlvHvhA1jxTwxxmMS2pKmR7mz 3NPRgTVuIny4FmWq+trFBsgwu1M2Xak= X-MC-Unique: 8Lk22GsLP262zdc6EIFnrg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v3 9/9] lxcDomainDetachDeviceHostdevUSBLive: Use VIR_WITH_OBJECT_LOCK_GUARD Date: Thu, 30 Sep 2021 13:24:59 +0200 Message-Id: <20210930112459.11429-10-twiederh@redhat.com> In-Reply-To: <20210930112459.11429-1-twiederh@redhat.com> References: <20210930112459.11429-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.12 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: 1633001164625100001 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 e2720a6f89..528af5d164 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -4079,9 +4079,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