[PATH] Fix build on CentOS 7

Message ID 20180810141116.24016-1-muriloo@linux.ibm.com
State New
Headers show
Series
  • [PATH] Fix build on CentOS 7
Related show

Commit Message

Murilo Opsfelder Araujo Aug. 10, 2018, 2:11 p.m.
After commit b3f1c8c413bc83e4a2cc7a63e4eddf9fe6449052 "qemu-pr-helper: use new
libmultipath API", QEMU started using new libmultipath API, which is not
available on CentOS 7.x.

This fixes that by probing the new libmultipath API in configure.  If it fails,
then try probing the old API.  If it fails, then consider libmultipath not
available.

With this, configure script defines CONFIG_MPATH_NEW_API that is used in
scsi/qemu-pr-helper.c to use the new libmultipath API.

Fixes: b3f1c8c413bc83e4a2cc7a63e4eddf9fe6449052
BugLink: https://bugs.launchpad.net/qemu/+bug/1786343
Signed-off-by: Murilo Opsfelder Araujo <muriloo@linux.ibm.com>
---
 configure             | 24 +++++++++++++++++++++++-
 scsi/qemu-pr-helper.c |  4 ++++
 2 files changed, 27 insertions(+), 1 deletion(-)

Comments

Paolo Bonzini Aug. 10, 2018, 5:34 p.m. | #1
On 10/08/2018 16:11, Murilo Opsfelder Araujo wrote:
> After commit b3f1c8c413bc83e4a2cc7a63e4eddf9fe6449052 "qemu-pr-helper: use new
> libmultipath API", QEMU started using new libmultipath API, which is not
> available on CentOS 7.x.
> 
> This fixes that by probing the new libmultipath API in configure.  If it fails,
> then try probing the old API.  If it fails, then consider libmultipath not
> available.
> 
> With this, configure script defines CONFIG_MPATH_NEW_API that is used in
> scsi/qemu-pr-helper.c to use the new libmultipath API.
> 
> Fixes: b3f1c8c413bc83e4a2cc7a63e4eddf9fe6449052
> BugLink: https://bugs.launchpad.net/qemu/+bug/1786343
> Signed-off-by: Murilo Opsfelder Araujo <muriloo@linux.ibm.com>

Thanks, I'll look at the patch for 3.1.  For what it's worth, RHEL7 has
simply reverted that patch in its RPM.

Paolo

Patch

diff --git a/configure b/configure
index 2a7796ea80..bc6000c24a 100755
--- a/configure
+++ b/configure
@@ -3558,6 +3558,7 @@  fi
 # libmpathpersist probe
 
 if test "$mpath" != "no" ; then
+  # probe for the new API
   cat > $TMPC <<EOF
 #include <libudev.h>
 #include <mpath_persist.h>
@@ -3579,8 +3580,26 @@  int main(void) {
 EOF
   if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
     mpathpersist=yes
+    mpathpersist_new_api=yes
   else
-    mpathpersist=no
+    # probe for the old API
+    cat > $TMPC <<EOF
+#include <libudev.h>
+#include <mpath_persist.h>
+unsigned mpath_mx_alloc_len = 1024;
+int logsink;
+int main(void) {
+    struct udev *udev = udev_new();
+    mpath_lib_init(udev);
+    return 0;
+}
+EOF
+    if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
+      mpathpersist=yes
+      mpathpersist_new_api=no
+    else
+      mpathpersist=no
+    fi
   fi
 else
   mpathpersist=no
@@ -6421,6 +6440,9 @@  if test "$virtfs" = "yes" ; then
 fi
 if test "$mpath" = "yes" ; then
   echo "CONFIG_MPATH=y" >> $config_host_mak
+  if test "$mpathpersist_new_api" = "yes"; then
+    echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
+  fi
 fi
 if test "$vhost_scsi" = "yes" ; then
   echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
index 1528a712a0..ed037aabee 100644
--- a/scsi/qemu-pr-helper.c
+++ b/scsi/qemu-pr-helper.c
@@ -301,7 +301,11 @@  void put_multipath_config(struct config *conf)
 static void multipath_pr_init(void)
 {
     udev = udev_new();
+#ifdef CONFIG_MPATH_NEW_API
     multipath_conf = mpath_lib_init();
+#else
+    mpath_lib_init(udev);
+#endif
 }
 
 static int is_mpath(int fd)