* then lockless thereafter */
virLXCDriverConfigPtr config;
+ /* pid file FD, ensures two copies of the driver can't use the same root */
+ int lockFD;
+
/* Require lock to get a reference on the object,
* lockless access thereafter */
virCapsPtr caps;
if (VIR_ALLOC(lxc_driver) < 0)
return -1;
+ lxc_driver->lockFD = -1;
if (virMutexInit(&lxc_driver->lock) < 0) {
VIR_FREE(lxc_driver);
return -1;
goto cleanup;
}
+ if ((lxc_driver->lockFD =
+ virPidFileAcquire(cfg->stateDir, "driver", true, getpid())) < 0)
+ goto cleanup;
+
/* Get all the running persistent or transient configs first */
if (virDomainObjListLoadAllConfigs(lxc_driver->domains,
cfg->stateDir,
virObjectUnref(lxc_driver->caps);
virObjectUnref(lxc_driver->securityManager);
virObjectUnref(lxc_driver->xmlopt);
+
+ if (lxc_driver->lockFD != -1)
+ virPidFileRelease(lxc_driver->config->stateDir, "driver", lxc_driver->lockFD);
+
virObjectUnref(lxc_driver->config);
virMutexDestroy(&lxc_driver->lock);
VIR_FREE(lxc_driver);