From nobody Mon Feb 9 17:34:45 2026 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=1646824353; cv=none; d=zohomail.com; s=zohoarc; b=KDJUHXbB5QrM3amrin3PdfVKNiUGlyXpt1j9SZI0nJKjyzCXjAY2Fi7CyyJDt9f+APWoh2MQpWM2xjxSfdgGhpblbmQe6fhlgaZCro2pDOl1hK/9ufSWsHFZBB2gHe3LW62RZpsQUGQ7Xsvz617IqzQJ4wapjOorvelKSR93nzc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646824353; 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=wW07S1qKn4g7JOIOisrtgZKUbcRrwg9kVSeudyowb7k=; b=fgEi7u/YVVF76PfW11CAaQahGkT2ZO9epqlMujSU3XEkezuqbzwdve3gKUCXc5aj1F35Nyv0BeU24hwz1W9p45iZ75KgItvCTEfM3ljfn0oaHng+YEPcL/xlW3vJHKKsrTTCWSPQFZnUiokjpW1gW5nexBDj4S7/LQAZdgRF4Ok= 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 1646824353422756.5376282257048; Wed, 9 Mar 2022 03:12:33 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-627-XeyencAuNaCP2aWXFh8ULA-1; Wed, 09 Mar 2022 06:12:30 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3E56329AA2FE; Wed, 9 Mar 2022 11:12:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 298DF1121319; Wed, 9 Mar 2022 11:12:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A361C1932121; Wed, 9 Mar 2022 11:03:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5E4EF1932121 for ; Wed, 9 Mar 2022 11:03:01 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 01C431059175; Wed, 9 Mar 2022 11:03:01 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.195.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B30110550B8; Wed, 9 Mar 2022 11:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646824353; 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=wW07S1qKn4g7JOIOisrtgZKUbcRrwg9kVSeudyowb7k=; b=hlzUvWMfxrq41WzhvS3UWo4xD4+kmkhxDIb290cPbkSaLzIjuNCXWHW315Seu7cLueTBMM H6gwnvLEETgjmVrlVikkdE/lI/L8ZtAjb3JFnOLNX8yxb9kYRmwHbZCqkw6u3bho/dWjf7 6y5aLb+6Kcso2mAZH48y0IyeCMNMvcM= X-MC-Unique: XeyencAuNaCP2aWXFh8ULA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 04/12] nwfilter_gentech: Use automatic mutex management Date: Wed, 9 Mar 2022 12:02:22 +0100 Message-Id: <20220309110230.24213-5-twiederh@redhat.com> In-Reply-To: <20220309110230.24213-1-twiederh@redhat.com> References: <20220309110230.24213-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tim Wiederhake Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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: 1646824354839100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake --- src/nwfilter/nwfilter_gentech_driver.c | 34 +++++++++----------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter= _gentech_driver.c index 7bbf1e12fb..3f888ce873 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -717,9 +717,7 @@ virNWFilterInstantiateFilterInternal(virNWFilterDriverS= tate *driver, bool *foundNewFilter) { int ifindex; - int rc; - - virMutexLock(&updateMutex); + VIR_LOCK_GUARD lock =3D virLockGuardLock(&updateMutex); =20 /* after grabbing the filter update lock check for the interface; if it's not there anymore its filters will be or are being removed @@ -729,20 +727,14 @@ virNWFilterInstantiateFilterInternal(virNWFilterDrive= rState *driver, /* interfaces / VMs can disappear during filter instantiation; don't mark it as an error */ virResetLastError(); - rc =3D 0; - goto cleanup; + return 0; } =20 - rc =3D virNWFilterInstantiateFilterUpdate(driver, teardownOld, - binding, - ifindex, - useNewFilter, - false, foundNewFilter); - - cleanup: - virMutexUnlock(&updateMutex); - - return rc; + return virNWFilterInstantiateFilterUpdate(driver, teardownOld, + binding, + ifindex, + useNewFilter, + false, foundNewFilter); } =20 =20 @@ -753,9 +745,10 @@ virNWFilterInstantiateFilterLate(virNWFilterDriverStat= e *driver, { int rc; bool foundNewFilter =3D false; + VIR_LOCK_GUARD lock =3D { NULL }; =20 virNWFilterReadLockFilterUpdates(); - virMutexLock(&updateMutex); + lock =3D virLockGuardLock(&updateMutex); =20 rc =3D virNWFilterInstantiateFilterUpdate(driver, true, binding, ifindex, @@ -772,7 +765,6 @@ virNWFilterInstantiateFilterLate(virNWFilterDriverState= *driver, } =20 virNWFilterUnlockFilterUpdates(); - virMutexUnlock(&updateMutex); =20 return rc; } @@ -894,11 +886,9 @@ _virNWFilterTeardownFilter(const char *ifname) int virNWFilterTeardownFilter(virNWFilterBindingDef *binding) { - int ret; - virMutexLock(&updateMutex); - ret =3D _virNWFilterTeardownFilter(binding->portdevname); - virMutexUnlock(&updateMutex); - return ret; + VIR_LOCK_GUARD lock =3D virLockGuardLock(&updateMutex); + + return _virNWFilterTeardownFilter(binding->portdevname); } =20 enum { --=20 2.31.1