At work we are in the process of migrating most of our physical infrastructure to virtualization using Xen on CentOS servers. Most of our servers are CentOS Linux, running a mix of open source and proprietary applications. On one of our servers, we run a Windows XP VirtualBox guest where some financial applications that are only available for windows are run, and it also needed to be migrated to our new virtualization platform. There’s not much info about how to perform this on the net, so after some trial and error and some pointers given out on xen’s mailing list, I was able to successfully migrate our Windows XP VirtualBox guest to Xen. The migration is fairly trivial, but you need to do some preparation to your Windows guest to be able to successfully migrate it to Xen. Here’s the procedure you need to follow:

1. Uninstall VirtualBox guest additions

Boot up your Windows guest. The first thing you need to do is to uninstall VirtualBox guest additions because they add some kind of virtual drivers for stuff like video cards, which they aren’t supported on Xen. You can accomplish that by going into Windows Control Panel->Add or remove Programs, remove the guest additions and reboot your guest.

2. Fix IDE controllers

According to the aforementioned guide in VirtualBox wiki, Windows memorizes which IDE/ATA controller it was installed on and fails to boot in case the controller changes (which is something that happens when booting up on Xen), an you will get the “safe mode” screen instead of Windows successfully booting. To fix this problem, some modifications need to be done to the Windows registry to relax IDE disks checks. There’s a tool for this called MergeIDE from German ct’ magazine, which is available for downloadfrom VirtualBox’s wiki. Uncompress the zip file and run the MergeIDE.bat file, this will update the registry with the needed modifications.

3. Convert VDI disk to raw format

Ok, the preparations to the Windows guest are done so we can proceed to converting the VirtualBox disk image from VDI format to raw format. There are several ways of doing this but we will use the following command to do it:

VBoxManage internalcommands converttoraw Windows.vdi Windows.img

Windows.vdi is the original disk in VDI format and Windows.img is the new converted disk in raw format.

4. Configure Xen guest

After having ready the Windows disk we now need to create a Xen configuration file for it. One important note is that PAE, ACPI and APIC needs to be enaled on the config file, if not you will get a nice Blue Screen of Death when booting your Windows guest on Xen. Here’s my config:

name = “WindowsXP”
uuid = “071a3gca-e016-456e-8a5e-ea23033sdcb4”
maxmem = 256
memory = 512
vcpus = 1
builder = “hvm”
kernel = “/usr/lib/xen/boot/hvmloader”
boot = “c”
pae = 1
acpi = 1
apic = 1
localtime = 0
on_poweroff = “destroy”
on_reboot = “restart”
on_crash = “restart”
device_model = “/usr/lib64/xen/bin/qemu-dm”
usb = 1
usbdevice = “tablet”
sdl = 0
vnc = 1
vncunused = 1
keymap = “en-us”
disk = [ “
file:/var/lib/xen/images/Windows.img,hda,w”,
file:/distros/windows/xp_sp3/winxp_sp3.iso,hdc:cdrom,r” ]
vif = [ “mac=00:16:36:75:32:52,bridge=xenbr0,script=vif-bridge” ]
parallel = “none”
serial = “pty”

After the config file is finished, place it on Xen’s configuration directory, /etc/xen, and you are ready to run it.

5. Boot Windows Xen guest

Ok, now the new Windows guest is ready to be started. Fire up virt-manager and start your new Windows guest from there. Look at the VNC window and see if it boots ok. You could use xm command on a terminal too, but it’s easier to test with virt-manager as you can easily access to the VNC console.

Troubleshooting

If you still get the “safe mode” screen you can try to repair your Windows installation as you would do with a physical installation. Boot the Windows guest with the Windows installation CD and perform a repair. Start the installation and continue up to the select a partition step and select the existing partition, and choose “repair”. This will replace some dll files placed by VirtualBox with the native files from the CD.
=-=-=-=-=
Powered by Blogilo