After installing a Windows XP under KVM today, I was wondering if there were any guest tools available for KVM, like virtually every other virtualization (VMware, VBox, even Xen) system provides them. The good news is, there are drivers available, at least for speeding up network and harddisk access, but none for graphics though.

The bad news for me, though, was the fact, that the harddisk driver should be added during Windows installation, and not afterwards. But with a little trick, switching the driver after installation works as well. This is archived by adding a second temporary disk to the setup, which uses the KVM drivers.

So in detail, consider your KVM command line, which should contain something similar to this:

-drive file=WinXp.qcow,if=ide,boot=on

The if=ide part tells qemu to use the standard IDE drivers, which emulate an Intel IDE controller. A simple switch to if=virtio would result in an unbootable machine, as Windows would have no drivers to access the disk.

So for the workaround, we are going to create another (small) disk and inject it. First of all, you need to download the viostor drivers, either from the original homepage or (better still for our needs) packed as an ISO file.

Now, put the ISO into the folder that contains the disk file(s) for your KVM machine, open a terminal in that directory and type:

# qemu-img create temp.qcow 1MB

This will create an image of 1MB with the name temp.qcow. Now assuming that the ISO you downloaded is named NetKVM-and-viostor.iso, type in your regular KVM command to fire up the virtual machine and append the following:

-drive file=temp.qcow,if=virtio,boot=off -cdrom NetKVM-and-viostor.iso

This will add another harddrive to your machine, which requires the viostor drivers. Also, the ISO containing the needed drivers is inserted as a CD drive.

Once the machine has started, Windows will query you for drivers needed to communicate with the new disk. Install the drivers from the CD and shutdown the machine. Now you can delete the temporary image, remove the added parameters from above and replace the parameter containing your hard disk with

-drive file=WinXp.qcow,if=virtio,boot=on

As Windows has already installed the drivers, it will know how to communicate with the disk. From now on, disk access should be faster.

Oh, by the way, changing the network interface to use virtio drivers is a lot easier, you just need to replace

-net nic

in your command with

-net nic,model=virtio

Again, Windows will ask you for drivers, since they are in the same ISO you can just as well install them while you’ve got the CD mounted.