From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCDBBC433F5 for ; Thu, 7 Oct 2021 20:57:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3BD356121F for ; Thu, 7 Oct 2021 20:57:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3BD356121F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:40152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYaRy-0006uC-E6 for qemu-devel@archiver.kernel.org; Thu, 07 Oct 2021 16:57:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYaDg-0005so-Mw for qemu-devel@nongnu.org; Thu, 07 Oct 2021 16:42:24 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:35766) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mYaDa-0006De-AQ for qemu-devel@nongnu.org; Thu, 07 Oct 2021 16:42:23 -0400 Received: by mail-wr1-x42a.google.com with SMTP id v25so22813856wra.2 for ; Thu, 07 Oct 2021 13:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3GtPQVYcQZHGNLfsgJ3bCr4rjeI68iTGsX5LONJQOf8=; b=nHxnAGVyGCieDrPJQzwCvr6ta00wrolIMJKNSRJbOOJOSAD01BrYJy8W0T5RxEGD0G ya6exdjAOdec2rZwld9Tqyicq3vwbVfECU5liPbjESLDCDslt1SMLeOj8+xg+ouPjD57 mvLE7n42152Dj5FcvSNPomMxX38cMGWaWMLzEOE4mjPY8meOfLXsd2R4kDc+th0hobTP +aAB4B9Nvtq3yy2qqvouyK1Lx1YDGVIMS9HXzIt8xQ/SI9ogOoVQ9OeAExaBwYM2/5UG g0sF98swABCn1dCbDJrN3xPRVeo1OQONHbHPEbiH/ZD0dkopvX0P45GdXb4B44j1RM0f lOkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3GtPQVYcQZHGNLfsgJ3bCr4rjeI68iTGsX5LONJQOf8=; b=64d6/D54IquJmESvBkQYgTnpyiZyIV1O3RCq5N1tm0AcG4ARBrVSnLWzZvsaHKdfI6 TRb1OGzE7XAS6iInuWtSsQVDoolVtIqrNSehiKWGKQ7QQLQMTaVIAP7ae3AzVwvvsqPI /bX8+gMRzg8MqIZ/w6JqIeRl/ZNJqlEr6PgV0RoR3cI6vOoWAde/tsP1bN3VYerFkUgh 0u9XvBRM67S7xqHrEKLCTdGgUmF4FlCMSmONTMnYNacfpGJ7XkPLAP/IWGxW0UP9yhN6 UwtDE7VUyXWrik1AkfqO+3XZKI72l1YUNByDqTNdJdmuOX1DEEY4Ph9Zv3vSdUYqRVNs 1NAA== X-Gm-Message-State: AOAM5304QauvMD/1wdpTibXqIKJGxNn65ombVYMgXV2h3SLEzZ9EFgt0 5ZZT43Jp0gsycQWGzLS84tCC0MAePBTB4/KuI1AiAArz X-Google-Smtp-Source: ABdhPJyi5YNqVCQh8jKljeRAlqIaCLjlTzYeIOYGA1anWYs35TJ2wDDOn6JW7nSnQXH0H0PO8fR6pREeBYxp/YOmAtc= X-Received: by 2002:a1c:a5cd:: with SMTP id o196mr7233146wme.96.1633639335900; Thu, 07 Oct 2021 13:42:15 -0700 (PDT) MIME-Version: 1.0 References: <20211007130630.632028-1-pbonzini@redhat.com> <20211007130829.632254-4-pbonzini@redhat.com> In-Reply-To: <20211007130829.632254-4-pbonzini@redhat.com> From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Date: Fri, 8 Oct 2021 00:41:59 +0400 Message-ID: Subject: Re: [PATCH 09/24] trace: move configuration from configure to Meson To: Paolo Bonzini Content-Type: multipart/alternative; boundary="0000000000004eb92f05cdc94cd2" Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=marcandre.lureau@gmail.com; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: QEMU , Stefan Hajnoczi Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --0000000000004eb92f05cdc94cd2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Oct 7, 2021 at 5:17 PM Paolo Bonzini wrote: > Cc: Stefan Hajnoczi > Signed-off-by: Paolo Bonzini > lgtm Reviewed-by: Marc-Andr=C3=A9 Lureau > --- > configure | 91 +-------------------------------------------- > docs/meson.build | 2 +- > meson.build | 51 +++++++++++++++++++++---- > meson_options.txt | 6 +++ > scripts/meson.build | 2 +- > trace/meson.build | 15 +++++--- > 6 files changed, 61 insertions(+), 106 deletions(-) > > diff --git a/configure b/configure > index 98723db0cd..4bfc5e350d 100755 > --- a/configure > +++ b/configure > @@ -216,10 +216,6 @@ version_ge () { > done > } > > -have_backend () { > - echo "$trace_backends" | grep "$1" >/dev/null > -} > - > glob() { > eval test -z '"${1#'"$2"'}"' > } > @@ -3512,56 +3508,6 @@ case "$capstone" in > ;; > esac > > -########################################## > -# check if we have posix_syslog > - > -posix_syslog=3Dno > -cat > $TMPC << EOF > -#include > -int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, > "configure"); return 0; } > -EOF > -if compile_prog "" "" ; then > - posix_syslog=3Dyes > -fi > - > -########################################## > -# check if trace backend exists > - > -$python "$source_path/scripts/tracetool.py" "--backends=3D$trace_backend= s" > --check-backends > /dev/null 2> /dev/null > -if test "$?" -ne 0 ; then > - error_exit "invalid trace backends" \ > - "Please choose supported trace backends." > -fi > - > -########################################## > -# For 'ust' backend, test if ust headers are present > -if have_backend "ust"; then > - if $pkg_config lttng-ust --exists; then > - lttng_ust_libs=3D$($pkg_config --libs lttng-ust) > - else > - error_exit "Trace backend 'ust' missing lttng-ust header files" > - fi > -fi > - > -########################################## > -# For 'dtrace' backend, test if 'dtrace' command is present > -if have_backend "dtrace"; then > - if ! has 'dtrace' ; then > - error_exit "dtrace command is not found in PATH $PATH" > - fi > - trace_backend_stap=3D"no" > - if has 'stap' ; then > - trace_backend_stap=3D"yes" > - > - # Workaround to avoid dtrace(1) producing a file with 'hidden' symbo= l > - # visibility. Define STAP_SDT_V2 to produce 'default' symbol > visibility > - # instead. QEMU --enable-modules depends on this because the SystemT= ap > - # semaphores are linked into the main binary and not the module's > shared > - # object. > - QEMU_CFLAGS=3D"$QEMU_CFLAGS -DSTAP_SDT_V2" > - fi > -fi > - > ########################################## > # check and set a backend for coroutine > > @@ -4572,42 +4518,6 @@ if test "$tpm" =3D "yes"; then > echo 'CONFIG_TPM=3Dy' >> $config_host_mak > fi > > -echo "TRACE_BACKENDS=3D$trace_backends" >> $config_host_mak > -if have_backend "nop"; then > - echo "CONFIG_TRACE_NOP=3Dy" >> $config_host_mak > -fi > -if have_backend "simple"; then > - echo "CONFIG_TRACE_SIMPLE=3Dy" >> $config_host_mak > -fi > -if have_backend "log"; then > - echo "CONFIG_TRACE_LOG=3Dy" >> $config_host_mak > -fi > -if have_backend "ust"; then > - echo "CONFIG_TRACE_UST=3Dy" >> $config_host_mak > - echo "LTTNG_UST_LIBS=3D$lttng_ust_libs" >> $config_host_mak > -fi > -if have_backend "dtrace"; then > - echo "CONFIG_TRACE_DTRACE=3Dy" >> $config_host_mak > - if test "$trace_backend_stap" =3D "yes" ; then > - echo "CONFIG_TRACE_SYSTEMTAP=3Dy" >> $config_host_mak > - fi > -fi > -if have_backend "ftrace"; then > - if test "$linux" =3D "yes" ; then > - echo "CONFIG_TRACE_FTRACE=3Dy" >> $config_host_mak > - else > - feature_not_found "ftrace(trace backend)" "ftrace requires Linux" > - fi > -fi > -if have_backend "syslog"; then > - if test "$posix_syslog" =3D "yes" ; then > - echo "CONFIG_TRACE_SYSLOG=3Dy" >> $config_host_mak > - else > - feature_not_found "syslog(trace backend)" "syslog not available" > - fi > -fi > -echo "CONFIG_TRACE_FILE=3D$trace_file" >> $config_host_mak > - > if test "$rdma" =3D "yes" ; then > echo "CONFIG_RDMA=3Dy" >> $config_host_mak > echo "RDMA_LIBS=3D$rdma_libs" >> $config_host_mak > @@ -4990,6 +4900,7 @@ if test "$skip_meson" =3D no; then > $(if test "$default_feature" =3D no; then echo > "-Dauto_features=3Ddisabled"; fi) \ > -Dalsa=3D$alsa -Dcoreaudio=3D$coreaudio -Ddsound=3D$dsound -Djac= k=3D$jack > -Doss=3D$oss \ > -Dpa=3D$pa -Daudio_drv_list=3D$audio_drv_list > -Dtcg_interpreter=3D$tcg_interpreter \ > + -Dtrace_backends=3D$trace_backends -Dtrace_file=3D$trace_file \ > $cross_arg \ > "$PWD" "$source_path" > > diff --git a/docs/meson.build b/docs/meson.build > index be4dc30f39..19cce670a2 100644 > --- a/docs/meson.build > +++ b/docs/meson.build > @@ -57,7 +57,7 @@ if build_docs > 'qemu-nbd.8': (have_tools ? 'man8' : ''), > 'qemu-pr-helper.8': (have_tools ? 'man8' : ''), > 'qemu-storage-daemon.1': (have_tools ? 'man1' : ''), > - 'qemu-trace-stap.1': > (config_host.has_key('CONFIG_TRACE_SYSTEMTAP') ? 'man1' : ''), > + 'qemu-trace-stap.1': (stap.found() ? 'man1' : ''), > 'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''= ), > 'virtiofsd.1': (have_virtiofsd ? 'man1' : ''), > 'qemu.1': 'man1', > diff --git a/meson.build b/meson.build > index 8752b757cc..98fa4b68d9 100644 > --- a/meson.build > +++ b/meson.build > @@ -111,6 +111,22 @@ foreach target : edk2_targets > endif > endforeach > > +dtrace =3D not_found > +stap =3D not_found > +if 'dtrace' in get_option('trace_backends') > + dtrace =3D find_program('dtrace', required: true) > + stap =3D find_program('stap', required: false) > + if stap.found() > + # Workaround to avoid dtrace(1) producing a file with 'hidden' symbo= l > + # visibility. Define STAP_SDT_V2 to produce 'default' symbol > visibility > + # instead. QEMU --enable-modules depends on this because the SystemT= ap > + # semaphores are linked into the main binary and not the module's > shared > + # object. > + add_global_arguments('-DSTAP_SDT_V2', > + native: false, language: ['c', 'cpp', 'objc']) > + endif > +endif > + > ################## > # Compiler flags # > ################## > @@ -201,6 +217,19 @@ if get_option('fuzzing') and > get_option('fuzzing_engine') =3D=3D '' and \ > error('Your compiler does not support -fsanitize=3Dfuzzer') > endif > > +if 'ftrace' in get_option('trace_backends') and targetos !=3D 'linux' > + error('ftrace is supported only on Linux') > +endif > +if 'syslog' in get_option('trace_backends') and not cc.compiles(''' > + #include > + int main(void) { > + openlog("qemu", LOG_PID, LOG_DAEMON); > + syslog(LOG_INFO, "configure"); > + return 0; > + }''') > + error('syslog is not supported on this system') > +endif > + > if targetos !=3D 'linux' and get_option('mpath').enabled() > error('Multipath is supported only on Linux') > endif > @@ -361,8 +390,9 @@ if 'CONFIG_GIO' in config_host > link_args: config_host['GIO_LIBS'].split()) > endif > lttng =3D not_found > -if 'CONFIG_TRACE_UST' in config_host > - lttng =3D declare_dependency(link_args: > config_host['LTTNG_UST_LIBS'].split()) > +if 'ust' in get_option('trace_backends') > + lttng =3D dependency('lttng-ust', required: true, method: 'pkg-config'= , > + kwargs: static_kwargs) > endif > pixman =3D not_found > if have_system or have_tools > @@ -1349,6 +1379,11 @@ elif get_option('virtfs').disabled() > have_virtfs =3D false > endif > > +foreach k : get_option('trace_backends') > + config_host_data.set('CONFIG_TRACE_' + k.to_upper(), true) > +endforeach > +config_host_data.set_quoted('CONFIG_TRACE_FILE', get_option('trace_file'= )) > + > config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / > get_option('bindir')) > config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix')) > config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') = / > qemu_confdir) > @@ -1574,7 +1609,7 @@ config_host_data.set('HAVE_BROKEN_SIZE_MAX', not > cc.compiles(''' > > ignored =3D ['CONFIG_QEMU_INTERP_PREFIX'] # actually per-target > arrays =3D ['CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST'] > -strings =3D ['HOST_DSOSUF', 'CONFIG_IASL', 'CONFIG_TRACE_FILE'] > +strings =3D ['HOST_DSOSUF', 'CONFIG_IASL'] > foreach k, v: config_host > if ignored.contains(k) > # do nothing > @@ -2112,7 +2147,7 @@ qapi_gen_depends =3D [ meson.current_source_dir() / > 'scripts/qapi/__init__.py', > > tracetool =3D [ > python, files('scripts/tracetool.py'), > - '--backend=3D' + config_host['TRACE_BACKENDS'] > + '--backend=3D' + ','.join(get_option('trace_backends')) > ] > tracetool_depends =3D files( > 'scripts/tracetool/backend/log.py', > @@ -2831,7 +2866,7 @@ foreach target : target_dirs > emulators +=3D {exe['name']: emulator} > endif > > - if 'CONFIG_TRACE_SYSTEMTAP' in config_host > + if stap.found() > foreach stp: [ > {'ext': '.stp-build', 'fmt': 'stap', 'bin': > meson.current_build_dir() / exe['name'], 'install': false}, > {'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / > get_option('bindir') / exe['name'], 'install': true}, > @@ -3012,9 +3047,9 @@ summary_info +=3D {'fuzzing support': > get_option('fuzzing')} > if have_system > summary_info +=3D {'Audio drivers': ' '.join(audio_drivers_selecte= d)} > endif > -summary_info +=3D {'Trace backends': config_host['TRACE_BACKENDS']} > -if config_host['TRACE_BACKENDS'].split().contains('simple') > - summary_info +=3D {'Trace output file': config_host['CONFIG_TRACE_FILE= '] > + '-'} > +summary_info +=3D {'Trace backends': > ','.join(get_option('trace_backends'))} > +if 'simple' in get_option('trace_backends') > + summary_info +=3D {'Trace output file': get_option('trace_file') + > '-'} > endif > summary_info +=3D {'QOM debugging': > config_host.has_key('CONFIG_QOM_CAST_DEBUG')} > summary_info +=3D {'vhost-kernel support': > config_host.has_key('CONFIG_VHOST_KERNEL')} > diff --git a/meson_options.txt b/meson_options.txt > index 100c30e967..8f9c3b5b17 100644 > --- a/meson_options.txt > +++ b/meson_options.txt > @@ -13,6 +13,8 @@ option('audio_drv_list', type: 'array', value: > ['default'], > description: 'Set audio driver list') > option('fuzzing_engine', type : 'string', value : '', > description: 'fuzzing engine library for OSS-Fuzz') > +option('trace_file', type: 'string', value: 'trace', > + description: 'Trace file prefix for simple backend') > > option('docs', type : 'feature', value : 'auto', > description: 'Documentations build support') > @@ -146,6 +148,10 @@ option('fuse', type: 'feature', value: 'auto', > option('fuse_lseek', type : 'feature', value : 'auto', > description: 'SEEK_HOLE/SEEK_DATA support for FUSE exports') > > +option('trace_backends', type: 'array', value: ['log'], > + choices: ['dtrace', 'ftrace', 'log', 'nop', 'simple', 'syslog', > 'ust'], > + description: 'Set available tracing backends') > + > option('alsa', type: 'feature', value: 'auto', > description: 'ALSA sound support') > option('coreaudio', type: 'feature', value: 'auto', > diff --git a/scripts/meson.build b/scripts/meson.build > index e8cc63896d..1c89e10a76 100644 > --- a/scripts/meson.build > +++ b/scripts/meson.build > @@ -1,3 +1,3 @@ > -if 'CONFIG_TRACE_SYSTEMTAP' in config_host > +if stap.found() > install_data('qemu-trace-stap', install_dir: get_option('bindir')) > endif > diff --git a/trace/meson.build b/trace/meson.build > index b8f95de200..573dd699c6 100644 > --- a/trace/meson.build > +++ b/trace/meson.build > @@ -2,7 +2,6 @@ > specific_ss.add(files('control-target.c')) > > trace_events_files =3D [] > -dtrace =3D find_program('dtrace', required: 'CONFIG_TRACE_DTRACE' in > config_host) > foreach dir : [ '.' ] + trace_events_subdirs > trace_events_file =3D meson.project_source_root() / dir / 'trace-event= s' > trace_events_files +=3D [ trace_events_file ] > @@ -21,7 +20,7 @@ foreach dir : [ '.' ] + trace_events_subdirs > input: trace_events_file, > command: [ tracetool, group, '--format=3Dc', > '@INPUT@', '@OUTPUT@' ], > depend_files: tracetool_depends) > - if 'CONFIG_TRACE_UST' in config_host > + if 'ust' in get_option('trace_backends') > trace_ust_h =3D custom_target(fmt.format('trace-ust', 'h'), > output: fmt.format('trace-ust', 'h'), > input: trace_events_file, > @@ -31,7 +30,7 @@ foreach dir : [ '.' ] + trace_events_subdirs > genh +=3D trace_ust_h > endif > trace_ss.add(trace_h, trace_c) > - if 'CONFIG_TRACE_DTRACE' in config_host > + if 'dtrace' in get_option('trace_backends') > trace_dtrace =3D custom_target(fmt.format('trace-dtrace', 'dtrace'), > output: fmt.format('trace-dtrace', > 'dtrace'), > input: trace_events_file, > @@ -76,7 +75,7 @@ foreach d : [ > specific_ss.add(when: 'CONFIG_TCG', if_true: gen) > endforeach > > -if 'CONFIG_TRACE_UST' in config_host > +if 'ust' in get_option('trace_backends') > trace_ust_all_h =3D custom_target('trace-ust-all.h', > output: 'trace-ust-all.h', > input: trace_events_files, > @@ -91,7 +90,11 @@ if 'CONFIG_TRACE_UST' in config_host > genh +=3D trace_ust_all_h > endif > > -trace_ss.add(when: 'CONFIG_TRACE_SIMPLE', if_true: files('simple.c')) > -trace_ss.add(when: 'CONFIG_TRACE_FTRACE', if_true: files('ftrace.c')) > +if 'simple' in get_option('trace_backends') > + trace_ss.add(files('simple.c')) > +endif > +if 'ftrace' in get_option('trace_backends') > + trace_ss.add(files('ftrace.c')) > +endif > trace_ss.add(files('control.c')) > trace_ss.add(files('qmp.c')) > -- > 2.31.1 > > > > --=20 Marc-Andr=C3=A9 Lureau --0000000000004eb92f05cdc94cd2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Thu, Oct 7, 2021 at 5:17 PM Paolo = Bonzini <pbonzi= ni@redhat.com> wrote:
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

<= div>
lgtm
Reviewed-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@= redhat.com>

=C2=A0
---
=C2=A0configure=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 91 +-------------= -------------------------------
=C2=A0docs/meson.build=C2=A0 =C2=A0 |=C2=A0 2 +-
=C2=A0meson.build=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 51 +++++++++++++++++++= ++----
=C2=A0meson_options.txt=C2=A0 =C2=A0|=C2=A0 6 +++
=C2=A0scripts/meson.build |=C2=A0 2 +-
=C2=A0trace/meson.build=C2=A0 =C2=A0| 15 +++++---
=C2=A06 files changed, 61 insertions(+), 106 deletions(-)

diff --git a/configure b/configure
index 98723db0cd..4bfc5e350d 100755
--- a/configure
+++ b/configure
@@ -216,10 +216,6 @@ version_ge () {
=C2=A0 =C2=A0 =C2=A0done
=C2=A0}

-have_backend () {
-=C2=A0 =C2=A0 echo "$trace_backends" | grep "$1" >/= dev/null
-}
-
=C2=A0glob() {
=C2=A0 =C2=A0 =C2=A0eval test -z '"${1#'"$2"'}&q= uot;'
=C2=A0}
@@ -3512,56 +3508,6 @@ case "$capstone" in
=C2=A0 =C2=A0 =C2=A0;;
=C2=A0esac

-##########################################
-# check if we have posix_syslog
-
-posix_syslog=3Dno
-cat > $TMPC << EOF
-#include <syslog.h>
-int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LO= G_INFO, "configure"); return 0; }
-EOF
-if compile_prog "" "" ; then
-=C2=A0 =C2=A0 posix_syslog=3Dyes
-fi
-
-##########################################
-# check if trace backend exists
-
-$python "$source_path/scripts/tracetool.py" "--backends=3D$= trace_backends" --check-backends=C2=A0 > /dev/null 2> /dev/null<= br> -if test "$?" -ne 0 ; then
-=C2=A0 error_exit "invalid trace backends" \
-=C2=A0 =C2=A0 =C2=A0 "Please choose supported trace backends." -fi
-
-##########################################
-# For 'ust' backend, test if ust headers are present
-if have_backend "ust"; then
-=C2=A0 if $pkg_config lttng-ust --exists; then
-=C2=A0 =C2=A0 lttng_ust_libs=3D$($pkg_config --libs lttng-ust)
-=C2=A0 else
-=C2=A0 =C2=A0 error_exit "Trace backend 'ust' missing lttng-u= st header files"
-=C2=A0 fi
-fi
-
-##########################################
-# For 'dtrace' backend, test if 'dtrace' command is presen= t
-if have_backend "dtrace"; then
-=C2=A0 if ! has 'dtrace' ; then
-=C2=A0 =C2=A0 error_exit "dtrace command is not found in PATH $PATH&q= uot;
-=C2=A0 fi
-=C2=A0 trace_backend_stap=3D"no"
-=C2=A0 if has 'stap' ; then
-=C2=A0 =C2=A0 trace_backend_stap=3D"yes"
-
-=C2=A0 =C2=A0 # Workaround to avoid dtrace(1) producing a file with 'h= idden' symbol
-=C2=A0 =C2=A0 # visibility. Define STAP_SDT_V2 to produce 'default'= ; symbol visibility
-=C2=A0 =C2=A0 # instead. QEMU --enable-modules depends on this because the= SystemTap
-=C2=A0 =C2=A0 # semaphores are linked into the main binary and not the mod= ule's shared
-=C2=A0 =C2=A0 # object.
-=C2=A0 =C2=A0 QEMU_CFLAGS=3D"$QEMU_CFLAGS -DSTAP_SDT_V2"
-=C2=A0 fi
-fi
-
=C2=A0##########################################
=C2=A0# check and set a backend for coroutine

@@ -4572,42 +4518,6 @@ if test "$tpm" =3D "yes"; then =C2=A0 =C2=A0echo 'CONFIG_TPM=3Dy' >> $config_host_mak
=C2=A0fi

-echo "TRACE_BACKENDS=3D$trace_backends" >> $config_host_ma= k
-if have_backend "nop"; then
-=C2=A0 echo "CONFIG_TRACE_NOP=3Dy" >> $config_host_mak
-fi
-if have_backend "simple"; then
-=C2=A0 echo "CONFIG_TRACE_SIMPLE=3Dy" >> $config_host_mak<= br> -fi
-if have_backend "log"; then
-=C2=A0 echo "CONFIG_TRACE_LOG=3Dy" >> $config_host_mak
-fi
-if have_backend "ust"; then
-=C2=A0 echo "CONFIG_TRACE_UST=3Dy" >> $config_host_mak
-=C2=A0 echo "LTTNG_UST_LIBS=3D$lttng_ust_libs" >> $config_= host_mak
-fi
-if have_backend "dtrace"; then
-=C2=A0 echo "CONFIG_TRACE_DTRACE=3Dy" >> $config_host_mak<= br> -=C2=A0 if test "$trace_backend_stap" =3D "yes" ; then<= br> -=C2=A0 =C2=A0 echo "CONFIG_TRACE_SYSTEMTAP=3Dy" >> $config= _host_mak
-=C2=A0 fi
-fi
-if have_backend "ftrace"; then
-=C2=A0 if test "$linux" =3D "yes" ; then
-=C2=A0 =C2=A0 echo "CONFIG_TRACE_FTRACE=3Dy" >> $config_ho= st_mak
-=C2=A0 else
-=C2=A0 =C2=A0 feature_not_found "ftrace(trace backend)" "ft= race requires Linux"
-=C2=A0 fi
-fi
-if have_backend "syslog"; then
-=C2=A0 if test "$posix_syslog" =3D "yes" ; then
-=C2=A0 =C2=A0 echo "CONFIG_TRACE_SYSLOG=3Dy" >> $config_ho= st_mak
-=C2=A0 else
-=C2=A0 =C2=A0 feature_not_found "syslog(trace backend)" "sy= slog not available"
-=C2=A0 fi
-fi
-echo "CONFIG_TRACE_FILE=3D$trace_file" >> $config_host_mak=
-
=C2=A0if test "$rdma" =3D "yes" ; then
=C2=A0 =C2=A0echo "CONFIG_RDMA=3Dy" >> $config_host_mak
=C2=A0 =C2=A0echo "RDMA_LIBS=3D$rdma_libs" >> $config_host_= mak
@@ -4990,6 +4900,7 @@ if test "$skip_meson" =3D no; then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$(if test "$default_feature" = =3D no; then echo "-Dauto_features=3Ddisabled"; fi) \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-Dalsa=3D$alsa -Dcoreaudio=3D$coreaudio -= Ddsound=3D$dsound -Djack=3D$jack -Doss=3D$oss \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-Dpa=3D$pa -Daudio_drv_list=3D$audio_drv_= list -Dtcg_interpreter=3D$tcg_interpreter \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 -Dtrace_backends=3D$trace_backends -Dtrace_fil= e=3D$trace_file \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$cross_arg \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"$PWD" "$source_path"=

diff --git a/docs/meson.build b/docs/meson.build
index be4dc30f39..19cce670a2 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -57,7 +57,7 @@ if build_docs
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'qemu-nbd.8': (have_tools ? '= man8' : ''),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'qemu-pr-helper.8': (have_tools ?= 'man8' : ''),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'qemu-storage-daemon.1': (have_to= ols ? 'man1' : ''),
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 'qemu-trace-stap.1': (config_host.has_= key('CONFIG_TRACE_SYSTEMTAP') ? 'man1' : ''),
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 'qemu-trace-stap.1': (stap.found() ? &= #39;man1' : ''),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'virtfs-proxy-helper.1': (have_vi= rtfs_proxy_helper ? 'man1' : ''),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'virtiofsd.1': (have_virtiofsd ? = 'man1' : ''),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'qemu.1': 'man1',
diff --git a/meson.build b/meson.build
index 8752b757cc..98fa4b68d9 100644
--- a/meson.build
+++ b/meson.build
@@ -111,6 +111,22 @@ foreach target : edk2_targets
=C2=A0 =C2=A0endif
=C2=A0endforeach

+dtrace =3D not_found
+stap =3D not_found
+if 'dtrace' in get_option('trace_backends')
+=C2=A0 dtrace =3D find_program('dtrace', required: true)
+=C2=A0 stap =3D find_program('stap', required: false)
+=C2=A0 if stap.found()
+=C2=A0 =C2=A0 # Workaround to avoid dtrace(1) producing a file with 'h= idden' symbol
+=C2=A0 =C2=A0 # visibility. Define STAP_SDT_V2 to produce 'default'= ; symbol visibility
+=C2=A0 =C2=A0 # instead. QEMU --enable-modules depends on this because the= SystemTap
+=C2=A0 =C2=A0 # semaphores are linked into the main binary and not the mod= ule's shared
+=C2=A0 =C2=A0 # object.
+=C2=A0 =C2=A0 add_global_arguments('-DSTAP_SDT_V2',
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0native: false, language: ['c', 'cpp', '= ;objc'])
+=C2=A0 endif
+endif
+
=C2=A0##################
=C2=A0# Compiler flags #
=C2=A0##################
@@ -201,6 +217,19 @@ if get_option('fuzzing') and get_option('f= uzzing_engine') =3D=3D '' and \
=C2=A0 =C2=A0error('Your compiler does not support -fsanitize=3Dfuzzer&= #39;)
=C2=A0endif

+if 'ftrace' in get_option('trace_backends') and targetos != =3D 'linux'
+=C2=A0 error('ftrace is supported only on Linux')
+endif
+if 'syslog' in get_option('trace_backends') and not cc.com= piles('''
+=C2=A0 =C2=A0 #include <syslog.h>
+=C2=A0 =C2=A0 int main(void) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 openlog("qemu", LOG_PID, LOG_DAEMON)= ;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 syslog(LOG_INFO, "configure");
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;
+=C2=A0 =C2=A0 }''')
+=C2=A0 error('syslog is not supported on this system')
+endif
+
=C2=A0if targetos !=3D 'linux' and get_option('mpath').enab= led()
=C2=A0 =C2=A0error('Multipath is supported only on Linux')
=C2=A0endif
@@ -361,8 +390,9 @@ if 'CONFIG_GIO' in config_host
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 link_args: config_host['GIO_LIBS'].split()= )
=C2=A0endif
=C2=A0lttng =3D not_found
-if 'CONFIG_TRACE_UST' in config_host
-=C2=A0 lttng =3D declare_dependency(link_args: config_host['LTTNG_UST_= LIBS'].split())
+if 'ust' in get_option('trace_backends')
+=C2=A0 lttng =3D dependency('lttng-ust', required: true, method: &= #39;pkg-config',
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0kwargs: static_kwargs)
=C2=A0endif
=C2=A0pixman =3D not_found
=C2=A0if have_system or have_tools
@@ -1349,6 +1379,11 @@ elif get_option('virtfs').disabled()
=C2=A0 =C2=A0have_virtfs =3D false
=C2=A0endif

+foreach k : get_option('trace_backends')
+=C2=A0 config_host_data.set('CONFIG_TRACE_' + k.to_upper(), true)<= br> +endforeach
+config_host_data.set_quoted('CONFIG_TRACE_FILE', get_option('t= race_file'))
+
=C2=A0config_host_data.set_quoted('CONFIG_BINDIR', get_option('= prefix') / get_option('bindir'))
=C2=A0config_host_data.set_quoted('CONFIG_PREFIX', get_option('= prefix'))
=C2=A0config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option= ('prefix') / qemu_confdir)
@@ -1574,7 +1609,7 @@ config_host_data.set('HAVE_BROKEN_SIZE_MAX', = not cc.compiles('''

=C2=A0ignored =3D ['CONFIG_QEMU_INTERP_PREFIX'] # actually per-targ= et
=C2=A0arrays =3D ['CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_W= HITELIST']
-strings =3D ['HOST_DSOSUF', 'CONFIG_IASL', 'CONFIG_TRA= CE_FILE']
+strings =3D ['HOST_DSOSUF', 'CONFIG_IASL']
=C2=A0foreach k, v: config_host
=C2=A0 =C2=A0if ignored.contains(k)
=C2=A0 =C2=A0 =C2=A0# do nothing
@@ -2112,7 +2147,7 @@ qapi_gen_depends =3D [ meson.current_source_dir() / &= #39;scripts/qapi/__init__.py',

=C2=A0tracetool =3D [
=C2=A0 =C2=A0python, files('scripts/tracetool.py'),
-=C2=A0 =C2=A0'--backend=3D' + config_host['TRACE_BACKENDS'= ]
+=C2=A0 =C2=A0'--backend=3D' + ','.join(get_option('tra= ce_backends'))
=C2=A0]
=C2=A0tracetool_depends =3D files(
=C2=A0 =C2=A0'scripts/tracetool/backend/log.py',
@@ -2831,7 +2866,7 @@ foreach target : target_dirs
=C2=A0 =C2=A0 =C2=A0 =C2=A0emulators +=3D {exe['name']: emulator} =C2=A0 =C2=A0 =C2=A0endif

-=C2=A0 =C2=A0 if 'CONFIG_TRACE_SYSTEMTAP' in config_host
+=C2=A0 =C2=A0 if stap.found()
=C2=A0 =C2=A0 =C2=A0 =C2=A0foreach stp: [
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'ext': '.stp-build', = 9;fmt': 'stap', 'bin': meson.current_build_dir() / exe[= 'name'], 'install': false},
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'ext': '.stp', 'fmt&= #39;: 'stap', 'bin': get_option('prefix') / get_opt= ion('bindir') / exe['name'], 'install': true},
@@ -3012,9 +3047,9 @@ summary_info +=3D {'fuzzing support':=C2=A0 = =C2=A0get_option('fuzzing')}
=C2=A0if have_system
=C2=A0 =C2=A0summary_info +=3D {'Audio drivers':=C2=A0 =C2=A0 =C2= =A0' '.join(audio_drivers_selected)}
=C2=A0endif
-summary_info +=3D {'Trace backends':=C2=A0 =C2=A0 config_host['= ;TRACE_BACKENDS']}
-if config_host['TRACE_BACKENDS'].split().contains('simple'= )
-=C2=A0 summary_info +=3D {'Trace output file': config_host['CO= NFIG_TRACE_FILE'] + '-<pid>'}
+summary_info +=3D {'Trace backends':=C2=A0 =C2=A0 ','.join= (get_option('trace_backends'))}
+if 'simple' in get_option('trace_backends')
+=C2=A0 summary_info +=3D {'Trace output file': get_option('tra= ce_file') + '-<pid>'}
=C2=A0endif
=C2=A0summary_info +=3D {'QOM debugging':=C2=A0 =C2=A0 =C2=A0config= _host.has_key('CONFIG_QOM_CAST_DEBUG')}
=C2=A0summary_info +=3D {'vhost-kernel support': config_host.has_ke= y('CONFIG_VHOST_KERNEL')}
diff --git a/meson_options.txt b/meson_options.txt
index 100c30e967..8f9c3b5b17 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -13,6 +13,8 @@ option('audio_drv_list', type: 'array', v= alue: ['default'],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 description: 'Set audio driver list') =C2=A0option('fuzzing_engine', type : 'string', value : = 9;',
=C2=A0 =C2=A0 =C2=A0 =C2=A0 description: 'fuzzing engine library for OS= S-Fuzz')
+option('trace_file', type: 'string', value: 'trace'= ;,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0description: 'Trace file prefix for simple = backend')

=C2=A0option('docs', type : 'feature', value : 'auto= 9;,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 description: 'Documentations build support&= #39;)
@@ -146,6 +148,10 @@ option('fuse', type: 'feature', value:= 'auto',
=C2=A0option('fuse_lseek', type : 'feature', value : 'a= uto',
=C2=A0 =C2=A0 =C2=A0 =C2=A0 description: 'SEEK_HOLE/SEEK_DATA support f= or FUSE exports')

+option('trace_backends', type: 'array', value: ['log&#= 39;],
+=C2=A0 =C2=A0 =C2=A0 =C2=A0choices: ['dtrace', 'ftrace', &= #39;log', 'nop', 'simple', 'syslog', 'ust&#= 39;],
+=C2=A0 =C2=A0 =C2=A0 =C2=A0description: 'Set available tracing backend= s')
+
=C2=A0option('alsa', type: 'feature', value: 'auto'= ,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 description: 'ALSA sound support')
=C2=A0option('coreaudio', type: 'feature', value: 'auto= ',
diff --git a/scripts/meson.build b/scripts/meson.build
index e8cc63896d..1c89e10a76 100644
--- a/scripts/meson.build
+++ b/scripts/meson.build
@@ -1,3 +1,3 @@
-if 'CONFIG_TRACE_SYSTEMTAP' in config_host
+if stap.found()
=C2=A0 =C2=A0install_data('qemu-trace-stap', install_dir: get_optio= n('bindir'))
=C2=A0endif
diff --git a/trace/meson.build b/trace/meson.build
index b8f95de200..573dd699c6 100644
--- a/trace/meson.build
+++ b/trace/meson.build
@@ -2,7 +2,6 @@
=C2=A0specific_ss.add(files('control-target.c'))

=C2=A0trace_events_files =3D []
-dtrace =3D find_program('dtrace', required: 'CONFIG_TRACE_DTRA= CE' in config_host)
=C2=A0foreach dir : [ '.' ] + trace_events_subdirs
=C2=A0 =C2=A0trace_events_file =3D meson.project_source_root() / dir / '= ;trace-events'
=C2=A0 =C2=A0trace_events_files +=3D [ trace_events_file ]
@@ -21,7 +20,7 @@ foreach dir : [ '.' ] + trace_events_subdirs
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0input: trace_events_file,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0command: [ tracetool, group, '--format=3Dc'= , '@INPUT@', '@OUTPUT@' ],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0depend_files: tracetool_depends)
-=C2=A0 if 'CONFIG_TRACE_UST' in config_host
+=C2=A0 if 'ust' in get_option('trace_backends')
=C2=A0 =C2=A0 =C2=A0trace_ust_h =3D custom_target(fmt.format('trace-ust= ', 'h'),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0output: fmt.format('trace-= ust', 'h'),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0input: trace_events_file,
@@ -31,7 +30,7 @@ foreach dir : [ '.' ] + trace_events_subdirs
=C2=A0 =C2=A0 =C2=A0genh +=3D trace_ust_h
=C2=A0 =C2=A0endif
=C2=A0 =C2=A0trace_ss.add(trace_h, trace_c)
-=C2=A0 if 'CONFIG_TRACE_DTRACE' in config_host
+=C2=A0 if 'dtrace' in get_option('trace_backends')
=C2=A0 =C2=A0 =C2=A0trace_dtrace =3D custom_target(fmt.format('trace-dt= race', 'dtrace'),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 output: fmt.format('trace= -dtrace', 'dtrace'),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 input: trace_events_file,
@@ -76,7 +75,7 @@ foreach d : [
=C2=A0 =C2=A0specific_ss.add(when: 'CONFIG_TCG', if_true: gen)
=C2=A0endforeach

-if 'CONFIG_TRACE_UST' in config_host
+if 'ust' in get_option('trace_backends')
=C2=A0 =C2=A0trace_ust_all_h =3D custom_target('trace-ust-all.h', =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0output: 'trace-ust-= all.h',
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0input: trace_events_fil= es,
@@ -91,7 +90,11 @@ if 'CONFIG_TRACE_UST' in config_host
=C2=A0 =C2=A0genh +=3D trace_ust_all_h
=C2=A0endif

-trace_ss.add(when: 'CONFIG_TRACE_SIMPLE', if_true: files('simp= le.c'))
-trace_ss.add(when: 'CONFIG_TRACE_FTRACE', if_true: files('ftra= ce.c'))
+if 'simple' in get_option('trace_backends')
+=C2=A0 trace_ss.add(files('simple.c'))
+endif
+if 'ftrace' in get_option('trace_backends')
+=C2=A0 trace_ss.add(files('ftrace.c'))
+endif
=C2=A0trace_ss.add(files('control.c'))
=C2=A0trace_ss.add(files('qmp.c'))
--
2.31.1





--
Marc-Andr= =C3=A9 Lureau
--0000000000004eb92f05cdc94cd2--