qemu-pr-helper: Fix build on CentOS 7

After commit b3f1c8c413 "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: b3f1c8c413
BugLink: https://bugs.launchpad.net/qemu/+bug/1786343
Signed-off-by: Murilo Opsfelder Araujo <muriloo@linux.ibm.com>
Message-Id: <20180810141116.24016-1-muriloo@linux.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Murilo Opsfelder Araujo 2018-08-10 11:11:16 -03:00 committed by Paolo Bonzini
parent 1a5c63ce88
commit 1b0578f5c4
2 changed files with 27 additions and 1 deletions

24
configure vendored
View file

@ -3612,6 +3612,7 @@ fi
# libmpathpersist probe # libmpathpersist probe
if test "$mpath" != "no" ; then if test "$mpath" != "no" ; then
# probe for the new API
cat > $TMPC <<EOF cat > $TMPC <<EOF
#include <libudev.h> #include <libudev.h>
#include <mpath_persist.h> #include <mpath_persist.h>
@ -3633,8 +3634,26 @@ int main(void) {
EOF EOF
if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
mpathpersist=yes mpathpersist=yes
mpathpersist_new_api=yes
else 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 fi
else else
mpathpersist=no mpathpersist=no
@ -6495,6 +6514,9 @@ if test "$virtfs" = "yes" ; then
fi fi
if test "$mpath" = "yes" ; then if test "$mpath" = "yes" ; then
echo "CONFIG_MPATH=y" >> $config_host_mak 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 fi
if test "$vhost_scsi" = "yes" ; then if test "$vhost_scsi" = "yes" ; then
echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak

View file

@ -301,7 +301,11 @@ void put_multipath_config(struct config *conf)
static void multipath_pr_init(void) static void multipath_pr_init(void)
{ {
udev = udev_new(); udev = udev_new();
#ifdef CONFIG_MPATH_NEW_API
multipath_conf = mpath_lib_init(); multipath_conf = mpath_lib_init();
#else
mpath_lib_init(udev);
#endif
} }
static int is_mpath(int fd) static int is_mpath(int fd)