On Fri, Feb 01, 2013 at 11:18:33 +0000, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Currently the activePciHostdevs, inactivePciHostdevsd and
activeUsbHostdevs lists are all implicitly protected by the
QEMU driver lock. Now that the lists all inherit from the
virObjectLockable, we can make the locking explicit, removing
the dependency on the QEMU driver lock for correctness.
...
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 3dfcf63..34a339c 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
...
@@ -165,10 +175,12 @@ qemuUpdateActiveUsbHostdevs(virQEMUDriverPtr
driver,
{
virDomainHostdevDefPtr hostdev = NULL;
int i;
+ int ret = -1;
if (!def->nhostdevs)
return 0;
+ virObjectLock(driver->activeUsbHostdevs);
for (i = 0; i < def->nhostdevs; i++) {
virUSBDevicePtr usb = NULL;
hostdev = def->hostdevs[i];
@@ -193,11 +205,13 @@ qemuUpdateActiveUsbHostdevs(virQEMUDriverPtr driver,
if (virUSBDeviceListAdd(driver->activeUsbHostdevs, usb) < 0) {
virUSBDeviceFree(usb);
- return -1;
+ goto cleanup;
}
}
-
- return 0;
+ ret = 0;
+cleanup:
+ virObjectLock(driver->activeUsbHostdevs);
Bad copy&paste, you really should call virObjectUnlock here :-)
+ return ret;
}
static int
ACK with the typo fixed.
Jirka