mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
nodedev: add persistent and transient filter on list
Allow to filter node devices based on their persistent or transient states. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
6fcf613c6f
commit
e2c5c47439
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user