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.
CLI Reference
Section titled “CLI Reference”elmos qemu run [-g] # boot the kernelelmos qemu debug [-g] # boot halted, with a GDB stubelmos 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).
elmos qemu runBoots 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.
elmos qemu debug # terminal 1: QEMU waits for the debuggerelmos gdb # terminal 2qemu 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.
Modules in the Guest
Section titled “Modules in the Guest”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/).
Architecture Defaults
Section titled “Architecture Defaults”| 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.
Graphical Mode
Section titled “Graphical Mode”elmos qemu run -gOpens a QEMU window (Cocoa on macOS) with virtio GPU, keyboard and mouse,
and the console on tty0. The kernel needs virtio GPU support.
Networking
Section titled “Networking”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.
ssh -p 2222 root@localhostTroubleshooting
Section titled “Troubleshooting”| 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 |