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

Use virFileFindResource to locate lock manager plugins

Replace virLockManagerSetPluginDir with virFileFindResource
usage.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 c8e22a4c
...@@ -1179,7 +1179,6 @@ int main(int argc, char **argv) { ...@@ -1179,7 +1179,6 @@ int main(int argc, char **argv) {
argv[0], driverdir); argv[0], driverdir);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
virLockManagerSetPluginDir(driverdir);
#ifdef WITH_DRIVER_MODULES #ifdef WITH_DRIVER_MODULES
virDriverModuleInitialize(driverdir); virDriverModuleInitialize(driverdir);
#endif #endif
......
...@@ -840,7 +840,6 @@ virLockManagerPluginRef; ...@@ -840,7 +840,6 @@ virLockManagerPluginRef;
virLockManagerPluginUnref; virLockManagerPluginUnref;
virLockManagerPluginUsesState; virLockManagerPluginUsesState;
virLockManagerRelease; virLockManagerRelease;
virLockManagerSetPluginDir;
# nodeinfo.h # nodeinfo.h
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "lock_manager.h" #include "lock_manager.h"
#include "lock_driver_nop.h" #include "lock_driver_nop.h"
#include "virerror.h" #include "virerror.h"
#include "virfile.h"
#include "virlog.h" #include "virlog.h"
#include "viralloc.h" #include "viralloc.h"
#include "viruuid.h" #include "viruuid.h"
...@@ -64,18 +65,6 @@ struct _virLockManagerPlugin { ...@@ -64,18 +65,6 @@ struct _virLockManagerPlugin {
int refs; int refs;
}; };
#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, static void virLockManagerLogParams(size_t nparams,
virLockManagerParamPtr params) virLockManagerParamPtr params)
{ {
...@@ -137,7 +126,6 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name, ...@@ -137,7 +126,6 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
void *handle = NULL; void *handle = NULL;
virLockDriverPtr driver; virLockDriverPtr driver;
virLockManagerPluginPtr plugin = NULL; virLockManagerPluginPtr plugin = NULL;
const char *moddir = virGetEnvBlockSUID("LIBVIRT_LOCK_MANAGER_PLUGIN_DIR");
char *modfile = NULL; char *modfile = NULL;
char *configFile = NULL; char *configFile = NULL;
...@@ -151,14 +139,16 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name, ...@@ -151,14 +139,16 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
if (STREQ(name, "nop")) { if (STREQ(name, "nop")) {
driver = &virLockDriverNop; driver = &virLockDriverNop;
} else { } else {
if (moddir == NULL) if (!(modfile = virFileFindResourceFull(name,
moddir = virLockManagerPluginDir; NULL,
".so",
VIR_DEBUG("Module load %s from %s", name, moddir); "src/.libs",
LIBDIR "/libvirt/lock-driver",
if (virAsprintf(&modfile, "%s/%s.so", moddir, name) < 0) "LIBVIRT_LOCK_MANAGER_PLUGIN_DIR")))
goto cleanup; goto cleanup;
VIR_DEBUG("Module load %s from %s", name, modfile);
if (access(modfile, R_OK) < 0) { if (access(modfile, R_OK) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("Plugin %s not accessible"), _("Plugin %s not accessible"),
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
typedef struct _virLockManagerPlugin virLockManagerPlugin; typedef struct _virLockManagerPlugin virLockManagerPlugin;
typedef virLockManagerPlugin *virLockManagerPluginPtr; typedef virLockManagerPlugin *virLockManagerPluginPtr;
void virLockManagerSetPluginDir(const char *dir);
virLockManagerPluginPtr virLockManagerPluginNew(const char *name, virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
const char *driverName, const char *driverName,
const char *configDir, const char *configDir,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册