29b115
From 51c310097832724bafac26aed81399da40128400 Mon Sep 17 00:00:00 2001
29b115
From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
29b115
Date: Thu, 21 Jul 2022 15:50:43 +0200
29b115
Subject: [PATCH 05/32] meson: create have_vhost_* variables
29b115
MIME-Version: 1.0
29b115
Content-Type: text/plain; charset=UTF-8
29b115
Content-Transfer-Encoding: 8bit
29b115
29b115
RH-Author: Eugenio Pérez <eperezma@redhat.com>
29b115
RH-MergeRequest: 108: Net Control Virtqueue shadow Support
29b115
RH-Commit: [5/27] 3b30f89e6d639923dc9d9a92a4261bb4509e5c83 (eperezmartin/qemu-kvm)
29b115
RH-Bugzilla: 1939363
29b115
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
29b115
RH-Acked-by: Cindy Lu <lulu@redhat.com>
29b115
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
29b115
29b115
Bugzilla: https://bugzilla.redhat.com/1939363
29b115
29b115
Upstream Status: git://git.qemu.org/qemu.git
29b115
29b115
commit 2a3129a37652e5e81d12f6e16dd3c447f09831f9
29b115
Author: Paolo Bonzini <pbonzini@redhat.com>
29b115
Date:   Wed Apr 20 17:34:05 2022 +0200
29b115
29b115
    meson: create have_vhost_* variables
29b115
29b115
    When using Meson options rather than config-host.h, the "when" clauses
29b115
    have to be changed to if statements (which is not necessarily great,
29b115
    though at least it highlights which parts of the build are per-target
29b115
    and which are not).
29b115
29b115
    Do that before moving vhost logic to meson.build, though for now
29b115
    the variables are just based on config-host.mak data.
29b115
29b115
    Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
29b115
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
29b115
29b115
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
29b115
---
29b115
 meson.build       | 30 ++++++++++++++++++++----------
29b115
 tests/meson.build |  2 +-
29b115
 tools/meson.build |  2 +-
29b115
 3 files changed, 22 insertions(+), 12 deletions(-)
29b115
29b115
diff --git a/meson.build b/meson.build
29b115
index 13e3323380..735f538497 100644
29b115
--- a/meson.build
29b115
+++ b/meson.build
29b115
@@ -298,6 +298,15 @@ have_tpm = get_option('tpm') \
29b115
   .require(targetos != 'windows', error_message: 'TPM emulation only available on POSIX systems') \
29b115
   .allowed()
29b115
 
29b115
+# vhost
29b115
+have_vhost_user = 'CONFIG_VHOST_USER' in config_host
29b115
+have_vhost_vdpa = 'CONFIG_VHOST_VDPA' in config_host
29b115
+have_vhost_kernel = 'CONFIG_VHOST_KERNEL' in config_host
29b115
+have_vhost_net_user = 'CONFIG_VHOST_NET_USER' in config_host
29b115
+have_vhost_net_vdpa = 'CONFIG_VHOST_NET_VDPA' in config_host
29b115
+have_vhost_net = 'CONFIG_VHOST_NET' in config_host
29b115
+have_vhost_user_crypto = 'CONFIG_VHOST_CRYPTO' in config_host
29b115
+
29b115
 # Target-specific libraries and flags
29b115
 libm = cc.find_library('m', required: false)
29b115
 threads = dependency('threads')
29b115
@@ -1335,7 +1344,7 @@ has_statx_mnt_id = cc.links(statx_mnt_id_test)
29b115
 have_vhost_user_blk_server = get_option('vhost_user_blk_server') \
29b115
   .require(targetos == 'linux',
29b115
            error_message: 'vhost_user_blk_server requires linux') \
29b115
-  .require('CONFIG_VHOST_USER' in config_host,
29b115
+  .require(have_vhost_user,
29b115
            error_message: 'vhost_user_blk_server requires vhost-user support') \
29b115
   .disable_auto_if(not have_system) \
29b115
   .allowed()
29b115
@@ -2116,9 +2125,9 @@ host_kconfig = \
29b115
   (have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \
29b115
   ('CONFIG_OPENGL' in config_host ? ['CONFIG_OPENGL=y'] : []) + \
29b115
   (x11.found() ? ['CONFIG_X11=y'] : []) + \
29b115
-  ('CONFIG_VHOST_USER' in config_host ? ['CONFIG_VHOST_USER=y'] : []) + \
29b115
-  ('CONFIG_VHOST_VDPA' in config_host ? ['CONFIG_VHOST_VDPA=y'] : []) + \
29b115
-  ('CONFIG_VHOST_KERNEL' in config_host ? ['CONFIG_VHOST_KERNEL=y'] : []) + \
29b115
+  (have_vhost_user ? ['CONFIG_VHOST_USER=y'] : []) + \
29b115
+  (have_vhost_vdpa ? ['CONFIG_VHOST_VDPA=y'] : []) + \
29b115
+  (have_vhost_kernel ? ['CONFIG_VHOST_KERNEL=y'] : []) + \
29b115
   (have_virtfs ? ['CONFIG_VIRTFS=y'] : []) + \
29b115
   ('CONFIG_LINUX' in config_host ? ['CONFIG_LINUX=y'] : []) + \
29b115
   ('CONFIG_PVRDMA' in config_host ? ['CONFIG_PVRDMA=y'] : []) + \
29b115
@@ -2799,7 +2808,7 @@ if have_system or have_user
29b115
 endif
29b115
 
29b115
 vhost_user = not_found
29b115
-if targetos == 'linux' and 'CONFIG_VHOST_USER' in config_host
29b115
+if targetos == 'linux' and have_vhost_user
29b115
   libvhost_user = subproject('libvhost-user')
29b115
   vhost_user = libvhost_user.get_variable('vhost_user_dep')
29b115
 endif
29b115
@@ -3386,7 +3395,7 @@ if have_tools
29b115
              dependencies: qemuutil,
29b115
              install: true)
29b115
 
29b115
-  if 'CONFIG_VHOST_USER' in config_host
29b115
+  if have_vhost_user
29b115
     subdir('contrib/vhost-user-blk')
29b115
     subdir('contrib/vhost-user-gpu')
29b115
     subdir('contrib/vhost-user-input')
29b115
@@ -3516,15 +3525,16 @@ if 'simple' in get_option('trace_backends')
29b115
 endif
29b115
 summary_info += {'D-Bus display':     dbus_display}
29b115
 summary_info += {'QOM debugging':     get_option('qom_cast_debug')}
29b115
-summary_info += {'vhost-kernel support': config_host.has_key('CONFIG_VHOST_KERNEL')}
29b115
-summary_info += {'vhost-net support': config_host.has_key('CONFIG_VHOST_NET')}
29b115
-summary_info += {'vhost-crypto support': config_host.has_key('CONFIG_VHOST_CRYPTO')}
29b115
+summary_info += {'vhost-kernel support': have_vhost_kernel}
29b115
+summary_info += {'vhost-net support': have_vhost_net}
29b115
+summary_info += {'vhost-user support': have_vhost_user}
29b115
+summary_info += {'vhost-user-crypto support': have_vhost_user_crypto}
29b115
 summary_info += {'vhost-scsi support': config_host.has_key('CONFIG_VHOST_SCSI')}
29b115
 summary_info += {'vhost-vsock support': config_host.has_key('CONFIG_VHOST_VSOCK')}
29b115
-summary_info += {'vhost-user support': config_host.has_key('CONFIG_VHOST_USER')}
29b115
 summary_info += {'vhost-user-blk server support': have_vhost_user_blk_server}
29b115
 summary_info += {'vhost-user-fs support': config_host.has_key('CONFIG_VHOST_USER_FS')}
29b115
 summary_info += {'vhost-vdpa support': config_host.has_key('CONFIG_VHOST_VDPA')}
29b115
+summary_info += {'vhost-vdpa support': have_vhost_vdpa}
29b115
 summary_info += {'build guest agent': have_ga}
29b115
 summary(summary_info, bool_yn: true, section: 'Configurable features')
29b115
 
29b115
diff --git a/tests/meson.build b/tests/meson.build
29b115
index 1d05109eb4..bbe41c8559 100644
29b115
--- a/tests/meson.build
29b115
+++ b/tests/meson.build
29b115
@@ -70,7 +70,7 @@ test_deps = {
29b115
   'test-qht-par': qht_bench,
29b115
 }
29b115
 
29b115
-if have_tools and 'CONFIG_VHOST_USER' in config_host and 'CONFIG_LINUX' in config_host
29b115
+if have_tools and have_vhost_user and 'CONFIG_LINUX' in config_host
29b115
   executable('vhost-user-bridge',
29b115
              sources: files('vhost-user-bridge.c'),
29b115
              dependencies: [qemuutil, vhost_user])
29b115
diff --git a/tools/meson.build b/tools/meson.build
29b115
index 46977af84f..10eb3a043f 100644
29b115
--- a/tools/meson.build
29b115
+++ b/tools/meson.build
29b115
@@ -3,7 +3,7 @@ have_virtiofsd = get_option('virtiofsd') \
29b115
              error_message: 'virtiofsd requires Linux') \
29b115
     .require(seccomp.found() and libcap_ng.found(),
29b115
              error_message: 'virtiofsd requires libcap-ng-devel and seccomp-devel') \
29b115
-    .require('CONFIG_VHOST_USER' in config_host,
29b115
+    .require(have_vhost_user,
29b115
              error_message: 'virtiofsd needs vhost-user-support') \
29b115
     .disable_auto_if(not have_tools and not have_system) \
29b115
     .allowed()
29b115
-- 
29b115
2.31.1
29b115