提交 bc2f42a0 编写于 作者: D Daniel P. Berrange

Use virFileFindResource to locate driver plugins

Replace virDriverModuleInitialize with virFileFindResource
usage.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 d3c76842
......@@ -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) {
......
......@@ -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) {
......
......@@ -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__ */
......@@ -4,7 +4,6 @@
# driver.h
virDriverLoadModule;
virDriverModuleInitialize;
# Let emacs know we want case-insensitive sorting
# Local Variables:
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册