CentOS7: KVM: error: Cannot create user runtime directory '/run/user/0/libvirt': Permission denied
By default non-root users cannot access libvirtd directly, unless explicitly granted authorization.
I've done this using PolicyKit:
# cat /etc/polkit-1/rules.d/50-org.libvirt.unix.manage.rules
polkit.addRule(function(action, subject) {
if (action.id == "org.libvirt.unix.manage" &&
subject.user == "nrpe") {
return polkit.Result.YES;
polkit.log("action=" + action);
polkit.log("subject=" + subject);
}
});
This will let user nrpe
do whatever they want to do with libvirtd without requiring a password.
Second, non-root users need to specify the connection URL explicitly in order to access the system libvirtd.
virsh --connect qemu:///system list --all