mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 02:51:16 +00:00
Fix HAL driver restart thread safety
This commit is contained in:
parent
c0d74ed43b
commit
1b28a99d14
@ -1,3 +1,11 @@
|
||||
Wed Jun 3 12:19:52 BST 2009 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
Fix HAL driver restart thread safety
|
||||
* src/node_device_hal.c: Only clear & recreate device objects,
|
||||
not entire driver struct.
|
||||
* src/node_device.c: Remove overly verbose logging of mutex
|
||||
operations.
|
||||
|
||||
Wed Jun 3 12:03:52 BST 2009 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
Support networking in UML driver
|
||||
|
@ -51,12 +51,10 @@ static int dev_has_cap(const virNodeDeviceObjPtr dev, const char *cap)
|
||||
|
||||
void nodeDeviceLock(virDeviceMonitorStatePtr driver)
|
||||
{
|
||||
DEBUG("LOCK node %p", driver);
|
||||
virMutexLock(&driver->lock);
|
||||
}
|
||||
void nodeDeviceUnlock(virDeviceMonitorStatePtr driver)
|
||||
{
|
||||
DEBUG("UNLOCK node %p", driver);
|
||||
virMutexUnlock(&driver->lock);
|
||||
}
|
||||
|
||||
|
@ -800,10 +800,33 @@ 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;
|
||||
|
||||
VIR_INFO0("Reloading HAL device state");
|
||||
nodeDeviceLock(driverState);
|
||||
VIR_INFO0("Removing existing objects");
|
||||
virNodeDeviceObjListFree(&driverState->devs);
|
||||
nodeDeviceUnlock(driverState);
|
||||
|
||||
hal_ctx = DRV_STATE_HAL_CTX(driverState);
|
||||
VIR_INFO0("Creating new objects");
|
||||
dbus_error_init(&err);
|
||||
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);
|
||||
VIR_INFO0("HAL device reload complete");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user