User Tools

Site Tools


OpenWrt in QEMU

QEMU is an an open source processor emulator (and virtualizer). 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

  • FIXME Trunk: test kernel image with rootfs
  • FIXME Trunk: use SD card with rootfs, NFS rootfs, NBD rootfs
  • FIXME Trunk: no sound, pcibus, usb emulation in qemu possible?

Getting QEMU

Qemu runs on many different systems.

Ubuntu Linux

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.

Windows version

The QEMU Wiki Links page provides you with several unoffical download links of Windows builds.

OpenWrt in QEMU arm

The "realview" platform is meant for use with QEMU for emulating an ARM system. The platform is available in the standard downloads.

Command line to get it booting (without a storage device):

qemu-system-arm -M realview-eb-mpcore -kernel openwrt-realview-vmlinux-initramfs.elf -net nic -net user -nographic

Basically, use the generated initramfs image as the -kernel parameter.

:!: This target does not support booting from hard disk (-hda or other syntax); emulation of the PCI bus is missing (source). However, realview does support SD card image files (-sd filename.img); see below.

Booting from SD card image

(Note: The SD card image generation is in OpenWRT SVN r46924 on newer; it will be part of the Designated Driver release.)

Download a nightly kernel and SD-card image from - download both openwrt-realview-vmlinux.elf and openwrt-realview-sdcard.img. Alternatively, you can build your own by choosing the realview target in make menuconfig and then start the build with make world (look for the generated files under bin/realview).

Then start QEMU with the following command:

qemu-system-arm -M realview-pbx-a9 -m 1024M -nographic \
    -kernel openwrt-realview-vmlinux.elf \
    -sd openwrt-realview-sdcard.img \
    -append "console=ttyAMA0 verbose debug root=/dev/mmcblk0p1"


    -sd rootfs.ext4 \
    -append "root=/dev/mmcblk0"

OpenWrt in QEMU arm64 / aarch64

:!: at least qemu 2.0 required

slightly modified from target/linx/arm64/README:

qemu-system-aarch64 -machine virt -cpu cortex-a57 -machine type=virt -nographic \
-smp 1 -m 2048 \
-kernel bin/arm64/openwrt-arm64-qemu-virt-initramfs.Image \
--append "console=ttyAMA0"

OpenWrt in QEMU MIPS

:!: Use QEMU >= 2.2 (earlier versions can have bugs with MIPS16) ticket 16881 - Ubuntu 14.03.x LTS uses qemu 2.0 which is has this bug.

The "malta" platform is meant for use with QEMU for emulating a MIPS system.

The malta target supports both big and little-endian variants, pick the matching files and qemu version (qemu-system-mips, or qemu-system-mipsel).

qemu-system-mipsel -kernel openwrt-malta-le-vmlinux-initramfs.elf -nographic -m 256

In recent enough versions one can enable ext4 root filesystem image building, and since r46269 (:!: only in trunk, it's not part of the 15.05 CC release) it's possible to boot straight from that image (without an initramfs):

qemu-system-mipsel -M malta \
-hda openwrt-malta-le-root.ext4 \
-kernel openwrt-malta-le-vmlinux.elf \
-nographic -append "root=/dev/sda console=ttyS0"

OpenWrt in QEMU X86-64

The x86-64 target has support for ESXI images by default. Booting the VMDK / VDI images might not work with newer qemu versions.

:!: IMG/VDI/VMDK with "-hda" switch do not work with qemu 2.x .

pc-q35-2.0 / q35 emulates a different machine. With new syntax (no -hda , -net) the IMG / VDI / VMDK works here.


  • 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

qemu-system-x86_64 -M q35 -drive file=openwrt-x86_64-combined-ext4.img,id=d0,if=none,bus=0,unit=0 -device ide-hd,drive=d0,bus=ide.0

Experiences: openwrt virtualized using debian, qemu/kvm and a lex twitter system with intel atom d525 and chipset ich8m

Normally openwrt works on most of the hardware mentioned in the table of hardware (search in this wiki), and also on most o0f the hardware that support intel x86 ISA or x86 in the address bar.

Anyway some embedded x86 board have particular hardware that is not always well supported by the openwrt platform, even if all the kmod packages are included in the basic image. One of this x86 compatible hardware family are systems based on intel atom and chipset ich8m (maybe also others), like the Lex twitter system 3I525U.

On that system openwrt is able to run but, for example, is not able to manage really well the possibility of having two wan connections with different metric. The request will be always routed to the interface with higher metric also using ping -I <wan2_interface> Moreover software like Nmap will fail to be bind to certain interfaces. Someone with more knowledge could explain why this happens but as workaround one can use a more complete linux system (for example debian) as base and then virtualize ( virtualization OR qemu OR kvm OR hypervisor in the address bar) openwrt, that in the end requires really a little resources most of the time, or one can assign plenty of resources because at the end the base system is quite powerful.

Prepare debian (7.1 in the test) for virtualization

Debian was installed on a 2Gb cf card through a usb stick and netinstaller, having only the basic system utilities and ssh utilities. 1.1Gb of space were used, 600mb free and the rest swap.

Install the following packages: apt-get install qemu-kvm bridge-utils libvirt-bin virtinst

  • Qemu-kvm for qemu and kvm additional software components.
  • bridge-utils for managing bridges in debian
  • libvirt-bin for additional virtualization packages
  • virtinst for handy virtualization management

Then, if you don't want to use any user but just work with root (the objective is: let run openwrt on the twitter system, not having a well setup debian system):

  • Change /etc/libvirt/qemu.conf uncommenting user/group to work as root.
  • restart /etc/init.d/libvirt* entries.

Then we have to prepare the network. Modify /etc/network/interfaces a follows (adapt according to your needs)

auto br0 br1 br2 br3

iface br0 inet dhcp
  bridge_ports eth0
iface br1 inet dhcp
  bridge_ports eth1
iface br2 inet dhcp
  bridge_ports eth2
iface br3 inet dhcp
  bridge_ports eth3

The bridges ( ) are helpful because they allows different network adapters, real or virtual ( network.interfaces to exchange data (as the word 'bridge' suggests) and not only, because the bridge will have a certain mac address but also the virtual interfaces attached to it can have different mac addresses. Here the marvels of the linux networking system have to be explained by someone with more knowledge.

Virtualization proper

Then we need to create our virtual machine. The additional packages, apart from qemu, will help here. We can issue the following command, using the x86 generic image placed in the folder /root/openwrt_kvm/:

virt-install --name=openwrt --ram=256 --vcpus=1 --os-type=linux --disk path=/root/openwrt_kvm/openwrt-x86-generic-combined-ext4.img,bus=ide --network bridge=br0,model=e1000 --import
# be careful to the model, e1000 let's openwrt recognize the interface.

If you want to interact with the system from command line, use virsh. For example to force the shutdown of a virtual machine virsh destroy openwrt or to delete the virtual machine (but not the disk file) virsh undefine openwrt.

For having multiple interfaces

virt-install --name=openwrt --ram=256 --vcpus=1 --os-type=linux --disk path=/root/openwrt_kvm/openwrt-x86-generic-combined-ext4.img,bus=ide \
   --network bridge=br0,model=e1000 --network bridge=br3,model=e1000 --import
Remember that the console requires ctrl+5 to exit (german keyboard).

To mark a virtual machine for the autostart, type: virsh autostart openwrt.

doc/howto/qemu.txt · Last modified: 2015/11/04 20:32 by dubek