This document descripes howto run the OpenWrt x86 port in QEMU.
- qemu an example setup
It is mixed descriptions from windows and linux, so please read through all of it before starting.
Choosing different emulation settings can affect performance greatly.
Example: 30s iperf-s@openwrt(qemu running on host) to host
ne2k_pci:0.0-31.3 sec 14.6 MBytes 3.92 Mbits/sec pcnet: 0.0-30.0 sec 2.38 GBytes 682 Mbits/sec e1000: 0.0-30.0 sec 6.23 GBytes 1.79 Gbits/sec vmxnet3: 0.0-30.0 sec 8.67 GBytes 2.48 Gbits/sec virtio-net-pci: 0.0-30.0 sec 44.6 GBytes 12.8 Gbits/sec
Many Linux Distributions like Debian, Ubuntu, Suse, Fedora provide a qemu package in their package repositories.
Example for Debian 7 (Wheezy):
sudo apt-get install qemu
Qemu is rapidly developing so features, syntax might change between versions.
QEMU is an an open source processor emulator (and virtualizer). The QEMU Wiki Links page provides you with several unoffical download links of Windows builds.
In this example download the qemu-0.9.0-windows.zip and unzip to a directory.
Download OpenWrt raw image (ex. kamikaze/8.09.1/x86/) and copy the raw image into the qemu directory.
Run QEMU by using following command:
C:\qemu-0.9.0-windows>qemu.exe -L . -hda openwrt-x86-ext2.image
Which shall result in a command window as shown below:
QEMU may issue warning message as following:
Could not open '\\.\kqemu' - QEMU acceleration layer not activated
You may correct this warning by installing KQEMU driver which provides better performance for the VM, but this is not as relevant to OpenWrt.
Upon execution of the above command new window shall appear with booting OpenWrt:
And in several seconds OpenWrt VM shall be up and running:
The "realview" platform is meant for use with QEMU for emulating an ARM system. This platform might not be available in the standard downloads (it isn't at time of writing), but it currently appears when building from scratch.
As of QEMU 1.1.2, use the following on the command line to get it booting:
qemu-system-arm -M realview-eb-mpcore -kernel openwrt-realview-vmlinux.elf -net nic -net user -nographic
Basically, use the generated image as the `-kernel` parameter.
Trunk: kernel image does not boot; initramfs image works Trunk: untested: use SD card with rootfs, NFS rootfs, NBD rootfs Trunk: no sound, pcibus, usb emulation in qemu possible?
The "malta" platform is meant for use with QEMU for emulating a MIPS system.
The malta platform is broken in trunk since gcc was switched to 4.8. Compile with gcc 4.6 to get it working or disable MIPS16. ticket #16881
depending on the malta variant
qemu-system-mipsel -kernel openwrt-malta-le-vmlinux-initramfs.elf -nographic -m 256
The x86-64 target has support for ESXI images by default. Booting the VMDK / VDI images might not work with newer qemu versions.
qemu-system-x86_64 2.0.0 with defaullt machine does not seem to work with simple "-hda openwrt.vdi".
pc-q35-2.0 emulates a different machine. With new syntax (no -hda , -net) the VDI / VMDK works.
- 2 HDDs (1 openwrt image, 1 data)
- 1 drive per bus, 6 bus available (until ide.5)
- 2 Network cards : 1 bridged to host (need higher permission) and 1 "user" (default, NAT 10.x.x.x)
Some emulated network cards might have performance issues.
qemu-system-x86_64 \ -enable-kvm \ -M pc-q35-2.0 \ -drive file=openwrt-x86_64-combined-ext4.vdi,id=d0,if=none \ -device ide-hd,drive=d0,bus=ide.0 \ -drive file=data.qcow2,id=d1,if=none \ -device ide-hd,drive=d1,bus=ide.1 \ -soundhw ac97 \ -netdev bridge,br=virbr0,id=hn0 \ -device e1000,netdev=hn0,id=nic1 \ -netdev user,id=hn1 \ -device e1000,netdev=hn1,id=nic2
doc/howto/qemu.txt · Last modified: 2014/07/10 22:04 by theoradicus