From nobody Mon Feb 9 19:06:51 2026 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=1622751156; cv=none; d=zohomail.com; s=zohoarc; b=cabvYEiFARw5Cpdt92115rAQPFcR/vyzWEDqHb9AuHwCXpdRM/rpFiNsExyZaJYBnPc7qgcjqgZVpuKNnEdCAjRlUE8M7DNfGNEyrTqtPCcw/wMdEE80dOggH59yul2UQ8Cs1/5tMszqggIT9XIB7XQn1narIHstcy5yYoTBgqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622751156; 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=njL2VYpOxxOWgUYbgQcrfh6jWb1Nye/jRgDOpD2AQHc=; b=KA6nldchvlQ5+X3+56vFsPKnuASJpfhJPfHUlETwj5WlYZ58dFpKE9T06v7EsFX6O6J8jEBHCSQ1eTLklYl8JjIu3S41+bTvy4Cpj19H+txC4M9WoRa/ce+lmgJHmV3oyAkp+b54Aj/vClfs0Q1/h+5TtOcdNqXNeTlbfj6LRZI= 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) header.from= 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 1622751156852535.3838489481504; Thu, 3 Jun 2021 13:12:36 -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-253-0eI3UbTYNT6ck4oFDTP4Zg-1; Thu, 03 Jun 2021 16:12:32 -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 5902E180FD6D; Thu, 3 Jun 2021 20:12: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 3CCA3579B1; Thu, 3 Jun 2021 20:12:26 +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 D5A871813CA5; Thu, 3 Jun 2021 20:12:25 +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 153KC2Vb000756 for ; Thu, 3 Jun 2021 16:12:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1699419D7D; Thu, 3 Jun 2021 20:12:02 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-114-235.phx2.redhat.com [10.3.114.235]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DB9C219C44 for ; Thu, 3 Jun 2021 20:12:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622751155; 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=njL2VYpOxxOWgUYbgQcrfh6jWb1Nye/jRgDOpD2AQHc=; b=MPOFB51fwsaNEr6vktSKu/NyJg79ue2WiCVUcWoFoY4XVb0Ep2uwUsMAxpSMekZ9VJsLSZ bWkZ1IfXnwdCVNc7dIaSob5iPEpeBD/HgVOKgjG23UY5KLQa34KVMuM/1zIIXHpZksZ04N jXMmiHAAtM8Esf25DZocRNlYMb66mDc= X-MC-Unique: 0eI3UbTYNT6ck4oFDTP4Zg-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH 5/7] api: add virNodeDeviceIsPersistent()/IsActive() Date: Thu, 3 Jun 2021 15:11:54 -0500 Message-Id: <20210603201156.3571972-6-jjongsma@redhat.com> In-Reply-To: <20210603201156.3571972-1-jjongsma@redhat.com> References: <20210603201156.3571972-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.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) Content-Type: text/plain; charset="utf-8" These two public APIs are implemented for almost all other objects that have a concept of persistent definition and activatability. Now that we have node devices (mdevs) that can be defined and inactive, it will be useful to query the persistent/active state of node devices as well. Signed-off-by: Jonathon Jongsma Reviewed-by: Daniel P. Berrang=C3=A9 --- include/libvirt/libvirt-nodedev.h | 4 ++ src/driver-nodedev.h | 8 ++++ src/libvirt-nodedev.c | 65 +++++++++++++++++++++++++++++++ src/libvirt_public.syms | 2 + src/remote/remote_driver.c | 2 + src/remote/remote_protocol.x | 32 ++++++++++++++- src/remote_protocol-structs | 14 +++++++ 7 files changed, 126 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-nodedev.h b/include/libvirt/libvirt-no= dedev.h index 0e841ada8a..e492634217 100644 --- a/include/libvirt/libvirt-nodedev.h +++ b/include/libvirt/libvirt-nodedev.h @@ -147,6 +147,10 @@ int virNodeDeviceSetAutostart(virNodeDevicePtr dev, int virNodeDeviceGetAutostart(virNodeDevicePtr dev, int *autostart); =20 +int virNodeDeviceIsPersistent(virNodeDevicePtr dev); + +int virNodeDeviceIsActive(virNodeDevicePtr dev); + /** * VIR_NODE_DEVICE_EVENT_CALLBACK: * diff --git a/src/driver-nodedev.h b/src/driver-nodedev.h index 125f4cfd9e..167a8166dd 100644 --- a/src/driver-nodedev.h +++ b/src/driver-nodedev.h @@ -95,6 +95,12 @@ typedef int (*virDrvNodeDeviceGetAutostart)(virNodeDevicePtr dev, int *autostart); =20 +typedef int +(*virDrvNodeDeviceIsPersistent)(virNodeDevicePtr dev); + +typedef int +(*virDrvNodeDeviceIsActive)(virNodeDevicePtr dev); + typedef int (*virDrvConnectNodeDeviceEventRegisterAny)(virConnectPtr conn, virNodeDevicePtr dev, @@ -138,4 +144,6 @@ struct _virNodeDeviceDriver { virDrvNodeDeviceCreate nodeDeviceCreate; virDrvNodeDeviceSetAutostart nodeDeviceSetAutostart; virDrvNodeDeviceGetAutostart nodeDeviceGetAutostart; + virDrvNodeDeviceIsPersistent nodeDeviceIsPersistent; + virDrvNodeDeviceIsActive nodeDeviceIsActive; }; diff --git a/src/libvirt-nodedev.c b/src/libvirt-nodedev.c index 68fc83203d..8ad1e9cb9e 100644 --- a/src/libvirt-nodedev.c +++ b/src/libvirt-nodedev.c @@ -1055,3 +1055,68 @@ virNodeDeviceGetAutostart(virNodeDevicePtr dev, virDispatchError(dev->conn); return -1; } + +/** + * virNodeDeviceIsPersistent: + * @dev: pointer to the nodedev object + * + * Determine if the node device has a persistent configuration + * which means it will still exist after shutting down + * + * Returns 1 if persistent, 0 if transient, -1 on error + */ +int +virNodeDeviceIsPersistent(virNodeDevicePtr dev) +{ + VIR_DEBUG("dev=3D%p", dev); + + virResetLastError(); + + virCheckNodeDeviceReturn(dev, -1); + + if (dev->conn->nodeDeviceDriver && + dev->conn->nodeDeviceDriver->nodeDeviceIsPersistent) { + int ret; + ret =3D dev->conn->nodeDeviceDriver->nodeDeviceIsPersistent(dev); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + error: + virDispatchError(dev->conn); + return -1; +} + + +/** + * virNodeDeviceIsActive: + * @dev: pointer to the node device object + * + * Determine if the node device is currently active + * + * Returns 1 if active, 0 if inactive, -1 on error + */ +int virNodeDeviceIsActive(virNodeDevicePtr dev) +{ + VIR_DEBUG("dev=3D%p", dev); + + virResetLastError(); + + virCheckNodeDeviceReturn(dev, -1); + + if (dev->conn->nodeDeviceDriver && + dev->conn->nodeDeviceDriver->nodeDeviceIsActive) { + int ret; + ret =3D dev->conn->nodeDeviceDriver->nodeDeviceIsActive(dev); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + error: + virDispatchError(dev->conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index a21bd6ac7d..c2b4b46a92 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -899,5 +899,7 @@ LIBVIRT_7.3.0 { LIBVIRT_7.5.0 { virNodeDeviceSetAutostart; virNodeDeviceGetAutostart; + virNodeDeviceIsPersistent; + virNodeDeviceIsActive; } LIBVIRT_7.3.0; # .... define new API here using predicted next version number .... diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 9070f648e2..edc01437e3 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8720,6 +8720,8 @@ static virNodeDeviceDriver node_device_driver =3D { .nodeDeviceDestroy =3D remoteNodeDeviceDestroy, /* 0.6.3 */ .nodeDeviceGetAutostart =3D remoteNodeDeviceGetAutostart, /* 7.5.0 */ .nodeDeviceSetAutostart =3D remoteNodeDeviceSetAutostart, /* 7.5.0 */ + .nodeDeviceIsPersistent =3D remoteNodeDeviceIsPersistent, /* 7.5.0 */ + .nodeDeviceIsActive =3D remoteNodeDeviceIsActive, /* 7.5.0 */ }; =20 static virNWFilterDriver nwfilter_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index a98ab49f2e..49218cb1df 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -2177,6 +2177,22 @@ struct remote_node_device_set_autostart_args { int autostart; }; =20 +struct remote_node_device_is_persistent_args { + remote_nonnull_string name; +}; + +struct remote_node_device_is_persistent_ret { + int persistent; +}; + +struct remote_node_device_is_active_args { + remote_nonnull_string name; +}; + +struct remote_node_device_is_active_ret { + int active; +}; + =20 /* * Events Register/Deregister: @@ -6811,6 +6827,20 @@ enum remote_procedure { * @priority: high * @acl: node_device:write */ - REMOTE_PROC_NODE_DEVICE_SET_AUTOSTART =3D 432 + REMOTE_PROC_NODE_DEVICE_SET_AUTOSTART =3D 432, + + /** + * @generate: both + * @priority: high + * @acl: node_device:read + */ + REMOTE_PROC_NODE_DEVICE_IS_PERSISTENT =3D 433, + + /** + * @generate: both + * @priority: high + * @acl: node_device:read + */ + REMOTE_PROC_NODE_DEVICE_IS_ACTIVE =3D 434 =20 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index b17372537b..7717b04804 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1625,6 +1625,18 @@ struct remote_node_device_set_autostart_args { remote_nonnull_string name; int autostart; }; +struct remote_node_device_is_persistent_args { + remote_nonnull_string name; +}; +struct remote_node_device_is_persistent_ret { + int persistent; +}; +struct remote_node_device_is_active_args { + remote_nonnull_string name; +}; +struct remote_node_device_is_active_ret { + int active; +}; struct remote_connect_domain_event_register_ret { int cb_registered; }; @@ -3635,4 +3647,6 @@ enum remote_procedure { REMOTE_PROC_NODE_DEVICE_CREATE =3D 430, REMOTE_PROC_NODE_DEVICE_GET_AUTOSTART =3D 431, REMOTE_PROC_NODE_DEVICE_SET_AUTOSTART =3D 432, + REMOTE_PROC_NODE_DEVICE_IS_PERSISTENT =3D 433, + REMOTE_PROC_NODE_DEVICE_IS_ACTIVE =3D 434, }; --=20 2.31.1