Skip to content

QEMU Integration

Run and debug kernels using ELMOS’s QEMU integration. Commands and options here are those of core/app/commands/qemu.go; the QEMU command line is built in core/domain/emulator/qemu.go.


Terminal window
elmos qemu run [-g] # boot the kernel
elmos qemu debug [-g] # boot halted, with a GDB stub
elmos gdb # attach the cross GDB to a debug session

-g, --graphical: a graphical display instead of the serial console.

Both QEMU commands need the workspace mounted (elmos init), a built kernel (elmos kernel build) and a root filesystem (elmos rootfs create).


Terminal window
elmos qemu run

Boots the configured architecture’s kernel with the disk image as the root filesystem (root=/dev/vda) and the serial console on the terminal (-nographic -serial mon:stdio). Ctrl-A X quits QEMU.

Terminal window
elmos qemu debug # terminal 1: QEMU waits for the debugger
elmos gdb # terminal 2

qemu debug adds a GDB stub on tcp::<gdb_port> (default 1234) and starts the CPU halted (-S). elmos gdb runs the architecture’s cross GDB from PATH with vmlinux, connects to localhost:<gdb_port>, opens layout src and sets a breakpoint at start_kernel. Put elmos’s toolchains on PATH with eval "$(elmos toolchains env)" if the GDB is not found.


The host’s modules directory (examples/modules/ in the workspace) is shared into the guest over virtio-9p (mount tag modules_mount). The guest’s init mounts it at /mnt/modules and runs guesync.sh, which elmos writes there before each boot; it loads every .ko it finds with insmod (assets/templates/init/).


Arch QEMU binary Machine CPU Console
arm64 qemu-system-aarch64 virt cortex-a72 ttyAMA0
arm qemu-system-arm virt,highmem=off cortex-a15 ttyAMA0
riscv qemu-system-riscv64 virt rv64 ttyS0

Memory and CPU count come from the qemu section of elmos.yaml (memory, smp). There is no option to pick another machine.


Terminal window
elmos qemu run -g

Opens a QEMU window (Cocoa on macOS) with virtio GPU, keyboard and mouse, and the console on tty0. The kernel needs virtio GPU support.


User-mode networking with SSH forwarded from the host:

  • host port <ssh_port> (default 2222) to guest port 22;
  • the guest reaches the host at 10.0.2.2.
Terminal window
ssh -p 2222 root@localhost

Issue Solution
no kernel image elmos kernel build
no root filesystem elmos rootfs create
boot hangs with no output check the kernel config for the console’s serial driver
elmos gdb: GDB not found elmos toolchains build, then eval "$(elmos toolchains env)", or a cross GDB from the system’s packages on PATH