Xen 
 
Home About Xen.org Xen Xen Summit Wiki Mailing List Bug Tracker Xen Downloads
 
   

Introduction

This procedure shows you how to install Windows under Xen on CentOS5, and fixes one of the big problems of Windows XP under Xen: Windows XP's inability to shut itself down fully (Windows ends up on the 'it is safe to turn off your computer' screen, but the virtual machine is not automatically destroyed). See XenWindowsACPI for a summary of how we achieve this.

We fix Windows XP's inability to shut down the VM properly by manipilating the VM during Windows Setup so that it installs ACPI drivers, despite the fact that Xen's current ACPI implementation seems to cause Windows Setup to choke or stall.

Caveats

This may work on other Xen setups, but I've only tested it on CentOS5 on an Intel DQ965GF motherboard. See HVM Compatible Motherboards for some additional information.

Preparation

This section is optional, and just describes a way that I've set things up that makes it easier to commission more than one VM.

  1. Create a folder for the ISO image; the folder should be in /var/lib/xen/images/media. Name it something like winxp-pro-corp-X08-31437 (in this case, X08-31437 is the media part number, but you can use whatever makes sense to you).

  2. Create the ISO image by putting the disc in the CDROM drive and issue a command such as:
    • dd if=/dev/cdrom of=/var/lib/xen/images/media/winxp-pro-corp-X08-31437/disc1.iso

Procedure

Note that vmname is the name of the new virtual machine that you are creating.

  1. Change to /var/lib/xen/images (eg: cd /var/lib/xen/images)

  2. Create a symbolic link to the install ISO image: ln -s media/winxp-pro-corp-X08-31437/disc1.iso vmname-install.iso

  3. Create a large file to be used as the hard drive of the virtual machine. EG: for a 4GB virtual hard drive:
    • nice dd if=/dev/zero of=vmname.img bs=1M count=4096

    • (Note that this will take some time, up to a minute per gigabyte, and will slow down the machine, which is why we 'nice' it)
  4. Use virt-install to start the installation process:

    • virt-install -n vmname -r 384 -f /var/lib/xen/images/vmname.img -b xenbr0 --sdl -v -c /var/lib/xen/images/vmname-install.iso

    • Note that this command will create a configuration file /etc/xen/vmname, start the new virtual machine, then try to connect to it.

  5. One of four things will happen:
    1. The virtual machine will fail to start, or will shut down relatively quickly;
    2. The virtual machine will start, but will reboot every minute or so (usually at the setup screen that "Setup is starting Windows" at the bottom);
    3. The virtual machine will start, but will stall on the blue setup screen that says "Setup is starting Windows" at the bottom;
    4. The virtual machine will start, and will reach the "Welcome to Setup" screen.
  6. Make a note of which of the four things happened, then issue xm destroy vmname to shut down the new virtual machine

  7. Make the following changes to /etc/xen/vmname:

    • Change the line apic=1 to apic=0

    • Change the line acpi=1 to acpi=0

    • Add file:/var/lib/xen/images/vmname-install.iso,hdb:cdrom,r', to the list in the line disk = [ ... ]

    • Add the line boot = 'd' (preferably after the line disk = [ ... ], but it shouldn't really matter)

    • Change the line on_reboot = 'restart' to on_reboot = 'destroy' (this will ensure that Windows doesn't restart during setup without our intervention, which will be required for ACPI support in the guest to be set up properly)

  8. Re-launch the virtual machine with xm create vmname

  9. Run through the normal Windows setup process. Notes:
    • Format the new partition as NTFS (Quick)
  10. When Setup tries to reboot, it will instead be shut down. Don't panic, this is intentional and was created by the line on_reboot = 'destroy' that we modified in the config file

  11. Make the following changes to /etc/xen/vmname:

    • Change the line apic=0 to apic=1

    • Change the line acpi=0 to acpi=1

    • Change the line boot = 'd' to boot = 'c'

    • Change the line on_reboot = 'destroy' to on_reboot = 'restart'

  12. Continue the setup process by restarting the virtual machine with xm create vmname`

  13. Run through the rest of the normal Windows setup process. Notes:
    • Add the machine to the domain
    • (other notes TBA)
  14. Install TightVNC in the guest so that you can access the guest remotely
  15. Shut down the virtual machine (from within Windows, not via xm)

  16. So that the virtual machine can start while we are not logged into the physical machine, make the following changes to /etc/xen/vmname:

    • Change the line vnc=0 to vnc=1

    • Change the line sdl=1 to sdl=0

  17. Boot the virtual machine with xm create vmname

  18. If successful, the virtual machine will not show a display, but will show up in the results of xm list and you can connect to it with vncviewer, TightVNC, etc.

If something goes wrong and you can't connect via VNC or rdesktop, you can use virt-manager (aka Applications → System Tools → Virtual Machine Manager) to connect directly to the virtual machine's console and see what it's doing.

HowToXenWindowsOnCentOS5 (last edited 2007-07-29 08:01:38 by SirMsquared)