[libvirt] [BUG, RFC] Python generator: missing error_codes in generated libvirError exceptions

Philipp Hahn hahn at univention.de
Mon Oct 17 14:12:32 UTC 2011


Hello,

I just encountered a situation, where a KVM instance was reported as "no 
state" in virsh. This broke some code of mine, which was 
using "lookupByUUID()" to lookup several VMs. The Python code did raise a 
libvirt.libvirtError('virDomainLookupByUUID() failed',), where all 
get_error_*() functions return None. This is because the generated libvirt.py 
wrapper just raises libvirtError('%s() failed'), which makes deteting the 
exact fault harder. My current code explicitly checks for get_error_code() == 
VIR_ERR_NO_DOMAIN.
On further investigation I also noticed that qemudDomainLookupByUUID() uses 
qemuReportError() to reports the error condition, which doesn't associate 
that error condition with the connection.

What's the most appropriate way to fix this:
1. Assume lookupBy*() only will ever report an invalid lookup key and catch 
all libvirtErrors?
2. Parse the exception string?
3. Extend the generator to add additional information from annotations?
4. Replace the generated code with hand-extended code.

Any ideas? Thanks for your input.

Sincerely
Philipp
-- 
Philipp Hahn           Open Source Software Engineer      hahn at univention.de
Univention GmbH        Linux for Your Business        fon: +49 421 22 232- 0
Mary-Somerville-Str.1  D-28359 Bremen                 fax: +49 421 22 232-99
                                                   http://www.univention.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20111017/78dc2a5f/attachment-0001.sig>


More information about the libvir-list mailing list