config: qemu: Add QEMU_EXTRA_FLAGS config option

Add QEMU_EXTRA_FLAGS as QEMU board config option.

This allows Twister tests to provide additional device setup
commands to QEMU in prj.conf or testcase.yaml configuration files.

Example use case: to setup TCP or UDP network interfaces
with non-conflicting port numbers in different test suites
to avoid conflicts when Twister run tests in parallel on the
same host.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
This commit is contained in:
Dmitrii Golovanov 2023-10-09 14:57:39 +02:00 committed by Carles Cufí
parent cbbb1cabd6
commit 5008c31f8c
2 changed files with 16 additions and 0 deletions

View file

@ -111,6 +111,15 @@ config QEMU_GDBSERVER_LISTEN_DEV
as the `QEMU_EXTRA_FLAGS` environment variable. Refer to application
development doc and/or QEMU invocation doc for more info.
config QEMU_EXTRA_FLAGS
string "QEMU extra flags"
depends on QEMU_TARGET
default ""
help
This option is to pass onto QEMU an extra list of parameters
to setup devices, for example to allocate interface for Zephyr
GDBstub over serial with `-serial tcp:127.0.0.1:5678,server`
# There might not be any board options, hence the optional source
osource "$(BOARD_DIR)/Kconfig"
endmenu

View file

@ -399,6 +399,13 @@ set(env_qemu $ENV{QEMU_EXTRA_FLAGS})
separate_arguments(env_qemu)
list(APPEND QEMU_EXTRA_FLAGS ${env_qemu})
# Also append QEMU flags from config
if(NOT CONFIG_QEMU_EXTRA_FLAGS STREQUAL "")
set(config_qemu_flags ${CONFIG_QEMU_EXTRA_FLAGS})
separate_arguments(config_qemu_flags)
list(APPEND QEMU_EXTRA_FLAGS "${config_qemu_flags}")
endif()
list(APPEND MORE_FLAGS_FOR_debugserver_qemu -S)
if(NOT CONFIG_QEMU_GDBSERVER_LISTEN_DEV STREQUAL "")