Saturday, October 1, 2016

Fedora 24: invisible mouse cursor after login to VM running on KVM.

Issue: In Fedora 24 after login into the VM running on a local host in KVM the mouse cursor becomes invisible.

Environment: 
Host
    - Fedora 24
    - kernel 4.7.4-200.fc24.x86_64
    - virt-manager-1.4.0-3.fc24.noarch
    - virt-viewer-4.0-1.fc24.x86_64
    - qemu-kvm-2.6.1-1.fc24.x86_64
VM
    - SUSE Linux Enterprise Server 12 SP1
    - kernel 3.12.49-11-default
    - video QXL / Spice
    - gnome-shell-3.10.4-40.1.x86_64

Solution:
I found that changing the screen resolution to a different value resolves the issue and mouse cursor becomes visible again.
To automate this workaround I wrote the following simple script named chres.sh:

     #!/bin/bash
     # Change the resolution
     XRANDR=`which xrandr`
     SCREEN="Virtual-0"
     $XRANDR --output $SCREEN --mode 1280x720
     sleep 1
     $XRANDR --output $SCREEN --mode 1280x800
     exit

I then created the autostart folder in ~/.config/ and added chres.sh to it and made it executable.
Finally, I created the following file in ~/.config/autostart/ named chres.desktop:

     [Desktop Entry]
     Name=chres
     GenericName=Changing resolution
     Comment=To change the resolution in Gnome session 
     Exec=/home/username/.config/autostart/chres.sh
     Terminal=true
     Type=Application
     X-GNOME-Autostart-enabled=true

Now when I login to Gnome session the chres.sh runs automatically changing quickly the resolution and resolving the issue, so the mouse cursor is immediately visible and available. 
If you have the same issue, you may need to check if the xrandr is installed in the same path and what is your default screen.


I hope this will help.