qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Zhang Chen <chen.zhang@intel.com>
To: "Jason Wang" <jasowang@redhat.com>,
	qemu-dev <qemu-devel@nongnu.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Eric Blake" <eblake@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>
Cc: Zhang Chen <chen.zhang@intel.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Thomas Huth <thuth@redhat.com>,
	Laurent Vivier <lvivier@redhat.com>,
	Yuri Benditovich <yuri.benditovich@daynix.com>,
	Andrew Melnychenko <andrew@daynix.com>
Subject: [RFC PATCH 02/12] meson: Add ubpf build config and misc
Date: Fri, 17 Jun 2022 15:36:20 +0800	[thread overview]
Message-ID: <20220617073630.535914-3-chen.zhang@intel.com> (raw)
In-Reply-To: <20220617073630.535914-1-chen.zhang@intel.com>

Make meson to build iovisor/ubpf code in Qemu.

Signed-off-by: Zhang Chen <chen.zhang@intel.com>
---
 meson.build                         | 47 +++++++++++++++++++++++++++++
 meson_options.txt                   |  3 ++
 scripts/coverity-scan/COMPONENTS.md |  3 ++
 scripts/meson-buildoptions.sh       |  5 +++
 4 files changed, 58 insertions(+)

diff --git a/meson.build b/meson.build
index 21cd949082..f370c1aba7 100644
--- a/meson.build
+++ b/meson.build
@@ -2717,9 +2717,53 @@ if not fdt.found() and fdt_required.length() > 0
   error('fdt not available but required by targets ' + ', '.join(fdt_required))
 endif
 
+ubpf = not_found
+ubpf_opt = 'disabled'
+if have_system
+  ubpf_opt = get_option('ubpf')
+  if ubpf_opt in ['enabled', 'auto', 'system']
+    have_internal = fs.exists(meson.current_source_dir() / 'ubpf/vm/Makefile')
+    ubpf = dependency('ubpf', kwargs: static_kwargs,
+                      method: 'pkg-config',
+                      required: ubpf_opt == 'system' or
+                      ubpf_opt == 'enabled' and not have_internal)
+    if ubpf.found()
+      ubpf_opt = 'system'
+    elif have_internal
+      ubpf_opt = 'internal'
+    else
+      ubpf_opt = 'disabled'
+    endif
+  endif
+  if ubpf_opt == 'internal'
+    ubpf_data = configuration_data()
+
+    ubpf_files = files(
+      'ubpf/vm/ubpf_jit_x86_64.c',
+      'ubpf/vm/ubpf_vm.c',
+      'ubpf/vm/ubpf_loader.c',
+    )
+
+    ubpf_cargs = [
+      '-Wno-error', '-w',
+      '-include', 'ubpf-defs.h'
+    ]
+
+    configure_file(output: 'ubpf-defs.h', configuration: ubpf_data)
+    ubpf_inc = include_directories('ubpf/vm', 'ubpf/vm/inc')
+    libubpf = static_library('ubpf',
+                             sources: ubpf_files,
+                             c_args: ubpf_cargs,
+                             include_directories: ubpf_inc)
+    ubpf = declare_dependency(link_with: libubpf,
+                              include_directories: ubpf_inc)
+  endif
+endif
+
 config_host_data.set('CONFIG_CAPSTONE', capstone.found())
 config_host_data.set('CONFIG_FDT', fdt.found())
 config_host_data.set('CONFIG_SLIRP', slirp.found())
+config_host_data.set('CONFIG_UBPF', ubpf.found())
 
 #####################
 # Generated sources #
@@ -3046,6 +3090,8 @@ subdir('softmmu')
 common_ss.add(capstone)
 specific_ss.add(files('cpu.c', 'disas.c', 'gdbstub.c'), capstone)
 
+common_ss.add(ubpf)
+
 # Work around a gcc bug/misfeature wherein constant propagation looks
 # through an alias:
 #   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99696
@@ -3911,6 +3957,7 @@ summary_info += {'libudev':           libudev}
 # Dummy dependency, keep .found()
 summary_info += {'FUSE lseek':        fuse_lseek.found()}
 summary_info += {'selinux':           selinux}
+summary_info += {'ubpf support':      ubpf_opt == 'internal' ? ubpf_opt : ubpf}
 summary(summary_info, bool_yn: true, section: 'Dependencies')
 
 if not supported_cpus.contains(cpu)
diff --git a/meson_options.txt b/meson_options.txt
index 2de94af037..1eb9164857 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -262,6 +262,9 @@ option('slirp', type: 'combo', value: 'auto',
 option('fdt', type: 'combo', value: 'auto',
        choices: ['disabled', 'enabled', 'auto', 'system', 'internal'],
        description: 'Whether and how to find the libfdt library')
+option('ubpf', type: 'combo', value: 'auto',
+       choices: ['disabled', 'enabled', 'auto', 'system', 'internal'],
+       description: 'Whether and how to find the ubpf library')
 
 option('selinux', type: 'feature', value: 'auto',
        description: 'SELinux support in qemu-nbd')
diff --git a/scripts/coverity-scan/COMPONENTS.md b/scripts/coverity-scan/COMPONENTS.md
index 183f26a32c..dd28116674 100644
--- a/scripts/coverity-scan/COMPONENTS.md
+++ b/scripts/coverity-scan/COMPONENTS.md
@@ -72,6 +72,9 @@ char
 capstone
   ~ (/qemu)?(/capstone/.*)
 
+ubpf
+  ~ (/qemu)?(/ubpf/vm/.*)
+
 crypto
   ~ (/qemu)?((/include)?/crypto/.*|/hw/.*/crypto.*)
 
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index 00ea4d8cd1..044dde1cff 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -37,6 +37,8 @@ meson_options_help() {
   printf "%s\n" '                           getrandom()'
   printf "%s\n" '  --enable-slirp[=CHOICE]  Whether and how to find the slirp library'
   printf "%s\n" '                           (choices: auto/disabled/enabled/internal/system)'
+  printf "%s\n" '  --enable-ubpf[=CHOICE]   Whether and how to find the ubpf library'
+  printf "%s\n" '                           (choices: auto/disabled/enabled/internal/system)'
   printf "%s\n" '  --enable-strip           Strip targets on install'
   printf "%s\n" '  --enable-tcg-interpreter TCG with bytecode interpreter (slow)'
   printf "%s\n" '  --enable-trace-backends=CHOICES'
@@ -379,6 +381,9 @@ _meson_option_parse() {
     --enable-slirp=*) quote_sh "-Dslirp=$2" ;;
     --enable-slirp-smbd) printf "%s" -Dslirp_smbd=enabled ;;
     --disable-slirp-smbd) printf "%s" -Dslirp_smbd=disabled ;;
+    --enable-ubpf) printf "%s" -Dubpf=enabled ;;
+    --disable-ubpf) printf "%s" -Dubpf=disabled ;;
+    --enable-ubpf=*) quote_sh "-Dubpf=$2" ;;
     --enable-smartcard) printf "%s" -Dsmartcard=enabled ;;
     --disable-smartcard) printf "%s" -Dsmartcard=disabled ;;
     --enable-snappy) printf "%s" -Dsnappy=enabled ;;
-- 
2.25.1



  parent reply	other threads:[~2022-06-17  7:54 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17  7:36 [RFC PATCH 00/12] Introduce QEMU userspace ebpf support Zhang Chen
2022-06-17  7:36 ` [RFC PATCH 01/12] configure: Add iovisor/ubpf project as a submodule for QEMU Zhang Chen
2022-06-17  8:05   ` Daniel P. Berrangé
2022-06-20  5:59     ` Zhang, Chen
2022-06-20  8:11       ` Daniel P. Berrangé
2022-06-20  8:46         ` Thomas Huth
2022-06-20  9:29           ` Zhang, Chen
2022-06-20  9:43             ` Thomas Huth
2022-06-20 10:29               ` Zhang, Chen
2022-06-20 10:37                 ` Daniel P. Berrangé
2022-06-22  9:21                   ` Zhang, Chen
2022-06-20 10:00             ` Daniel P. Berrangé
2022-06-20 10:22               ` Zhang, Chen
2022-06-17  7:36 ` Zhang Chen [this message]
2022-06-17  7:36 ` [RFC PATCH 03/12] ebpf/uBPF: Introduce userspace ebpf data structure Zhang Chen
2022-06-17  7:36 ` [RFC PATCH 04/12] ebpf/uBPF: Introduce ubpf initialize functions Zhang Chen
2022-06-17  7:36 ` [RFC PATCH 05/12] ebpf/uBPF: Add qemu_prepare_ubpf to load ebpf binary Zhang Chen
2022-06-17  7:36 ` [RFC PATCH 06/12] ebpf/uBPF: Add qemu_ubpf_run_once excute real ebpf program Zhang Chen
2022-06-17  7:36 ` [RFC PATCH 07/12] net/filter: Introduce filter-ubpf module Zhang Chen
2022-06-17  7:36 ` [RFC PATCH 08/12] qapi: Add FilterUbpfProperties and qemu-options Zhang Chen
2022-06-20  7:45   ` Markus Armbruster
2022-06-20  9:40     ` Zhang, Chen
2022-06-17  7:36 ` [RFC PATCH 09/12] softmmu/vl.c: Add filter-ubpf for netdev as other netfilters Zhang Chen
2022-06-17  7:36 ` [RFC PATCH 10/12] net/filter-ubpf.c: run the ubpf program to handle network packet Zhang Chen
2022-06-17  7:36 ` [RFC PATCH 11/12] docs/devel: Add userspace-ebpf.rst Zhang Chen
2022-06-17  7:36 ` [RFC PATCH 12/12] test/qtest: Add ubpf basic test case Zhang Chen
2022-06-17  9:34   ` Thomas Huth
2022-06-20  9:31     ` Zhang, Chen
2022-06-20  9:51       ` Thomas Huth
2022-06-29 10:43 ` [RFC PATCH 00/12] Introduce QEMU userspace ebpf support Andrew Melnichenko
2022-07-01  6:14   ` Zhang, Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220617073630.535914-3-chen.zhang@intel.com \
    --to=chen.zhang@intel.com \
    --cc=andrew@daynix.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=jasowang@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    --cc=yuri.benditovich@daynix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).