From: "Daniel P. Berrange" <berrange@xxxxxxxxxx> * daemon/libvirtd.c: Set custom driver module dir if the current binary name is 'lt-libvirtd' (indicating execution directly from GIT checkout) * src/driver.c, src/driver.h, src/libvirt_driver_modules.syms: Add virDriverModuleInitialize to allow driver module location to be changed Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx> --- daemon/libvirtd.c | 6 ++++++ src/driver.c | 18 ++++++++++++++++-- src/driver.h | 1 + src/libvirt_driver_modules.syms | 1 + 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index dfab810..ead160e 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -1341,6 +1341,12 @@ int main(int argc, char **argv) { /* initialize early logging */ virLogSetFromEnv(); +#ifdef WITH_DRIVER_MODULES + if (strstr(argv[0], "lt-libvirtd") && + (access("./.git", R_OK) >= 0 || access("../.git", R_OK) >= 0)) + virDriverModuleInitialize("./src/.libs"); +#endif + while (1) { int optidx = 0; int c; diff --git a/src/driver.c b/src/driver.c index fb162e0..da4bee5 100644 --- a/src/driver.c +++ b/src/driver.c @@ -38,16 +38,30 @@ # include <dlfcn.h> +static const char *moddir = NULL; + +void +virDriverModuleInitialize(const char *defmoddir) +{ + const char *custommoddir = getenv("LIBVIRT_DRIVER_DIR"); + if (custommoddir) + moddir = custommoddir; + else if (defmoddir) + moddir = defmoddir; + else + moddir = DEFAULT_DRIVER_DIR; + VIR_DEBUG("Module dir %s", moddir); +} + void * virDriverLoadModule(const char *name) { - const char *moddir = getenv("LIBVIRT_DRIVER_DIR"); char *modfile = NULL, *regfunc = NULL; void *handle = NULL; int (*regsym)(void); if (moddir == NULL) - moddir = DEFAULT_DRIVER_DIR; + virDriverModuleInitialize(NULL); VIR_DEBUG("Module load %s", name); diff --git a/src/driver.h b/src/driver.h index 03d249b..aa7a377 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1621,6 +1621,7 @@ int virRegisterNWFilterDriver(virNWFilterDriverPtr); # ifdef WITH_LIBVIRTD int virRegisterStateDriver(virStateDriverPtr); # endif +void virDriverModuleInitialize(const char *defmoddir); void *virDriverLoadModule(const char *name); #endif /* __VIR_DRIVER_H__ */ diff --git a/src/libvirt_driver_modules.syms b/src/libvirt_driver_modules.syms index ce8d9b8..a5dd58b 100644 --- a/src/libvirt_driver_modules.syms +++ b/src/libvirt_driver_modules.syms @@ -5,3 +5,4 @@ # driver.h virDriverLoadModule; +virDriverModuleInitialize; -- 1.7.7.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list