sway
sway copied to clipboard
Mouse cursor is shown below its actual position in qemu
Please fill out the following:
-
Sway Version:
- sway version 1.6.1
-
Debug Log:
- https://gist.github.com/lilydjwg/c1f17305c017d89a8e03eaca4b6bfac6
-
Configuration File:
- default
-
Description:
In qemu virtual machine with spice display, the mouse cursor is
- pointing to 60px down from the actual position
- turned upside down
Running with WLR_NO_HARDWARE_CURSORS=1 will show a correct cursor alongside the wrong cursor.
The spice client is spicy and the monitor is a 4K one, but without any scaling configured in the virtual machine.
wayfire also has this problem. KDE (wayland session) doesn't have this problem.
Both host and guest machines are running recent Arch Linux.
This happens because wlroots is using the atomic KMS interface, which is lacking cursor hotspot support. This is a kernel limitation.
Some more info: I confirm the hotspot is indeed zero (as the SPICE client log says) compared to KDE which has a correct hotspot. But this shouldn't be too big an issue since the default cursor hotspot is only (4, 4). The bigger problem is that the cursor is upside down. This happens to all kinds of cursors. I didn't notice because the I beam looks the same. I realize that the various resize cursors are upside down too.
I'm also running into the same issue. Any updates on this or ways to fix this issue? I've tried many different combinations of QEMU configuration options but I've been unable to find a solution.
A workaround I've found in QEMU 6.1.0 is to toggle Grab Input (Ctrl+Alt+G), I'm currently running with -vga none -device virtio-vga-gl and using WLR_NO_HARDWARE_CURSORS=1
I tried to run with WLR_DRM_NO_ATOMIC=1 and update drmModeSetCursor with drmModeSetCursor2 which supports hotspots but nothing has changed.
Same issue for me in Proxmox VM with Arch Linux as Guest, and Sway 1.7
This bug also affects a Devuan (Debian without systemd) guest running swaywm 1.7 and wlroots 0.15.1 on a macOS M2 host, using UTM GUI frontend for QEMU + Spice. The WLR_NO_HARDWARE_CURSORS=1 environment variable does flip the mouse cursor to the correct orientation and position but is almost unusable because it is so laggy.
As OP mentions, there is no problem with KDE Wayland session; I'd also like to add that Weston does not suffer from this problem either, presumably because Weston does not use wlroots.
Also, as @emersion mentioned, wlroots is using Linux Kernel atomic KMS interface which doesn't (yet) support cursor hotspot however, there is a long discussion and patch series on the Linux Kernel mailing list about this:
https://lore.kernel.org/all/20220613104529.25fc650a@eldfell/T/
Anyone brave enough to test this? I'll attempt it myself soon....
EDIT: Ah, sorry @emersion, I've just noticed you are already an important part of that discussion!
I don't think this is a guest OS problem:
https://user-images.githubusercontent.com/6388823/200804565-3eb82fac-a513-4b31-ac7f-02ca1b9cd08d.mp4
I'm no expert, but I'd say this happens on the host (sway 1.7 / ubuntu 22.10 / virt-manager qemu kvm host; arch linux guest)
100% a guest OS problem. And it is because of the Linux Kernel KMS interface. See above.
But how is the guest OS drawing the mouse cursor when it's not even loaded?
Edit: had to take a pic with my phone as I wasn't able to screenshot the window with the cursor

Edit: another instance on a separate display not even over the guest OS window, happens for a couple hundred pixels after abandoning it

Any progress on that? I'm having the same problem but have no idea what I could help or fix it.
I switched to QXL to temporarily avoid this problem.
I cannot switch to QXL, I need VirtIO for 3d acceleration :slightly_frowning_face:
Any update on this? It's also affecting me
This is actually a qemu/kernel bug, see this for context: https://lore.kernel.org/dri-devel/[email protected]/
Yes, this is caused by a kernel bug. Both GNOME and KDE have a working workaround that does not using the atomic APIs, but wlroots' one doesn't work.
I can confirm that after applying the patches in this series to the latest kernel 6.7, the cursor is displayed correctly. Since it landed in drm-misc-next on 24.11. it's included in kernel 6.8 and will be available soon.
I tried the patchset with 6.6.14 with spicy as the SPICE client. The cursor is still inverted and misplaced. Is there other things I'm missing?
I don't really know, I'm using sway 1.8.1 in virt-manager with kernel 6.7.2 and it worked directly after upgrading the kernel.
OK, it worked for me, sort of. My qemu process needed a restart, and now I have two cursors: one with pointer shape and one with expected shape following the former tightly.
If there is a double cursor, that sounds like an hypervisor bug.
The wlroots issue tracking full virtualized cursor support is https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3776
Thanks. I doubt my wlroots build (0.17.0) contains that commit. I'll try to get an update soon.
There's no commit, it's an issue, a TODO.
I've cherry-picked the wlroots commit and seen DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT supported in the log. However, the cursor is still inverted.
I've cherry-picked the wlroots commit and seen
DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT supportedin the log. However, the cursor is still inverted.
What kernel version are you using?
host 6.6.14, vm 6.8.1.
host 6.6.14, vm 6.8.1.
I can reproduce the same using wlroots and sway '$HEAD'. Using kernel 6.8.2 for the guest.
This should be fixed with a recent kernel and https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4621.
I have both host and vm at 6.8.1 now and still can reproduce this issue.
I can reproduce the same issue. I have attached the output of sway -d. I compiled the master branch of sway and wlroots on the 24th March. As you can see from the log, sway is using atomic KMS and using DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT
https://gist.github.com/lewis262626/7715d52e08d928e30d25e675c787c45b
guest: Linux lewis-vm 6.8.1-2-aarch64-ARCH #1 SMP PREEMPT_DYNAMIC Wed Mar 20 09:56:17 MDT 2024 aarch64 GNU/Linux
host: Mac OS QEMU 7.2 using:
qemu-system-aarch64 -L /Applications/UTM.app/Contents/Resources/qemu -S -spice unix=on,addr=38FC4794-7C1E-4A3F-8735-F4190B386710.spice,disable-ticketing=on,image-compression=off,playback-compression=off,streaming-video=off,gl=on -chardev spiceport,id=org.qemu.monitor.qmp,name=org.qemu.monitor.qmp.0 -mon chardev=org.qemu.monitor.qmp,mode=control -nodefaults -vga none -device virtio-net-pci,mac=AE:D8:74:41:E8:A6,netdev=net0 -netdev vmnet-shared,id=net0 -device virtio-gpu-gl-pci -chardev spiceport,id=term0,name=com.utmapp.terminal.0 -serial chardev:term0 -cpu host -smp cpus=4,sockets=1,cores=4,threads=1 -machine virt -accel hvf -drive if=pflash,format=raw,unit=0,file.filename=/Applications/UTM.app/Contents/Resources/qemu/edk2-aarch64-code.fd,file.locking=off,readonly=on -drive if=pflash,unit=1,file=/Users/lewis/Library/Containers/com.utmapp.UTM/Data/Documents/Linux-btrfs.utm/Data/efi_vars.fd -m 4096 -audiodev spice,id=audio0 -device intel-hda -device hda-duplex,audiodev=audio0 -device nec-usb-xhci,id=usb-bus -device usb-tablet,bus=usb-bus.0 -device usb-mouse,bus=usb-bus.0 -device usb-kbd,bus=usb-bus.0 -device qemu-xhci,id=usb-controller-0 -chardev spicevmc,name=usbredir,id=usbredirchardev0 -device usb-redir,chardev=usbredirchardev0,id=usbredirdev0,bus=usb-controller-0.0 -chardev spicevmc,name=usbredir,id=usbredirchardev1 -device usb-redir,chardev=usbredirchardev1,id=usbredirdev1,bus=usb-controller-0.0 -chardev spicevmc,name=usbredir,id=usbredirchardev2 -device usb-redir,chardev=usbredirchardev2,id=usbredirdev2,bus=usb-controller-0.0 -device virtio-blk-pci,drive=drive8BDE1949-7083-4D3F-B2EF-9D25E12B715D,bootindex=0 -drive if=none,media=disk,id=drive8BDE1949-7083-4D3F-B2EF-9D25E12B715D,file=/Users/lewis/Library/Containers/com.utmapp.UTM/Data/Documents/Linux-btrfs.utm/Data/8BDE1949-7083-4D3F-B2EF-9D25E12B715D.qcow2,discard=unmap,detect-zeroes=unmap -device virtio-serial -device virtserialport,chardev=org.qemu.guest_agent,name=org.qemu.guest_agent.0 -chardev spiceport,id=org.qemu.guest_agent,name=org.qemu.guest_agent.0 -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 -chardev spicevmc,id=vdagent,debug=0,name=vdagent -name Linuxbtrfs -uuid 38FC4794-7C1E-4A3F-8735-F4190B386710 -device virtio-rng-pci