Qemu Windows Xp Installation

Table of Contents

Installing Windows XP

Product Key: MRX3F-47B9T-2487J-KWKMF-RPWBY

Here's the shell script to start the installation. Windows XP will automatically search through the virtio.vfd floppy image when locating the storage drivers. That floppy image has all the drivers your networking, virtual display, virtio, etc. Mouse input and networking won't work until after you're logged in.

  qemu-system-x86_64 \
      -enable-kvm \
      -cpu host -smp 4 \
      -m 3G \
      -boot d \
      -cdrom  "WINDOWSXP.iso" \
      -fda "VIRTIO.vfd" \
      -vga qxl \
      -spice port=55555,addr=0.0.0.0,disable-ticketing \
      -chardev spicevmc,id=vdagent,name=vdagent \
      -device virtio-net,netdev=netdevice -netdev user,id=netdevice,smb=$HOME \
      -drive file=windowsxp.qcow2,if=virtio,cache=none,aio=native

After you run that, use a spice client to connect to the VM. I use spice-gtk.

Installing Mouse Drivers

When you log in, WindowsXP is going to open a wizard that lets you automatically add new hardware. Use your keyboard to go through these prompts. This step is important since it will install the drivers to get your mouse working

After that's done, poweroff the VM and replace your qemu shell script with the following:

qemu-system-x86_64 \
	-enable-kvm \
	-daemonize \
	-cpu host -smp 4 \
	-m 3G \
	-device virtio-net,netdev=netdevice -netdev user,id=netdevice,smb=$HOME \
 	-fda "VIRTIO.vfd" \
	-usb \
	-device ich9-usb-ehci1,id=usb \
	-device ich9-usb-uhci1,masterbus=usb.0,firstport=0,multifunction=on \
	-device ich9-usb-uhci2,masterbus=usb.0,firstport=2 \
	-device ich9-usb-uhci3,masterbus=usb.0,firstport=4 \
	-chardev spicevmc,name=usbredir,id=usbredirchardev1 \
	-device usb-redir,chardev=usbredirchardev1,id=usbredirdev1 \
	-chardev spicevmc,name=usbredir,id=usbredirchardev2 \
	-device usb-redir,chardev=usbredirchardev2,id=usbredirdev2 \
	-chardev spicevmc,name=usbredir,id=usbredirchardev3 \
	-device usb-redir,chardev=usbredirchardev3,id=usbredirdev3 \
	-vga qxl \
	-spice port=55555,disable-ticketing \
	-usbdevice tablet \
	-device virtio-serial \
	-chardev spicevmc,id=vdagent,name=vdagent \
	-device virtserialport,chardev=vdagent,name=com.redhat.spice.0 \
	-drive file=windowsxp.qcow2,if=virtio,cache=none,aio=native

You really only need to remove your WindowsXP iso, but I added more qemu arguemnts to enable USB redirection in spice-gtk.

Installing Ethernet and Display Drivers

Open up a command prompt and type "devmgmt.msc" to open the Device Manager. Under "Unknown Devices", right click each item to open the properties, then re-install the driver. Since our VIRTIO.VFD file is still attached, Windows XP will automatically install the drivers for the networking, display, etc.

Sharing HOST folder through SMB

In the shell snippets above, I have smb=$HOME added to expose my home folder as an SMB share on the guest. Qemu will use a newer version of SMB that Windows XP wont support, causing the whole thing to be broken. To fix this, we have to edit Qemu's temporary SMB.CONF file while the Virtual Machine is booting up.

Add the sed command to the bottom of your Qemu shell script. When Windows XP boots up, you should be able to access your files using this UNC path: \\10.0.2.4\qemu

  qemu-system-x86_64 \
      -daemonize...

  # Fixing SMB
  sed -e 's/\[qemu\]/min protocol = NT1\n\[qemu\]/' -i /tmp/qemu-smb.*/smb.conf