# problems with libvirt and virt-manager

## Adel Ahmed

Whenever I try to run virt-manager I get the following error:

"Unable to connect to libvirt

module object has no attribute 'VIR_CRED_AUTHNAME'

here's libvirtd's status:

llibvirtd.service - Virtualization daemon

   Loaded: loaded (/usr/lib64/systemd/system/libvirtd.service; enabled)

   Active: active (running) since Mon 2014-05-12 10:58:08 EET; 3h 42min ago

     Docs: man:libvirtd( :Cool: 

http://libvirt.org

 Main PID: 3259 (libvirtd)

   CGroup: /system.slice/libvirtd.service

           └─3259 /usr/sbin/libvirtd

May 12 10:58:08 delln4050 systemd[1]: Started Virtualization daemon.

May 12 10:58:09 delln4050 libvirtd[3259]: libvirt version: 1.2.3

May 12 10:58:09 delln4050 libvirtd[3259]: Could not find 'ebtables' executable

May 12 10:58:09 delln4050 libvirtd[3259]: Could not find 'ip6tables' executable

here's libvirt:

[ebuild   R    ] app-emulation/libvirt-1.2.3:0/1.2.3  USE="caps libvirtd policykit qemu systemd udev -audit -avahi -firewalld -fuse -iscsi -lvm -lxc -macvtap -nfs -nls -numa -openvz -parted -pcap -phyp -rbd -sasl (-selinux) -uml -vepa -virt-network -virtualbox -xen" 0

here's virt-manager:

[ebuild   R    ] app-emulation/virt-manager-0.10.0-r1  USE="policykit -debug -gnome-keyring -sasl" PYTHON_SINGLE_TARGET="python2_7 (-python2_6%)" PYTHON_TARGETS="python2_7 (-python2_6%)" 0 kB

thanks

----------

## Adel Ahmed

here's some more info:

adel@delln4050 ~ $ virt-manager --debug

2014-05-12 21:38:31,233 (cliutils:75): virt-manager startup

2014-05-12 21:38:31,233 (virt-manager:199): Launched as: ['/usr/share/virt-manager/virt-manager', '--debug']

2014-05-12 21:38:31,233 (virt-manager:200): virt-manager version: 0.10.0

2014-05-12 21:38:31,234 (virt-manager:201): virtManager import: <module 'virtManager' from '/usr/share/virt-manager/virtManager/__init__.pyc'>

2014-05-12 21:38:31,321 (virt-manager:247): GTK version: 3.10.8

2014-05-12 21:38:31,377 (importer:51): Could not find any typelib for AppIndicator3

2014-05-12 21:38:31,381 (engine:426): libguestfs inspection support: False

2014-05-12 21:38:31,384 (systray:157): Showing systray: False

2014-05-12 21:38:31,384 (engine:232): About to connect to uris ['qemu:///system']

2014-05-12 21:38:31,450 (manager:202): Showing manager

2014-05-12 21:38:31,450 (engine:329): window counter incremented to 1

2014-05-12 21:38:31,452 (connection:941): Scheduling background open thread for qemu:///system

2014-05-12 21:38:31,452 (connection:994): Background 'open connection' thread is running

2014-05-12 21:38:31,453 (connection:1045): Background open thread complete, scheduling notify

2014-05-12 21:38:31,474 (connection:1050): Notifying open result

2014-05-12 21:38:31,476 (error:7 :Cool: : error dialog message:

summary=Unable to connect to libvirt.

'module' object has no attribute 'VIR_CRED_AUTHNAME'

details=Unable to connect to libvirt.

'module' object has no attribute 'VIR_CRED_AUTHNAME'

Libvirt URI is: qemu:///system

Traceback (most recent call last):

  File "/usr/share/virt-manager/virtManager/connection.py", line 1002, in _open_thread

    self.vmm = self._try_open()

  File "/usr/share/virt-manager/virtManager/connection.py", line 980, in _try_open

    [[libvirt.VIR_CRED_AUTHNAME,

AttributeError: 'module' object has no attribute 'VIR_CRED_AUTHNAME'

----------

## Adel Ahmed

help anyone?

----------

## ShinyDoofy

I just ran into the same issue. For me, I could fix it by running

```
emerge -1v libvirt libvirt-glib virt-manager libvirt-python
```

and restarting the application. This is, however, on ~amd64 and thus libvirt 1.2.4.

----------

## Adel Ahmed

well a few updates later and libvirt is working now

It's only working for the root user though, If i try running virt-manager as a regular user I get the following error:

unable to connect to libvirt.

authentication failed: polkit: polkit

\56retains_authorization_after_challenge=1

Authorization required but no agent is available

I tried installing the gksu-polkit package but it wasn't very helpful or I didn't configure things properly

thanks

----------

## Adel Ahmed

I fixed the non-root issue by creating the following file:

/etc/polkit-1/localauthority/50-local.d/50-org.example-libvirt-remote-access.pkla:

 [Remote libvirt SSH access]

  Identity=unix-group:kvm

   Action=org.libvirt.unix.manage

    ResultAny=yes

     ResultInactive=yes

      ResultActive=yes

of course I had to add the user to the kvm group

----------

## Horatio

I had the very same error

```

virt-manager --debug

2014-11-04 02:03:41,363 (cliutils:75): virt-manager startup

2014-11-04 02:03:41,363 (virt-manager:199): Launched as: ['/usr/share/virt-manager/virt-manager', '--debug']

2014-11-04 02:03:41,364 (virt-manager:200): virt-manager version: 0.10.0

2014-11-04 02:03:41,364 (virt-manager:201): virtManager import: <module 'virtManager' from '/usr/share/virt-manager/virtManager/__init__.py'>

2014-11-04 02:03:41,788 (virt-manager:247): GTK version: 3.12.2

2014-11-04 02:03:42,220 (importer:51): Could not find any typelib for AppIndicator3

2014-11-04 02:03:42,237 (engine:426): libguestfs inspection support: False

2014-11-04 02:03:42,240 (systray:157): Showing systray: False

2014-11-04 02:03:42,241 (engine:232): About to connect to uris ['qemu:///system']

2014-11-04 02:03:42,337 (manager:202): Showing manager

2014-11-04 02:03:42,338 (engine:329): window counter incremented to 1

2014-11-04 02:03:42,340 (connection:941): Scheduling background open thread for qemu:///system

2014-11-04 02:03:42,340 (connection:994): Background 'open connection' thread is running

2014-11-04 02:03:42,341 (connection:1045): Background open thread complete, scheduling notify

2014-11-04 02:03:42,358 (connection:1050): Notifying open result

2014-11-04 02:03:42,374 (error:78): error dialog message:

summary=Unable to connect to libvirt.

'module' object has no attribute 'VIR_CRED_AUTHNAME'

details=Unable to connect to libvirt.

'module' object has no attribute 'VIR_CRED_AUTHNAME'

Libvirt URI is: qemu:///system

Traceback (most recent call last):

  File "/usr/share/virt-manager/virtManager/connection.py", line 1002, in _open_thread

    self.vmm = self._try_open()

  File "/usr/share/virt-manager/virtManager/connection.py", line 980, in _try_open

    [[libvirt.VIR_CRED_AUTHNAME,

AttributeError: 'module' object has no attribute 'VIR_CRED_AUTHNAME'

2014-11-04 02:14:06,468 (manager:213): Closing manager

2014-11-04 02:14:06,469 (engine:333): window counter decremented to 0

/usr/share/virt-manager/virtManager/engine.py:352: Warning: Source ID 8 was not found when attempting to remove it

  GLib.source_remove(self.timer)

2014-11-04 02:14:06,480 (engine:413): Exiting app normally.

```

The following, as ShinyDoofy suggested, was all that I needed to do to fix this for me, as I already made edits to /etc//libvirt/libvirtd.conf to allow users in the kvm group to connect.

```

emerge -1v libvirt libvirt-glib virt-manager libvirt-python

```

```

# diff /etc/libvirt/libvirtd.conf.orig.bak /etc/libvirt/libvirtd.conf

81a82

>  unix_sock_group = "kvm"

88c89

< #unix_sock_ro_perms = "0777"

---

>  unix_sock_ro_perms = "0777"

98c99

< #unix_sock_rw_perms = "0770"

---

>  unix_sock_rw_perms = "0770"

101c102

< #unix_sock_dir = "/var/run/libvirt"

---

>  unix_sock_dir = "/var/run/libvirt"

129c130

< #auth_unix_ro = "none"

---

>  auth_unix_ro = "none"

138c139

< #auth_unix_rw = "none"

---

>  auth_unix_rw = "none"

```

----------

## Wallsandfences

It does not for me with the same error.

Any further measures required?

Rüdiger

----------

## Horatio

Did you add your user to the "kvm" group, or what ever group you assigned to, unix_sock_group = "kvm"? You'll have to logout and back in for your user to be effectively in this group.

Did you reboot? Or at least restart libvirt? 

```

$ /etc/init.d/libvirtd restart

```

I believe restarting networking also restarts libvirt.

If you have restarted the service and you believe you are in the group then try to check.

```

$ ls -l /var/run/libvirt

total 0

drwxr-xr-x 2 root root 40 Dec 18 02:11 hostdevmgr

srwxrwx--- 1 root kvm   0 Dec 18 02:11 libvirt-sock

srwxrwxrwx 1 root kvm   0 Dec 18 02:11 libvirt-sock-ro

drwxr-xr-x 2 root root 60 Dec 18 02:11 network

drwxr-xr-x 2 root root 40 Dec 18 02:11 qemu

```

Notice the group and permissions of the libvirt-sock and libvirt-sock-ro files. 

Then check your groups:

```

$ groups

wheel audio cdrom kvm cdrw users plugdev ...

```

You should be at least in the kvm group.

Also notice that I don't have any authentication in the libvirt configuration 

```

auth_unix_ro = "none" 

auth_unix_rw = "none"

```

That's about all I remember testing when I was first setting it up. I can't remember right at the moment what I installed. KVM is built in the kernel so you don't need to install kvm anymore. I believe I just followed this https://forums.gentoo.org/viewtopic-t-712629-start-0.html and setup a bridge and install.

----------

## mushr00m

This might be of some interest to you:

https://bugs.gentoo.org/show_bug.cgi?id=532410

----------

## Horatio

Thx mushr00m for the link and Wallsandfences for asking. I've noticed that after an emerge update that the same error was back. I currently have the following installed

```

dev-python/libvirt-python-1.2.9  USE="{-test}" PYTHON_TARGETS="python2_7 python3_3" 

app-emulation/virt-manager-0.10.0-r2  USE="gnome-keyring gtk (policykit) sasl -debug" PYTHON_TARGETS="python2_7"

```

I'll see if emerging virt-manager-1.0.1 fixes this and report back on that.

----------

## Horatio

Emerging app-emulation/virt-manager-1.0.1 also introduces net-libs/libsoup-gnome-2.46.0:2.4 which fails to apply a patch during the build.

```

Calculating dependencies... done!

[ebuild  N     ] net-libs/libsoup-gnome-2.46.0:2.4  USE="introspection -debug" 0 KiB

[ebuild  N     ] sys-libs/libosinfo-0.2.11  USE="introspection vala {-test}" 0 KiB

[ebuild     U ~] app-emulation/virt-manager-1.0.1 [0.10.0-r2] USE="gnome-keyring gtk (policykit) sasl -debug" PYTHON_TARGETS="python2_7" 0 KiB

```

I'd downgrade my version of libvirt-python to try a temporary fix until newer packages become stable, but I already removed them with an emerge --sync

```

# ls /usr/portage/dev-python/libvirt-python

ChangeLog  libvirt-python-1.2.10.ebuild  libvirt-python-1.2.11.ebuild  libvirt-python-9999.ebuild  Manifest  metadata.xml

```

----------

## Horatio

I tried the libvirt-python-1.2.5.ebuild from  attic https://forums.gentoo.org/viewtopic-t-957354-start-0.html Although it didn't change anything. libvirt-python-1.2.5.ebuild seemed to be what was last installed from reviewing /var/log/emerge.log

I did notice after a emerge --sync a new version of libvirt. I have everything working again with the following  :Very Happy: 

```

# emerge -pv libvirt-python libvirt virt-manager

Calculating dependencies... done!

[ebuild   R    ] app-emulation/libvirt-1.2.10-r3:0/1.2.10  USE="audit avahi caps fuse iscsi libvirtd lvm lxc macvtap nfs nls openvz parted pcap (policykit) qemu sasl systemd udev vepa virt-network -firewalld -numa -phyp -rbd (-selinux) -uml -virtualbox -wireshark-plugins -xen" 0 KiB

[ebuild   R    ] dev-python/libvirt-python-1.2.10  USE="{-test}" PYTHON_TARGETS="python2_7 python3_3 -python3_4" 0 KiB

[ebuild   R    ] app-emulation/virt-manager-0.10.0-r2  USE="gnome-keyring gtk (policykit) sasl -debug" PYTHON_TARGETS="python2_7" 0 KiB

```

I had thought that the bug report 532410 stated that virt-manager needed to be upgraded.   :Rolling Eyes:  and *sigh*

----------

