I'm running Ubuntu 12.04.2 32 bits.
The error doesn't show up if I start gksudo virt-manager
.
libvirt-bin
is installed.- I don't know how to check for the daemon.
- I am a member of
libvirtd
.
Output of ps ax | grep libvirt
:
9225 ? Sl 0:04 /usr/sbin/libvirtd -d
9302 ? S 0:00 /usr/sbin/dnsmasq -u libvirt-dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/default.pid --conf-file= --except-interface lo --listen-address 192.168.122.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases --dhcp-lease-max=253 --dhcp-no-override`
Output of ls -l /var/run/libvirt/libvirt-sock
:
srwxrwx--- 1 root libvirtd 0 Set 13 15:04 /var/run/libvirt/libvirt-sock
Output of getent group libvirtd
:
libvirtd:x:130:OTHERUSER,MYUSER
Detailed error message
Unable to connect to libvirt.
Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied
Verify that:
- The 'libvirt-bin' package is installed
- The 'libvirtd' daemon has been started
- You are member of the 'libvirtd' group
Libvirt URI is: qemu:///system
Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager/connection.py", line 1185, in _open_thread
self.vmm = self._try_open()
File "/usr/share/virt-manager/virtManager/connection.py", line 1167, in _try_open
flags)
File "/usr/lib/python2.7/dist-packages/libvirt.py", line 102, in openAuth
if ret is None:raise libvirtError('virConnectOpenAuth() failed')
libvirtError: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied
Rebooting the system where
virt-manager
is installed solved the issue.After installing KVM, run this command then that error will not occur again.
An alternative to reboot/logout is to run the following commands from a terminal:
The
newgrp
command allows the user to join thelibvirt
group without logout, for processes that are started in the same shell afternewgrp
. Of course this only works if the libvirt installer put you in the libvirt group, which you can check with:For me, the error was caused because group membership changes don't apply without a logout-login (or reboot). I had just installed KVM and libvirt-bin. The installer automatically added my user to the libvirtd group, I had restarted the libvirt-bin service, but I was still getting the error.
Don't change file permissions to 777. Don't just run everything as root or sudo to avoid understanding what's wrong.
Simply logging out and back in resolved the problem by applying my new group membership.
Assuming you just installed libvirt-bin and already confirmed that your current user is a member of the libvirtd group as the error message suggests, you will need to log out and back in for the new group membership to apply.
I hope this helps someone.
I'm managing both Qemu and Virtualbox on my Ubuntu 14.02 machine, and after installing Virtualbox libvirt-bin failed to autostart. So check if libvirt-bin is running:
ps faux | grep libvirt-bin
if you don't see it in ps output - start in manually, then run virt-manager:
sudo service libvirt-bin start
On Ubuntu 16.04.3 LTS
was the only answer. The socket has its own daemon. That's unusual.
After installing all of the packages stated by the op, you can log out then log back in. Anything that add you to user groups you need to log out and back in to be added to the new groups. It is a minor inconvenience, less of one than rebooting.
This was flagged as not complete however this goes as a general rule for adding your user to a group. A relog is needed, that was the missing part that I did not see here.
Logged in user has to be added to
libvirt
usergroupThe user in
libvirt
group can runvirt-manager
andvirsh
withoutsudo
.For me the case was that when using
service libvirt-bin status
it showed that everything was just running fine though I could not connect like:In
/var/run/libvirt/
there should be these two files:If the sockets are not showing, use
service libvirt-bin stop; service libvirt-bin start
to completely restart the process. Usingservice libvirt-bin restart
is not sufficient and will not re-create the socket.The
libvirt-bin
service can safely be stopped and will not poweroff the guests.