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.

    - 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
    - SUSE Linux Enterprise Server 12 SP1
    - kernel 3.12.49-11-default
    - video QXL / Spice
    - gnome-shell-3.10.4-40.1.x86_64

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

     # Change the resolution
     XRANDR=`which xrandr`
     $XRANDR --output $SCREEN --mode 1280x720
     sleep 1
     $XRANDR --output $SCREEN --mode 1280x800

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

     [Desktop Entry]
     GenericName=Changing resolution
     Comment=To change the resolution in Gnome session 

Now when I login to Gnome session the 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.