Re: [PATCH v3 11/13] Protect USB/PCI device list access in QEMU with dedicated locks

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

 



On Fri, Feb 01, 2013 at 11:18:33 +0000, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> 
> 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

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