[libvirt] PATCH: Fix thread safety with HAL driver restart

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

 



The restart method of the HAL implementation of node device is not 
currently threadsafe, because it destroys and creates the entire
driver, including its mutexes. This patch changes it to simply throw
away all existing devices, and re-load them from dbus.

Daniel

diff -r 625ffe1918a4 src/node_device_hal.c
--- a/src/node_device_hal.c	Thu May 21 15:56:27 2009 +0100
+++ b/src/node_device_hal.c	Thu May 21 15:56:33 2009 +0100
@@ -785,10 +785,28 @@ static int halDeviceMonitorShutdown(void
 
 static int halDeviceMonitorReload(void)
 {
-    /* XXX This isn't thread safe because its free'ing the thing
-     * we're locking */
-    (void)halDeviceMonitorShutdown();
-    return halDeviceMonitorStartup();
+    DBusError err;
+    char **udi = NULL;
+    int num_devs, i;
+    LibHalContext *hal_ctx;
+
+    nodeDeviceLock(driverState);
+    virNodeDeviceObjListFree(&driverState->devs);
+    nodeDeviceUnlock(driverState);
+
+    hal_ctx = DRV_STATE_HAL_CTX(driverState);
+    udi = libhal_get_all_devices(hal_ctx, &num_devs, &err);
+    if (udi == NULL) {
+        fprintf(stderr, "%s: libhal_get_all_devices failed\n", __FUNCTION__);
+        return -1;
+    }
+    for (i = 0; i < num_devs; i++) {
+        dev_create(udi[i]);
+        VIR_FREE(udi[i]);
+    }
+    VIR_FREE(udi);
+
+    return 0;
 }
 
 


-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
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]