Allow users to run virsh and manage VMs


Defining custom rules requires creation of a file in the /etc/polkit-1/rules.d directory with a name chosen by the administrator (100-libvirt-acl.rules would be a reasonable choice). See the polkit(8) manual page for a description of how to write these files in general.

We're going to allow members of the libvirt group to manage VM's:

mkdir /etc/polkit-1/rules.d
vi /etc/polkit-1/rules.d/100-libvirt-acl.rules

polkit.addRule(function(action, subject) {
if ( == "org.libvirt.unix.manage" && subject.local && && subject.isInGroup("libvirt")) {
return polkit.Result.YES;

NB. Add to user's .bashrc:

export LIBVIRT_DEFAULT_URI=qemu:///system


Add bash completion library:

Download the bash completion library: virsh_bash_completion

How to use it: Copy virsh_bash_completion file to /etc/bash_completion.d/ then restart bash.