On Wed, Jul 17, 2013 at 03:04:20PM +0200, Michal Privoznik wrote: > --- > src/lxc/lxc_conf.h | 2 +- > src/lxc/lxc_process.c | 10 ++++------ > 2 files changed, 5 insertions(+), 7 deletions(-) > > diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h > index 6ca6198..f9a3e53 100644 > --- a/src/lxc/lxc_conf.h > +++ b/src/lxc/lxc_conf.h > @@ -77,7 +77,7 @@ struct _virLXCDriver { > > virSysinfoDefPtr hostsysinfo; > > - size_t nactive; > + unsigned int nactive; > > virStateInhibitCallback inhibitCallback; > void *inhibitOpaque; > diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c > index 1024576..4b83729 100644 > --- a/src/lxc/lxc_process.c > +++ b/src/lxc/lxc_process.c > @@ -48,6 +48,7 @@ > #include "lxc_hostdev.h" > #include "virhook.h" > #include "virstring.h" > +#include "viratomic.h" > > #define VIR_FROM_THIS VIR_FROM_LXC > > @@ -256,8 +257,7 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver, > vm->pid = -1; > vm->def->id = -1; > > - driver->nactive--; > - if (!driver->nactive && driver->inhibitCallback) > + if (virAtomicIntDecAndTest(&driver->nactive) && driver->inhibitCallback) > driver->inhibitCallback(false, driver->inhibitOpaque); > > virLXCDomainReAttachHostDevices(driver, vm->def); > @@ -1273,9 +1273,8 @@ int virLXCProcessStart(virConnectPtr conn, > virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason); > priv->doneStopEvent = false; > > - if (!driver->nactive && driver->inhibitCallback) > + if (virAtomicIntInc(&driver->nactive) && driver->inhibitCallback) > driver->inhibitCallback(true, driver->inhibitOpaque); > - driver->nactive++; I think you need virAtomicIntInc() == 1 here, otherwise this will execute on every single VM start, instead of only the first. > > if (lxcContainerWaitForContinue(handshakefds[0]) < 0) { > char out[1024]; > @@ -1458,9 +1457,8 @@ virLXCProcessReconnectDomain(virDomainObjPtr vm, > virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, > VIR_DOMAIN_RUNNING_UNKNOWN); > > - if (!driver->nactive && driver->inhibitCallback) > + if (virAtomicIntInc(&driver->nactive) && driver->inhibitCallback) > driver->inhibitCallback(true, driver->inhibitOpaque); > - driver->nactive++; Again here, we want == 1. virAtomicIntInc() == 1, is the pattern the QEMU driver uses for this code. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list