Skip to content

Commit 9c29b74

Browse files
committed
trace: move configuration from configure to Meson
Cc: Stefan Hajnoczi <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 0955d66 commit 9c29b74

File tree

6 files changed

+61
-106
lines changed

6 files changed

+61
-106
lines changed

configure

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,6 @@ version_ge () {
216216
done
217217
}
218218

219-
have_backend () {
220-
echo "$trace_backends" | grep "$1" >/dev/null
221-
}
222-
223219
glob() {
224220
eval test -z '"${1#'"$2"'}"'
225221
}
@@ -3514,56 +3510,6 @@ case "$capstone" in
35143510
;;
35153511
esac
35163512

3517-
##########################################
3518-
# check if we have posix_syslog
3519-
3520-
posix_syslog=no
3521-
cat > $TMPC << EOF
3522-
#include <syslog.h>
3523-
int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
3524-
EOF
3525-
if compile_prog "" "" ; then
3526-
posix_syslog=yes
3527-
fi
3528-
3529-
##########################################
3530-
# check if trace backend exists
3531-
3532-
$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
3533-
if test "$?" -ne 0 ; then
3534-
error_exit "invalid trace backends" \
3535-
"Please choose supported trace backends."
3536-
fi
3537-
3538-
##########################################
3539-
# For 'ust' backend, test if ust headers are present
3540-
if have_backend "ust"; then
3541-
if $pkg_config lttng-ust --exists; then
3542-
lttng_ust_libs=$($pkg_config --libs lttng-ust)
3543-
else
3544-
error_exit "Trace backend 'ust' missing lttng-ust header files"
3545-
fi
3546-
fi
3547-
3548-
##########################################
3549-
# For 'dtrace' backend, test if 'dtrace' command is present
3550-
if have_backend "dtrace"; then
3551-
if ! has 'dtrace' ; then
3552-
error_exit "dtrace command is not found in PATH $PATH"
3553-
fi
3554-
trace_backend_stap="no"
3555-
if has 'stap' ; then
3556-
trace_backend_stap="yes"
3557-
3558-
# Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
3559-
# visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
3560-
# instead. QEMU --enable-modules depends on this because the SystemTap
3561-
# semaphores are linked into the main binary and not the module's shared
3562-
# object.
3563-
QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2"
3564-
fi
3565-
fi
3566-
35673513
##########################################
35683514
# check and set a backend for coroutine
35693515

@@ -4574,42 +4520,6 @@ if test "$tpm" = "yes"; then
45744520
echo 'CONFIG_TPM=y' >> $config_host_mak
45754521
fi
45764522

4577-
echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
4578-
if have_backend "nop"; then
4579-
echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
4580-
fi
4581-
if have_backend "simple"; then
4582-
echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
4583-
fi
4584-
if have_backend "log"; then
4585-
echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
4586-
fi
4587-
if have_backend "ust"; then
4588-
echo "CONFIG_TRACE_UST=y" >> $config_host_mak
4589-
echo "LTTNG_UST_LIBS=$lttng_ust_libs" >> $config_host_mak
4590-
fi
4591-
if have_backend "dtrace"; then
4592-
echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
4593-
if test "$trace_backend_stap" = "yes" ; then
4594-
echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
4595-
fi
4596-
fi
4597-
if have_backend "ftrace"; then
4598-
if test "$linux" = "yes" ; then
4599-
echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
4600-
else
4601-
feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
4602-
fi
4603-
fi
4604-
if have_backend "syslog"; then
4605-
if test "$posix_syslog" = "yes" ; then
4606-
echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
4607-
else
4608-
feature_not_found "syslog(trace backend)" "syslog not available"
4609-
fi
4610-
fi
4611-
echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
4612-
46134523
if test "$rdma" = "yes" ; then
46144524
echo "CONFIG_RDMA=y" >> $config_host_mak
46154525
echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
@@ -4992,6 +4902,7 @@ if test "$skip_meson" = no; then
49924902
$(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
49934903
-Dalsa=$alsa -Dcoreaudio=$coreaudio -Ddsound=$dsound -Djack=$jack -Doss=$oss \
49944904
-Dpa=$pa -Daudio_drv_list=$audio_drv_list -Dtcg_interpreter=$tcg_interpreter \
4905+
-Dtrace_backends=$trace_backends -Dtrace_file=$trace_file \
49954906
$cross_arg \
49964907
"$PWD" "$source_path"
49974908

docs/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ if build_docs
5757
'qemu-nbd.8': (have_tools ? 'man8' : ''),
5858
'qemu-pr-helper.8': (have_tools ? 'man8' : ''),
5959
'qemu-storage-daemon.1': (have_tools ? 'man1' : ''),
60-
'qemu-trace-stap.1': (config_host.has_key('CONFIG_TRACE_SYSTEMTAP') ? 'man1' : ''),
60+
'qemu-trace-stap.1': (stap.found() ? 'man1' : ''),
6161
'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''),
6262
'virtiofsd.1': (have_virtiofsd ? 'man1' : ''),
6363
'qemu.1': 'man1',

meson.build

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,22 @@ foreach target : edk2_targets
111111
endif
112112
endforeach
113113

114+
dtrace = not_found
115+
stap = not_found
116+
if 'dtrace' in get_option('trace_backends')
117+
dtrace = find_program('dtrace', required: true)
118+
stap = find_program('stap', required: false)
119+
if stap.found()
120+
# Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
121+
# visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
122+
# instead. QEMU --enable-modules depends on this because the SystemTap
123+
# semaphores are linked into the main binary and not the module's shared
124+
# object.
125+
add_global_arguments('-DSTAP_SDT_V2',
126+
native: false, language: ['c', 'cpp', 'objc'])
127+
endif
128+
endif
129+
114130
##################
115131
# Compiler flags #
116132
##################
@@ -201,6 +217,19 @@ if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \
201217
error('Your compiler does not support -fsanitize=fuzzer')
202218
endif
203219

220+
if 'ftrace' in get_option('trace_backends') and targetos != 'linux'
221+
error('ftrace is supported only on Linux')
222+
endif
223+
if 'syslog' in get_option('trace_backends') and not cc.compiles('''
224+
#include <syslog.h>
225+
int main(void) {
226+
openlog("qemu", LOG_PID, LOG_DAEMON);
227+
syslog(LOG_INFO, "configure");
228+
return 0;
229+
}''')
230+
error('syslog is not supported on this system')
231+
endif
232+
204233
if targetos != 'linux' and get_option('mpath').enabled()
205234
error('Multipath is supported only on Linux')
206235
endif
@@ -359,8 +388,9 @@ if 'CONFIG_GIO' in config_host
359388
link_args: config_host['GIO_LIBS'].split())
360389
endif
361390
lttng = not_found
362-
if 'CONFIG_TRACE_UST' in config_host
363-
lttng = declare_dependency(link_args: config_host['LTTNG_UST_LIBS'].split())
391+
if 'ust' in get_option('trace_backends')
392+
lttng = dependency('lttng-ust', required: true, method: 'pkg-config',
393+
kwargs: static_kwargs)
364394
endif
365395
pixman = not_found
366396
if have_system or have_tools
@@ -1347,6 +1377,11 @@ elif get_option('virtfs').disabled()
13471377
have_virtfs = false
13481378
endif
13491379

1380+
foreach k : get_option('trace_backends')
1381+
config_host_data.set('CONFIG_TRACE_' + k.to_upper(), true)
1382+
endforeach
1383+
config_host_data.set_quoted('CONFIG_TRACE_FILE', get_option('trace_file'))
1384+
13501385
config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / get_option('bindir'))
13511386
config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix'))
13521387
config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir)
@@ -1571,7 +1606,7 @@ config_host_data.set('HAVE_BROKEN_SIZE_MAX', not cc.compiles('''
15711606

15721607
ignored = ['CONFIG_QEMU_INTERP_PREFIX'] # actually per-target
15731608
arrays = ['CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST']
1574-
strings = ['HOST_DSOSUF', 'CONFIG_IASL', 'CONFIG_TRACE_FILE']
1609+
strings = ['HOST_DSOSUF', 'CONFIG_IASL']
15751610
foreach k, v: config_host
15761611
if ignored.contains(k)
15771612
# do nothing
@@ -2109,7 +2144,7 @@ qapi_gen_depends = [ meson.current_source_dir() / 'scripts/qapi/__init__.py',
21092144

21102145
tracetool = [
21112146
python, files('scripts/tracetool.py'),
2112-
'--backend=' + config_host['TRACE_BACKENDS']
2147+
'--backend=' + ','.join(get_option('trace_backends'))
21132148
]
21142149
tracetool_depends = files(
21152150
'scripts/tracetool/backend/log.py',
@@ -2826,7 +2861,7 @@ foreach target : target_dirs
28262861
emulators += {exe['name']: emulator}
28272862
endif
28282863

2829-
if 'CONFIG_TRACE_SYSTEMTAP' in config_host
2864+
if stap.found()
28302865
foreach stp: [
28312866
{'ext': '.stp-build', 'fmt': 'stap', 'bin': meson.current_build_dir() / exe['name'], 'install': false},
28322867
{'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / get_option('bindir') / exe['name'], 'install': true},
@@ -3007,9 +3042,9 @@ summary_info += {'fuzzing support': get_option('fuzzing')}
30073042
if have_system
30083043
summary_info += {'Audio drivers': ' '.join(audio_drivers_selected)}
30093044
endif
3010-
summary_info += {'Trace backends': config_host['TRACE_BACKENDS']}
3011-
if config_host['TRACE_BACKENDS'].split().contains('simple')
3012-
summary_info += {'Trace output file': config_host['CONFIG_TRACE_FILE'] + '-<pid>'}
3045+
summary_info += {'Trace backends': ','.join(get_option('trace_backends'))}
3046+
if 'simple' in get_option('trace_backends')
3047+
summary_info += {'Trace output file': get_option('trace_file') + '-<pid>'}
30133048
endif
30143049
summary_info += {'QOM debugging': config_host.has_key('CONFIG_QOM_CAST_DEBUG')}
30153050
summary_info += {'vhost-kernel support': config_host.has_key('CONFIG_VHOST_KERNEL')}

meson_options.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ option('audio_drv_list', type: 'array', value: ['default'],
1313
description: 'Set audio driver list')
1414
option('fuzzing_engine', type : 'string', value : '',
1515
description: 'fuzzing engine library for OSS-Fuzz')
16+
option('trace_file', type: 'string', value: 'trace',
17+
description: 'Trace file prefix for simple backend')
1618

1719
option('docs', type : 'feature', value : 'auto',
1820
description: 'Documentations build support')
@@ -146,6 +148,10 @@ option('fuse', type: 'feature', value: 'auto',
146148
option('fuse_lseek', type : 'feature', value : 'auto',
147149
description: 'SEEK_HOLE/SEEK_DATA support for FUSE exports')
148150

151+
option('trace_backends', type: 'array', value: ['log'],
152+
choices: ['dtrace', 'ftrace', 'log', 'nop', 'simple', 'syslog', 'ust'],
153+
description: 'Set available tracing backends')
154+
149155
option('alsa', type: 'feature', value: 'auto',
150156
description: 'ALSA sound support')
151157
option('coreaudio', type: 'feature', value: 'auto',

scripts/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
if 'CONFIG_TRACE_SYSTEMTAP' in config_host
1+
if stap.found()
22
install_data('qemu-trace-stap', install_dir: get_option('bindir'))
33
endif

trace/meson.build

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
specific_ss.add(files('control-target.c'))
33

44
trace_events_files = []
5-
dtrace = find_program('dtrace', required: 'CONFIG_TRACE_DTRACE' in config_host)
65
foreach dir : [ '.' ] + trace_events_subdirs
76
trace_events_file = meson.project_source_root() / dir / 'trace-events'
87
trace_events_files += [ trace_events_file ]
@@ -21,7 +20,7 @@ foreach dir : [ '.' ] + trace_events_subdirs
2120
input: trace_events_file,
2221
command: [ tracetool, group, '--format=c', '@INPUT@', '@OUTPUT@' ],
2322
depend_files: tracetool_depends)
24-
if 'CONFIG_TRACE_UST' in config_host
23+
if 'ust' in get_option('trace_backends')
2524
trace_ust_h = custom_target(fmt.format('trace-ust', 'h'),
2625
output: fmt.format('trace-ust', 'h'),
2726
input: trace_events_file,
@@ -31,7 +30,7 @@ foreach dir : [ '.' ] + trace_events_subdirs
3130
genh += trace_ust_h
3231
endif
3332
trace_ss.add(trace_h, trace_c)
34-
if 'CONFIG_TRACE_DTRACE' in config_host
33+
if 'dtrace' in get_option('trace_backends')
3534
trace_dtrace = custom_target(fmt.format('trace-dtrace', 'dtrace'),
3635
output: fmt.format('trace-dtrace', 'dtrace'),
3736
input: trace_events_file,
@@ -76,7 +75,7 @@ foreach d : [
7675
specific_ss.add(when: 'CONFIG_TCG', if_true: gen)
7776
endforeach
7877

79-
if 'CONFIG_TRACE_UST' in config_host
78+
if 'ust' in get_option('trace_backends')
8079
trace_ust_all_h = custom_target('trace-ust-all.h',
8180
output: 'trace-ust-all.h',
8281
input: trace_events_files,
@@ -91,7 +90,11 @@ if 'CONFIG_TRACE_UST' in config_host
9190
genh += trace_ust_all_h
9291
endif
9392

94-
trace_ss.add(when: 'CONFIG_TRACE_SIMPLE', if_true: files('simple.c'))
95-
trace_ss.add(when: 'CONFIG_TRACE_FTRACE', if_true: files('ftrace.c'))
93+
if 'simple' in get_option('trace_backends')
94+
trace_ss.add(files('simple.c'))
95+
endif
96+
if 'ftrace' in get_option('trace_backends')
97+
trace_ss.add(files('ftrace.c'))
98+
endif
9699
trace_ss.add(files('control.c'))
97100
trace_ss.add(files('qmp.c'))

0 commit comments

Comments
 (0)