Re: libvirt-python virNodeGetInfo returns None

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23.08.2016 13:03, Christian Loehle wrote:
> I'm trying to use virt-manager with a custom libvirt hypervisor driver.

Wow, custom hypervisor driver? Sounds interesting - for what hypervisor
it is?

> My current problem is that virt-manager closes the connection because virNodeGetInfo(the python binding) returns None:
> Traceback (most recent call last):
>   File "/home/cloehle/Documents/libvirt/virt-manager/virtManager/connection.py", line 1390, in tick_from_engine
>     self._tick(*args, **kwargs)
>   File "/home/cloehle/Documents/libvirt/virt-manager/virtManager/connection.py", line 1280, in _tick
>     self._hostinfo = self._backend.getInfo()
>   File "/usr/lib/python2.7/dist-packages/libvirt.py", line 3612, in getInfo
>     if ret is None: raise libvirtError ('virNodeGetInfo() failed', conn=self)
> libvirtError: internal error: client socket is closed
> 
> The virNodeGetInfo function of my driver should set a valid virNodeInfoPtr, since it only consists of the line:
> return nodeGetInfo(NULL, info);

Ah, this is the problem. You may want to look how other drivers do this.
For instance, qemu driver defines its own implementation:

    .nodeGetInfo = qemuNodeGetInfo, /* 0.2.0 */

static int
qemuNodeGetInfo(virConnectPtr conn,
                virNodeInfoPtr nodeinfo)
{
    if (virNodeGetInfoEnsureACL(conn) < 0)
        return -1;

    return nodeGetInfo(nodeinfo);
}

> virsh shows no problems which is why I suspect this is a problem with libvirt-python.

This looks suspicious, are you sure you have the correct connection URI
in virsh?

> So I looked at the source and the first thing that I noticed is in line 2753 of libvirt-override.c:
>     if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetInfo", &pyobj_conn))
>         return NULL;
> 
> Since this is for virNodeGetInfo this should probably be virNodeGetInfo instead of domain(the same thing occurs in line 2794 for another function).

Yeah, nice catch! But those are just prefixes for some error messages
[1]. Nevertheless, I've posted a fix for that [2].

> This could be my source of error but doesn't have to be. Could someone walk me through finding the reason why libvirt-python returns None for my virNodeGetInfo?

One possibility might be that you've passed invalid connection. It
should be possible to: a) see error in the daemon's log, b) set up
client logs to see whether error occurs there. [3].

> Is there any good way of debugging where exactly libvirt-python encounters an error and returns None?4

Yes, you should be able to just attach gdb to it and set a breakpoint.
After that you can just step through the function.

Michal

1: https://docs.python.org/3.5/c-api/arg.html
2: https://www.redhat.com/archives/libvir-list/2016-August/msg01089.html
3: http://wiki.libvirt.org/page/DebugLogs

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]