When running libvirtd from a build directory, libvirtd would load lock drivers from system directory unless explicitly overridden by setting LIBVIRT_LOCK_MANAGER_PLUGIN_DIR environment variable. Since we already autodetect driver directory if libvirt is build with driver modules, we can use the same trick to automagically set lock driver directory. --- daemon/libvirtd.c | 6 ++++-- src/libvirt_private.syms | 1 + src/locking/lock_manager.c | 12 +++++++++++- src/locking/lock_manager.h | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index f0b0a3c..5245740 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -55,6 +55,7 @@ #include "hooks.h" #include "uuid.h" #include "viraudit.h" +#include "locking/lock_manager.h" #ifdef WITH_DRIVER_MODULES # include "driver.h" @@ -971,7 +972,6 @@ int main(int argc, char **argv) { /* initialize early logging */ virLogSetFromEnv(); -#ifdef WITH_DRIVER_MODULES if (strstr(argv[0], "lt-libvirtd") || strstr(argv[0], "/daemon/.libs/libvirtd")) { char *tmp = strrchr(argv[0], '/'); @@ -990,11 +990,13 @@ int main(int argc, char **argv) { argv[0], driverdir); exit(EXIT_FAILURE); } + virLockManagerSetPluginDir(driverdir); +#ifdef WITH_DRIVER_MODULES virDriverModuleInitialize(driverdir); +#endif *tmp = '/'; /* Must not free 'driverdir' - it is still used */ } -#endif while (1) { int optidx = 0; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4cfa95f..e2d6d27 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -757,6 +757,7 @@ virLockManagerPluginUnref; virLockManagerPluginUsesState; virLockManagerPluginGetName; virLockManagerRelease; +virLockManagerSetPluginDir; # logging.h diff --git a/src/locking/lock_manager.c b/src/locking/lock_manager.c index 1d9c1bf..068327f 100644 --- a/src/locking/lock_manager.c +++ b/src/locking/lock_manager.c @@ -64,6 +64,16 @@ struct _virLockManagerPlugin { #define DEFAULT_LOCK_MANAGER_PLUGIN_DIR LIBDIR "/libvirt/lock-driver" +static const char *virLockManagerPluginDir = DEFAULT_LOCK_MANAGER_PLUGIN_DIR; + +void +virLockManagerSetPluginDir(const char *dir) +{ + if (dir) + virLockManagerPluginDir = dir; +} + + static void virLockManagerLogParams(size_t nparams, virLockManagerParamPtr params) { @@ -128,7 +138,7 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name, driver = &virLockDriverNop; } else { if (moddir == NULL) - moddir = DEFAULT_LOCK_MANAGER_PLUGIN_DIR; + moddir = virLockManagerPluginDir; VIR_DEBUG("Module load %s from %s", name, moddir); diff --git a/src/locking/lock_manager.h b/src/locking/lock_manager.h index 25c7f7f..6a779f0 100644 --- a/src/locking/lock_manager.h +++ b/src/locking/lock_manager.h @@ -28,6 +28,7 @@ typedef struct _virLockManagerPlugin virLockManagerPlugin; typedef virLockManagerPlugin *virLockManagerPluginPtr; +void virLockManagerSetPluginDir(const char *dir); virLockManagerPluginPtr virLockManagerPluginNew(const char *name, const char *configFile, unsigned int flags); -- 1.7.11.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list