[libvirt] [PATCH] Define SANLK_INQ_WAIT if missing in headers

so we can build with older sanlock (like 2.2) --- I've applied this to the current Debian builds since we're lagging a bit regarding sanlock but it might make sense to also support this upstream. Cheers, -- Guido src/locking/lock_driver_sanlock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c index 430e11e..84f81ec 100644 --- a/src/locking/lock_driver_sanlock.c +++ b/src/locking/lock_driver_sanlock.c @@ -338,6 +338,9 @@ retry: if ((rv = sanlock_add_lockspace(&ls, 0)) < 0) { if (-rv == EINPROGRESS) { #ifdef HAVE_SANLOCK_INQ_LOCKSPACE +# ifndef SANLK_INQ_WAIT +# define SANLK_INQ_WAIT 0x00000001 +# endif /* we have this function which blocks until lockspace change the * state. It returns 0 if lockspace has been added, -ENOENT if it * hasn't. XXX should we goto retry? */ -- 1.7.10.4

On Thu, Dec 13, 2012 at 06:20:06PM +0100, Guido Günther wrote:
so we can build with older sanlock (like 2.2) --- I've applied this to the current Debian builds since we're lagging a bit regarding sanlock but it might make sense to also support this upstream. Cheers, -- Guido
src/locking/lock_driver_sanlock.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c index 430e11e..84f81ec 100644 --- a/src/locking/lock_driver_sanlock.c +++ b/src/locking/lock_driver_sanlock.c @@ -338,6 +338,9 @@ retry: if ((rv = sanlock_add_lockspace(&ls, 0)) < 0) { if (-rv == EINPROGRESS) { #ifdef HAVE_SANLOCK_INQ_LOCKSPACE +# ifndef SANLK_INQ_WAIT +# define SANLK_INQ_WAIT 0x00000001 +# endif /* we have this function which blocks until lockspace change the * state. It returns 0 if lockspace has been added, -ENOENT if it * hasn't. XXX should we goto retry? */
I don't think this is the right approach. The code relies on the fact that INQ_WAIT actally works. Just passing this flag to an impl which doesn't support it will not do the right thing. This piece of code is already conditionalized on HAVE_SANLOCK_INQ_LOCKSPACE to fallback to alternative busy-wait loop impl. We need to make sure that the Debian falls back to the alternative impl. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

since compilation breaks otherwise with older libsanlock. --- Hi Daniel, does this make more sense then? Cheers, -- Guido configure.ac | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index bf32f95..1936982 100644 --- a/configure.ac +++ b/configure.ac @@ -1216,8 +1216,14 @@ if test "x$with_sanlock" != "xno"; then fi ]) fi - test $fail = 1 && + if test $fail = 1; then AC_MSG_ERROR([You must install the Sanlock development package in order to compile libvirt]) + else + AC_CHECK_DECLS([SANLK_INQ_WAIT], [sanlock_inq_wait=1], [sanlock_inq_wait=0], [[ + #include <stdint.h> + #include <sanlock_admin.h> + ]]) + fi CPPFLAGS="$old_cppflags" LIBS="$old_libs" if test "x$with_sanlock" = "xyes" ; then @@ -1233,7 +1239,8 @@ if test "x$with_sanlock" != "xno"; then AC_CHECK_LIB([sanlock_client], [sanlock_inq_lockspace], [sanlock_inq_lockspace=yes], [sanlock_inq_lockspace=no]) - if test "x$sanlock_inq_lockspace" = "xyes" ; then + if test "x$sanlock_inq_lockspace" = "xyes" && \ + test $sanlock_inq_wait = 1; then AC_DEFINE_UNQUOTED([HAVE_SANLOCK_INQ_LOCKSPACE], 1, [whether sanlock supports sanlock_inq_lockspace]) fi -- 1.7.10.4

On 12/13/2012 03:48 PM, Guido Günther wrote:
since compilation breaks otherwise with older libsanlock. --- Hi Daniel, does this make more sense then? Cheers, -- Guido
I'm not Daniel, but it looks right to me. ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Thu, Dec 13, 2012 at 03:55:21PM -0700, Eric Blake wrote:
On 12/13/2012 03:48 PM, Guido Günther wrote:
since compilation breaks otherwise with older libsanlock. --- Hi Daniel, does this make more sense then? Cheers, -- Guido
I'm not Daniel, but it looks right to me.
ACK. Pushed. Thanks, -- Guido
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Guido Günther