[PATCH 7/9] Use virFileFindResource to locate lock manager plugins

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Replace virLockManagerSetPluginDir with virFileFindResource
usage.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 daemon/libvirtd.c          |  1 -
 src/locking/lock_manager.c | 28 +++++++++-------------------
 src/locking/lock_manager.h |  1 -
 3 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index b4e9c1f..c5915bd 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1179,7 +1179,6 @@ int main(int argc, char **argv) {
                     argv[0], driverdir);
             exit(EXIT_FAILURE);
         }
-        virLockManagerSetPluginDir(driverdir);
 #ifdef WITH_DRIVER_MODULES
         virDriverModuleInitialize(driverdir);
 #endif
diff --git a/src/locking/lock_manager.c b/src/locking/lock_manager.c
index 5093739..ec90d04 100644
--- a/src/locking/lock_manager.c
+++ b/src/locking/lock_manager.c
@@ -24,6 +24,7 @@
 #include "lock_manager.h"
 #include "lock_driver_nop.h"
 #include "virerror.h"
+#include "virfile.h"
 #include "virlog.h"
 #include "viralloc.h"
 #include "viruuid.h"
@@ -64,18 +65,6 @@ struct _virLockManagerPlugin {
     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,
                                     virLockManagerParamPtr params)
 {
@@ -137,7 +126,6 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
     void *handle = NULL;
     virLockDriverPtr driver;
     virLockManagerPluginPtr plugin = NULL;
-    const char *moddir = virGetEnvBlockSUID("LIBVIRT_LOCK_MANAGER_PLUGIN_DIR");
     char *modfile = NULL;
     char *configFile = NULL;
 
@@ -151,14 +139,16 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
     if (STREQ(name, "nop")) {
         driver = &virLockDriverNop;
     } else {
-        if (moddir == NULL)
-            moddir = virLockManagerPluginDir;
-
-        VIR_DEBUG("Module load %s from %s", name, moddir);
-
-        if (virAsprintf(&modfile, "%s/%s.so", moddir, name) < 0)
+        if (!(modfile = virFileFindResourceFull(name,
+                                                NULL,
+                                                ".so",
+                                                "src/.libs",
+                                                LIBDIR "/libvirt/lock-driver",
+                                                "LIBVIRT_LOCK_MANAGER_PLUGIN_DIR")))
             goto cleanup;
 
+        VIR_DEBUG("Module load %s from %s", name, modfile);
+
         if (access(modfile, R_OK) < 0) {
             virReportSystemError(errno,
                                  _("Plugin %s not accessible"),
diff --git a/src/locking/lock_manager.h b/src/locking/lock_manager.h
index fea9db8..4189759 100644
--- a/src/locking/lock_manager.h
+++ b/src/locking/lock_manager.h
@@ -28,7 +28,6 @@
 typedef struct _virLockManagerPlugin virLockManagerPlugin;
 typedef virLockManagerPlugin *virLockManagerPluginPtr;
 
-void virLockManagerSetPluginDir(const char *dir);
 virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
                                                 const char *driverName,
                                                 const char *configDir,
-- 
1.9.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]