mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 05:25:18 +00:00
nodedev: Break out virNodeDeviceHasCap to node_conf
Will be used by test driver node device implementation. Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
112746cdc5
commit
6e24ccb266
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user