(11.Apr.2011)
Some short notes about setting up a Windows VM (Windows XP and Windows 7) with "better" video and disk performance.
Index
In the case of the disks you want to use the virtual IO functionality of KVM.
You can download the iso-image of the drivers from linux-kvm.com (choose on the left the link "cdrom image" under the "Windows Guest Drivers").
If you have installed Windows XP or Windows 7 without using the virtio drivers (e.g. you didn't have the drivers available at that point) you'll have to enable them in a 2-step procedure.
After having downloaded the iso-image of the drivers, create a dumb file on your host (with e.g. "dd if=/dev/zero of=dumb.file bs=1M count=100") and start the VM with this file as a new drive having the virtio feature enabled, plus the iso-image in normal mode.
The shell script / command would look as follows:
kvm \
-vga std \
-hda /mydirectory/my-windows-os.img \
-cdrom /mydirectory/virtio-kvm-downloaded.img \
-drive file=/mydirectory/dumb.file,if=virtio,cache=writeback \
-usb -usbdevice tablet \
-soundhw ac97 \
-boot c \
-m 1024 -smp 2 \
-net nic,model=rtl8139,vlan=0,macaddr=DE:AD:BE:EF:40:64 \
-net tap,vlan=0,script=no,downscript=no,ifname=tap0
- The line "-hda /mydirectory/my-windows-os.img \" specifies the Windows OS - dependent on your setup.
- The line "-cdrom /mydirectory/virtio-kvm-downloaded.img \" is the one that specifies the virtio-drivers you just downloaded from the KVM site.
- The line "-drive file=/mydirectory/dumb.file,if=virtio,cache=writeback \" specifies a new drive which uses "virtio" as interface. I use "cache=writeback" because the new standard setting of KVM ("writethrough"?) gives me problems from time to time - up to you to decide which one to use.
Start at this point Windows and you should see that it sees the new device (the dumb file) but it doesn't have any drivers able to handle it. If you don't get a prompt go to the control panel/device manager and select "Update driver..." by right-clicking on the drive. At this point select the cdrom-device and go to the "virtio" subdirectory of your windows version and install.
Once it's done and Windows is happy, shutdown the VM and re-edit the command / shell script:
kvm \
-vga std \
-drive file=/mydirectory/my-windows-os.img,if=virtio,cache=writeback \
-usb -usbdevice tablet \
-soundhw ac97 \
-boot c \
-m 1024 -smp 2 \
-net nic,model=rtl8139,vlan=0,macaddr=DE:AD:BE:EF:40:64 \
-net tap,vlan=0,script=no,downscript=no,ifname=tap0
- Deleted the cdrom and dumb.file lines.
- I set "-drive file=/mydirectory/my-windows-os.img,if=virtio,cache=writeback \" for windows to use its C-drive using the virtio interface.
That's it - if you restart now your VM you should see "Red Hat VirtIO SCSI Disk Device" in the Device Manager for your C-drive.
The VMware video driver is much faster then the others.
Edit therefore your command / shell script to use "-vga vmware" instead of "-vga std" or whatever you were using.
Starting the VM with this option should still work even if you didn't install yet the drivers in the VM.
Download the driver images.
- Windows XP
If you're using Windows XP in the VM you can download the images directly from here (under the "Attachment" section). You then mount the file as a normal cdrom as I mentioned below and perform a normal driver installation. - Windows 7
If you're using Windows 7 or if you're using another version of Windows or if you get while installing the drivers an error message saying that they're not for your specific Windows version or if the above link does not work anymore you'll have to get the drivers directly from VMware. This is a bit more complicated:
-
- Go to the VMware site, navigate to "Support & Downloads => VMware Workstation", click on the "Download" button on the right of the line "VMware Workstation 7 for Linux", insert your email and pwd (you have to register using a valid email-address but otherwise it's for free), accept the terms and download the Linux 32/64-bit .bundle of the "VMware Workstation for Linux 32/64-bit with VMware Tools" (choose your 32 or 64-bit version).
- Once you have downloaded the big file mark it as executable (e.g. "chmod 777 VMware-Workstation-Full-7.1.4-385536.x86_64.bundle").
- Extract the contents of the big file to some temporary directory using the "-x" option (e.g. "./VMware-Workstation-Full-7.1.4-385536.x86_64.bundle -x /home/myuser/mytempdir").
- Go to the temporary directory and search the subdirectory "vmware-tools-windows". In that directory you should find a file called something like "windows.iso".
- Copy the file "windows.iso" to where you have your VM files.
Modify the configuration file to attach that windows.iso file as a new drive:
kvm \
-vga vmware \
-drive file=/mydirectory/my-windows-os.img,if=virtio,cache=writeback \
-cdrom /mydirectory/windows.iso \
-usb -usbdevice tablet \
-soundhw ac97 \
-boot c \
-m 1024 -smp 2 \
-net nic,model=rtl8139,vlan=0,macaddr=DE:AD:BE:EF:40:64 \
-net tap,vlan=0,script=no,downscript=no,ifname=tap0
- I attached the windows.iso as a normal cdrom on the line "-cdrom /mydirectory/windows.iso \".
- The KVM setting for vmware is already in place with "-vga vmware".
The last steps:
- Start up Windows 7 (I am using Windows 7 Home Premium edition).
- Running the file "setup.exe" directly from the cdrom did not work in my case - I got all the time an error message saying "the vmware tools should only be installed inside a virtual machine". Probably the installer checks if the VM is running under VMware - but in my case I was using KVM :o)
- To solve the problem with the nasty installer open a command shell and run "setup /a" which will prepare a so-called "server-image". Set as destination directory anything which does not yet exist - e.g. "C:\whatever" and click on "Install". The video drivers you are looking for will then be in that directory.
- Go to the device manager,
right-click on your standard vga under "Display adapters",
choose "Update driver software",
select to browse your computer, choose to let you pick a driver instead of performing a search on the CD-ROM,
choose "Have a disk", navigate to "C: => whatever => Common64 (or just "Common" if your version is 32bit) => VMware => Drivers => video" and choose the "vmx_svga" file.
This should install a "VMware SVGA II" adapter. The other one - the WDMA-something-driver, which is optimized as well for 3D, didn't work under KVM and probably works only under a VMware host. - Done - your display should now be a bit quicker :o)