]> xenbits.xensource.com Git - libvirt.git/commitdiff
lock_manager: Allow disabling configFile for virLockManagerPluginNew
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 21 Aug 2018 12:08:54 +0000 (14:08 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 18 Sep 2018 15:12:53 +0000 (17:12 +0200)
In some cases we might want to not load the lock driver config.
Alter virLockManagerPluginNew() and the lock drivers to cope with
this fact.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/locking/lock_driver.h
src/locking/lock_driver_lockd.c
src/locking/lock_driver_sanlock.c
src/locking/lock_manager.c

index 7c8f744be3baa38022856f6ea91ea6645389bddc..ae30abda7dfacaa243e4887fc93d98e9bffacaa4 100644 (file)
@@ -124,6 +124,7 @@ struct _virLockManagerParam {
 /**
  * virLockDriverInit:
  * @version: the libvirt requested plugin ABI version
+ * @configFile: path to config file
  * @flags: the libvirt requested plugin optional extras
  *
  * Allow the plugin to validate the libvirt requested
@@ -131,6 +132,9 @@ struct _virLockManagerParam {
  * to block its use in versions of libvirtd which are
  * too old to support key features.
  *
+ * The @configFile variable points to config file that the driver
+ * should load. If NULL, no config file should be loaded.
+ *
  * NB: A plugin may be loaded multiple times, for different
  * libvirt drivers (eg QEMU, LXC, UML)
  *
index 85cdcf97be6fad76974cf0673d6ad8a0e8aa9c11..0c672b05b178d4ca3652a27056271d53940ea389 100644 (file)
@@ -371,8 +371,10 @@ static int virLockManagerLockDaemonInit(unsigned int version,
     driver->requireLeaseForDisks = true;
     driver->autoDiskLease = true;
 
-    if (virLockManagerLockDaemonLoadConfig(configFile) < 0)
+    if (configFile &&
+        virLockManagerLockDaemonLoadConfig(configFile) < 0) {
         goto error;
+    }
 
     if (driver->autoDiskLease) {
         if (driver->fileLockSpaceDir &&
index 9393e7d9a27afe697d1a021c8abb2c075e78c603..66953c70d5194a8c78deba6d5d2aed8afc9dbb9f 100644 (file)
@@ -450,8 +450,10 @@ static int virLockManagerSanlockInit(unsigned int version,
         goto error;
     }
 
-    if (virLockManagerSanlockLoadConfig(driver, configFile) < 0)
+    if (configFile &&
+        virLockManagerSanlockLoadConfig(driver, configFile) < 0) {
         goto error;
+    }
 
     if (driver->autoDiskLease && !driver->hostID) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
index 4ef9f9e69250ec003a42d61a428ff0b6c6bc6cb6..84d0c30d370b629bc9334c14b562b976dc0bd858 100644 (file)
@@ -105,6 +105,8 @@ static void virLockManagerLogParams(size_t nparams,
 /**
  * virLockManagerPluginNew:
  * @name: the name of the plugin
+ * @driverName: the hypervisor driver that loads the plugin
+ * @configDir: path to dir where config files are stored
  * @flag: optional plugin flags
  *
  * Attempt to load the plugin $(libdir)/libvirt/lock-driver/@name.so
@@ -130,11 +132,13 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
     char *configFile = NULL;
 
     VIR_DEBUG("name=%s driverName=%s configDir=%s flags=0x%x",
-              name, driverName, configDir, flags);
+              name, NULLSTR(driverName), NULLSTR(configDir), flags);
 
-    if (virAsprintf(&configFile, "%s/%s-%s.conf",
-                    configDir, driverName, name) < 0)
+    if (driverName && configDir &&
+        virAsprintf(&configFile, "%s/%s-%s.conf",
+                    configDir, driverName, name) < 0) {
         return NULL;
+    }
 
     if (STREQ(name, "nop")) {
         driver = &virLockDriverNop;