Wireless mouse issues on Libvirt/QEMU based VMs
There are problems with event device (mouse, keyboard) support in Libvirt/QEMU.
- Mouse cannot be reconnected
- When mouse is not connected, VM won’t start, XML must be modified, this is not practical.
Solution
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
- Install proxydev from AUR
- Configure
/etc/proxydev/config.toml
- Run
systemctl enable --now proxydev.service
to start now and enable service on system boot - Configure xml inside vm
<domain xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0" type="kvm">
<devices>
...
</devices>
<!-- start of relevant part -->
<qemu:commandline>
<qemu:arg value="-object"/>
<qemu:arg value="input-linux,id=input1,evdev=/dev/input/by-id/proxydev,grab_all=yes,repeat=on"/>
</qemu:commandline>
<!-- end of relevant part-->
</domain>
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.