On Wed, Apr 20, 2022 at 8:16 PM Paolo Bonzini <pbonz...@redhat.com> wrote:

> When using Meson options rather than config-host.h, the "when" clauses
> have to be changed to if statements (which is not necessarily great,
> though at least it highlights which parts of the build are per-target
> and which are not).
>
> Do that before moving vhost logic to meson.build, though for now
> the variables are just based on config-host.mak data.
>
> Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
>

Reviewed-by: Marc-André Lureau <marcandre.lur...@redhat.com>

---
>  meson.build       | 31 ++++++++++++++++++++-----------
>  tests/meson.build |  2 +-
>  tools/meson.build |  2 +-
>  3 files changed, 22 insertions(+), 13 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index 870dd8dee0..5b5eb442c4 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -312,6 +312,15 @@ have_tpm = get_option('tpm') \
>    .require(targetos != 'windows', error_message: 'TPM emulation only
> available on POSIX systems') \
>    .allowed()
>
> +# vhost
> +have_vhost_user = 'CONFIG_VHOST_USER' in config_host
> +have_vhost_vdpa = 'CONFIG_VHOST_VDPA' in config_host
> +have_vhost_kernel = 'CONFIG_VHOST_KERNEL' in config_host
> +have_vhost_net_user = 'CONFIG_VHOST_NET_USER' in config_host
> +have_vhost_net_vdpa = 'CONFIG_VHOST_NET_VDPA' in config_host
> +have_vhost_net = 'CONFIG_VHOST_NET' in config_host
> +have_vhost_user_crypto = 'CONFIG_VHOST_CRYPTO' in config_host
> +
>  # Target-specific libraries and flags
>  libm = cc.find_library('m', required: false)
>  threads = dependency('threads')
> @@ -1440,7 +1449,7 @@ has_statx_mnt_id = cc.links(statx_mnt_id_test)
>  have_vhost_user_blk_server = get_option('vhost_user_blk_server') \
>    .require(targetos == 'linux',
>             error_message: 'vhost_user_blk_server requires linux') \
> -  .require('CONFIG_VHOST_USER' in config_host,
> +  .require(have_vhost_user,
>             error_message: 'vhost_user_blk_server requires vhost-user
> support') \
>    .disable_auto_if(not have_system) \
>    .allowed()
> @@ -2283,9 +2292,9 @@ host_kconfig = \
>    (have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \
>    (opengl.found() ? ['CONFIG_OPENGL=y'] : []) + \
>    (x11.found() ? ['CONFIG_X11=y'] : []) + \
> -  ('CONFIG_VHOST_USER' in config_host ? ['CONFIG_VHOST_USER=y'] : []) + \
> -  ('CONFIG_VHOST_VDPA' in config_host ? ['CONFIG_VHOST_VDPA=y'] : []) + \
> -  ('CONFIG_VHOST_KERNEL' in config_host ? ['CONFIG_VHOST_KERNEL=y'] : [])
> + \
> +  (have_vhost_user ? ['CONFIG_VHOST_USER=y'] : []) + \
> +  (have_vhost_vdpa ? ['CONFIG_VHOST_VDPA=y'] : []) + \
> +  (have_vhost_kernel ? ['CONFIG_VHOST_KERNEL=y'] : []) + \
>    (have_virtfs ? ['CONFIG_VIRTFS=y'] : []) + \
>    ('CONFIG_LINUX' in config_host ? ['CONFIG_LINUX=y'] : []) + \
>    (have_pvrdma ? ['CONFIG_PVRDMA=y'] : []) + \
> @@ -2967,7 +2976,7 @@ if have_system or have_user
>  endif
>
>  vhost_user = not_found
> -if targetos == 'linux' and 'CONFIG_VHOST_USER' in config_host
> +if targetos == 'linux' and have_vhost_user
>    libvhost_user = subproject('libvhost-user')
>    vhost_user = libvhost_user.get_variable('vhost_user_dep')
>  endif
> @@ -3548,7 +3557,7 @@ if have_tools
>               dependencies: qemuutil,
>               install: true)
>
> -  if 'CONFIG_VHOST_USER' in config_host
> +  if have_vhost_user
>      subdir('contrib/vhost-user-blk')
>      subdir('contrib/vhost-user-gpu')
>      subdir('contrib/vhost-user-input')
> @@ -3674,12 +3683,12 @@ if 'simple' in get_option('trace_backends')
>  endif
>  summary_info += {'D-Bus display':     dbus_display}
>  summary_info += {'QOM debugging':     get_option('qom_cast_debug')}
> -summary_info += {'vhost-kernel support':
> config_host.has_key('CONFIG_VHOST_KERNEL')}
> -summary_info += {'vhost-net support':
> config_host.has_key('CONFIG_VHOST_NET')}
> -summary_info += {'vhost-crypto support':
> config_host.has_key('CONFIG_VHOST_CRYPTO')}
> -summary_info += {'vhost-user support':
> config_host.has_key('CONFIG_VHOST_USER')}
> +summary_info += {'vhost-kernel support': have_vhost_kernel}
> +summary_info += {'vhost-net support': have_vhost_net}
> +summary_info += {'vhost-user support': have_vhost_user}
> +summary_info += {'vhost-user-crypto support': have_vhost_user_crypto}
>  summary_info += {'vhost-user-blk server support':
> have_vhost_user_blk_server}
> -summary_info += {'vhost-vdpa support':
> config_host.has_key('CONFIG_VHOST_VDPA')}
> +summary_info += {'vhost-vdpa support': have_vhost_vdpa}
>  summary_info += {'build guest agent': have_ga}
>  summary(summary_info, bool_yn: true, section: 'Configurable features')
>
> diff --git a/tests/meson.build b/tests/meson.build
> index 4f691e8465..8e318ec513 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -68,7 +68,7 @@ test_deps = {
>    'test-qht-par': qht_bench,
>  }
>
> -if have_tools and 'CONFIG_VHOST_USER' in config_host and 'CONFIG_LINUX'
> in config_host
> +if have_tools and have_vhost_user and 'CONFIG_LINUX' in config_host
>    executable('vhost-user-bridge',
>               sources: files('vhost-user-bridge.c'),
>               dependencies: [qemuutil, vhost_user])
> diff --git a/tools/meson.build b/tools/meson.build
> index 46977af84f..10eb3a043f 100644
> --- a/tools/meson.build
> +++ b/tools/meson.build
> @@ -3,7 +3,7 @@ have_virtiofsd = get_option('virtiofsd') \
>               error_message: 'virtiofsd requires Linux') \
>      .require(seccomp.found() and libcap_ng.found(),
>               error_message: 'virtiofsd requires libcap-ng-devel and
> seccomp-devel') \
> -    .require('CONFIG_VHOST_USER' in config_host,
> +    .require(have_vhost_user,
>               error_message: 'virtiofsd needs vhost-user-support') \
>      .disable_auto_if(not have_tools and not have_system) \
>      .allowed()
> --
> 2.35.1
>
>
>
>

-- 
Marc-André Lureau

Reply via email to