diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index a79f620a39c81dcc90dea49e08730584f5ddc75b..7cfd450bbdae30f23c2b06571a86c6862c063594 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -4167,7 +4167,9 @@ lxcDomainDetachDeviceHostdevUSBLive(virLXCDriverPtr driver, VIR_WARN("cannot deny device %s for domain %s", dst, vm->def->name); + virObjectLock(driver->activeUsbHostdevs); virUSBDeviceListDel(driver->activeUsbHostdevs, usb); + virObjectUnlock(driver->activeUsbHostdevs); virDomainHostdevRemove(vm->def, idx); virDomainHostdevDefFree(def); diff --git a/src/lxc/lxc_hostdev.c b/src/lxc/lxc_hostdev.c index 257e93b343f8a145514cc646b870b3dd56780c11..3b371fc002314d6944a1aef9b896c83efb41f606 100644 --- a/src/lxc/lxc_hostdev.c +++ b/src/lxc/lxc_hostdev.c @@ -62,10 +62,13 @@ virLXCUpdateActiveUsbHostdevs(virLXCDriverPtr driver, virUSBDeviceSetUsedBy(usb, def->name); + virObjectLock(driver->activeUsbHostdevs); if (virUSBDeviceListAdd(driver->activeUsbHostdevs, usb) < 0) { + virObjectUnlock(driver->activeUsbHostdevs); virUSBDeviceFree(usb); return -1; } + virObjectUnlock(driver->activeUsbHostdevs); } return 0; @@ -83,6 +86,7 @@ virLXCPrepareHostdevUSBDevices(virLXCDriverPtr driver, count = virUSBDeviceListCount(list); + virObjectLock(driver->activeUsbHostdevs); for (i = 0; i < count; i++) { virUSBDevicePtr usb = virUSBDeviceListGet(list, i); if ((tmp = virUSBDeviceListFind(driver->activeUsbHostdevs, usb))) { @@ -110,6 +114,7 @@ virLXCPrepareHostdevUSBDevices(virLXCDriverPtr driver, if (virUSBDeviceListAdd(driver->activeUsbHostdevs, usb) < 0) goto error; } + virObjectUnlock(driver->activeUsbHostdevs); return 0; error: @@ -117,6 +122,7 @@ error: tmp = virUSBDeviceListGet(list, i); virUSBDeviceListSteal(driver->activeUsbHostdevs, tmp); } + virObjectUnlock(driver->activeUsbHostdevs); return -1; } @@ -341,6 +347,7 @@ virLXCDomainReAttachHostUsbDevices(virLXCDriverPtr driver, { size_t i; + virObjectLock(driver->activeUsbHostdevs); for (i = 0; i < nhostdevs; i++) { virDomainHostdevDefPtr hostdev = hostdevs[i]; virUSBDevicePtr usb, tmp; @@ -392,6 +399,7 @@ virLXCDomainReAttachHostUsbDevices(virLXCDriverPtr driver, virUSBDeviceListDel(driver->activeUsbHostdevs, tmp); } } + virObjectUnlock(driver->activeUsbHostdevs); } void virLXCDomainReAttachHostDevices(virLXCDriverPtr driver,