mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
lxc: Make activeUsbHostdevs use locks
The activeUsbHostdevs item in LXCDriver are lockable, but the lock has to be called explicitly. Call the virObject(Un)Lock() in order to achieve mutual exclusion once lxcDriverLock is removed.
This commit is contained in:
parent
64ec738e58
commit
2a82171aff
@ -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);
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user