meson: move libmpathpersist test

This is the first compiler/linker test that has been moved to Meson.
Add more section headings to keep things clearer.

This also fixes static linking to libmpathpersist, which has a
dependency on libmultipath but no pkg-config file to describe it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2020-09-16 18:07:29 +02:00
parent f01496a314
commit 6ec0e15d95
3 changed files with 80 additions and 80 deletions

77
configure vendored
View File

@ -403,7 +403,7 @@ netmap="no"
sdl="auto" sdl="auto"
sdl_image="auto" sdl_image="auto"
virtfs="" virtfs=""
mpath="" mpath="auto"
vnc="enabled" vnc="enabled"
sparse="no" sparse="no"
vde="" vde=""
@ -1116,9 +1116,9 @@ for opt do
;; ;;
--enable-virtfs) virtfs="yes" --enable-virtfs) virtfs="yes"
;; ;;
--disable-mpath) mpath="no" --disable-mpath) mpath="disabled"
;; ;;
--enable-mpath) mpath="yes" --enable-mpath) mpath="enabled"
;; ;;
--disable-vnc) vnc="disabled" --disable-vnc) vnc="disabled"
;; ;;
@ -3852,57 +3852,6 @@ if test "$modules" = yes; then
fi fi
fi fi
##########################################
# libmpathpersist probe
if test "$mpath" != "no" ; then
# probe for the new API
cat > $TMPC <<EOF
#include <libudev.h>
#include <mpath_persist.h>
unsigned mpath_mx_alloc_len = 1024;
int logsink;
static struct config *multipath_conf;
extern struct udev *udev;
extern struct config *get_multipath_config(void);
extern void put_multipath_config(struct config *conf);
struct udev *udev;
struct config *get_multipath_config(void) { return multipath_conf; }
void put_multipath_config(struct config *conf) { }
int main(void) {
udev = udev_new();
multipath_conf = mpath_lib_init();
return 0;
}
EOF
if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
mpathpersist=yes
mpathpersist_new_api=yes
else
# 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
fi
########################################## ##########################################
# pthread probe # pthread probe
PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2" PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
@ -6337,23 +6286,11 @@ if test "$softmmu" = yes ; then
fi fi
virtfs=no virtfs=no
fi fi
if test "$mpath" != no && test "$mpathpersist" = yes ; then
mpath=yes
else
if test "$mpath" = yes; then
error_exit "Multipath requires libmpathpersist devel"
fi
mpath=no
fi
else else
if test "$virtfs" = yes; then if test "$virtfs" = yes; then
error_exit "VirtFS is supported only on Linux" error_exit "VirtFS is supported only on Linux"
fi fi
virtfs=no virtfs=no
if test "$mpath" = yes; then
error_exit "Multipath is supported only on Linux"
fi
mpath=no
fi fi
fi fi
@ -6894,12 +6831,6 @@ fi
if test "$virtfs" = "yes" ; then if test "$virtfs" = "yes" ; then
echo "CONFIG_VIRTFS=y" >> $config_host_mak echo "CONFIG_VIRTFS=y" >> $config_host_mak
fi 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 if test "$vhost_scsi" = "yes" ; then
echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
fi fi
@ -7988,7 +7919,7 @@ NINJA=${ninja:-$PWD/ninjatool} $meson setup \
-Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \ -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
-Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \ -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
-Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \ -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
-Dsdl=$sdl -Dsdl_image=$sdl_image \ -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
-Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \ -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
-Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f\ -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f\
$cross_arg \ $cross_arg \

View File

@ -86,6 +86,14 @@ if 'SPARSE_CFLAGS' in config_host
'compile_commands.json']) 'compile_commands.json'])
endif endif
###########################################
# Target-specific checks and dependencies #
###########################################
if targetos != 'linux' and get_option('mpath').enabled()
error('Multipath is supported only on Linux')
endif
m = cc.find_library('m', required: false) m = cc.find_library('m', required: false)
util = cc.find_library('util', required: false) util = cc.find_library('util', required: false)
winmm = [] winmm = []
@ -117,6 +125,11 @@ elif targetos == 'haiku'
cc.find_library('network'), cc.find_library('network'),
cc.find_library('bsd')] cc.find_library('bsd')]
endif endif
################
# Dependencies #
################
# The path to glib.h is added to all compilation commands. This was # The path to glib.h is added to all compilation commands. This was
# grandfathered in from the QEMU Makefiles. # grandfathered in from the QEMU Makefiles.
add_project_arguments(config_host['GLIB_CFLAGS'].split(), add_project_arguments(config_host['GLIB_CFLAGS'].split(),
@ -223,10 +236,6 @@ if 'CONFIG_SPICE' in config_host
link_args: config_host['SPICE_LIBS'].split()) link_args: config_host['SPICE_LIBS'].split())
endif endif
rt = cc.find_library('rt', required: false) rt = cc.find_library('rt', required: false)
libmpathpersist = not_found
if config_host.has_key('CONFIG_MPATH')
libmpathpersist = cc.find_library('mpathpersist')
endif
libdl = not_found libdl = not_found
if 'CONFIG_PLUGIN' in config_host if 'CONFIG_PLUGIN' in config_host
libdl = cc.find_library('dl', required: true) libdl = cc.find_library('dl', required: true)
@ -258,8 +267,64 @@ if 'CONFIG_CURL' in config_host
endif endif
libudev = not_found libudev = not_found
if targetos == 'linux' and (have_system or have_tools) if targetos == 'linux' and (have_system or have_tools)
libudev = dependency('libudev', static: enable_static) libudev = dependency('libudev',
required: get_option('mpath').enabled(),
static: enable_static)
endif endif
mpathpersist = not_found
mpathpersist_new_api = false
if targetos == 'linux' and have_tools and not get_option('mpath').disabled()
mpath_test_source_new = '''
#include <libudev.h>
#include <mpath_persist.h>
unsigned mpath_mx_alloc_len = 1024;
int logsink;
static struct config *multipath_conf;
extern struct udev *udev;
extern struct config *get_multipath_config(void);
extern void put_multipath_config(struct config *conf);
struct udev *udev;
struct config *get_multipath_config(void) { return multipath_conf; }
void put_multipath_config(struct config *conf) { }
int main(void) {
udev = udev_new();
multipath_conf = mpath_lib_init();
return 0;
}'''
mpath_test_source_old = '''
#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;
}'''
libmultipath = cc.find_library('multipath',
required: get_option('mpath'),
static: enable_static)
libmpathpersist = cc.find_library('mpathpersist',
required: get_option('mpath'),
static: enable_static)
if libmultipath.found() and libmpathpersist.found() and libudev.found()
mpathlibs = [libmultipath, libmpathpersist, libudev]
if cc.links(mpath_test_source_new, dependencies: mpathlibs)
mpathpersist = declare_dependency(dependencies: mpathlibs)
mpathpersist_new_api = true
elif cc.links(mpath_test_source_old, dependencies: mpathlibs)
mpathpersist = declare_dependency(dependencies: mpathlibs)
else
if get_option('mpath').enabled()
error('Cannot detect libmpathpersist API')
else
warning('Cannot detect libmpathpersist API, disabling')
endif
endif
endif
endif
brlapi = not_found brlapi = not_found
if 'CONFIG_BRLAPI' in config_host if 'CONFIG_BRLAPI' in config_host
brlapi = declare_dependency(link_args: config_host['BRLAPI_LIBS'].split()) brlapi = declare_dependency(link_args: config_host['BRLAPI_LIBS'].split())
@ -441,6 +506,8 @@ has_gettid = cc.has_function('gettid')
# Create config-host.h # Create config-host.h
config_host_data.set('CONFIG_LIBUDEV', libudev.found()) config_host_data.set('CONFIG_LIBUDEV', libudev.found())
config_host_data.set('CONFIG_MPATH', mpathpersist.found())
config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
config_host_data.set('CONFIG_SDL', sdl.found()) config_host_data.set('CONFIG_SDL', sdl.found())
config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found()) config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
config_host_data.set('CONFIG_VNC', vnc.found()) config_host_data.set('CONFIG_VNC', vnc.found())
@ -1205,7 +1272,7 @@ if have_tools
executable('qemu-pr-helper', files('scsi/qemu-pr-helper.c', 'scsi/utils.c'), executable('qemu-pr-helper', files('scsi/qemu-pr-helper.c', 'scsi/utils.c'),
dependencies: [authz, crypto, io, qom, qemuutil, dependencies: [authz, crypto, io, qom, qemuutil,
libcap_ng, libudev, libmpathpersist], libcap_ng, mpathpersist],
install: true) install: true)
endif endif
@ -1342,7 +1409,7 @@ summary_info += {'Audio drivers': config_host['CONFIG_AUDIO_DRIVERS']}
summary_info += {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHITELIST']} summary_info += {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHITELIST']}
summary_info += {'Block whitelist (ro)': config_host['CONFIG_BDRV_RO_WHITELIST']} summary_info += {'Block whitelist (ro)': config_host['CONFIG_BDRV_RO_WHITELIST']}
summary_info += {'VirtFS support': config_host.has_key('CONFIG_VIRTFS')} summary_info += {'VirtFS support': config_host.has_key('CONFIG_VIRTFS')}
summary_info += {'Multipath support': config_host.has_key('CONFIG_MPATH')} summary_info += {'Multipath support': mpathpersist.found()}
summary_info += {'VNC support': vnc.found()} summary_info += {'VNC support': vnc.found()}
if vnc.found() if vnc.found()
summary_info += {'VNC SASL support': sasl.found()} summary_info += {'VNC SASL support': sasl.found()}

View File

@ -6,6 +6,8 @@ option('docdir', type : 'string', value : 'doc',
option('gettext', type : 'boolean', value : true, option('gettext', type : 'boolean', value : true,
description: 'Localization of the GTK+ user interface') description: 'Localization of the GTK+ user interface')
option('mpath', type : 'feature', value : 'auto',
description: 'Multipath persistent reservation passthrough')
option('sdl', type : 'feature', value : 'auto', option('sdl', type : 'feature', value : 'auto',
description: 'SDL user interface') description: 'SDL user interface')
option('sdl_image', type : 'feature', value : 'auto', option('sdl_image', type : 'feature', value : 'auto',