No Cursor When Passing Through Mouse Events On Spice + VirtIO GPU In Libvirt

I’m using Libvirt via Virt Manager but with custom entries to my VM’s XML which Virt Manager can’t generate on its own. I’m using the VirtIO GPU and sending its output to the Spice display built in to Virt Manager. I’m trying to run games which capture the mouse. I’m able to get these working well enough using evdev passthrough with the following custom devices:

<input type="evdev">
  <source dev="/dev/input/by-id/MOUSE_NAME"/>
</input>
<input type="evdev">
  <source dev="/dev/input/by-id/KEYBOARD_NAME" grab="all" repeat="on"/>
</input>

Of course the device names are set to the actual devices I’m using. This works well, but even when not being captured, the VM renders no cursor at the actual position of the pointer. I can move the pointer. Hover animations on GUI elements work and I can click on them fine. There is just no graphical cursor. I get around this now by using the VirtIO tablet as a second input. Evdev inputs allow me to switch back and forth between the VM and host by pressing both Ctrl buttons, so I can switch to the host to then send inputs through the tablet. This is usable, but it’s not just that I want the Evdev inputs in game and the tablet inputs otherwise. Even in games it’s difficult to use the Evdev inputs when the cursor is released to interact with an inventory, an in game menu, etc. and cumbersome to have to switch to the tablet every time I need to do this. I’d like to find the correct way to tell Spice/VirtIO/X/whichever is hiding the cursor to not do so. In searching, I found that I could add <mouse mode="server"/> to my Spice configuration, which someone claimed tells Spice to render the cursor on the VM, but the cursor is still invisible when using Evdev, and still rendered on the host when using the tablet. Thank you for your time if you’ve read all this.

The latest looking glass beta added support for using the virtual display. Gaming is one of looking glasses core features, so it can capture the mouse (with Scroll Lock). Maybe that will work better for your use case? (No idea if looking glass works with only a virtual display though).

Otherwise do you have any issues with the regular spice mouse? If you disable the tablet, and only use the mouse, you should get regular capture behaviour.

Thank you for your reply cowphrase. I was under the impression that looking glass was only for VMs with passed through GPUs, and even then only supported some of them, it’s been a while since I’ve looked at it though, I’ll see if I can use it. In the mean time, I believe you’re referring to the various relative movement mouse types including the VirtIO mouse, USB mouse, and PS/2 mouse, all of which capture the mouse when the Spice display is clicked and release it by pressing LCtrl + LAlt on the keyboard. Please correct me if I am wrong. These inputs work with mouse capturing games and render the cursor on the host (regardless of the mouse mode still as mentioned above with tablet input). The problem is these mice stutter rapidly with any movement, jumping back and forth between their currently location and where they’re moving to. There’s a fraction of a second of lag before they start moving, easily enough to be noticeable in game, and when moved far enough, they begin to lag far behind as if the inputs are building up in a buffer and slowly flushing to the VM. Moving the mouse enough will result in the pointer falling seconds behind. None of these are graphical glitches, they translate to stuttering and delayed movements in game that don’t exist using Evdev or direct USB passthrough, the latter of which I have also tried, but it has the same problems as Evdev.

1 Like

Unfortunately it seems that Looking Glass doesn’t support the VirtIO GPU, or at least I can’t find any documentation on how to set it up this way. I still haven’t found a good solution, open to suggestions from anyone.