#include "virthread.h"
#include "virlog.h"
#include "virfile.h"
+#include "virpidfile.h"
#include "virtypedparam.h"
#include "virrandom.h"
#include "virstring.h"
virObjectUnref(bhyve_driver->config);
virPortAllocatorRangeFree(bhyve_driver->remotePorts);
+ if (bhyve_driver->lockFD != -1)
+ virPidFileRelease(BHYVE_STATE_DIR, "driver", bhyve_driver->lockFD);
+
virMutexDestroy(&bhyve_driver->lock);
VIR_FREE(bhyve_driver);
if (VIR_ALLOC(bhyve_driver) < 0)
return -1;
+ bhyve_driver->lockFD = -1;
if (virMutexInit(&bhyve_driver->lock) < 0) {
VIR_FREE(bhyve_driver);
return -1;
goto cleanup;
}
+ if ((bhyve_driver->lockFD =
+ virPidFileAcquire(BHYVE_STATE_DIR, "driver", true, getpid())) < 0)
+ goto cleanup;
+
if (virDomainObjListLoadAllConfigs(bhyve_driver->domains,
BHYVE_STATE_DIR,
NULL, true,
virBhyveDriverConfigPtr config;
+ /* pid file FD, ensures two copies of the driver can't use the same root */
+ int lockFD;
+
virDomainObjListPtr domains;
virCapsPtr caps;
virDomainXMLOptionPtr xmlopt;