Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Failed to connect socket to '/var/run/libvirt/libvirt-sock'
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
juliedeville
n00b
n00b


Joined: 14 Oct 2024
Posts: 39

PostPosted: Sun Oct 20, 2024 5:42 pm    Post subject: Failed to connect socket to '/var/run/libvirt/libvirt-sock' Reply with quote

I get this error when trying to run virt-manager as my user

Code:
Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/connection.py", line 923, in _do_open
    self._backend.open(cb, data)
  File "/usr/share/virt-manager/virtinst/connection.py", line 171, in open
    conn = libvirt.openAuth(self._open_uri,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/libvirt.py", line 147, in openAuth
    raise libvirtError('virConnectOpenAuth() failed')
libvirt.libvirtError: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied




But I can run it and connect to the daemon as root. I have added myself to the libvirt group, and emerged virt-manager using policykit. Any advice is appreciated.

I am also unable to start virtbr0, and get an error saying "Package not installed," but I can't figure out what package I am missing.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22745

PostPosted: Sun Oct 20, 2024 5:56 pm    Post subject: Reply with quote

What is the output of id; namei -l /var/run/libvirt/libvirt-sock, as run from the same shell where that error can be reproduced?
Back to top
View user's profile Send private message
juliedeville
n00b
n00b


Joined: 14 Oct 2024
Posts: 39

PostPosted: Sun Oct 20, 2024 7:48 pm    Post subject: Reply with quote

Code:
uid=1000(julie) gid=1000(julie) groups=1000(julie),10(wheel),18(audio),27(video),79(libvirt),100(users)
f: /var/run/libvirt/libvirt-sock
drwxr-xr-x root root /
drwxr-xr-x root root var
lrwxrwxrwx root root run -> ../run
drwxr-xr-x root root   ..
drwxrwxrwt root root   run
drwxr-xr-x root root libvirt
srwx------ root root libvirt-sock
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22745

PostPosted: Sun Oct 20, 2024 8:08 pm    Post subject: Reply with quote

The socket is only accessible to root, so membership in the libvirt group will not help you. This seems wrong to me. I would have expected the socket to be accessible by a reasonable group, such as libvirt.
Back to top
View user's profile Send private message
juliedeville
n00b
n00b


Joined: 14 Oct 2024
Posts: 39

PostPosted: Sun Oct 20, 2024 10:20 pm    Post subject: Reply with quote

I see. How do I make it accessible to users? I read that libvirt uses polkit to allow user access, but I wasn't sure if it had to be configured manually.
Back to top
View user's profile Send private message
Ralphred
l33t
l33t


Joined: 31 Dec 2013
Posts: 661

PostPosted: Sun Oct 20, 2024 10:32 pm    Post subject: Reply with quote

Hu wrote:
The socket is only accessible to root, so membership in the libvirt group will not help you. This seems wrong to me. I would have expected the socket to be accessible by a reasonable group, such as libvirt.
Indeed, in all contexts.

polkit can (apparently?) override this, but I changed it a long time ago* so it took me a while to locate, but:
/etc/libvirt/libvirtd.conf:
#################################################################
#
# UNIX socket access controls
#

# Set the UNIX domain socket group ownership. This can be used to
# allow a 'trusted' set of users access to management capabilities
# without becoming root.
#
# This setting is not required or honoured if using systemd socket
# activation.
#
# This is restricted to 'root' by default.
unix_sock_group = "libvirt"

There is a bunch of other "stuff" you can alter after this section too, including "0775" style socket permissions.

*nano backups say aug 22.
Back to top
View user's profile Send private message
juliedeville
n00b
n00b


Joined: 14 Oct 2024
Posts: 39

PostPosted: Mon Oct 21, 2024 4:01 pm    Post subject: Reply with quote

Setting the socket to libvirt and permissions at 0775 did the trick, thank you much! However, I am still getting
Code:
error: Failed to start network default
error: Unable to create bridge virbr0: Package not installed
when trying to start the default network device.

Here is emerge --info for libvirt

Code:
app-emulation/libvirt-10.3.0-r3::gentoo was built with the following:
USE="caps libvirtd nls qemu udev virt-network -apparmor -audit -bash-completion -dtrace -firewalld -fuse -glusterfs -iscsi -iscsi-direct -libssh -libssh2 -lvm -lxc -nbd -nfs -numa (-openvz) -parted -pcap -policykit -rbd -sasl (-selinux) -test -verify-sig -virtiofsd -virtualbox -wireshark-plugins -xen -zfs" ABI_X86="(64)"
Back to top
View user's profile Send private message
Ralphred
l33t
l33t


Joined: 31 Dec 2013
Posts: 661

PostPosted: Mon Oct 21, 2024 4:41 pm    Post subject: Reply with quote

Does
Code:
ebuild /var/db/repos/gentoo/app-emulation/libvirt/libvirt-10.3.0-r3.ebuild setup clean
tell you about any missing kernel config?
Back to top
View user's profile Send private message
juliedeville
n00b
n00b


Joined: 14 Oct 2024
Posts: 39

PostPosted: Mon Oct 21, 2024 7:37 pm    Post subject: Reply with quote

Oh that's it, I was missing a couple. Thank you!
Back to top
View user's profile Send private message
juliedeville
n00b
n00b


Joined: 14 Oct 2024
Posts: 39

PostPosted: Tue Oct 22, 2024 5:15 pm    Post subject: Reply with quote

Still getting the package error when trying to start virbr0, here is the output of the most recent command you gave me

Code:
 sudo ebuild /var/db/repos/gentoo/app-emulation/libvirt/libvirt-10.3.0-r3.ebuild setup clean                          1 ↵
 * libvirt-10.3.0.tar.xz BLAKE2B SHA512 size ;-) ...                                                                  [ ok ]
 * checking ebuild checksums ;-) ...                                                                                  [ ok ]
 * checking auxfile checksums ;-) ...                                                                                 [ ok ]
 * checking miscfile checksums ;-) ...                                                                                [ ok ]
 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux
 * Found sources for kernel version:
 *     6.6.52-gentoo
 * Checking for suitable kernel configuration options ...                                                             [ ok ]
 * Checking whether python3_13 is suitable ...
 *   dev-lang/python:3.13 ...                                                                                         [ !! ]
 * Checking whether python3_12 is suitable ...
 *   dev-lang/python:3.12 ...                                                                                         [ ok ]
 *   python_check_deps ...                                                                                            [ ok ]
 * Using python3.12 to build (via PYTHON_COMPAT iteration)


I enabled all of the kernel params I was missing and rebuilt.
Back to top
View user's profile Send private message
Ralphred
l33t
l33t


Joined: 31 Dec 2013
Posts: 661

PostPosted: Tue Oct 22, 2024 5:28 pm    Post subject: Reply with quote

juliedeville wrote:
I enabled all of the kernel params I was missing and rebuilt.
Let's check the simple things first, did you reboot too?
Back to top
View user's profile Send private message
juliedeville
n00b
n00b


Joined: 14 Oct 2024
Posts: 39

PostPosted: Wed Oct 23, 2024 3:02 pm    Post subject: Reply with quote

Yes. Also, if it matters, I have tried starting it with root and my user
Back to top
View user's profile Send private message
sMueggli
Guru
Guru


Joined: 03 Sep 2022
Posts: 500

PostPosted: Wed Oct 23, 2024 3:51 pm    Post subject: Reply with quote

Did you change /etc/libvirt/libvirtd.conf (https://wiki.gentoo.org/wiki/Libvirt#User_permissions)? Please read also the comments above the options prior to uncommenting it.
Back to top
View user's profile Send private message
Ralphred
l33t
l33t


Joined: 31 Dec 2013
Posts: 661

PostPosted: Wed Oct 23, 2024 11:16 pm    Post subject: Reply with quote

juliedeville wrote:
Yes. Also, if it matters, I have tried starting it with root and my user

I can't help but think there is some "helper" package that VMM/libvirt is trying to use that has somehow slipped past the ebuild's dependency config.
If you try and follow https://wiki.gentoo.org/wiki/Network_bridge#Installation , mainly the ip link add br0 type bridge and try to make a "single nic bridge", just live, don't mess with any config, you are just running PoC to prove the kernel is up to the task, so shut down /etc/init.d/net.[some interface], and add it to br0 with ip link set dev [some interface] master br0, and bring br0 up/give it an ip/test it.
If that works, it's time to start looking harder at libvirt(d).
Back to top
View user's profile Send private message
juliedeville
n00b
n00b


Joined: 14 Oct 2024
Posts: 39

PostPosted: Sun Nov 03, 2024 6:10 pm    Post subject: Reply with quote

Thank you. When I try to create a bridge manually, I get "Error: Unknown device type"

Edit: It's fixed now! I think I might have been loading the wrong kernel after I enabled the bridge params
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum