From nobody Tue Feb 10 04:03:30 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=1618244745; cv=none; d=zohomail.com; s=zohoarc; b=XHW3lKpUytrErSAzHpnxVPcTIHi6ACbono1UaVWXEnli5hWte9hugQuSHVWBGNSH8p50FAYETnEHInRGtg0PsX+uQkEOFw9cGq1VnHQOa1VAl6BoarWem4EoYagkikN5Z58T2xqmpBtFPj7G2FOb1hNnqA99V1cCFjW7N/9IqJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618244745; h=Content-Type:Content-Transfer-Encoding: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=f/ph8nLyqpzT+uBi7XVemDKQ1U/rMHbKRUn8KohbAbw=; b=RpHfnZokCANZZ+wTFoQhczQXtY/cnqjgmue4y6rZGRdlYBSeeiitB+/q4nWpbb0QXHBouhaMGfxG47TBmTmerLCvz7vPtO1BTovjejpypSQZG+xR4Cvnq5elcRLwm40/8CU66LKVAFP+S4fHi3a8R2EkAIfPGx5tUnFSl2O+Gac= 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) header.from= 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 1618244745721452.4332995302069; Mon, 12 Apr 2021 09:25:45 -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-162-kJMOl66YP2yDbpabGG4gXw-1; Mon, 12 Apr 2021 12:25:42 -0400 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 3B19F87A826; Mon, 12 Apr 2021 16:25:37 +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 16DE85D9DE; Mon, 12 Apr 2021 16:25: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 D278E44A60; Mon, 12 Apr 2021 16:25:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13CGMXIp004572 for ; Mon, 12 Apr 2021 12:22:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2C5D550DE3; Mon, 12 Apr 2021 16:22:33 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.200]) by smtp.corp.redhat.com (Postfix) with ESMTP id A48496062F for ; Mon, 12 Apr 2021 16:22:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618244744; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=f/ph8nLyqpzT+uBi7XVemDKQ1U/rMHbKRUn8KohbAbw=; b=gpDX53wumOmxpsKg81q5Rslo/Bq9uD2zM/z8Lj1Wq5w+2ebxL04xo+pmQnGdyWhEQ6JJp4 C5MqqvUvcjWuQkZ4NbRitPkNZ12oXDXB7zIzCk0u1BW4FbQe9CKja+btDHG43rGXuiYhUZ Fw9bneFsQAqo+Y+LlCe7i60lb7eM8iA= X-MC-Unique: kJMOl66YP2yDbpabGG4gXw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/5] nodedev: Separate mdevctl monitor setup into a function Date: Mon, 12 Apr 2021 18:22:23 +0200 Message-Id: <0752102c7000e1d5cdfa2e3f3d36dbbab0e7d9cb.1618243050.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik --- src/node_device/node_device_udev.c | 37 +++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 3e9c7a8d80..18219175c5 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -2119,6 +2119,29 @@ monitorFileRecursively(udevEventData *udev, } =20 =20 +static int +mdevctlEnableMonitor(udevEventData *priv) +{ + g_autoptr(GFile) mdevctlConfigDir =3D g_file_new_for_path("/etc/mdevct= l.d"); + + /* mdevctl may add notification events in the future: + * https://github.com/mdevctl/mdevctl/issues/27. For now, fall back to + * monitoring the mdevctl configuration directory for changes. + * mdevctl configuration is stored in a directory tree within + * /etc/mdevctl.d/. There is a directory for each parent device, which + * contains a file defining each mediated device */ + virMutexLock(&priv->mdevctlLock); + if (!(priv->mdevctlMonitors =3D monitorFileRecursively(priv, + mdevctlConfigDir)= )) { + virMutexUnlock(&priv->mdevctlLock); + return -1; + } + virMutexUnlock(&priv->mdevctlLock); + + return 0; +} + + static void mdevctlEventHandleCallback(GFileMonitor *monitor G_GNUC_UNUSED, GFile *file, @@ -2168,7 +2191,6 @@ nodeStateInitialize(bool privileged, { udevEventDataPtr priv =3D NULL; struct udev *udev =3D NULL; - g_autoptr(GFile) mdevctlConfigDir =3D g_file_new_for_path("/etc/mdevct= l.d"); =20 if (root !=3D NULL) { virReportError(VIR_ERR_INVALID_ARG, "%s", @@ -2272,19 +2294,8 @@ nodeStateInitialize(bool privileged, if (priv->watch =3D=3D -1) goto unlock; =20 - /* mdevctl may add notification events in the future: - * https://github.com/mdevctl/mdevctl/issues/27. For now, fall back to - * monitoring the mdevctl configuration directory for changes. - * mdevctl configuration is stored in a directory tree within - * /etc/mdevctl.d/. There is a directory for each parent device, which - * contains a file defining each mediated device */ - virMutexLock(&priv->mdevctlLock); - if (!(priv->mdevctlMonitors =3D monitorFileRecursively(priv, - mdevctlConfigDir)= )) { - virMutexUnlock(&priv->mdevctlLock); + if (mdevctlEnableMonitor(priv) < 0) goto unlock; - } - virMutexUnlock(&priv->mdevctlLock); =20 virObjectUnlock(priv); =20 --=20 2.26.3