From 5008c31f8c6d2094cc3ce9de876fba0fb9338a9d Mon Sep 17 00:00:00 2001 From: Dmitrii Golovanov Date: Mon, 9 Oct 2023 14:57:39 +0200 Subject: [PATCH] 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 --- boards/Kconfig | 9 +++++++++ cmake/emu/qemu.cmake | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/boards/Kconfig b/boards/Kconfig index fbab1e97d9..f56c2cab04 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -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 diff --git a/cmake/emu/qemu.cmake b/cmake/emu/qemu.cmake index a3a8a94515..6103fc1cef 100644 --- a/cmake/emu/qemu.cmake +++ b/cmake/emu/qemu.cmake @@ -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 "")