Description of problem: When using a factory pattern to lookup a domain in python, libvirt produces the following error: libvir: Xen error : failed Xen syscall ioctl 3166208 Here's some sample code that reproduces the problem (assuming an existing domain called "mydomain"): import libvirt def get_domain(dom_name): conn = libvirt.openReadOnly(None) domain = conn.lookupByName(dom_name) return domain d = get_domain("mydomain") print d.info() The problem is that the connection object falls out of scope after the get_domain routine ends, and is therefore garbage collected. This leaves the "d" domain object with no valid connection, resulting in the above error message. The simple solution would be for the connection object to pass a reference to itself into each domain object it creates. The domain objects would then maintain the reference until they are destroyed.
Fixed in CVS: paphio:~ -> cat tst.py #!/usr/bin/python -u import libvirt def get_domain(dom_name): conn = libvirt.openReadOnly(None) domain = conn.lookupByName(dom_name) return domain d = get_domain("rhel5") print d.info() paphio:~ -> ./tst.py [2, 394240, 393824, 1, 24694771381L] paphio:~ -> commited upstream with this changelog: Thu Nov 9 15:39:19 CET 2006 Daniel Veillard <veillard> * python/generator.py: changed the generator to generate a reference from Domain class instances to the Connect they were issued from should fix rhbz#204490 I think it's the simplest and cleanest fix. thanks ! Daniel