An issue of rodent locations…

July 5, 2011

For a while now, I’ve been using KVM on my Ubuntu server for all sorts of things.  Once I got it running, it was really quite slick.  This post, however, isn’t about the merits of KVM as a virtualization platform.

One of my virtual PCs is a Windows XP Home instance which I use when I need to try something on a Windows PC that’s not Windows 7.  Because the KVM server sits in a closet with no console, I use the -vnc flag to have KVM start a VNC server attached to the virtual PC’s console. The performance of this connection far outstrips that of a VNC server running on the virtual PC (which only sort of works at all), plus it allows the user to see the virtual PC boot, enter safe mode or even install an operating system, if that’s what you’re up to.

Until recently, I’d always had issues with the mouse on this “VNC Console”. Specifically, it was like the remote pointer didn’t track properly when mouse acceleration was enabled on the controlling PC.  This weekend, I got sick of chasing the mouse pointer around the screen (accelerating it to the edge of the screen, to get the client and server pointers realigned) and did some googling. I found a site whose url escapes me now that described my problem exactly, and suggested switching my mouse driver to “tablet” (connected via a virtual USB port), which uses absolute positioning to align the mouse. I made the change, as described below, and my mice now align perfectly!  One interesting side effect of “tablet” mode is that I find that you have to hold the mouse button briefly when clicking. Most people would probably never notice this, but I tend to click pretty quickly. I blame the caffeine completely.

Example

Because I’m a bit lazy (And don’t have an X server on the computer at all), I start my VMs manually from the command line.  My startup command now looks like this (changes in bold)

kvm -hda ‘/path/to/disk.img‘ -boot c -m 1024 -vnc ipaddress:port,password -usb -usbdevice tablet -net nic,macaddr=mymac -net tap &

The -usb is an important change because, in my initial setup, I had USB completely disabled, as I wasn’t using it for anything.  The KVM/QEMU forums say that USB passthrough is still a development feature, and as such may use more than its fair share of resources.  In my (limited) experience, it seems to consume quite a bit more CPU with USB turned on; That said, this server does almost nothing in terms of CPU, so I’m not too worried.

Leave a Reply