From 6e24ccb266b20dfd5a081e15b7f478da2ea12412 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Thu, 1 Oct 2009 14:53:43 -0400 Subject: [PATCH] nodedev: Break out virNodeDeviceHasCap to node_conf Will be used by test driver node device implementation. Signed-off-by: Cole Robinson --- 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 5b25bb7787..a810940056 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 c33cc738c2..9fa9127e60 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 49bbf9660a..952ed2968c 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 c902e7d943..14b309898b 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; -- GitLab