Allow to filter node devices based on their persisted or transient states.
Signed-off-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
---
include/libvirt/libvirt-nodedev.h | 2 ++
src/conf/node_device_conf.h | 7 ++++++-
src/conf/virnodedeviceobj.c | 8 ++++++++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/include/libvirt/libvirt-nodedev.h b/include/libvirt/libvirt-nodedev.h
index d18246e2f6..dff394ec86 100644
--- a/include/libvirt/libvirt-nodedev.h
+++ b/include/libvirt/libvirt-nodedev.h
@@ -91,6 +91,8 @@ typedef enum {
VIR_CONNECT_LIST_NODE_DEVICES_CAP_AP_MATRIX = 1 << 20, /* s390 AP Matrix
(Since: 7.0.0) */
VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPD = 1 << 21, /* Device with VPD
(Since: 7.9.0) */
+ VIR_CONNECT_LIST_NODE_DEVICES_PERSISTED = 1 << 28, /* Persisted devices
(Since: 10.1.0) */
+ VIR_CONNECT_LIST_NODE_DEVICES_TRANSIENT = 1 << 29, /* Transient devices
(Since: 10.1.0) */
VIR_CONNECT_LIST_NODE_DEVICES_INACTIVE = 1 << 30, /* Inactive devices
(Since: 7.3.0) */
VIR_CONNECT_LIST_NODE_DEVICES_ACTIVE = 1U << 31, /* Active devices
(Since: 7.3.0) */
} virConnectListAllNodeDeviceFlags;
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index f59440dbb9..3ee1fbc665 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -432,9 +432,14 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNodeDevCapsDef,
virNodeDevCapsDefFree);
VIR_CONNECT_LIST_NODE_DEVICES_ACTIVE | \
VIR_CONNECT_LIST_NODE_DEVICES_INACTIVE
+#define VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_PERSIST \
+ VIR_CONNECT_LIST_NODE_DEVICES_PERSISTED | \
+ VIR_CONNECT_LIST_NODE_DEVICES_TRANSIENT
+
#define VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_ALL \
VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_CAP | \
- VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_ACTIVE
+ VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_ACTIVE | \
+ VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_PERSIST
int
virNodeDeviceGetSCSIHostCaps(virNodeDevCapSCSIHost *scsi_host);
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index cfef30d47e..0b9ca8c864 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -911,6 +911,14 @@ virNodeDeviceObjMatch(virNodeDeviceObj *obj,
return false;
}
+ if (flags & (VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_PERSIST)) {
+ if (!((MATCH(VIR_CONNECT_LIST_NODE_DEVICES_PERSISTED) &&
+ virNodeDeviceObjIsPersistent(obj)) ||
+ (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_TRANSIENT) &&
+ !virNodeDeviceObjIsPersistent(obj))))
+ return false;
+ }
+
return true;
}
#undef MATCH
--
2.42.0