Booting a Windows Virtual Machine from Debian "Lenny" on AMD64 using Xen HVM
This article describes how I created a Windows XP virtual machine on a physical box which runs Xen 3.2. The dom0 for Xen is a Linux distro - Debian "Lenny". The physical box has an AMD Athlon X2 64-bit dual-core processor with 4GB of RAM. Xen's HVM emulation functionality is used to create the Windows domU.
This article might equally well be used to model how to use Xen HVM to boot any operating system for which you have an installation CD.
Quick Start
For the impatient, here is my working configuration file with which I issue 'xm create':
name = "winxp-hvm"
kernel = "/usr/lib/xen-default/boot/hvmloader"
builder = 'hvm'
device_model = '/usr/lib/xen-default/bin/qemu-dm.debug'
memory = 1024
shadow_memory = 8
disk = [ 'file:/home/xen/domains/winxp/winxp.iso,hdc:cdrom,r'
, 'phy:/dev/sda1,ioemu:hda,w'
]
vif = [ 'type=ioemu, bridge=eth0' ]
# Boot hard disk first, then CD-ROM. [Options are: boot on
# floppy (a), hard disk (c) or CD-ROM (d).]
boot="cd"
vnc=1
vncconsole=1
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'destroy'
Backgroud
I wanted to be able to operate a Windows VM via VNC from my iMac, and I wanted the Windows VM to run on an AMD64-based box that is on my at-home LAN. I didn't want to run the Windows VM directly on my iMac because I did not want it to consume RAM on my oft-used desktop computer. The AMD64-based box is a silent PC, consumes little power, is always on, and had RAM to spare. So, it made sense to run the Windows VM on that box. That makes an instance of Windows always available via VNC. Sweet.
Installation CD Image
My copy of Windows XP comes on a single CD-ROM disc. Since it is my only copy, it is convenient that running Windows in a VM allows me to emulate the disc via a file on my dom0's hard drive. This avoids wear on the disc, and avoid the useless waste of power required to spin up the physical disc in a CD-ROM drive. Also, it's faster.
With the Windows installation disc in the CD-ROM drive, from the dom0, to create the copy of the disc, I issued:
dd if=/dev/cdrom of=winxp.iso
This left a 701 MB file called 'winxp.iso' in my '/home/xen/domains/winxp/' directory, which is where I'm choosing to keep files on the dom0 related to the Windows VM.
Launch and use VNC
The .cfg file is called winxp-hvm.xen.cfg, and is linked to from '/etc/xen' (with 'ln -s /home/xen/domains/winxp/winxp-hvm.xen.cfg /etc/xen/winxp-hvm.xen.cfg'). This allows me to create the domain with 'xm winxp-hvm.xen.cfg'.
The 'vnc=1' line in the .cfg file causes Xen to emulate the display of the Windows VM via a VNC server. The password for the server is to be found in the dom0's '/etc/xen/xend-config.sxp' file. The line will read (vncpasswd 'blah!').
The 'vncconsole=1' line causes 'xm' to launch a VNC client from the console from which the 'xm create' command is invoked. In my case, that is from a SSH connection which was created with "ssh -X" from my iMac. So, when I issue 'xm create', I input my vncpasswd and then immediately see the booting Windows VM in a VNC viewer window.
Troubleshooting
Xen utilities on the dom0 leave files in '/var/log/xen'. Check in there if you are having problems. The log files for 'xend' are 'xend.log*'. The QEMU device model executable, 'qemu-dm', logs in '/var/log/xen/qemu-dm-*.log'.
Replace 'qemu-dm' with 'qemu-dm.debug' in the .cfg file to log the arguments to 'qemu-dm' to '/tmp/args'. Here are the arguments that are actually passed to qemu-dm for me. ('qemu-dm.debug' is a shell script. Examine it for details.)
-d 32 -domain-name winxp-hvm -vnc 0.0.0.0:0,password -vncunused -vcpus 1 -boot cd -acpi -net nic,vlan=1,macaddr=00:16:3e:6d:f1:71,model=rtl8139 -net tap,vlan=1,bridge=eth0 -M xenfv -vncviewer localhost:10.0
Tune Windows
To resolve problems with the mouse not being in sync with the pointer in VNC, in the Windows XP guest VM, go to Start > Control Panel > Mouse > Pointer Options, and deselect (make unchecked) "Enhance pointer precision".
- Robin's blog
- Login to post comments