Creating Shortcut

If you notice virsh always requires root permission due to the access to libvirt and kvm. When it comes to creating shortcut for non-root user, you're stuck.

Handling Root Permission Issue

To overcome the root permission request (e.g. sudo password), what you need is to export the LIBVIRT_DEFAULT_URI variable for that user.

$ export LIBVIRT_DEFAULT_URI=qemu:///system

This way, when virsh picks up the environment variable, it knows which qemu URI to interface with.

Creating Shortcut File

With that in mind, you need to create a standard Linux shortcut file, something like the following example. Of course, please replace YOUR_VM_NAME to your actual VM name.

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=bash -c "export LIBVIRT_DEFAULT_URI=qemu:///system && virsh start YOUR_VM_NAME && virt-viewer YOUR_VM_NAME &"
Name=My Shortcut Name
Comment= My VM Quick Launch
Icon=/path/to/image.png

That's all about it!