提交 6e24ccb2 编写于 作者: C Cole Robinson

nodedev: Break out virNodeDeviceHasCap to node_conf

Will be used by test driver node device implementation.
Signed-off-by: NCole Robinson <crobinso@redhat.com>
上级 112746cd
......@@ -80,6 +80,16 @@ virNodeDevCapsDefParseString(virConnectPtr conn,
return 0;
}
int virNodeDeviceHasCap(const virNodeDeviceObjPtr dev, const char *cap)
{
virNodeDevCapsDefPtr caps = dev->def->caps;
while (caps) {
if (STREQ(cap, virNodeDevCapTypeToString(caps->type)))
return 1;
caps = caps->next;
}
return 0;
}
virNodeDeviceObjPtr virNodeDeviceFindByName(const virNodeDeviceObjListPtr devs,
const char *name)
......
......@@ -193,6 +193,8 @@ struct _virDeviceMonitorState {
virReportErrorHelper(conn, VIR_FROM_NODEDEV, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
int virNodeDeviceHasCap(const virNodeDeviceObjPtr dev, const char *cap);
virNodeDeviceObjPtr virNodeDeviceFindByName(const virNodeDeviceObjListPtr devs,
const char *name);
......
......@@ -302,6 +302,7 @@ nodeGetFreeMemory;
# node_device_conf.h
virNodeDeviceHasCap;
virNodeDeviceObjRemove;
virNodeDevCapTypeToString;
virNodeDeviceFindByName;
......
......@@ -39,17 +39,6 @@
#define VIR_FROM_THIS VIR_FROM_NODEDEV
static int dev_has_cap(const virNodeDeviceObjPtr dev, const char *cap)
{
virNodeDevCapsDefPtr caps = dev->def->caps;
while (caps) {
if (STREQ(cap, virNodeDevCapTypeToString(caps->type)))
return 1;
caps = caps->next;
}
return 0;
}
static int update_caps(virNodeDeviceObjPtr dev)
{
......@@ -157,7 +146,7 @@ static int nodeNumOfDevices(virConnectPtr conn,
for (i = 0; i < driver->devs.count; i++) {
virNodeDeviceObjLock(driver->devs.objs[i]);
if ((cap == NULL) ||
dev_has_cap(driver->devs.objs[i], cap))
virNodeDeviceHasCap(driver->devs.objs[i], cap))
++ndevs;
virNodeDeviceObjUnlock(driver->devs.objs[i]);
}
......@@ -180,7 +169,7 @@ nodeListDevices(virConnectPtr conn,
for (i = 0; i < driver->devs.count && ndevs < maxnames; i++) {
virNodeDeviceObjLock(driver->devs.objs[i]);
if (cap == NULL ||
dev_has_cap(driver->devs.objs[i], cap)) {
virNodeDeviceHasCap(driver->devs.objs[i], cap)) {
if ((names[ndevs++] = strdup(driver->devs.objs[i]->def->name)) == NULL) {
virNodeDeviceObjUnlock(driver->devs.objs[i]);
goto failure;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册