@@ -37,6 +37,8 @@ struct _virNodeDeviceObj {
virObjectLockable parent;
virNodeDeviceDefPtr def; /* device definition */
+ bool skipUpdateCaps; /* whether to skip checking host caps,
+ used by testdriver */
};
struct _virNodeDeviceObjList {
@@ -806,7 +808,8 @@ virNodeDeviceMatch(virNodeDeviceObjPtr obj,
unsigned int flags)
{
/* Refresh the capabilities first, e.g. due to a driver change */
- if (virNodeDeviceUpdateCaps(obj->def) < 0)
+ if (!obj->skipUpdateCaps &&
+ virNodeDeviceUpdateCaps(obj->def) < 0)
return false;
/* filter by cap type */
@@ -915,3 +918,11 @@ virNodeDeviceObjListExport(virConnectPtr conn,
virObjectListFree(data.devices);
return -1;
}
+
+
+void
+virNodeDeviceObjSetSkipUpdateCaps(virNodeDeviceObjPtr obj,
+ bool skipUpdateCaps)
+{
+ obj->skipUpdateCaps = skipUpdateCaps;
+}
@@ -109,4 +109,8 @@ virNodeDeviceObjListExport(virConnectPtr conn,
virNodeDeviceObjListFilter filter,
unsigned int flags);
+void
+virNodeDeviceObjSetSkipUpdateCaps(virNodeDeviceObjPtr obj,
+ bool skipUpdateCaps);
+
#endif /* __VIRNODEDEVICEOBJ_H__ */
@@ -1165,6 +1165,7 @@ testParseNodedevs(testDriverPtr privconn,
goto error;
}
+ virNodeDeviceObjSetSkipUpdateCaps(obj, true);
virNodeDeviceObjEndAPI(&obj);
}
@@ -5565,6 +5566,7 @@ testNodeDeviceMockCreateVport(testDriverPtr driver,
goto cleanup;
def = NULL;
objdef = virNodeDeviceObjGetDef(obj);
+ virNodeDeviceObjSetSkipUpdateCaps(obj, true);
event = virNodeDeviceEventLifecycleNew(objdef->name,
VIR_NODE_DEVICE_EVENT_CREATED,
Add a 'skipUpdateCaps' bool that we set for test_driver.c nodedevs which will skip accessing host resources via virNodeDeviceUpdateCaps Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/conf/virnodedeviceobj.c | 13 ++++++++++++- src/conf/virnodedeviceobj.h | 4 ++++ src/test/test_driver.c | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list