Monthly Archives: March 2014

qemu and usb-tablet cpu consumtion

It’s a long standing problem that the qemu cpu consumtion goes up when you hook up a usb-tablet to your virtual machine to get a absolute pointing device. The underlying problem is that the usb host adapter by design polls the usb devices. The hardware design of the uhci, ohci and ehci usb host adapters pretty much forces qemu to do the same polling when emulating the host adapter, which is where the cpu consumption comes from.

There are a few ways to tackle the problem.

Number one is using the xhci host adapter emulation. xhci has a radically different hardware design, which allows to emulate it with noticeable less cpu overhead compared to uhci and ehci. Unfortunately only win8+ ships with xhci support, so that doesn’t fly for older windows versions.

Number two is remote wakeup. When usb devices support remote wakeup the usb host adapter can suspend the usb device (i.e. stop polling for events). The usb device will signal a wakeup request when it has new events to deliver and wants the usb host adapter resume polling to deliver the new events. The purpose of this mechanism is to save power. It also reduces the cpu consumption of the usb emulation in qemu. Unfortunately remote wakeup support often is broken in usb devices (that includes usb hid device emulation in qemu up to version 0.12), and operating systems do not enable remote wakeup by default because of that.

For linux guests the problem is long solved. udev got some rules (see 42-usb-hid-pm.rules) to enable remote wakeup for the usb hid devices emulated by qemu a few years ago, so on any recent linux distro the usb tablet will be suspended when idle.

For windows guests the upcoming qemu 2.0 release has improvements, qemu got support for Microsoft OS Descriptors. They can be used to turn on remote wakeup by default on windows guests. There are a few obstacles through. First is that it is turned of for compatibility reasons on older machine types, so make sure you are using a 2.0 machine type (pc-i440fx-2.0 or pc-q35-2.0), otherwise you don’t get this. Second is that windows checks for Microsoft OS Descriptors only once, then caches the result in the registry. Therefore existing windows guest image will not notice without manual invention. Deleting these two registry subtrees …

  • HLM\SYSTEM\CurrentControlSet\Control\usbflags
  • HLM\SYSTEM\CurrentControlSet\Enum\USB

… and rebooting should do the trick. Windows will re-detect the usb devices and should enable remote wakeup support for the usb-tablet. You can verify this using the device manager:


If the “Power Management” tab is present and “Allow the computer to turn off this device to save power” is checked everything is fine.

Update: qemu 2.0 has been released on April 17th, 2014.