Re: [libvirt] PATCH: 7/28: Thread safety for QEMU driver

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

 



On Sun, Nov 30, 2008 at 11:33:06PM +0000, Daniel P. Berrange wrote:
> This patch makes the QEMU driver threadsafe with the exception of the
> domain events code.
> @@ -229,20 +243,22 @@ qemudStartup(void) {
[...]
> +error:
> +    if (qemu_driver)
> +        qemuDriverUnlock(qemu_driver);
>      VIR_FREE(base);
> -    VIR_FREE(qemu_driver);
> +    qemudShutdown();

  okay the clean way to free the driver structure

> @@ -314,16 +334,16 @@ qemudShutdown(void) {
>      if (!qemu_driver)
>          return -1;
>  
> +    qemuDriverLock(qemu_driver);
>      virCapabilitiesFree(qemu_driver->caps);
>  
>      /* shutdown active VMs */
>      for (i = 0 ; i < qemu_driver->domains.count ; i++) {
>          virDomainObjPtr dom = qemu_driver->domains.objs[i];
> +        virDomainObjLock(dom);
>          if (virDomainIsActive(dom))
>              qemudShutdownVMDaemon(NULL, qemu_driver, dom);
> -        if (!dom->persistent)
> -            virDomainRemoveInactive(&qemu_driver->domains,
> -                                    dom);
> +        virDomainObjUnlock(dom);
>      }
>  
>      virDomainObjListFree(&qemu_driver->domains);
> @@ -340,6 +360,7 @@ qemudShutdown(void) {
>      if (qemu_driver->brctl)
>          brShutdown(qemu_driver->brctl);
>  
> +    qemuDriverUnlock(qemu_driver);
>      VIR_FREE(qemu_driver);
>  
>      return 0;

   We don't remove anymore the non-persistent domain on shutdown ?
Is that because we can hook this to the event lifecycle processing ?

> @@ -1089,18 +1087,38 @@ qemudDispatchVMEvent(int watch, int fd, 
[...]
> +    if (failed || quit) {
> +        qemudShutdownVMDaemon(NULL, driver, vm);
> +        qemudDomainEventDispatch(driver, vm,
> +                                 VIR_DOMAIN_EVENT_STOPPED,
> +                                 quit ?
> +                                 VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN :
> +                                 VIR_DOMAIN_EVENT_STOPPED_FAILED);
> +        if (!vm->persistent) {
> +            virDomainRemoveInactive(&driver->domains,
> +                                    vm);
> +            vm = NULL;
> +        }
> +    }

  seems to be done here now, okay

   I could not spot anything on the locking side, +1

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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