This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours
Bug 204490 - libvirt fails when 'factory' pattern used in python
libvirt fails when 'factory' pattern used in python
Status: CLOSED UPSTREAM
Product: Fedora
Classification: Fedora
Component: libvirt (Show other bugs)
rawhide
All All
medium Severity medium
: ---
: ---
Assigned To: Daniel Veillard
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-08-29 11:00 EDT by Pete Vetere
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-11-09 09:56:45 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Pete Vetere 2006-08-29 11:00:07 EDT
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.
Comment 1 Daniel Veillard 2006-11-09 09:56:45 EST
 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@redhat.com>

        * 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

Note You need to log in before you can comment on or make changes to this bug.