Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KVM - failed to connect to the hypervisor error

I am trying to run kvm, but this error occurs:

$ virsh -c qemu:///system list
error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied
error: failed to connect to the hypervisor

So I enter to:

cd /var/run/libvirt/

and changed privilages by:

sudo chmod -R +777 libvirt

Everything is working now, but I have concerns about security issues, as privileges for all users and groups is not the safest way to do it? What could you recommend instead?

like image 724
Linux In Practice Avatar asked Dec 10 '25 17:12

Linux In Practice


2 Answers

Add your user to the kvm and libvirtd groups:

sudo usermod -aG kvm $USER
sudo usermod -aG libvirt $USER

After these group changes you have to logout/login the terminal you are using to have the changes taken into account. The groups you belongs to, can be check with the groups command.

like image 170
jeremf Avatar answered Dec 13 '25 07:12

jeremf


I think

sudo usermod -aG libvirt $USER

is the correct command

like image 44
Syed Rizvi Avatar answered Dec 13 '25 05:12

Syed Rizvi