Microsoft Windows XP as a Xen domU

From Wiki
Jump to: navigation, search

This information is correct as of OpenBSD 4.6 and Xen 3.2.1.

Does it Work?

Yes, it works in HVM (full virtualisation mode), but it can not be paravirtualised and never will be. You need a processor that supports Hyper-V (intel call it something else). If you have the following, you're fine:

# xm dmesg | grep HVM
(XEN) HVM: SVM enabled
(XEN) HVM: Hardware Assisted Paging detected and enabled.

Do it

  • Create a logical volume. (This also works with an image file, but an LV gives better performance):
# lvcreate -L10G -n example.spruce.toastputer.net-disk xen-vol
  Logical volume "example.spruce.toastputer.net-disk" created
  • Place the .iso that you legally ripped legally from your completely legal and fully licenced original legal copy of Microsoft Windows XP in a convenient location:
# ls /home/xen
xp.iso
  • Create a configuration file for the domU:
# vi /etc/xen/example.spruce.toastputer.net.cfg 
import os, re
arch = os.uname()[4]
kernel = "/usr/lib/xen-default/boot/hvmloader"
builder='hvm'

memory = 512
shadow_memory = 8
name = "example.spruce.toastputer.net"
# Setting ne2k_pci is essential if you want the virtual NIC to work
vif = [ 'type=ioemu, bridge=eth0, model=ne2k_pci' ]
# for image file instead of LV:
#disk = [ 'file:/home/xen/example.spruce.toastputer.net.img,xvda,w', 'file:/home/xen/xp.iso,xvdc:cdrom,r' ]
disk = [ 'phy:/dev/xen-vol/example.spruce.toastputer.net-disk,xvda,w', 'file:/home/xen/xp.iso,xvdc:cdrom,r' ]
device_model = '/usr/lib/xen-default/bin/qemu-dm'
# boot on floppy (a), hard disk (c) or CD-ROM (d)
# default: hard disk, cd-rom, floppy
boot="cd"

sdl=0 
# Enable VNC
vnc=1 
# Listen on 127.0.0.1:5901
vncconsole=1
# Listen on all IPs (Do not want)
#listen='0.0.0.0'
vncviewer=0 
nographic=0 
stdvga=0 
serial='pty' 
audio=0 
localtime=1 
acpi=0
apic=0

  • Instantiate the VM:
# xm create example.spruce.toastputer.net.cfg
Using config file "/etc/xen/example.spruce.toastputer.net.cfg".
Started domain example.spruce.toastputer.net
  • Verify that the dom0 has a listening socket for VNC:
# netstat -ntap | grep 5901
tcp        0      0 127.0.0.1:5901          0.0.0.0:*               LISTEN      9953/qemu-dm
  • ssh to the dom0, forwarding port 5901:
# ssh user@dom0-address -L 5901:127.0.0.1:5901
  • You will now be able to VNC to 127.0.0.1:5901 and see the domU console, so just install Microsoft Windows as usual.
  • NOTE: Chicken of the VNC on OS X doesn't like the VNC encoding used by Xen. Vine Viewer works fine but isn't free, I'm looking for something better.