build: add --enable/--disable-libudev

Initially, libudev detection was bundled with --enable-mpath because
qemu-pr-helper was the only user of libudev.  Recently however the USB
U2F emulation has also started using libudev, so add a separate
option.  This also allows 1) disabling libudev if desired for static
builds and 2) for non-static builds, requiring libudev even if
multipath support is undesirable.

The multipath test is adjusted, because it is now possible to enter it
with configurations that should fail, such as --static --enable-mpath
--disable-libudev.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
master
Paolo Bonzini 2020-10-15 06:09:27 -04:00
parent 09e93326e4
commit 5c53015a48
3 changed files with 37 additions and 23 deletions

8
configure vendored
View File

@ -303,6 +303,7 @@ netmap="no"
sdl="auto" sdl="auto"
sdl_image="auto" sdl_image="auto"
virtfs="" virtfs=""
libudev="auto"
mpath="auto" mpath="auto"
vnc="enabled" vnc="enabled"
sparse="auto" sparse="auto"
@ -1002,6 +1003,10 @@ for opt do
;; ;;
--enable-virtfs) virtfs="yes" --enable-virtfs) virtfs="yes"
;; ;;
--disable-libudev) libudev="disabled"
;;
--enable-libudev) libudev="enabled"
;;
--disable-mpath) mpath="disabled" --disable-mpath) mpath="disabled"
;; ;;
--enable-mpath) mpath="enabled" --enable-mpath) mpath="enabled"
@ -1759,6 +1764,7 @@ disabled with --disable-FEATURE, default is enabled if available:
vnc-png PNG compression for VNC server vnc-png PNG compression for VNC server
cocoa Cocoa UI (Mac OS X only) cocoa Cocoa UI (Mac OS X only)
virtfs VirtFS virtfs VirtFS
libudev Use libudev to enumerate host devices
mpath Multipath persistent reservation passthrough mpath Multipath persistent reservation passthrough
xen xen backend driver support xen xen backend driver support
xen-pci-passthrough PCI passthrough support for Xen xen-pci-passthrough PCI passthrough support for Xen
@ -7060,7 +7066,7 @@ NINJA=$ninja $meson setup \
-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 \
-Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \ -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \
-Diconv=$iconv -Dcurses=$curses \ -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
$cross_arg \ $cross_arg \
"$PWD" "$source_path" "$PWD" "$source_path"

View File

@ -380,10 +380,11 @@ 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', libudev = dependency('libudev',
required: get_option('mpath').enabled(), required: get_option('libudev'),
static: enable_static) static: enable_static)
endif endif
mpathlibs = [libudev]
mpathpersist = not_found mpathpersist = not_found
mpathpersist_new_api = false mpathpersist_new_api = false
if targetos == 'linux' and have_tools and not get_option('mpath').disabled() if targetos == 'linux' and have_tools and not get_option('mpath').disabled()
@ -414,35 +415,40 @@ if targetos == 'linux' and have_tools and not get_option('mpath').disabled()
mpath_lib_init(udev); mpath_lib_init(udev);
return 0; return 0;
}''' }'''
mpathlibs = [libudev] libmpathpersist = cc.find_library('mpathpersist',
if enable_static required: get_option('mpath'),
mpathlibs += cc.find_library('devmapper', static: enable_static)
required: get_option('mpath'), if libmpathpersist.found()
static: enable_static) mpathlibs += libmpathpersist
endif if enable_static
mpathlibs += cc.find_library('multipath', mpathlibs += cc.find_library('devmapper',
required: get_option('mpath'), required: get_option('mpath'),
static: enable_static) static: enable_static)
mpathlibs += cc.find_library('mpathpersist',
required: get_option('mpath'),
static: enable_static)
foreach lib: mpathlibs
if not lib.found()
mpathlibs = []
break
endif endif
endforeach mpathlibs += cc.find_library('multipath',
if mpathlibs.length() > 0 required: get_option('mpath'),
if cc.links(mpath_test_source_new, dependencies: mpathlibs) static: enable_static)
foreach lib: mpathlibs
if not lib.found()
mpathlibs = []
break
endif
endforeach
if mpathlibs.length() == 0
msg = 'Dependencies missing for libmpathpersist'
elif cc.links(mpath_test_source_new, dependencies: mpathlibs)
mpathpersist = declare_dependency(dependencies: mpathlibs) mpathpersist = declare_dependency(dependencies: mpathlibs)
mpathpersist_new_api = true mpathpersist_new_api = true
elif cc.links(mpath_test_source_old, dependencies: mpathlibs) elif cc.links(mpath_test_source_old, dependencies: mpathlibs)
mpathpersist = declare_dependency(dependencies: mpathlibs) mpathpersist = declare_dependency(dependencies: mpathlibs)
else else
msg = 'Cannot detect libmpathpersist API'
endif
if not mpathpersist.found()
if get_option('mpath').enabled() if get_option('mpath').enabled()
error('Cannot detect libmpathpersist API') error(msg)
else else
warning('Cannot detect libmpathpersist API, disabling') warning(msg + ', disabling')
endif endif
endif endif
endif endif

View File

@ -36,6 +36,8 @@ option('iconv', type : 'feature', value : 'auto',
description: 'Font glyph conversion support') description: 'Font glyph conversion support')
option('curses', type : 'feature', value : 'auto', option('curses', type : 'feature', value : 'auto',
description: 'curses UI') description: 'curses UI')
option('libudev', type : 'feature', value : 'auto',
description: 'Use libudev to enumerate host devices')
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',