[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libvir] [PATCH] Python bindings: Use virDomain/NetworkGetConnect instead of storing connection in domain/network object

Daniel Veillard wrote:
On Mon, Jul 23, 2007 at 04:00:59PM +0100, Richard W.M. Jones wrote:
Previously[1] I patched libvirt to add the virDomainGetConnect and virNetworkGetConnect functions. The rationale for these is explained here[2].

The attached patch makes the Python bindings use these functions instead of storing the connection object explicitly.

  Hum ... The problem was the following:

    - you create a connection
    - you get a domain pointer from the connection

At the C level, conn->uses is incremented when we get a new domain object.

    - you delete the reference from the connection (e.g. by exiting
      the method) but keep the domain object
    - the connection count of the python object goes down to 0
    - _del() is called on the object
    - the connection is closed at the C level

conn->uses should still be >= 1 (reflecting the outstanding domain object), so the connection shouldn't be closed.

    - you have a dandling domain python object whose C pointer is dead

Are you sure your patch is safe ?

Having said that, I will now go and construct a test case to see if this really is safe.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]