[PATCH 00/36] convert virObjects to GObject

Daniel P. Berrangé berrange at redhat.com
Thu Apr 9 09:18:34 UTC 2020


On Wed, Apr 08, 2020 at 07:38:33PM -0500, Jonathon Jongsma wrote:
> On Fri, 2020-04-03 at 17:03 +0100, Daniel P. Berrangé wrote:
> > On Fri, Apr 03, 2020 at 05:15:28PM +0200, Rafael Fonseca wrote:
> > > This patch series convert various simple instances of virObject to
> > > a
> > > GObject equivalent.
> > > 
> > > virDomain is still WIP because it causes some linking problem I am
> > > still
> > > investigating.
> > > 
> > > virObjects that work as parent class to other objects will be
> > > covered in
> > > a next patchset.
> > 
> > virConnectPtr is the one I don't know how we'll solve.
> > 
> > virConnectClose requires us to return 0 if the last reference
> > was released, 1 otherwise.  g_object_unref  returns void  :-(
> > 
> > I've tried to think about ways to detect the removal of the
> > last reference, but can't figure out a nice solution thus far...
> 
> 
> Wouldn't something like g_object_add_weak_pointer() work for this?

I've investigated this and there are thread safety issues here

  "Note that as with g_object_weak_ref(), the weak references created 
   by this method are not thread-safe: they cannot safely be used in 
   one thread if the object's last g_object_unref() might happen in 
   another thread. Use GWeakRef if thread-safety is required."

Possibly GWeakRef might be viable, but I've not investigated that in
enough detail to be sure. Thread safety is the real key issue to worry
about in general.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list