[libvirt] [PATCH] locking: Fix build with sanlock < 2.4

Jiri Denemark jdenemar at redhat.com
Tue Oct 16 10:54:53 UTC 2012


libvirt started using sanlock_killpath to implement on_lockfailure
action. Since sanlock_killpath was introduced in sanlock 2.4, libvirt
fails to build with older sanlock.
---
 configure.ac                      |  7 +++++++
 src/locking/lock_driver_sanlock.c | 13 +++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/configure.ac b/configure.ac
index 08dc63d..8810efd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1216,6 +1216,13 @@ if test "x$with_sanlock" != "xno"; then
   if test "x$with_sanlock" = "xyes" ; then
     AC_DEFINE_UNQUOTED([HAVE_SANLOCK], 1,
       [whether Sanlock plugin for lock management is available])
+
+    AC_CHECK_LIB([sanlock_client], [sanlock_killpath],
+                 [sanlock_killpath=yes], [sanlock_killpath=no])
+    if test "x$sanlock_killpath" = "xyes" ; then
+      AC_DEFINE_UNQUOTED([HAVE_SANLOCK_KILLPATH], 1,
+        [whether Sanlock supports sanlock_killpath])
+    fi
   fi
 fi
 AM_CONDITIONAL([HAVE_SANLOCK], [test "x$with_sanlock" = "xyes"])
diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index a218432..4682701 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -687,6 +687,7 @@ static int virLockManagerSanlockAddResource(virLockManagerPtr lock,
     return 0;
 }
 
+#if HAVE_SANLOCK_KILLPATH
 static int
 virLockManagerSanlockRegisterKillscript(int sock,
                                         const char *vmuri,
@@ -762,6 +763,18 @@ cleanup:
     VIR_FREE(args);
     return ret;
 }
+#else
+static int
+virLockManagerSanlockRegisterKillscript(int sock ATTRIBUTE_UNUSED,
+                                        const char *vmuri ATTRIBUTE_UNUSED,
+                                        const char *uuidstr ATTRIBUTE_UNUSED,
+                                        virDomainLockFailureAction action ATTRIBUTE_UNUSED)
+{
+    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                   _("sanlock is too old to support lock failure action"));
+    return -1;
+}
+#endif
 
 static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
                                         const char *state,
-- 
1.7.12.3




More information about the libvir-list mailing list