I found a tutorial on Reddit which I have not seen being discussed around here that much (if at all). It explains how to make use of input event devices inside virtual guests using qemu and VirtIO drivers (optional).
I would like to know if you are familiar with it or if you even use it right now. I have followed the steps on Reddit and it works outstandingly well with one exception… My mouse, once grabbed, does not react on the left + right Ctrl shortcut which switches your devices between host and guest. It is stuck on my Windows guest and I can’t figure out what’s wrong.
I have tried two mice at this point, one wired and one wireless mouse. Maybe you guys have an idea.
My config (Updated):
- Added myself it the group ‘input’
$ ls -l /dev/input/by-id/*-event-*
lrwxrwxrwx 1 root root 9 4. Dez 13:09 /dev/input/by-id/usb-Kingston_HyperX_Alloy_FPS_Mechanical_Gaming_Keyboard-event-kbd -> ../event4
lrwxrwxrwx 1 root root 9 4. Dez 13:09 /dev/input/by-id/usb-Kingston_HyperX_Alloy_FPS_Mechanical_Gaming_Keyboard-if01-event-mouse -> ../event5
lrwxrwxrwx 1 root root 9 4. Dez 13:14 /dev/input/by-id/usb-Logitech_USB_Receiver-if02-event-mouse -> ../event6
/etc/libvirt/qemu.conf:
cgroup_device_acl = [
"/dev/input/by-id/usb-Kingston_HyperX_Alloy_FPS_Mechanical_Gaming_Keyboard-event-kbd",
"/dev/input/by-id/usb-Kingston_HyperX_Alloy_FPS_Mechanical_Gaming_Keyboard-if01-event-mouse",
"/dev/input/by-id/usb-Logitech_USB_Receiver-if02-event-mouse",
"/dev/null", "/dev/full", "/dev/zero",
"/dev/random", "/dev/urandom",
"/dev/ptmx", "/dev/kvm", "/dev/kqemu",
"/dev/rtc","/dev/hpet", "/dev/vfio/vfio"
]
Libvirt guest config XML:
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
...
<devices>
...
<input type='keyboard' bus='virtio'>
<address type='pci' domain='0x0000' bus='0x0d' slot='0x00' function='0x0'/>
</input>
<input type='mouse' bus='virtio'>
<address type='pci' domain='0x0000' bus='0x0f' slot='0x00' function='0x0'/>
</input>
...
</devices>
...
<qemu:commandline>
<qemu:arg value='-object'/>
<qemu:arg value='input-linux,id=mouse1,evdev=/dev/input/by-id/usb-Logitech_USB_Receiver-if02-event-mouse'/>
<qemu:arg value='-object'/>
<qemu:arg value='input-linux,id=kbd1,evdev=/dev/input/by-id/usb-Kingston_HyperX_Alloy_FPS_Mechanical_Gaming_Keyboard-if01-event-mouse,grab_all=on,repeat=on'/>
<qemu:arg value='-object'/>
<qemu:arg value='input-linux,id=kbd2,evdev=/dev/input/by-id/usb-Kingston_HyperX_Alloy_FPS_Mechanical_Gaming_Keyboard-event-kbd,grab_all=on,repeat=on'/>
<qemu:env name='QEMU_AUDIO_DRV' value='pa'/>
<qemu:env name='QEMU_PA_SERVER' value='/run/user/1000/pulse/native'/>
</qemu:commandline>
</domain>