Replace virDriverModuleInitialize with virFileFindResource usage. Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx> --- daemon/libvirtd.c | 13 +------------ src/driver.c | 26 +++++++------------------- src/driver.h | 1 - tests/virdrivermoduletest.c | 2 -- 4 files changed, 8 insertions(+), 34 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index c5915bd..e549783 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -1167,25 +1167,14 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } *tmp = '\0'; - char *driverdir; - if (virAsprintfQuiet(&driverdir, "%s/../../src/.libs", argv[0]) < 0 || - virAsprintfQuiet(&cpumap, "%s/../../src/cpu/cpu_map.xml", + if (virAsprintfQuiet(&cpumap, "%s/../../src/cpu/cpu_map.xml", argv[0]) < 0) { fprintf(stderr, _("%s: initialization failed\n"), argv[0]); exit(EXIT_FAILURE); } - if (access(driverdir, R_OK) < 0) { - fprintf(stderr, _("%s: expected driver directory '%s' is missing\n"), - argv[0], driverdir); - exit(EXIT_FAILURE); - } -#ifdef WITH_DRIVER_MODULES - virDriverModuleInitialize(driverdir); -#endif cpuMapOverride(cpumap); VIR_FREE(cpumap); *tmp = '/'; - /* Must not free 'driverdir' - it is still used */ } while (1) { diff --git a/src/driver.c b/src/driver.c index 6b79b5e..9e3a2eb 100644 --- a/src/driver.c +++ b/src/driver.c @@ -26,6 +26,7 @@ #include "driver.h" #include "viralloc.h" +#include "virfile.h" #include "virlog.h" #include "virutil.h" #include "configmake.h" @@ -41,21 +42,6 @@ VIR_LOG_INIT("driver"); # include <dlfcn.h> -static const char *moddir = NULL; - -void -virDriverModuleInitialize(const char *defmoddir) -{ - const char *custommoddir = virGetEnvBlockSUID("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) { @@ -63,12 +49,14 @@ virDriverLoadModule(const char *name) void *handle = NULL; int (*regsym)(void); - if (moddir == NULL) - virDriverModuleInitialize(NULL); - VIR_DEBUG("Module load %s", name); - if (virAsprintfQuiet(&modfile, "%s/libvirt_driver_%s.so", moddir, name) < 0) + if (!(modfile = virFileFindResourceFull(name, + "libvirt_driver_", + ".so", + "src/.libs", + LIBDIR "/libvirt/connection-driver", + "LIBVIRT_DRIVER_DIR"))) return NULL; if (access(modfile, R_OK) < 0) { diff --git a/src/driver.h b/src/driver.h index e66fc7a..729e743 100644 --- a/src/driver.h +++ b/src/driver.h @@ -2164,7 +2164,6 @@ int virRegisterNWFilterDriver(virNWFilterDriverPtr) ATTRIBUTE_RETURN_CHECK; # ifdef WITH_LIBVIRTD int virRegisterStateDriver(virStateDriverPtr) ATTRIBUTE_RETURN_CHECK; # endif -void virDriverModuleInitialize(const char *defmoddir); void *virDriverLoadModule(const char *name); #endif /* __VIR_DRIVER_H__ */ diff --git a/tests/virdrivermoduletest.c b/tests/virdrivermoduletest.c index 4203f5b..840fc28 100644 --- a/tests/virdrivermoduletest.c +++ b/tests/virdrivermoduletest.c @@ -65,8 +65,6 @@ mymain(void) ret = -1; \ } while (0) - virDriverModuleInitialize(abs_builddir "/../src/.libs"); - #ifdef WITH_NETWORK # define USE_NETWORK "network" TEST("network", NULL); -- 1.9.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list