[libvirt] [RFC 0/1] convert virStorageSource to GObject

Daniel P. Berrangé berrange at redhat.com
Tue Oct 15 12:55:33 UTC 2019


On Tue, Oct 15, 2019 at 09:42:45AM -0300, Daniel Henrique Barboza wrote:
> I was hoping to quickly re-send the qemu_driver cleanups I've
> sent some time ago, now using Glib. I started by attempting to
> change the first VIR_AUTOUNREF() call in qemu_driver.c to
> g_autoptr(), which happens to be a virStorageSourcePtr type,
> then I realized that it wasn't that simple.

It should be that simple with this commit:

  commit 667ff797e8eb8d82f30ab430216a8d2eef6b915a
  Author: Daniel P. Berrangé <berrange at redhat.com>
  Date:   Fri Oct 4 17:14:10 2019 +0100

    src: add support for g_autoptr with virObject instances

we should be able to use g_autoptr for any virObject, without
having to lock-step convert to GObject.

What actual problem did you find ?

> Following up the instructions found on commit 16121a88a7, I started
> the conversion. Then 'make check' started to fail because some
> calls to virObjectRef/virObjectUnref were still remaining
> in the code, messing up stuff related with mirrorChain in
> qemu_blockjob.c. Turns out it was easier to burn through all the
> instances and change them to use GLib.

Yes, if you convert from virObject to GObject, you *must*
convert all virObjectRef/Unref calls at that time.

> This is being sent as RFC because x-I am aware that docs/hacking.html
> mentions that we shouldn't mix up certain GLib macros with Libvirt
> ones, thus I am uncertain of whether I have messed up or not.
> 'make check' works, did a few sanity checks with libvirtd as
> well.

Yes, the need to not mix  g_auto* with VIR_AUTO*, is why I did commit
667ff797e8eb8d82f30ab430216a8d2eef6b915a to let you use g_autoptr
with virObject, without first converting to GObject.

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