On 04.10.2016 10:43, Kashyap Chamarthy wrote:
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.)
I've bisected this one down to 8e09c79a07b097a6ba9af83be4916fb9c9538500:
$ git describe --contains 8e09c79a07b097a6ba9af83be4916fb9c9538500
v1.2.10^0
It's a result of a split of python bindings we made a long time ago.
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).
Correct, the exception is raised in C API fails. Note, that it is not
considered a failure if there's no job running (in which case an empty
dict is returned).
Michal