[PATCH v5 06/12] nodedev: add persistent and transient filter on list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Allow to filter node devices based on their persistent or transient
states.

Signed-off-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>
Reviewed-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
 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 53ffce6c69..f7ddbfa4ad 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_PERSISTENT        = 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..f0a5333881 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_PERSISTENT \
+    VIR_CONNECT_LIST_NODE_DEVICES_PERSISTENT | \
+    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_PERSISTENT
 
 int
 virNodeDeviceGetSCSIHostCaps(virNodeDevCapSCSIHost *scsi_host);
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index cfef30d47e..31ec4249d8 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_PERSISTENT)) {
+        if (!((MATCH(VIR_CONNECT_LIST_NODE_DEVICES_PERSISTENT) &&
+              virNodeDeviceObjIsPersistent(obj)) ||
+              (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_TRANSIENT) &&
+               !virNodeDeviceObjIsPersistent(obj))))
+            return false;
+    }
+
     return true;
 }
 #undef MATCH
-- 
2.42.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux