[libvirt] Missing blockJobInfo() method from v1.2.5 Python bindings?

Kashyap Chamarthy kchamart at redhat.com
Tue Oct 4 08:43:31 UTC 2016


Last night I was trying to check whether blockJobInfo() method will
raise an error when it returns 'None' in v1.2.5 libvirt Python bindings.
(Eric Blake confirmed on IRC: "the python bindings have, as a general
rule, always raised a libvirtError if the C binding code returns None").

Before asking on IRC, I built the bindings and the below is what I noticed.

Let's first see what's in current Git master:

    $ less build/libvirt.py
    [...]
    def blockJobInfo(self, path, flags=0):
        """Get progress information for a block job """
        ret = libvirtmod.virDomainGetBlockJobInfo(self._o, path, flags)
        if ret is None: raise libvirtError ('virDomainGetBlockJobInfo() failed', dom=self)
        return ret
    [...]

Now try to find out what is present in v1.2.5 by quickly building the
bindings for that tag:

    $ git checkout v1.2.5
    $ python setup.py build

Hmm, once built, there's no blockJobInfo() method in build/libvirt.py!
(When I mentioned this on #virt, OFTC, Cole confirmed he could reproduce
the behavior, too.  Not sure if it's a regression in v1.2.5.)

However, the libvirt "glue code" for libvirt_virDomainGetBlockJobInfo()
exists in libvirt-python/libvirt-override.c, so checking there (again,
for v1.2.5), we see:

   4755     if (c_ret == 0) {
   4756         return dict;
   4757     } else if (c_ret < 0) {
   4758         Py_DECREF(dict);
   4759         return VIR_PY_NONE;
   4760     }

IIUC, the VIR_PY_NONE means it raises an exception (libvirtError).

-- 
/kashyap




More information about the libvir-list mailing list