提交 881a486a 编写于 作者: J John Ferlan

nodedev: Alter node device obj list function names

Ensure that any function that walks the node device object list is prefixed
by virNodeDeviceObjList.

Also, modify the @filter param name for virNodeDeviceObjListExport to
be @aclfilter.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 9c5d98fd
......@@ -165,7 +165,7 @@ virNodeDeviceFindVPORTCapDef(const virNodeDeviceObj *obj)
virNodeDeviceObjPtr
virNodeDeviceObjFindBySysfsPath(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListFindBySysfsPath(virNodeDeviceObjListPtr devs,
const char *sysfs_path)
{
size_t i;
......@@ -184,7 +184,7 @@ virNodeDeviceObjFindBySysfsPath(virNodeDeviceObjListPtr devs,
virNodeDeviceObjPtr
virNodeDeviceObjFindByName(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListFindByName(virNodeDeviceObjListPtr devs,
const char *name)
{
size_t i;
......@@ -201,7 +201,7 @@ virNodeDeviceObjFindByName(virNodeDeviceObjListPtr devs,
static virNodeDeviceObjPtr
virNodeDeviceFindByWWNs(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListFindByWWNs(virNodeDeviceObjListPtr devs,
const char *parent_wwnn,
const char *parent_wwpn)
{
......@@ -223,7 +223,7 @@ virNodeDeviceFindByWWNs(virNodeDeviceObjListPtr devs,
static virNodeDeviceObjPtr
virNodeDeviceFindByFabricWWN(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListFindByFabricWWN(virNodeDeviceObjListPtr devs,
const char *parent_fabric_wwn)
{
size_t i;
......@@ -243,7 +243,7 @@ virNodeDeviceFindByFabricWWN(virNodeDeviceObjListPtr devs,
static virNodeDeviceObjPtr
virNodeDeviceFindByCap(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListFindByCap(virNodeDeviceObjListPtr devs,
const char *cap)
{
size_t i;
......@@ -296,12 +296,12 @@ virNodeDeviceObjListFree(virNodeDeviceObjListPtr devs)
virNodeDeviceObjPtr
virNodeDeviceObjAssignDef(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListAssignDef(virNodeDeviceObjListPtr devs,
virNodeDeviceDefPtr def)
{
virNodeDeviceObjPtr obj;
if ((obj = virNodeDeviceObjFindByName(devs, def->name))) {
if ((obj = virNodeDeviceObjListFindByName(devs, def->name))) {
virNodeDeviceDefFree(obj->def);
obj->def = def;
return obj;
......@@ -322,7 +322,7 @@ virNodeDeviceObjAssignDef(virNodeDeviceObjListPtr devs,
void
virNodeDeviceObjRemove(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListRemove(virNodeDeviceObjListPtr devs,
virNodeDeviceObjPtr obj)
{
size_t i;
......@@ -372,14 +372,14 @@ virNodeDeviceFindFCParentHost(virNodeDeviceObjPtr obj)
static int
virNodeDeviceGetParentHostByParent(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListGetParentHostByParent(virNodeDeviceObjListPtr devs,
const char *dev_name,
const char *parent_name)
{
virNodeDeviceObjPtr obj = NULL;
int ret;
if (!(obj = virNodeDeviceObjFindByName(devs, parent_name))) {
if (!(obj = virNodeDeviceObjListFindByName(devs, parent_name))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not find parent device for '%s'"),
dev_name);
......@@ -395,7 +395,7 @@ virNodeDeviceGetParentHostByParent(virNodeDeviceObjListPtr devs,
static int
virNodeDeviceGetParentHostByWWNs(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListGetParentHostByWWNs(virNodeDeviceObjListPtr devs,
const char *dev_name,
const char *parent_wwnn,
const char *parent_wwpn)
......@@ -403,7 +403,8 @@ virNodeDeviceGetParentHostByWWNs(virNodeDeviceObjListPtr devs,
virNodeDeviceObjPtr obj = NULL;
int ret;
if (!(obj = virNodeDeviceFindByWWNs(devs, parent_wwnn, parent_wwpn))) {
if (!(obj = virNodeDeviceObjListFindByWWNs(devs, parent_wwnn,
parent_wwpn))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not find parent device for '%s'"),
dev_name);
......@@ -419,14 +420,14 @@ virNodeDeviceGetParentHostByWWNs(virNodeDeviceObjListPtr devs,
static int
virNodeDeviceGetParentHostByFabricWWN(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListGetParentHostByFabricWWN(virNodeDeviceObjListPtr devs,
const char *dev_name,
const char *parent_fabric_wwn)
{
virNodeDeviceObjPtr obj = NULL;
int ret;
if (!(obj = virNodeDeviceFindByFabricWWN(devs, parent_fabric_wwn))) {
if (!(obj = virNodeDeviceObjListFindByFabricWWN(devs, parent_fabric_wwn))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not find parent device for '%s'"),
dev_name);
......@@ -442,13 +443,13 @@ virNodeDeviceGetParentHostByFabricWWN(virNodeDeviceObjListPtr devs,
static int
virNodeDeviceFindVportParentHost(virNodeDeviceObjListPtr devs)
virNodeDeviceObjListFindVportParentHost(virNodeDeviceObjListPtr devs)
{
virNodeDeviceObjPtr obj = NULL;
const char *cap = virNodeDevCapTypeToString(VIR_NODE_DEV_CAP_VPORTS);
int ret;
if (!(obj = virNodeDeviceFindByCap(devs, cap))) {
if (!(obj = virNodeDeviceObjListFindByCap(devs, cap))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not find any vport capable device"));
return -1;
......@@ -463,26 +464,26 @@ virNodeDeviceFindVportParentHost(virNodeDeviceObjListPtr devs)
int
virNodeDeviceObjGetParentHost(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListGetParentHost(virNodeDeviceObjListPtr devs,
virNodeDeviceDefPtr def,
int create)
{
int parent_host = -1;
if (def->parent) {
parent_host = virNodeDeviceGetParentHostByParent(devs, def->name,
parent_host = virNodeDeviceObjListGetParentHostByParent(devs, def->name,
def->parent);
} else if (def->parent_wwnn && def->parent_wwpn) {
parent_host = virNodeDeviceGetParentHostByWWNs(devs, def->name,
parent_host = virNodeDeviceObjListGetParentHostByWWNs(devs, def->name,
def->parent_wwnn,
def->parent_wwpn);
} else if (def->parent_fabric_wwn) {
parent_host =
virNodeDeviceGetParentHostByFabricWWN(devs, def->name,
virNodeDeviceObjListGetParentHostByFabricWWN(devs, def->name,
def->parent_fabric_wwn);
} else if (create == CREATE_DEVICE) {
/* Try to find a vport capable scsi_host when no parent supplied */
parent_host = virNodeDeviceFindVportParentHost(devs);
parent_host = virNodeDeviceObjListFindVportParentHost(devs);
}
return parent_host;
......@@ -554,7 +555,7 @@ virNodeDeviceCapMatch(virNodeDeviceObjPtr obj,
int
virNodeDeviceObjNumOfDevices(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListNumOfDevices(virNodeDeviceObjListPtr devs,
virConnectPtr conn,
const char *cap,
virNodeDeviceObjListFilter aclfilter)
......@@ -576,7 +577,7 @@ virNodeDeviceObjNumOfDevices(virNodeDeviceObjListPtr devs,
int
virNodeDeviceObjGetNames(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListGetNames(virNodeDeviceObjListPtr devs,
virConnectPtr conn,
virNodeDeviceObjListFilter aclfilter,
const char *cap,
......@@ -645,7 +646,7 @@ int
virNodeDeviceObjListExport(virConnectPtr conn,
virNodeDeviceObjListPtr devs,
virNodeDevicePtr **devices,
virNodeDeviceObjListFilter filter,
virNodeDeviceObjListFilter aclfilter,
unsigned int flags)
{
virNodeDevicePtr *tmp_devices = NULL;
......@@ -660,7 +661,7 @@ virNodeDeviceObjListExport(virConnectPtr conn,
for (i = 0; i < devs->count; i++) {
virNodeDeviceObjPtr obj = devs->objs[i];
virNodeDeviceObjLock(obj);
if ((!filter || filter(conn, obj->def)) &&
if ((!aclfilter || aclfilter(conn, obj->def)) &&
virNodeDeviceMatch(obj, flags)) {
if (devices) {
if (!(device = virGetNodeDevice(conn, obj->def->name)) ||
......
......@@ -44,24 +44,24 @@ virNodeDeviceDefPtr
virNodeDeviceObjGetDef(virNodeDeviceObjPtr obj);
virNodeDeviceObjPtr
virNodeDeviceObjFindByName(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListFindByName(virNodeDeviceObjListPtr devs,
const char *name);
virNodeDeviceObjPtr
virNodeDeviceObjFindBySysfsPath(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListFindBySysfsPath(virNodeDeviceObjListPtr devs,
const char *sysfs_path)
ATTRIBUTE_NONNULL(2);
virNodeDeviceObjPtr
virNodeDeviceObjAssignDef(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListAssignDef(virNodeDeviceObjListPtr devs,
virNodeDeviceDefPtr def);
void
virNodeDeviceObjRemove(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListRemove(virNodeDeviceObjListPtr devs,
virNodeDeviceObjPtr dev);
int
virNodeDeviceObjGetParentHost(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListGetParentHost(virNodeDeviceObjListPtr devs,
virNodeDeviceDefPtr def,
int create);
......@@ -85,13 +85,13 @@ typedef bool
virNodeDeviceDefPtr def);
int
virNodeDeviceObjNumOfDevices(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListNumOfDevices(virNodeDeviceObjListPtr devs,
virConnectPtr conn,
const char *cap,
virNodeDeviceObjListFilter aclfilter);
int
virNodeDeviceObjGetNames(virNodeDeviceObjListPtr devs,
virNodeDeviceObjListGetNames(virNodeDeviceObjListPtr devs,
virConnectPtr conn,
virNodeDeviceObjListFilter aclfilter,
const char *cap,
......@@ -102,7 +102,7 @@ int
virNodeDeviceObjListExport(virConnectPtr conn,
virNodeDeviceObjListPtr devobjs,
virNodeDevicePtr **devices,
virNodeDeviceObjListFilter filter,
virNodeDeviceObjListFilter aclfilter,
unsigned int flags);
#endif /* __VIRNODEDEVICEOBJ_H__ */
......@@ -963,19 +963,19 @@ virNetworkObjUpdateAssignDef;
# conf/virnodedeviceobj.h
virNodeDeviceObjAssignDef;
virNodeDeviceObjFindByName;
virNodeDeviceObjFindBySysfsPath;
virNodeDeviceObjFree;
virNodeDeviceObjGetDef;
virNodeDeviceObjGetNames;
virNodeDeviceObjGetParentHost;
virNodeDeviceObjListAssignDef;
virNodeDeviceObjListExport;
virNodeDeviceObjListFindByName;
virNodeDeviceObjListFindBySysfsPath;
virNodeDeviceObjListFree;
virNodeDeviceObjListGetNames;
virNodeDeviceObjListGetParentHost;
virNodeDeviceObjListNew;
virNodeDeviceObjListNumOfDevices;
virNodeDeviceObjListRemove;
virNodeDeviceObjLock;
virNodeDeviceObjNumOfDevices;
virNodeDeviceObjRemove;
virNodeDeviceObjUnlock;
......
......@@ -182,7 +182,7 @@ nodeNumOfDevices(virConnectPtr conn,
virCheckFlags(0, -1);
nodeDeviceLock();
ndevs = virNodeDeviceObjNumOfDevices(driver->devs, conn, cap,
ndevs = virNodeDeviceObjListNumOfDevices(driver->devs, conn, cap,
virNodeNumOfDevicesCheckACL);
nodeDeviceUnlock();
......@@ -205,7 +205,7 @@ nodeListDevices(virConnectPtr conn,
virCheckFlags(0, -1);
nodeDeviceLock();
nnames = virNodeDeviceObjGetNames(driver->devs, conn,
nnames = virNodeDeviceObjListGetNames(driver->devs, conn,
virNodeListDevicesCheckACL,
cap, names, maxnames);
nodeDeviceUnlock();
......@@ -241,7 +241,7 @@ nodeDeviceObjFindByName(const char *name)
virNodeDeviceObjPtr obj;
nodeDeviceLock();
obj = virNodeDeviceObjFindByName(driver->devs, name);
obj = virNodeDeviceObjListFindByName(driver->devs, name);
nodeDeviceUnlock();
if (!obj) {
......@@ -587,7 +587,7 @@ nodeDeviceCreateXML(virConnectPtr conn,
if (virNodeDeviceGetWWNs(def, &wwnn, &wwpn) == -1)
goto cleanup;
if ((parent_host = virNodeDeviceObjGetParentHost(driver->devs, def,
if ((parent_host = virNodeDeviceObjListGetParentHost(driver->devs, def,
CREATE_DEVICE)) < 0)
goto cleanup;
......@@ -639,7 +639,7 @@ nodeDeviceDestroy(virNodeDevicePtr device)
* or parent_fabric_wwn) and drop the object lock. */
virNodeDeviceObjUnlock(obj);
obj = NULL;
if ((parent_host = virNodeDeviceObjGetParentHost(driver->devs, def,
if ((parent_host = virNodeDeviceObjListGetParentHost(driver->devs, def,
EXISTING_DEVICE)) < 0)
goto cleanup;
......
......@@ -482,7 +482,7 @@ dev_create(const char *udi)
/* Some devices don't have a path in sysfs, so ignore failure */
(void)get_str_prop(ctx, udi, "linux.sysfs_path", &devicePath);
if (!(obj = virNodeDeviceObjAssignDef(driver->devs, def))) {
if (!(obj = virNodeDeviceObjListAssignDef(driver->devs, def))) {
VIR_FREE(devicePath);
goto failure;
}
......@@ -509,11 +509,11 @@ dev_refresh(const char *udi)
virNodeDeviceObjPtr obj;
nodeDeviceLock();
if ((obj = virNodeDeviceObjFindByName(driver->devs, name))) {
if ((obj = virNodeDeviceObjListFindByName(driver->devs, name))) {
/* Simply "rediscover" device -- incrementally handling changes
* to sub-capabilities (like net.80203) is nasty ... so avoid it.
*/
virNodeDeviceObjRemove(driver->devs, obj);
virNodeDeviceObjListRemove(driver->devs, obj);
} else {
VIR_DEBUG("no device named %s", name);
}
......@@ -542,10 +542,10 @@ device_removed(LibHalContext *ctx ATTRIBUTE_UNUSED,
virNodeDeviceObjPtr obj;
nodeDeviceLock();
obj = virNodeDeviceObjFindByName(driver->devs, name);
obj = virNodeDeviceObjListFindByName(driver->devs, name);
VIR_DEBUG("%s", name);
if (obj)
virNodeDeviceObjRemove(driver->devs, obj);
virNodeDeviceObjListRemove(driver->devs, obj);
else
VIR_DEBUG("no device named %s", name);
nodeDeviceUnlock();
......@@ -562,7 +562,7 @@ device_cap_added(LibHalContext *ctx,
virNodeDeviceDefPtr def;
nodeDeviceLock();
obj = virNodeDeviceObjFindByName(driver->devs, name);
obj = virNodeDeviceObjListFindByName(driver->devs, name);
nodeDeviceUnlock();
VIR_DEBUG("%s %s", cap, name);
if (obj) {
......
......@@ -1318,7 +1318,7 @@ udevRemoveOneDevice(struct udev_device *device)
const char *name = NULL;
name = udev_device_get_syspath(device);
if (!(obj = virNodeDeviceObjFindBySysfsPath(driver->devs, name))) {
if (!(obj = virNodeDeviceObjListFindBySysfsPath(driver->devs, name))) {
VIR_DEBUG("Failed to find device to remove that has udev name '%s'",
name);
return -1;
......@@ -1331,7 +1331,7 @@ udevRemoveOneDevice(struct udev_device *device)
VIR_DEBUG("Removing device '%s' with sysfs path '%s'",
def->name, name);
virNodeDeviceObjRemove(driver->devs, obj);
virNodeDeviceObjListRemove(driver->devs, obj);
virNodeDeviceObjFree(obj);
if (event)
......@@ -1365,7 +1365,7 @@ udevSetParent(struct udev_device *device,
goto cleanup;
}
if ((obj = virNodeDeviceObjFindBySysfsPath(driver->devs,
if ((obj = virNodeDeviceObjListFindBySysfsPath(driver->devs,
parent_sysfs_path))) {
objdef = virNodeDeviceObjGetDef(obj);
if (VIR_STRDUP(def->parent, objdef->name) < 0) {
......@@ -1424,14 +1424,14 @@ udevAddOneDevice(struct udev_device *device)
if (udevSetParent(device, def) != 0)
goto cleanup;
if ((obj = virNodeDeviceObjFindByName(driver->devs, def->name))) {
if ((obj = virNodeDeviceObjListFindByName(driver->devs, def->name))) {
virNodeDeviceObjUnlock(obj);
new_device = false;
}
/* If this is a device change, the old definition will be freed
* and the current definition will take its place. */
if (!(obj = virNodeDeviceObjAssignDef(driver->devs, def)))
if (!(obj = virNodeDeviceObjListAssignDef(driver->devs, def)))
goto cleanup;
objdef = virNodeDeviceObjGetDef(obj);
......@@ -1721,7 +1721,7 @@ udevSetupSystemDev(void)
udevGetDMIData(&def->caps->data.system);
#endif
if (!(obj = virNodeDeviceObjAssignDef(driver->devs, def)))
if (!(obj = virNodeDeviceObjListAssignDef(driver->devs, def)))
goto cleanup;
virNodeDeviceObjUnlock(obj);
......
......@@ -1172,7 +1172,7 @@ testParseNodedevs(testDriverPtr privconn,
if (!def)
goto error;
if (!(obj = virNodeDeviceObjAssignDef(privconn->devs, def))) {
if (!(obj = virNodeDeviceObjListAssignDef(privconn->devs, def))) {
virNodeDeviceDefFree(def);
goto error;
}
......@@ -4561,7 +4561,8 @@ testDestroyVport(testDriverPtr privconn,
*
* Reaching across the boundaries of space and time into the
* Node Device in order to remove */
if (!(obj = virNodeDeviceObjFindByName(privconn->devs, "scsi_host12"))) {
if (!(obj = virNodeDeviceObjListFindByName(privconn->devs,
"scsi_host12"))) {
virReportError(VIR_ERR_NO_NODE_DEVICE, "%s",
_("no node device with matching name 'scsi_host12'"));
return -1;
......@@ -4571,7 +4572,7 @@ testDestroyVport(testDriverPtr privconn,
VIR_NODE_DEVICE_EVENT_DELETED,
0);
virNodeDeviceObjRemove(privconn->devs, obj);
virNodeDeviceObjListRemove(privconn->devs, obj);
virNodeDeviceObjFree(obj);
testObjectEventQueue(privconn, event);
......@@ -5303,7 +5304,7 @@ testNodeDeviceObjFindByName(testDriverPtr driver,
virNodeDeviceObjPtr obj;
testDriverLock(driver);
obj = virNodeDeviceObjFindByName(driver->devs, name);
obj = virNodeDeviceObjListFindByName(driver->devs, name);
testDriverUnlock(driver);
if (!obj)
......@@ -5326,7 +5327,7 @@ testNodeNumOfDevices(virConnectPtr conn,
virCheckFlags(0, -1);
testDriverLock(driver);
ndevs = virNodeDeviceObjNumOfDevices(driver->devs, conn, cap, NULL);
ndevs = virNodeDeviceObjListNumOfDevices(driver->devs, conn, cap, NULL);
testDriverUnlock(driver);
return ndevs;
......@@ -5346,7 +5347,7 @@ testNodeListDevices(virConnectPtr conn,
virCheckFlags(0, -1);
testDriverLock(driver);
nnames = virNodeDeviceObjGetNames(driver->devs, conn, NULL,
nnames = virNodeDeviceObjListGetNames(driver->devs, conn, NULL,
cap, names, maxnames);
testDriverUnlock(driver);
......@@ -5493,7 +5494,8 @@ testNodeDeviceMockCreateVport(testDriverPtr driver,
* using the scsi_host11 definition, changing the name and the
* scsi_host capability fields before calling virNodeDeviceAssignDef
* to add the def to the node device objects list. */
if (!(objcopy = virNodeDeviceObjFindByName(driver->devs, "scsi_host11")))
if (!(objcopy = virNodeDeviceObjListFindByName(driver->devs,
"scsi_host11")))
goto cleanup;
xml = virNodeDeviceDefFormat(virNodeDeviceObjGetDef(objcopy));
......@@ -5533,7 +5535,7 @@ testNodeDeviceMockCreateVport(testDriverPtr driver,
caps = caps->next;
}
if (!(obj = virNodeDeviceObjAssignDef(driver->devs, def)))
if (!(obj = virNodeDeviceObjListAssignDef(driver->devs, def)))
goto cleanup;
def = NULL;
objdef = virNodeDeviceObjGetDef(obj);
......@@ -5578,7 +5580,7 @@ testNodeDeviceCreateXML(virConnectPtr conn,
/* Unlike the "real" code we don't need the parent_host in order to
* call virVHBAManageVport, but still let's make sure the code finds
* something valid and no one messed up the mock environment. */
if (virNodeDeviceObjGetParentHost(driver->devs, def, CREATE_DEVICE) < 0)
if (virNodeDeviceObjListGetParentHost(driver->devs, def, CREATE_DEVICE) < 0)
goto cleanup;
/* In the real code, we'd call virVHBAManageVport followed by
......@@ -5639,7 +5641,7 @@ testNodeDeviceDestroy(virNodeDevicePtr dev)
/* We do this just for basic validation, but also avoid finding a
* vport capable HBA if for some reason our vHBA doesn't exist */
if (virNodeDeviceObjGetParentHost(driver->devs, def,
if (virNodeDeviceObjListGetParentHost(driver->devs, def,
EXISTING_DEVICE) < 0) {
obj = NULL;
goto cleanup;
......@@ -5650,7 +5652,7 @@ testNodeDeviceDestroy(virNodeDevicePtr dev)
0);
virNodeDeviceObjLock(obj);
virNodeDeviceObjRemove(driver->devs, obj);
virNodeDeviceObjListRemove(driver->devs, obj);
virNodeDeviceObjFree(obj);
obj = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册