
On Tue, Aug 18, 2020 at 09:47:53AM -0500, Jonathon Jongsma wrote:
Add two flag values for virConnectListAllNodeDevices() so that we can list only node devices that are active or inactive.
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- ...
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index 88a7746b27..9838513b69 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -865,6 +865,16 @@ virNodeDeviceObjMatch(virNodeDeviceObjPtr obj, return false; }
+#undef MATCH +#define MATCH(FLAG) (flags & (FLAG)) + + if (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_ACTIVE) && + !((MATCH(VIR_CONNECT_LIST_NODE_DEVICES_ACTIVE) && + virNodeDeviceObjIsActive(obj)) || + (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_INACTIVE) && + !virNodeDeviceObjIsActive(obj)))) + return false; + return true; } #undef MATCH
^This produces a significantly smaller diff, but I'm not really a fan of re-defining the same macro in a different way, it can turn out being confusing in the end, since it's a different macro. I suggest renaming the original MATCH macro to something like MATCH_CAP(CAP) and defining this new one as MATCH. ACK to the rest. Erik