conf: nodedev: Don't refresh host caps in testdriver

Add a 'skipUpdateCaps' bool that we set for test_driver.c nodedevs
which will skip accessing host resources via virNodeDeviceUpdateCaps

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2018-02-23 18:09:20 -05:00
parent c379576dbc
commit 4afa955365
3 changed files with 18 additions and 1 deletions

View File

@ -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;
}

View File

@ -109,4 +109,8 @@ virNodeDeviceObjListExport(virConnectPtr conn,
virNodeDeviceObjListFilter filter,
unsigned int flags);
void
virNodeDeviceObjSetSkipUpdateCaps(virNodeDeviceObjPtr obj,
bool skipUpdateCaps);
#endif /* __VIRNODEDEVICEOBJ_H__ */

View File

@ -1165,6 +1165,7 @@ testParseNodedevs(testDriverPtr privconn,
goto error;
}
virNodeDeviceObjSetSkipUpdateCaps(obj, true);
virNodeDeviceObjEndAPI(&obj);
}
@ -5549,6 +5550,7 @@ testNodeDeviceMockCreateVport(testDriverPtr driver,
if (!(obj = virNodeDeviceObjListAssignDef(driver->devs, def)))
goto cleanup;
virNodeDeviceObjSetSkipUpdateCaps(obj, true);
def = NULL;
objdef = virNodeDeviceObjGetDef(obj);