aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2009-10-01 14:51:39 -0400
committerCole Robinson <crobinso@redhat.com>2009-10-05 14:07:15 -0400
commit112746cdc52577463e7c587eae3731f8b30b95e6 (patch)
tree2b07033c2eab5570b08d4bc02a80d05cf19e445f /src/node_device/node_device_driver.c
parenttest: Throw a proper error in GetBridgeName (diff)
downloadlibvirt-112746cdc52577463e7c587eae3731f8b30b95e6.tar.gz
libvirt-112746cdc52577463e7c587eae3731f8b30b95e6.tar.bz2
libvirt-112746cdc52577463e7c587eae3731f8b30b95e6.zip
nodedev: Add locking in nodeNumOfDevices
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Diffstat (limited to 'src/node_device/node_device_driver.c')
-rw-r--r--src/node_device/node_device_driver.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 93ca28c22..c902e7d94 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -153,10 +153,15 @@ static int nodeNumOfDevices(virConnectPtr conn,
int ndevs = 0;
unsigned int i;
- for (i = 0; i < driver->devs.count; i++)
+ nodeDeviceLock(driver);
+ for (i = 0; i < driver->devs.count; i++) {
+ virNodeDeviceObjLock(driver->devs.objs[i]);
if ((cap == NULL) ||
dev_has_cap(driver->devs.objs[i], cap))
++ndevs;
+ virNodeDeviceObjUnlock(driver->devs.objs[i]);
+ }
+ nodeDeviceUnlock(driver);
return ndevs;
}