Running ELKS in QEMU

Last QEMU version tested: 2.7.0

QEMU is the prefered emulator to test ELKS, as it is mainstream, is able to emulate a pure ISA machine, and provides some useful debug facilities, like the guest network dump.

Another emulator is EMU86, but is more intended for low level debugging for the ELKS developers.

To run ELKS in QEMU, use the launcher script in:

cd .../elks
./qemu.sh

Edit this script to customize your QEMU configuration. It contains some comments to explain the most useful options.

ELKS networking in QEMU

The ktcp network process and the NE2K Ethernet driver run well on QEMU.

The simplest way to do networking in QEMU is the "user" mode. In this mode, QEMU connects the ELKS Ethernet interface (default address 10.0.2.15) to a guest VLAN, with a router at default address 10.0.2.2. That router acts as a gateway that performs outgoing and incoming NAT.

That router does not forward ICMP packets, so you cannot ping ELKS from the host and ELKS cannot ping ip addresses beyond the 10.0.2.0 network. However, there is no ping utility on ELKS yet.

Outgoing connections work without additional configuration. For incoming connections, use the "host-to-guest" forwarding of the guest VLAN.

In the following example, we tell QEMU to listen on port 2323 on the host local address 127.0.0.1, and to redirect to port 23 on ELKS, so that we can telnet to ELKS:

qemu.sh: -net user,hostfwd=tcp:127.0.0.1:2323-10.0.2.15:23
telnet 127.0.0.1 2323

In the following example, we tell QEMU to listen on port 8080 on the host local address 127.0.0.1, and to redirect to port 80 on ELKS, so that we can query the httpd process on ELKS:

qemu.sh: -net user,hostfwd=tcp:127.0.0.1:8080-10.0.2.15:80
wget 127.0.0.1:8080

To capture and dump the packets from the user VLAN, use the option:

qemu.sh: -net dump

Then use TcpDump or Wireshark to display the network trafic:

tcpdump -r qemu-vlan0.pcap