diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2022-04-20 17:33:47 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-05-07 07:46:58 +0200 |
commit | 14efd8d3b5fee7027f0ee072aea6620e0655774f (patch) | |
tree | 2545715139f3cc7c60f69e8c7eff9acd408d18b7 /configure | |
parent | 119fc611eac96d5ad5c407860b29c0fd5d072f6d (diff) |
meson, configure: move Xen detection to meson
This is quite a complicated check. I moved all the test programs to
a single file in scripts/, picking the right program with #if and a -D
flag in meson.build's cc.links() invocation.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 322 |
1 files changed, 1 insertions, 321 deletions
@@ -292,7 +292,6 @@ EXTRA_CXXFLAGS="" EXTRA_OBJCFLAGS="" EXTRA_LDFLAGS="" -xen_ctrl_version="$default_feature" vhost_kernel="$default_feature" vhost_net="$default_feature" vhost_crypto="$default_feature" @@ -346,9 +345,6 @@ default_devices="true" tcg="enabled" cfi="false" -# 4. Detection partly done in configure -xen=${default_feature:+disabled} - # parse CC options second for opt do optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') @@ -867,10 +863,6 @@ for opt do ;; --enable-slirp=*) slirp="$optarg" ;; - --disable-xen) xen="disabled" - ;; - --enable-xen) xen="enabled" - ;; --disable-tcg) tcg="disabled" plugins="no" ;; @@ -1699,312 +1691,6 @@ if ! has "$pkg_config_exe"; then fi ########################################## -# xen probe - -if test "$xen" != "disabled" ; then - # Check whether Xen library path is specified via --extra-ldflags to avoid - # overriding this setting with pkg-config output. If not, try pkg-config - # to obtain all needed flags. - - if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \ - $pkg_config --exists xencontrol ; then - xen_ctrl_version="$(printf '%d%02d%02d' \ - $($pkg_config --modversion xencontrol | sed 's/\./ /g') )" - xen=enabled - xen_pc="xencontrol xenstore xenforeignmemory xengnttab" - xen_pc="$xen_pc xenevtchn xendevicemodel" - if $pkg_config --exists xentoolcore; then - xen_pc="$xen_pc xentoolcore" - fi - xen_cflags="$($pkg_config --cflags $xen_pc)" - xen_libs="$($pkg_config --libs $xen_pc)" - else - - xen_libs="-lxenstore -lxenctrl" - xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn" - - # First we test whether Xen headers and libraries are available. - # If no, we are done and there is no Xen support. - # If yes, more tests are run to detect the Xen version. - - # Xen (any) - cat > $TMPC <<EOF -#include <xenctrl.h> -int main(void) { - return 0; -} -EOF - if ! compile_prog "" "$xen_libs" ; then - # Xen not found - if test "$xen" = "enabled" ; then - feature_not_found "xen" "Install xen devel" - fi - xen=disabled - - # Xen unstable - elif - cat > $TMPC <<EOF && -#undef XC_WANT_COMPAT_DEVICEMODEL_API -#define __XEN_TOOLS__ -#include <xendevicemodel.h> -#include <xenforeignmemory.h> -int main(void) { - xendevicemodel_handle *xd; - xenforeignmemory_handle *xfmem; - - xd = xendevicemodel_open(0, 0); - xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0); - - xfmem = xenforeignmemory_open(0, 0); - xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0); - - return 0; -} -EOF - compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" - then - xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" - xen_ctrl_version=41100 - xen=enabled - elif - cat > $TMPC <<EOF && -#undef XC_WANT_COMPAT_MAP_FOREIGN_API -#include <xenforeignmemory.h> -#include <xentoolcore.h> -int main(void) { - xenforeignmemory_handle *xfmem; - - xfmem = xenforeignmemory_open(0, 0); - xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0); - xentoolcore_restrict_all(0); - - return 0; -} -EOF - compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" - then - xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" - xen_ctrl_version=41000 - xen=enabled - elif - cat > $TMPC <<EOF && -#undef XC_WANT_COMPAT_DEVICEMODEL_API -#define __XEN_TOOLS__ -#include <xendevicemodel.h> -int main(void) { - xendevicemodel_handle *xd; - - xd = xendevicemodel_open(0, 0); - xendevicemodel_close(xd); - - return 0; -} -EOF - compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs" - then - xen_stable_libs="-lxendevicemodel $xen_stable_libs" - xen_ctrl_version=40900 - xen=enabled - elif - cat > $TMPC <<EOF && -/* - * If we have stable libs the we don't want the libxc compat - * layers, regardless of what CFLAGS we may have been given. - * - * Also, check if xengnttab_grant_copy_segment_t is defined and - * grant copy operation is implemented. - */ -#undef XC_WANT_COMPAT_EVTCHN_API -#undef XC_WANT_COMPAT_GNTTAB_API -#undef XC_WANT_COMPAT_MAP_FOREIGN_API -#include <xenctrl.h> -#include <xenstore.h> -#include <xenevtchn.h> -#include <xengnttab.h> -#include <xenforeignmemory.h> -#include <stdint.h> -#include <xen/hvm/hvm_info_table.h> -#if !defined(HVM_MAX_VCPUS) -# error HVM_MAX_VCPUS not defined -#endif -int main(void) { - xc_interface *xc = NULL; - xenforeignmemory_handle *xfmem; - xenevtchn_handle *xe; - xengnttab_handle *xg; - xengnttab_grant_copy_segment_t* seg = NULL; - - xs_daemon_open(); - - xc = xc_interface_open(0, 0, 0); - xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); - xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); - xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); - xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); - - xfmem = xenforeignmemory_open(0, 0); - xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); - - xe = xenevtchn_open(0, 0); - xenevtchn_fd(xe); - - xg = xengnttab_open(0, 0); - xengnttab_grant_copy(xg, 0, seg); - - return 0; -} -EOF - compile_prog "" "$xen_libs $xen_stable_libs" - then - xen_ctrl_version=40800 - xen=enabled - elif - cat > $TMPC <<EOF && -/* - * If we have stable libs the we don't want the libxc compat - * layers, regardless of what CFLAGS we may have been given. - */ -#undef XC_WANT_COMPAT_EVTCHN_API -#undef XC_WANT_COMPAT_GNTTAB_API -#undef XC_WANT_COMPAT_MAP_FOREIGN_API -#include <xenctrl.h> -#include <xenstore.h> -#include <xenevtchn.h> -#include <xengnttab.h> -#include <xenforeignmemory.h> -#include <stdint.h> -#include <xen/hvm/hvm_info_table.h> -#if !defined(HVM_MAX_VCPUS) -# error HVM_MAX_VCPUS not defined -#endif -int main(void) { - xc_interface *xc = NULL; - xenforeignmemory_handle *xfmem; - xenevtchn_handle *xe; - xengnttab_handle *xg; - - xs_daemon_open(); - - xc = xc_interface_open(0, 0, 0); - xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); - xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); - xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); - xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); - - xfmem = xenforeignmemory_open(0, 0); - xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); - - xe = xenevtchn_open(0, 0); - xenevtchn_fd(xe); - - xg = xengnttab_open(0, 0); - xengnttab_map_grant_ref(xg, 0, 0, 0); - - return 0; -} -EOF - compile_prog "" "$xen_libs $xen_stable_libs" - then - xen_ctrl_version=40701 - xen=enabled - - # Xen 4.6 - elif - cat > $TMPC <<EOF && -#include <xenctrl.h> -#include <xenstore.h> -#include <stdint.h> -#include <xen/hvm/hvm_info_table.h> -#if !defined(HVM_MAX_VCPUS) -# error HVM_MAX_VCPUS not defined -#endif -int main(void) { - xc_interface *xc; - xs_daemon_open(); - xc = xc_interface_open(0, 0, 0); - xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); - xc_gnttab_open(NULL, 0); - xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); - xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); - xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); - xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0); - return 0; -} -EOF - compile_prog "" "$xen_libs" - then - xen_ctrl_version=40600 - xen=enabled - - # Xen 4.5 - elif - cat > $TMPC <<EOF && -#include <xenctrl.h> -#include <xenstore.h> -#include <stdint.h> -#include <xen/hvm/hvm_info_table.h> -#if !defined(HVM_MAX_VCPUS) -# error HVM_MAX_VCPUS not defined -#endif -int main(void) { - xc_interface *xc; - xs_daemon_open(); - xc = xc_interface_open(0, 0, 0); - xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); - xc_gnttab_open(NULL, 0); - xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); - xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); - xc_hvm_create_ioreq_server(xc, 0, 0, NULL); - return 0; -} -EOF - compile_prog "" "$xen_libs" - then - xen_ctrl_version=40500 - xen=enabled - - elif - cat > $TMPC <<EOF && -#include <xenctrl.h> -#include <xenstore.h> -#include <stdint.h> -#include <xen/hvm/hvm_info_table.h> -#if !defined(HVM_MAX_VCPUS) -# error HVM_MAX_VCPUS not defined -#endif -int main(void) { - xc_interface *xc; - xs_daemon_open(); - xc = xc_interface_open(0, 0, 0); - xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); - xc_gnttab_open(NULL, 0); - xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); - xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); - return 0; -} -EOF - compile_prog "" "$xen_libs" - then - xen_ctrl_version=40200 - xen=enabled - - else - if test "$xen" = "enabled" ; then - feature_not_found "xen (unsupported version)" \ - "Install a supported xen (xen 4.2 or newer)" - fi - xen=disabled - fi - - if test "$xen" = enabled; then - if test $xen_ctrl_version -ge 40701 ; then - xen_libs="$xen_libs $xen_stable_libs " - fi - fi - fi -fi - -########################################## # glib support probe glib_req_ver=2.56 @@ -2555,12 +2241,6 @@ if test "$modules" = "yes"; then fi echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak -if test "$xen" = "enabled" ; then - echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak - echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak - echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak - echo "XEN_LIBS=$xen_libs" >> $config_host_mak -fi if test "$vhost_scsi" = "yes" ; then echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak fi @@ -2839,7 +2519,7 @@ if test "$skip_meson" = no; then -Dwerror=$(if test "$werror" = 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_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \ + -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg \ -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \ $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \ $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \ |