Will be used by test driver node device implementation. Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx> --- src/conf/node_device_conf.c | 10 ++++++++++ src/conf/node_device_conf.h | 2 ++ src/libvirt_private.syms | 1 + src/node_device/node_device_driver.c | 15 ++------------- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 5b25bb7..a810940 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -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) diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index c33cc73..9fa9127 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -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); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 49bbf96..952ed29 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -302,6 +302,7 @@ nodeGetFreeMemory; # node_device_conf.h +virNodeDeviceHasCap; virNodeDeviceObjRemove; virNodeDevCapTypeToString; virNodeDeviceFindByName; diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index c902e7d..14b3098 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -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; -- 1.6.5.rc2 -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list