In this section, we'll explore how to share a locally attached input device with a guest virtual machine.
As of libvirt version 7.4.0, the Linux evdev event interface can be used to share an input device physically attached to the host with a guest, in a low-latency manner.
Before sharing an input device, follow these steps:
if
in their name, including those containing event
in their name:ls /dev/input/by-id/* | grep event | grep -v if
This command should output the names of eligible devices.
Example output:
/dev/input/by-id/usb-Corsair_CORSAIR_HARPOON_RGB_PRO_Gaming_Mouse_1902B02BAF5E04655DEB612AF5001C05-event-mouse
/dev/input/by-id/usb-Logitech_G513_RGB_MECHANICAL_GAMING_KEYBOARD_156930783132-event-kbd
/dev/input/by-id/usb-Logitech_USB_Keyboard-event-kbd
/dev/input/by-id/usb-Logitech_USB_Optical_Mouse-event-mouse
cat /dev/input/by-id/usb-Logitech_G513_RGB_MECHANICAL_GAMING_KEYBOARD_156930783132-event-kbd
This step ensures you're working with the desired input device.
��c $
��c���c���c�$��c�$��c��c��c
<input type='evdev'>
<source dev='/dev/input/by-id/usb-Logitech_G513_RGB_MECHANICAL_GAMING_KEYBOARD_156930783132-event-kbd' grab='all' repeat='on'/>
</input>
Once the virtual machine is started, the input device will be captured by the guest system.
Press Left Ctrl + Right Ctrl simultaneously to switch your devices between the guest and the host.