* then lockless thereafter */
virQEMUDriverConfigPtr config;
+ /* pid file FD, ensures two copies of the driver can't use the same root */
+ int lockFD;
+
/* Immutable pointer, self-locking APIs */
virThreadPoolPtr workerPool;
#include "node_device_conf.h"
#include "virpci.h"
#include "virusb.h"
+#include "virpidfile.h"
#include "virprocess.h"
#include "libvirt_internal.h"
#include "virxml.h"
if (VIR_ALLOC(qemu_driver) < 0)
return -1;
+ qemu_driver->lockFD = -1;
+
if (virMutexInit(&qemu_driver->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot initialize mutex"));
goto error;
}
+ if ((qemu_driver->lockFD =
+ virPidFileAcquire(cfg->stateDir, "driver", true, getpid())) < 0)
+ goto error;
+
qemu_driver->qemuImgBinary = virFindFileInPath("qemu-img");
if (!(qemu_driver->lockManager =
if (!qemu_driver)
return -1;
+ if (qemu_driver->lockFD != -1)
+ virPidFileRelease(qemu_driver->config->stateDir, "driver", qemu_driver->lockFD);
virThreadPoolFree(qemu_driver->workerPool);
virObjectUnref(qemu_driver->config);
virObjectUnref(qemu_driver->hostdevMgr);