[Libvir] [PATCH] deep copy dom structure

Daniel Veillard veillard at redhat.com
Mon Mar 31 12:12:19 UTC 2008

On Mon, Mar 31, 2008 at 01:02:49PM +0100, Daniel P. Berrange wrote:
> On Mon, Mar 31, 2008 at 11:00:56AM +0100, Richard W.M. Jones wrote:
> > The 'conn', 'dom' and 'net' fields in a virterror can't be accessed
> > safely, particularly from a garbage-collected language.  The only safe
> > thing one could do with them is a physical equality test on the
> > pointer against an existing conn/dom/net pointer.
> > 
> > But the solution isn't to copy the dom object, since in a GC-d
> > language someone could grab a handle to the copied dom which would
> > have a different lifetime from the error object.  If anything the
> > solution would be to remove those fields from the error object since
> > they are highly unlikely to be useful in any real world application.
> > We can't do this because of backwards compatibility promises but we
> > should instead deprecate them.
> We should at the very least NULL-ify the dom/net fields in the Error 
> object associated with the Connection when we free the Domain/Network
> object.

  agreed, very simple test but avoids dandling pointers.

> We also probably need to re-arrange the remote daemon code a
> little so that it serializes to XDR format before the Domain/Network object
> are free'd.
> I agree that deep copying isn't the answer here & messes up the reference
> counting and will cause potential memory leaks. 

  yes, this will become unmanageable very fast i'm afraid.


Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard at redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/

More information about the libvir-list mailing list