cmake: qemu: Use chardev for console

The current QEMU console configuration directly connects the console
serial port to the backend using '-serial' option.

This is less than ideal because only single console instance can be
connected to a backend and aggregation of multiple console outputs is
not possible (e.g. multiple console serial ports and semihosting
console to single console backend).

In order to solve this problem, single multiplexed chardev console
backend is declared and all consoles are connected to it.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
Stephanos Ioannidis 2020-01-02 15:09:42 +09:00 committed by Anas Nashif
commit 244148a883

View file

@ -35,33 +35,23 @@ else()
list(APPEND QEMU_FLAGS qemu${QEMU_INSTANCE}.pid) list(APPEND QEMU_FLAGS qemu${QEMU_INSTANCE}.pid)
endif() endif()
# We can set "default" value for QEMU_PTY & QEMU_PIPE on cmake invocation. # Set up chardev for console.
if(QEMU_PTY) if(QEMU_PTY)
# Send console output to a pseudo-tty, used for running automated tests # Redirect console to a pseudo-tty, used for running automated tests.
set(CMAKE_QEMU_SERIAL0 pty) list(APPEND QEMU_FLAGS -chardev pty,id=con,mux=on)
elseif(QEMU_PIPE)
# Redirect console to a pipe, used for running automated tests.
list(APPEND QEMU_FLAGS -chardev pipe,id=con,mux=on,path=${QEMU_PIPE})
else() else()
if(QEMU_PIPE) # Redirect console to stdio, used for manual debugging.
# Send console output to a pipe, used for running automated tests list(APPEND QEMU_FLAGS -chardev stdio,id=con,mux=on)
set(CMAKE_QEMU_SERIAL0 pipe:${QEMU_PIPE})
else()
set(CMAKE_QEMU_SERIAL0 mon:stdio)
endif()
endif() endif()
# But also can set QEMU_PTY & QEMU_PIPE on *make* (not cmake) invocation, # Connect main serial port to the console chardev.
# like it was before cmake. list(APPEND QEMU_FLAGS -serial chardev:con)
if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
list(APPEND QEMU_FLAGS # Connect monitor to the console chardev.
-serial list(APPEND QEMU_FLAGS -mon chardev=con,mode=readline)
\${if \${QEMU_PTY}, pty, \${if \${QEMU_PIPE}, pipe:\${QEMU_PIPE}, ${CMAKE_QEMU_SERIAL0}}}
# NB: \$ is not supported by Ninja
)
else()
list(APPEND QEMU_FLAGS
-serial
${CMAKE_QEMU_SERIAL0}
)
endif()
# Add a BT serial device when building for bluetooth, unless the # Add a BT serial device when building for bluetooth, unless the
# application explicitly opts out with NO_QEMU_SERIAL_BT_SERVER. # application explicitly opts out with NO_QEMU_SERIAL_BT_SERVER.