Open Source


System Integration


Platform virtualization

Software-based virtualization

Create an empty disk image and then install Fedora onto it:
qemu-img create -f qcow2 disk.qcow2 4G
qemu-system-x86_64 -hda disk.qcow2 \
	-cdrom Fedora-20-x86_64-netinst.iso \
	-boot d \
	-net nic \
	-net user \
	-m 512 \
To accelerate qemu when virtualizing the same platform as the host, first use modprobe to install the appropriate KVM modules, and then add the --enable-kvm option to the qemu-system-x86_64 command above.


Running OpenWrt as a Xen HVM DomU guest

Configure a Xen DomU guest using the following:
name    = "OpenWrt"
memory  =  1024
vcpus   =  1
builder = "hvm"
vif     = [ "model=e1000,script=vif-bridge" ]
disk    = [ "tap2:tapdisk:aio:/path/to/openwrt-x86-generic-combined-ext4.img,xvda,w" ]
serial  = "pty"
To select a network bridge on a host which has configured more than one, add a statement of the form bridge=brname to the list of network parameters. To hard-code an Ethernet MAC, add mac=mac.

Running CentOS as a Xen HVM DomU guest

Configure a Xen DomU guest using the following:
name    = "CentOS"
memory  =  4096
vcpus   =  1
builder = "hvm"
vif     = [ "model=e1000,script=vif-bridge" ]
disk    = [ "tap2:tapdisk:aio:/path/to/disk.img,xvda,w" ]
serial  = "pty"
sdl     = 1
If you click on the SDL window, then the Xen interface will capture your mouse. To release the mouse, press Ctrl-Alt. Ctl-Alt-f will enter or leave full screen mode. Alternatively, you can omit sdl = 1 and configure GRUB to boot the Linux kernel with console=ttyS0.

Running OpenBSD as a Xen HVM DomU guest

Configure a Xen DomU guest using the following:
name    = "OpenBSD"
memory  =  4096
vcpus   =  1
builder = "hvm"
vif     = [ "model=e1000,script=vif-bridge" ]
disk    = [ "tap2:tapdisk:aio:/path/to/disk.img,xvda,w" ]
serial  = "pty"
sdl     = 1
See the description of CentOS above for how to use the SDL console. Alternatively, you can omit sdl = 1 and configure OpenBSD to use a serial console. To do this, add tty00 "/usr/libexec/getty std.9600" vt220 on secure to /etc/ttys and add:
stty com0 19200
set tty com0
to /etc/boot.conf.


The Xen domain configurations above assume bridged networking. This requires some configuration on the host.


You can set up a network bridge by placing the following in Dom0's /etc/sysconfig/network-scripts/ifcfg-xenbr0:


along with this in /etc/sysconfig/network-scripts/ifcfg-DEVICE, replacing MACADDRESS and DEVICE:



Alternatively, you can configure a Xen guest to connect to a network through Dom0 with Dom0 acting as a NAT router.

  1. Configure the guest with vif = [ "model=e1000,script=vif-nat,ip=,gatewaydev=INTERFACE" ], where INTERFACE is the network interface which serves as your default route to the Internet.
  2. Add the following to /etc/sysctl.conf on Dom0: net.ipv4.ip_forward=1 and run sysctl -p
  3. Run iptables -t nat -A POSTROUTING -o INTERFACE -j MASQUERADE, where INTERFACE is the interface from step one. (If you use firewalld, then run firewall-cmd --add-masquerade instead.)
  4. Boot the guest and configure its IP address as, its default gateway to (Dom0's virtual interface), and its DNS resolver to a valid server.

Boot from an installation CD

Add the following to your Xen DomU guest configuration:
disk = [ "tap2:tapdisk:aio:/path/to/cdrom.iso,hdc:cdrom,r" ]
You might want to instead add this statement to an existing disk list.

Pass an entire logical volume into a Xen guest

If you have an entire logical volume on Dom0 set aside for the guest, then you can pass it to the guest using:
disk = [ "phy:/dev/mapper/lv-name,xvdb,w" ]

Pass a USB device into a Xen guest

Add the following to your Xen DomU guest configuration:
usb       = 1
usbdevice = "host:xxxx:yyyy"
usb       = 1
usbdevice = "host:x.y"
In the first example, xxxx:xxxx represents the USB device's tag. In the second example, x.y represents the USB device's bus address. You can learn these identifiers by using lsusb.

Ensuring DomU virtual machines start after booting Dom0

  1. Place the configurations which you want to start upon booting in /etc/xen/.
  2. Make a symlink for each configuration from /etc/xen/ to /etc/xen/auto/.
  3. Run chkconfig xendomains on to ensure the xendomains script executes when Dom0 boots.


Share a folder from host to Linux guest

  1. Select guest Settings→Shared Folders.
  2. Add the folder on your host which you would like to add to your guest; remember the folder name.
  3. Ensure VirtualBox guest addition exists on the guest.
  4. On the Linux guest, run mount -t vboxsf folder-name mount-point.

Pass a USB device from host to Linux guest

  1. If you need USB 2 and 3 support, then install the VirtualBox extension pack from Oracle on the host: sudo VBoxManage extpack install path-to-extpack.
  2. Add the user running VirtualBox to the vboxusers group: sudo gpasswd -a $USER vboxusers. You might need to log out and log back in for this change to take affect.
  3. After booting the guest, look for the USB icon in VirtualBox's guest control panel at the bottom of the guest's window. Right click on it to select a USB device to pass through.

You might want to always pass a certain USB device to the guest. To do this, first identify the device's properties using VBoxManager list usbhost, and then create a filter using the interface at guest Settings→USB.

Disk images

Convert a raw disk image such that it can be used with VirtualBox or VMware:
qemu-img convert -f raw foo.img -O vmdk foo.vmdk (This will allow the use of an OpenWrt image such as openwrt-x86-generic-combined-ext4.img.gz if you uncompress it first.)
Create a sparse QCOW image for use with Xen:
qcow-create $((1024*1024)) vm-disk.qcow
Email: www@flyn.org — ✉ 6110 Campfire Court; Columbia, Maryland 21045; USA