From nobody Tue Feb 10 09:24:50 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=1629498925; cv=none; d=zohomail.com; s=zohoarc; b=LuZ3xw1hBtCyzbWd1/KCh3sdthtK3iWiPA0jYiZVDEV+aBg3XZ1D4Lwo8wrTpx7DFIrWLxOMSlggSx88OzeIBL+iwMW3Q88DwF8faRehJ04CZAi2nPpS7uWCiXNwhL3v+qWeWfRTTeE4gtzStMZmRarGZXzzbuG5MPIyYC+PdMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629498925; 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=avDiUmgWwqTQ6N+zqzpsNEbuX2Y7LL94w8Sh7BpUIwA=; b=X9+MTZK/WKRp/MjihJN7ht9BXcoFap18zYWFoyVhVttz6wEAKFRj4ZT4w+jvzK/yeuBn4jXzJjDYutCW/qMn+Z+6iiYzlxEfApw8s1SwX8ul9OcIB8ENzMe0ClWNjVty30sMSRgVNwSc22iVyWRKZzZBw6q/kZ1YGKKiArDIR30= 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 1629498925224779.6852741208153; Fri, 20 Aug 2021 15:35: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-306-r-fDyrhMOZmtikcoWfC_Jg-1; Fri, 20 Aug 2021 18:35:21 -0400 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 30BD0871812; Fri, 20 Aug 2021 22:35:17 +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 11EC869FAE; Fri, 20 Aug 2021 22:35:17 +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 D159F4A7CD; Fri, 20 Aug 2021 22:35:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KMTgFK028176 for ; Fri, 20 Aug 2021 18:29:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id D13991A26A; Fri, 20 Aug 2021 22:29:42 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-114-57.phx2.redhat.com [10.3.114.57]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 934451F5; Fri, 20 Aug 2021 22:29:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629498924; 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=avDiUmgWwqTQ6N+zqzpsNEbuX2Y7LL94w8Sh7BpUIwA=; b=boNHfYaprvBEKZFua7pbMxoFZBp192tsEEspCNmGxVaJpYqLQIchfYTwBWZZRl48X/FQVO 1SIMh/1jeHeR8N+rHvA2GHobtU6ALkf5l98jICw/IUukesxqbHGMu1UeA0+VF3Kdan4av8 ShUnwpfO1zXNQS1fCJW74jKUo4LSIeY= X-MC-Unique: r-fDyrhMOZmtikcoWfC_Jg-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v3 6/7] nodedev: Implement virNodeDeviceIsPersistent()/IsActive() Date: Fri, 20 Aug 2021 17:29:34 -0500 Message-Id: <20210820222935.3414029-7-jjongsma@redhat.com> In-Reply-To: <20210820222935.3414029-1-jjongsma@redhat.com> References: <20210820222935.3414029-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629498926389100001 Implement these new API functions in the nodedev driver. Signed-off-by: Jonathon Jongsma Reviewed-by: Daniel P. Berrang=C3=A9 --- src/node_device/node_device_driver.c | 50 ++++++++++++++++++++++++++++ src/node_device/node_device_driver.h | 6 ++++ src/node_device/node_device_udev.c | 10 ++++-- 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index bb18b24e53..3bc6eb1c11 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -1989,3 +1989,53 @@ int nodeDeviceDefValidate(virNodeDeviceDef *def, } return 0; } + + +int +nodeDeviceIsPersistent(virNodeDevice *device) +{ + virNodeDeviceObj *obj =3D NULL; + virNodeDeviceDef *def =3D NULL; + int ret =3D -1; + + if (nodeDeviceInitWait() < 0) + return -1; + + if (!(obj =3D nodeDeviceObjFindByName(device->name))) + return -1; + def =3D virNodeDeviceObjGetDef(obj); + + if (virNodeDeviceIsPersistentEnsureACL(device->conn, def) < 0) + goto cleanup; + + ret =3D virNodeDeviceObjIsPersistent(obj); + + cleanup: + virNodeDeviceObjEndAPI(&obj); + return ret; +} + + +int +nodeDeviceIsActive(virNodeDevice *device) +{ + virNodeDeviceObj *obj =3D NULL; + virNodeDeviceDef *def =3D NULL; + int ret =3D -1; + + if (nodeDeviceInitWait() < 0) + return -1; + + if (!(obj =3D nodeDeviceObjFindByName(device->name))) + return -1; + def =3D virNodeDeviceObjGetDef(obj); + + if (virNodeDeviceIsActiveEnsureACL(device->conn, def) < 0) + goto cleanup; + + ret =3D virNodeDeviceObjIsActive(obj); + + cleanup: + virNodeDeviceObjEndAPI(&obj); + return ret; +} diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_de= vice_driver.h index 17c7473d85..7311b603ac 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -186,6 +186,12 @@ int nodeDeviceGetAutostart(virNodeDevice *dev, int *autostart); =20 +int +nodeDeviceIsPersistent(virNodeDevice *dev); + +int +nodeDeviceIsActive(virNodeDevice *dev); + virCommand* nodeDeviceGetMdevctlSetAutostartCommand(virNodeDeviceDef *def, bool autostart, diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 73334c1cc7..0f1770f771 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1503,7 +1503,7 @@ udevAddOneDevice(struct udev_device *device) virObjectEvent *event =3D NULL; bool new_device =3D true; int ret =3D -1; - bool was_persistent =3D false; + bool persistent =3D false; bool autostart =3D false; bool is_mdev; =20 @@ -1534,7 +1534,8 @@ udevAddOneDevice(struct udev_device *device) =20 if (is_mdev) nodeDeviceDefCopyFromMdevctl(def, objdef); - was_persistent =3D virNodeDeviceObjIsPersistent(obj); + + persistent =3D virNodeDeviceObjIsPersistent(obj); autostart =3D virNodeDeviceObjIsAutostart(obj); =20 /* If the device was defined by mdevctl and was never instantiated= , it @@ -1548,7 +1549,7 @@ udevAddOneDevice(struct udev_device *device) * and the current definition will take its place. */ if (!(obj =3D virNodeDeviceObjListAssignDef(driver->devs, def))) goto cleanup; - virNodeDeviceObjSetPersistent(obj, was_persistent); + virNodeDeviceObjSetPersistent(obj, persistent); virNodeDeviceObjSetAutostart(obj, autostart); objdef =3D virNodeDeviceObjGetDef(obj); =20 @@ -1954,6 +1955,7 @@ udevSetupSystemDev(void) =20 virNodeDeviceObjSetActive(obj, true); virNodeDeviceObjSetAutostart(obj, true); + virNodeDeviceObjSetPersistent(obj, true); =20 virNodeDeviceObjEndAPI(&obj); =20 @@ -2360,6 +2362,8 @@ static virNodeDeviceDriver udevNodeDeviceDriver =3D { .nodeDeviceCreate =3D nodeDeviceCreate, /* 7.3.0 */ .nodeDeviceSetAutostart =3D nodeDeviceSetAutostart, /* 7.7.0 */ .nodeDeviceGetAutostart =3D nodeDeviceGetAutostart, /* 7.7.0 */ + .nodeDeviceIsPersistent =3D nodeDeviceIsPersistent, /* 7.7.0 */ + .nodeDeviceIsActive =3D nodeDeviceIsActive, /* 7.7.0 */ }; =20 =20 --=20 2.31.1