This documents describes how to run the OpenWrt x86 port as a Xen domU guest.
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.
On the dom0 guest, create a domain configuration file,
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
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.
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.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.
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
br0. Obtain an IP address using
dhclient br0 or assign a
static IP address:
ip link set dev br0 up ip addr add 192.168.1.2/24 dev br0 broadcast 192.168.1.255
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