Saturday, March 7, 2009
How do I improve mouse tracking in a virtual machine?
The mouse cursor in virtual machines under Red Hat Enterprise Linux 5 does not track well with the actual mouse movements. This is because mouse drivers expect relative motion deltas. For example, the mouse moved up and right one centimeter, but the virtual machine console sends absolute coordinates. The conversion from absolute coordinates to relative deltas is an approximation. As errors in the approximations accumulate, the virtual cursor drifts farther and farther from the host cursor.
One solution to this problem is to switch from a virtual mouse to a virtual tablet. A tablet sends absolute coordinates instead of relative motion deltas, so no conversion is necessary. See the instructions below to enable a virtual tablet.
Another solution is to switch from a VNC console to an SDL console, however, the SDL console has its own set of problems: it does not work with the Virtual Machine Manager (virt-manager), and if you close the SDL console, it immediately kills the virtual machine, possibly resulting in data loss.
Enabling a Virtual Tablet
1. Launch the Virtual Machine Manager (virt-manager).
2. If the virtual machine is running, turn it off.
3. Select the virtual machine, then click Details. In the Hardware tab, click Add. For Hardware type, choose Input Device and click Forward. For Type, select the "EvTouch USB Graphics Tablet", click Forward, and click Finish. Alternately, on the host (dom0) system, open the /etc/xen/virtual-machine-name file with your favorite text editor and add the following line at the bottom of the file:
usbdevice = 'tablet'
4. Turn on the virtual machine.
5. If necessary, switch to a text console: using the Virtual Machine Manager console, go to the Send Key menu and click CTRL-ALT-F1.
6. Log in to the virtual machine as root.
7. Switch to run level 3 (to disable X Windows) by running init 3:
[root@hostname ~]# init 3
8. Run the following command to find the name of the event for the tablet:
[root@hostname ~]# egrep 'Name|Handlers' /proc/bus/input/devices | grep -i -A 1 tablet
N: Name="QEMU 0.8.2 QEMU USB Tablet"
H: Handlers=mouse1 event2 js0
9 . Open /etc/X11/xorg.conf with your favorite text editor. If necessary, add the following InputDevice line to the ServerLayout section:
Section "ServerLayout"
...
...
InputDevice "Mouse0" "CorePointer"
EndSection
Then, create a new InputDevice section:
Section "InputDevice"
Identifier "Mouse0"
Driver "evdev"
Option "Device" "/dev/input/event2"
Option "Name" "QEMU 0.8.2 QEMU USB Tablet"
Option "Mode" "Absolute"
EndSection
For the Device and Name values, use the eventX value ("event2" in this case) and name found in the previous step.
10. Restart X Windows and exit the root shell by running
[root@hostname ~]# init 5; exit
The mouse tracking should be much more accurate now.
One solution to this problem is to switch from a virtual mouse to a virtual tablet. A tablet sends absolute coordinates instead of relative motion deltas, so no conversion is necessary. See the instructions below to enable a virtual tablet.
Another solution is to switch from a VNC console to an SDL console, however, the SDL console has its own set of problems: it does not work with the Virtual Machine Manager (virt-manager), and if you close the SDL console, it immediately kills the virtual machine, possibly resulting in data loss.
Enabling a Virtual Tablet
1. Launch the Virtual Machine Manager (virt-manager).
2. If the virtual machine is running, turn it off.
3. Select the virtual machine, then click Details. In the Hardware tab, click Add. For Hardware type, choose Input Device and click Forward. For Type, select the "EvTouch USB Graphics Tablet", click Forward, and click Finish. Alternately, on the host (dom0) system, open the /etc/xen/virtual-machine-name file with your favorite text editor and add the following line at the bottom of the file:
usbdevice = 'tablet'
4. Turn on the virtual machine.
5. If necessary, switch to a text console: using the Virtual Machine Manager console, go to the Send Key menu and click CTRL-ALT-F1.
6. Log in to the virtual machine as root.
7. Switch to run level 3 (to disable X Windows) by running init 3:
[root@hostname ~]# init 3
8. Run the following command to find the name of the event for the tablet:
[root@hostname ~]# egrep 'Name|Handlers' /proc/bus/input/devices | grep -i -A 1 tablet
N: Name="QEMU 0.8.2 QEMU USB Tablet"
H: Handlers=mouse1 event2 js0
9 . Open /etc/X11/xorg.conf with your favorite text editor. If necessary, add the following InputDevice line to the ServerLayout section:
Section "ServerLayout"
...
...
InputDevice "Mouse0" "CorePointer"
EndSection
Then, create a new InputDevice section:
Section "InputDevice"
Identifier "Mouse0"
Driver "evdev"
Option "Device" "/dev/input/event2"
Option "Name" "QEMU 0.8.2 QEMU USB Tablet"
Option "Mode" "Absolute"
EndSection
For the Device and Name values, use the eventX value ("event2" in this case) and name found in the previous step.
10. Restart X Windows and exit the root shell by running
[root@hostname ~]# init 5; exit
The mouse tracking should be much more accurate now.
Labels:
configuration,
desktop,
redhatenterpriselinux5,
virtualization
Subscribe to:
Post Comments (Atom)

1 comments:
Excellent tip on fixing the mouse tracking! This worked perfectly with RHEL5.4 except that the device name was a little different: "QEMU 0.9.1 QEMU USB Table".
Thanks!
Iggy
Post a Comment