From nobody Mon Feb 9 16:13:04 2026 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=1644359587; cv=none; d=zohomail.com; s=zohoarc; b=gkn35NLzB6H1n/eLVkTfuDXGsNR8HsCT/ahDznhLHKK8NcwbgULQqmswy7Hntlp6AtdMXWGv19M9uOoSOI9TMHDnqpWdb5U+mBIWMmohYqEHCwA8+lKI35XTjzYz+GBy67I7vJzobJjjev+9u/YG0CMMnBkC4jxfottPKHdr9Z0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644359587; 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=qH3VOOf1wryJ4XbPQficW95IO5SDomwET7zczJ97HMU=; b=WAFW5f90jM21OEtCN11TWPgKOK4THz+3TSHYtLu0zQ8QGpz5x7Xhq35KIlh4GgB6KVGyuqfKJ56oa3XgdUJdm5YP9EcLxeL93M9RC87PrFCsFze1ShAKKLJJ3bRj18lF3rtyEGCPyOsKGideBknO94xrjJdU39YKehDX5UCRGWU= 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 1644359587662861.6405794764096; Tue, 8 Feb 2022 14:33:07 -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-518-Hgjy0VR8OkyKDitwSNHl6A-1; Tue, 08 Feb 2022 17:33:03 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C42618397A7; Tue, 8 Feb 2022 22:32:58 +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 026014CEEC; Tue, 8 Feb 2022 22:32:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9DFBF4A7C8; Tue, 8 Feb 2022 22:32:55 +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 217DCKoe006317 for ; Mon, 7 Feb 2022 08:12:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 69AF01038ACA; Mon, 7 Feb 2022 13:12:20 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.192.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id B35DD1038AC4; Mon, 7 Feb 2022 13:12:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644359586; 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=qH3VOOf1wryJ4XbPQficW95IO5SDomwET7zczJ97HMU=; b=gJ1vsb5y+8PM8F14xVP7W7ZZt3SgVpFwaS8awGYi1lwdAMHDFfcmpDLvVAtO2ZUhmFdDfM IoL/I6Oz4Eh5Me6laHG51j4gTGtyEO3UKnHJeNNXI15X1dgC3uazIzIqAPX/+U8EXwuPJr B3q6wv24IFa03MRkLuD5mfPcy6L64fY= X-MC-Unique: Hgjy0VR8OkyKDitwSNHl6A-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 04/11] lxc: Prepare virLXCDriverGetCapabilities for automatic mutex management Date: Mon, 7 Feb 2022 14:12:07 +0100 Message-Id: <20220207131214.54855-5-twiederh@redhat.com> In-Reply-To: <20220207131214.54855-1-twiederh@redhat.com> References: <20220207131214.54855-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.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1644359588873100001 Content-Type: text/plain; charset="utf-8" No functional change intended. This change makes the recfatoring to automatic mutex management easier to follow. Signed-off-by: Tim Wiederhake --- src/lxc/lxc_conf.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index 8955578d54..cf6679711a 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -156,28 +156,28 @@ virCaps *virLXCDriverCapsInit(virLXCDriver *driver) virCaps *virLXCDriverGetCapabilities(virLXCDriver *driver, bool refresh) { - virCaps *ret; - if (refresh) { - virCaps *caps =3D NULL; - if ((caps =3D virLXCDriverCapsInit(driver)) =3D=3D NULL) - return NULL; + virCaps *ret =3D NULL; + virCaps *caps =3D NULL; + + lxcDriverLock(driver); + if (!refresh && !driver->caps) { + VIR_DEBUG("Capabilities didn't detect any guests. Forcing a refres= h."); + refresh =3D true; + } + lxcDriverUnlock(driver); =20 - lxcDriverLock(driver); + if (refresh && !(caps =3D virLXCDriverCapsInit(driver))) + return NULL; + + lxcDriverLock(driver); + if (refresh) { virObjectUnref(driver->caps); driver->caps =3D caps; - } else { - lxcDriverLock(driver); - - if (driver->caps =3D=3D NULL) { - VIR_DEBUG("Capabilities didn't detect any guests. Forcing a " - "refresh."); - lxcDriverUnlock(driver); - return virLXCDriverGetCapabilities(driver, true); - } } =20 ret =3D virObjectRef(driver->caps); lxcDriverUnlock(driver); + return ret; } =20 --=20 2.31.1