From 6d2ff13a639b9fff72842869cfd78f78ff21bbf2 Mon Sep 17 00:00:00 2001 From: Ruihan Li Date: Thu, 29 Jan 2026 10:31:06 +0800 Subject: [PATCH] Redirect serial output if `hvc0` is on --- .gitignore | 1 + tools/qemu_args.sh | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index f8c1e80d9..cd5a35190 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ target/ # qemu log file qemu.log +qemu-serial.log # packet dump file virtio-net.pcap diff --git a/tools/qemu_args.sh b/tools/qemu_args.sh index 92696f498..1be720403 100755 --- a/tools/qemu_args.sh +++ b/tools/qemu_args.sh @@ -49,7 +49,10 @@ else fi if [ "$CONSOLE" = "hvc0" ]; then - CONSOLE_ARGS="-device virtconsole,chardev=mux" + # Kernel logs are printed to all consoles. Redirect serial output to a file to avoid duplicate logs. + CONSOLE_ARGS="-device virtconsole,chardev=mux -serial file:qemu-serial.log" +else + CONSOLE_ARGS="-serial chardev:mux" fi if [ "$1" = "tdx" ]; then @@ -75,7 +78,6 @@ if [ "$1" = "tdx" ]; then $CONSOLE_ARGS \ -device isa-debug-exit,iobase=0xf4,iosize=0x04 \ -monitor chardev:mux \ - -serial chardev:mux \ -d guest_errors \ " echo $QEMU_ARGS @@ -89,7 +91,6 @@ COMMON_QEMU_ARGS="\ --no-reboot \ -nographic \ -display vnc=0.0.0.0:${VNC_PORT:-42} \ - -serial chardev:mux \ -monitor chardev:mux \ -chardev stdio,id=mux,mux=on,signal=off,logfile=qemu.log \ $NETDEV_ARGS \