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

[libvirt] [PATCH 1/4] Allow per-driver config file for lock manager plugins



Allow a 'configFile' parameter to be passed into the lock
drivers to provide configuration. Wire up the QEMU driver
to pass in file names '/etc/libvirt/qemu-$NAME.conf
eg qemu-sanlock.conf

* src/locking/lock_driver.h, src/locking/lock_driver_nop.c,
  src/locking/lock_driver_sanlock.c, src/locking/lock_manager.c,
  src/locking/lock_manager.h: Add configFile parameter
* src/qemu/qemu_conf.c: Pass in configuration file path to
  lock driver plugins
---
 src/locking/lock_driver.h         |    1 +
 src/locking/lock_driver_nop.c     |    3 ++-
 src/locking/lock_driver_sanlock.c |    1 +
 src/locking/lock_manager.c        |    7 +++----
 src/locking/lock_manager.h        |    1 +
 src/qemu/qemu_conf.c              |   11 +++++++++--
 6 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/locking/lock_driver.h b/src/locking/lock_driver.h
index 2e71113..3b90efa 100644
--- a/src/locking/lock_driver.h
+++ b/src/locking/lock_driver.h
@@ -121,6 +121,7 @@ struct _virLockManagerParam {
  * Returns -1 if the requested version/flags were inadequate
  */
 typedef int (*virLockDriverInit)(unsigned int version,
+                                 const char *configFile,
                                  unsigned int flags);
 
 /**
diff --git a/src/locking/lock_driver_nop.c b/src/locking/lock_driver_nop.c
index 36a9083..43374e4 100644
--- a/src/locking/lock_driver_nop.c
+++ b/src/locking/lock_driver_nop.c
@@ -28,9 +28,10 @@
 
 
 static int virLockManagerNopInit(unsigned int version,
+                                 const char *configFile,
                                  unsigned int flags)
 {
-    VIR_DEBUG("version=%u flags=%u", version, flags);
+    VIR_DEBUG("version=%u configFile=%s flags=%u", version, NULLSTR(configFile), flags);
 
     return 0;
 }
diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index adead76..3eab23e 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -64,6 +64,7 @@ struct _virLockManagerSanlockPrivate {
  */
 
 static int virLockManagerSanlockInit(unsigned int version ATTRIBUTE_UNUSED,
+                                     const char *configFile ATTRIBUTE_UNUSED,
                                      unsigned int flags)
 {
     virCheckFlags(0, -1);
diff --git a/src/locking/lock_manager.c b/src/locking/lock_manager.c
index e97c738..c28ca86 100644
--- a/src/locking/lock_manager.c
+++ b/src/locking/lock_manager.c
@@ -119,6 +119,7 @@ static void virLockManagerLogParams(size_t nparams,
  */
 #if HAVE_DLFCN_H
 virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
+                                                const char *configFile,
                                                 unsigned int flags)
 {
     void *handle = NULL;
@@ -162,11 +163,8 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
         }
     }
 
-    if (driver->drvInit(VIR_LOCK_MANAGER_VERSION, flags) < 0) {
-        virLockError(VIR_ERR_INTERNAL_ERROR, "%s",
-                     _("plugin ABI is not compatible"));
+    if (driver->drvInit(VIR_LOCK_MANAGER_VERSION, configFile, flags) < 0)
         goto cleanup;
-    }
 
     if (VIR_ALLOC(plugin) < 0) {
         virReportOOMError();
@@ -193,6 +191,7 @@ cleanup:
 }
 #else /* !HAVE_DLFCN_H */
 virLockManagerPluginPtr virLockManagerPluginNew(const char *name ATTRIBUTE_UNUSED,
+                                                const char *configFile ATTRIBUTE_UNUSED,
                                                 unsigned int flags ATTRIBUTE_UNUSED)
 {
     virLockError(VIR_ERR_INTERNAL_ERROR, "%s",
diff --git a/src/locking/lock_manager.h b/src/locking/lock_manager.h
index 13ad372..315c798 100644
--- a/src/locking/lock_manager.h
+++ b/src/locking/lock_manager.h
@@ -29,6 +29,7 @@ typedef struct _virLockManagerPlugin virLockManagerPlugin;
 typedef virLockManagerPlugin *virLockManagerPluginPtr;
 
 virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
+                                                const char *configFile,
                                                 unsigned int flags);
 void virLockManagerPluginRef(virLockManagerPluginPtr plugin);
 void virLockManagerPluginUnref(virLockManagerPluginPtr plugin);
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 46f6976..3d8aba4 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -116,7 +116,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
 #endif
 
     if (!(driver->lockManager =
-          virLockManagerPluginNew("nop", 0)))
+          virLockManagerPluginNew("nop", NULL, 0)))
         return -1;
 
     /* Just check the file is readable before opening it, otherwise
@@ -438,10 +438,17 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
     p = virConfGetValue (conf, "lock_manager");
     CHECK_TYPE ("lock_manager", VIR_CONF_STRING);
     if (p && p->str) {
+        char *lockConf;
         virLockManagerPluginUnref(driver->lockManager);
+        if (virAsprintf(&lockConf, "%s/libvirt/qemu-%s.conf", SYSCONFDIR, p->str) < 0) {
+            virReportOOMError();
+            virConfFree(conf);
+            return -1;
+        }
         if (!(driver->lockManager =
-              virLockManagerPluginNew(p->str, 0)))
+              virLockManagerPluginNew(p->str, lockConf, 0)))
             VIR_ERROR(_("Failed to load lock manager %s"), p->str);
+        VIR_FREE(lockConf);
     }
 
     virConfFree (conf);
-- 
1.7.4.4


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