Skip to content

Instantly share code, notes, and snippets.

@mcastelino
Last active July 28, 2025 22:25
Show Gist options
  • Select an option

  • Save mcastelino/f42848fe00bab0bec90c4cb175463810 to your computer and use it in GitHub Desktop.

Select an option

Save mcastelino/f42848fe00bab0bec90c4cb175463810 to your computer and use it in GitHub Desktop.
QEMU Console forwarding

Why

To programatically interact with the workload inside the container. But how can we differentiate stdout and stderr

(based on http://nairobi-embedded.org/qemu_serial_terminal_redirection.html)

QEMU Command line

qemu-system-x86_64 \
    -enable-kvm \
    -bios OVMF.fd \
    -smp sockets=1,cpus=4,cores=2 -cpu host \
    -m 1024 \
    -vga none -nographic \
    -drive file="$IMAGE",if=virtio,aio=threads,format=raw \
    -chardev socket,host=localhost,port=4555,server,nowait,id=gnc0 \
    -device isa-serial,chardev=gnc0 \
    -monitor stdio \
    -debugcon file:debug.log -global isa-debugcon.iobase=0x402 $@

On the host

nc localhost 4555
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment