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

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

 



On Tue, Dec 02, 2008 at 10:45:32AM +0100, Daniel Veillard wrote:
> 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 ?

Thq qemudShutdown() method is invoked when the daemon itself is
shutting down completely. There's no need to call  the individual
object deletion virDomainRemoveInactive() in this case, because a 
few lines later we do a virDomainObjListFree() which bulk removes
all of them. 

Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

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