[libvirt] [PATCH 1/5] nodedev: Add locking in nodeNumOfDevices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
---
 src/node_device/node_device_driver.c |    7 ++++++-
 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 93ca28c..c902e7d 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;
 }
-- 
1.6.5.rc2

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]