User Tools

Site Tools


OpenWrt as a Xen DomU guest

This documents describes how to run the OpenWrt x86 port as a Xen domU guest.


  • A Xen dom0 host
  • The OpenWrt source tree

Build OpenWrt

Configure OpenWrt to build the x86 target and the Xen Paravirt Guest subtarget. Build the OpenWrt image.

:!: When using squashfs images, the Pad images to filesystem size (for JFFS2) option in the Target Images menu must be enabled, otherwise the attempt to initialize JFFS2 will result in "Access beyound end of device" errors during boot.

Configure Xen

On the dom0 guest, create a domain configuration file, Xen-OpenWrt.conf, with the following contents:

import subprocess

kernel          = "/path/to/openwrt-x86-vmlinuz"
disk            = ["file:///path/to/openwrt-x86-squashfs.fs,xvda1,r"]
root            = "/dev/xvda1"
memory          =  64
name            = "OpenWrt"
on_crash        = "destroy"
vif             =  [ "" ]

This will map openwrt-x86-squashfs.fs from dom0 to /dev/xvda1 on the domU guest and instruct the guest to use this device as its root filesystem. Refer to the xmdomain.cfg man page for documentation on the semantics of this configuration file.

FIXME Squashfs needs the block2mtd driver which has timing problems because xen seem to initialize its block driver asynchronously

The following configuration file uses the combined ext2/ext4 Image, which does not have such problems. It uses pygrub that chains the builtin grub.

bootloader = "/usr/bin/pygrub"
memory = 256
name = "owrt"
disk = ['file:/etc/xen/openwrt-x86-ext[24].image,xvda,w']
vif = [ 'bridge=mybrigde,mac=00:16:3E:00:00:01' ]
vcpus = 2
on_reboot = 'restart'
on_crash = 'destroy'
root = '/dev/xvda2 rw'


There exist many ways to configure networking within Xen. The technique that this document describes bridges between the dom0 guest's physical interface and a virtual interface that connects to the domU guest. This results in the domU guest receiving a connection on the same network as the dom0 guest.

Configure networking on the dom0 guest

Ensure that the host's firewall will allow traffic (e.g., DHCP) originating from the domU guest to pass through the dom0 guest.

brctl addbr br0

ip link set dev eth0 up
brctl addif br0 eth0

Ensure the device eth0 does not have an IP address because it is bridged to br0. Obtain an IP address using dhclient br0 or assign a static IP address:

ip link set dev br0 up
ip addr add dev br0 broadcast

Configure networking on the domU guest

Execute xm create Xen-OpenWrt.conf -c on the dom0 guest to start the domU guest.

Configure networking on the domU guest as you would in a bare-metal environment. For example, use udhcp -i br-lan or configure a static IP address.

doc/howto/xen.txt · Last modified: 2011/01/14 03:30 by soma