Szymon Niedźwiedź 2023/11/14

Wireless mouse issues on Libvirt/QEMU based VMs

There are problems with event device (mouse, keyboard) support in Libvirt/QEMU.

  1. Mouse cannot be reconnected
  2. When mouse is not connected, VM won’t start, XML must be modified, this is not practical.


I created proxydev which is simple Linux C program which allows to pass all event devices at one after configuring single file and allows to add simple keyboard macros. This allows bluetooth mouse hot-plug support.

Libvirt part

  1. Install proxydev from AUR
  2. Configure /etc/proxydev/config.toml
  3. Run systemctl enable --now proxydev.service to start now and enable service on system boot
  4. Configure xml inside vm
<domain xmlns:qemu="" type="kvm">
  <!-- start of relevant part -->
    <qemu:arg value="-object"/>
    <qemu:arg value="input-linux,id=input1,evdev=/dev/input/by-id/proxydev,grab_all=yes,repeat=on"/>
  <!-- end of relevant part-->

Give libvirt/QEMU access to input devices.

QEMU needs to access to /dev/input/by-id/proxydev device so it will be added to input group, otherwise machine start-up fails.

# usermod -aG input libvirt-qemu

User Experience

When using Looking Glass usually i had use two key-combinations CTRL+CTRL for QEMU to grab proxydev and NUMLOCK+F to maximize Looking Glass window. In order to make this experience better i added two macros. When user presses F11 - CTRL+CTRL is actually pressed and when user presses F12, then NUMLOCK+F is pressed. I never had to use these keys so i hardcoded them for VM activities.

enable disqus comments