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@xxxxxxxxxx> --- src/conf/virnodedeviceobj.c | 13 ++++++++++++- src/conf/virnodedeviceobj.h | 4 ++++ src/test/test_driver.c | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index 13e9a17518..6c04caf6ab 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -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; +} diff --git a/src/conf/virnodedeviceobj.h b/src/conf/virnodedeviceobj.h index 87f9083696..ffbe4e32e5 100644 --- a/src/conf/virnodedeviceobj.h +++ b/src/conf/virnodedeviceobj.h @@ -109,4 +109,8 @@ virNodeDeviceObjListExport(virConnectPtr conn, virNodeDeviceObjListFilter filter, unsigned int flags); +void +virNodeDeviceObjSetSkipUpdateCaps(virNodeDeviceObjPtr obj, + bool skipUpdateCaps); + #endif /* __VIRNODEDEVICEOBJ_H__ */ diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 951d9c4151..7374c83eaa 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -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, -- 2.17.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list