[PATCH v2 00/40] convert virObjects to GObject

Rafael Fonseca posted 40 patches 3 years, 12 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20200421134921.3717019-1-r4f4rfs@gmail.com
src/admin/admin_remote.c                |   9 +-
src/admin/libvirt-admin.c               |   4 +-
src/admin/libvirt_admin_private.syms    |   4 +-
src/bhyve/bhyve_capabilities.c          |  19 +-
src/bhyve/bhyve_conf.c                  |  36 +-
src/bhyve/bhyve_driver.c                |  33 +-
src/bhyve/bhyve_monitor.c               |  48 +-
src/bhyve/bhyve_monitor.h               |   3 +-
src/bhyve/bhyve_utils.h                 |  11 +-
src/conf/capabilities.c                 |  51 +-
src/conf/capabilities.h                 |   6 +-
src/conf/domain_capabilities.c          |  48 +-
src/conf/domain_capabilities.h          |  10 +-
src/conf/domain_conf.c                  | 129 ++--
src/conf/domain_conf.h                  |  36 +-
src/conf/domain_event.c                 |  58 +-
src/conf/network_conf.c                 |  24 +-
src/conf/network_conf.h                 |  12 +-
src/conf/network_event.c                |   7 +-
src/conf/node_device_event.c            |  11 +-
src/conf/node_device_util.c             |   4 +-
src/conf/secret_event.c                 |  15 +-
src/conf/snapshot_conf.c                |   2 +-
src/conf/snapshot_conf.h                |   2 +-
src/conf/storage_capabilities.c         |   4 +-
src/conf/storage_event.c                |  15 +-
src/conf/virchrdev.c                    |   4 +-
src/conf/virconftypes.h                 |   3 +-
src/conf/virdomaincheckpointobjlist.c   |   7 +-
src/conf/virdomainsnapshotobjlist.c     |   7 +-
src/conf/virinterfaceobj.c              |   5 +-
src/conf/virnetworkobj.c                |  10 +-
src/conf/virnodedeviceobj.c             |   3 +-
src/conf/virnwfilterbindingobjlist.c    |   2 +-
src/conf/virnwfilterobj.c               |   7 +-
src/conf/virsavecookie.c                |  10 +-
src/conf/virsavecookie.h                |  14 +-
src/conf/virsecretobj.c                 |   2 +-
src/conf/virstorageobj.c                |   4 +-
src/datatypes.c                         | 977 ++++++++++++++++--------
src/datatypes.h                         | 219 +++---
src/esx/esx_driver.c                    |  33 +-
src/hyperv/hyperv_driver.c              |   8 +-
src/hypervisor/virhostdev.c             |  49 +-
src/hypervisor/virhostdev.h             |  13 +-
src/interface/interface_backend_netcf.c |   7 +-
src/interface/interface_backend_udev.c  |   8 +-
src/libvirt-domain-checkpoint.c         |   7 +-
src/libvirt-domain-snapshot.c           |   7 +-
src/libvirt-domain.c                    |   6 +-
src/libvirt-interface.c                 |   6 +-
src/libvirt-network.c                   |  14 +-
src/libvirt-nodedev.c                   |   6 +-
src/libvirt-nwfilter.c                  |  14 +-
src/libvirt-secret.c                    |   7 +-
src/libvirt-storage.c                   |  12 +-
src/libvirt-stream.c                    |   7 +-
src/libvirt_private.syms                |  35 +-
src/libxl/libxl_capabilities.c          |  19 +-
src/libxl/libxl_conf.c                  |  65 +-
src/libxl/libxl_conf.h                  |  12 +-
src/libxl/libxl_driver.c                | 175 ++---
src/libxl/libxl_migration.c             | 103 +--
src/libxl/xen_common.c                  |   3 +-
src/locking/lock_daemon.c               |  28 +-
src/locking/lock_driver_lockd.c         |  19 +-
src/locking/sanlock_helper.c            |   5 +-
src/logging/log_daemon.c                |  28 +-
src/logging/log_manager.c               |  15 +-
src/lxc/lxc_conf.c                      |  46 +-
src/lxc/lxc_conf.h                      |  10 +-
src/lxc/lxc_controller.c                |  20 +-
src/lxc/lxc_driver.c                    |  98 +--
src/lxc/lxc_monitor.c                   |   2 +-
src/lxc/lxc_process.c                   |  35 +-
src/network/bridge_driver.c             |  24 +-
src/nwfilter/nwfilter_driver.c          |   3 +-
src/openvz/openvz_conf.c                |   8 +-
src/qemu/qemu_blockjob.c                | 130 ++--
src/qemu/qemu_blockjob.h                |  15 +-
src/qemu/qemu_capabilities.c            | 176 +++--
src/qemu/qemu_capabilities.h            |   9 +-
src/qemu/qemu_conf.c                    |  42 +-
src/qemu/qemu_conf.h                    |  19 +-
src/qemu/qemu_domain.c                  | 441 +++++------
src/qemu/qemu_domain.h                  | 157 ++--
src/qemu/qemu_driver.c                  |  34 +-
src/qemu/qemu_hotplug.c                 |   3 +-
src/qemu/qemu_migration.c               |  34 +-
src/qemu/qemu_process.c                 |  20 +-
src/qemu/qemu_virtiofs.c                |  12 +-
src/remote/remote_daemon.c              |  52 +-
src/remote/remote_daemon_dispatch.c     | 188 ++---
src/remote/remote_daemon_stream.c       |   6 +-
src/remote/remote_driver.c              | 178 ++---
src/rpc/gendispatch.pl                  |  90 ++-
src/rpc/virnetclient.c                  |   7 +-
src/rpc/virnetclientprogram.c           |  29 +-
src/rpc/virnetclientprogram.h           |  10 +-
src/rpc/virnetclientstream.c            |   4 +-
src/rpc/virnetserver.c                  |  21 +-
src/rpc/virnetserverprogram.c           |  30 +-
src/rpc/virnetserverprogram.h           |  17 +-
src/rpc/virnetserverservice.c           | 103 ++-
src/security/virt-aa-helper.c           |   9 +-
src/storage/storage_backend.c           |   3 +-
src/storage/storage_driver.c            |   7 +-
src/storage/storage_util.c              |   4 +-
src/test/test_driver.c                  |  33 +-
src/util/virdnsmasq.c                   |  56 +-
src/util/virdnsmasq.h                   |   6 +-
src/util/virfdstream.c                  |   4 +-
src/util/virfilecache.c                 |  43 +-
src/util/virfilecache.h                 |  12 +-
src/util/virobject.c                    |  24 +
src/util/virobject.h                    |   4 +
src/util/virresctrl.c                   | 164 ++--
src/util/virresctrl.h                   |  15 +-
src/util/virsecret.c                    |   3 +-
src/util/virstoragefile.c               |  45 +-
src/util/virstoragefile.h               |   9 +-
src/vbox/vbox_common.c                  |  19 +-
src/vmware/vmware_conf.c                |  13 +-
src/vz/vz_driver.c                      |  33 +-
src/vz/vz_sdk.c                         |  22 +-
tests/bhyveargv2xmltest.c               |   4 +-
tests/bhyvexml2argvtest.c               |   4 +-
tests/bhyvexml2xmltest.c                |   4 +-
tests/cputest.c                         |  48 +-
tests/domaincapstest.c                  |   5 +-
tests/domainconftest.c                  |   4 +-
tests/genericxml2xmltest.c              |   4 +-
tests/networkxml2conftest.c             |  10 +-
tests/networkxml2xmltest.c              |   3 +-
tests/openvzutilstest.c                 |   4 +-
tests/qemublocktest.c                   |   3 +-
tests/qemucapabilitiestest.c            |   9 +-
tests/qemucaps2xmltest.c                |  29 +-
tests/qemucapsprobe.c                   |   4 +-
tests/qemuhotplugtest.c                 |   6 +-
tests/qemumemlocktest.c                 |   3 +-
tests/testutils.c                       |   4 +-
tests/testutilslxc.c                    |  22 +-
tests/testutilsqemu.c                   |  31 +-
tests/testutilsxen.c                    |   7 +-
tests/vircaps2xmltest.c                 |   6 +-
tests/vircapstest.c                     |  14 +-
tests/virfilecachetest.c                |  69 +-
tests/virnetdaemontest.c                |   4 +-
tests/virresctrltest.c                  |   6 +-
tests/vmx2xmltest.c                     |  10 +-
tests/xml2vmxtest.c                     |  12 +-
152 files changed, 2804 insertions(+), 2712 deletions(-)
[PATCH v2 00/40] convert virObjects to GObject
Posted by Rafael Fonseca 3 years, 12 months ago
 This patch series convert various simple instances of virObject to a
 GObject equivalent.

 virLockableObject and virObjects which are subclassed will be covered
 in future patchsets.

New in v2:
 - use *Dispose for unreffing objects and *Finalize for freeing data,
 as suggested in the GLib documentation
 - use `g_clear_object` instead of `if + g_object_unref`
 - properly update gendispatch as types are converted
 - virDomain is now converted to GObject too
 - added a helper function for freeing array of GObjects
 - added previously missed conversion spots

Rafael Fonseca (40):
  util: virresctrl: convert classes to GObject
  conf: capabilities: convert virCaps to GOBject
  qemu: convert virQEMUCaps to GObject
  util: add function to unref array of GObjects
  rpc: convert virNetClientProgram to GObject
  rpc: convert virNetServerProgram to GObject
  conf: convert virDomainXMLOption to GObject
  bhyve: convert bhyveMonitor to GObject
  bhyve: convert virBhyveDriverConfig to GObject
  rpc: convert virNetServerService to GObject
  conf: convert virDomainCapsCPUModels to GObject
  util: convert dnsmasqCaps to GObject
  conf: convert virDomainChrSourceDef to GObject
  rpc: gendispatch: prepare for GObject conversion
  admin: convert virAdmServer to GObject
  admin: convert virAdmClient to GObject
  datatypes: convert virDomainCheckpoint to GObject
  datatypes: convert virDomainSnapshot to GObject
  datatypes: convert virNWFilter to GObject
  datatypes: convert virNWFilterBinding to GObject
  datatypes: convert virNetwork to GObject
  datatypes: convert virNetworkPort to GObject
  datatypes: convert virInterface to GObject
  datatypes: convert virStoragePool to GObject
  datatypes: convert virStorageVol to GObject
  datatypes: convert virNodeDevice to GObject
  datatypes: convert virSecret to GObject
  datatypes: convert virStream to GObject
  datatypes: convert virDomain to GObject
  rpc: gendispatch: use g_autoptr where possible
  conf: convert virNetworkXMLOption to GObject
  lxc: convert virLXCDriverConfig to GObject
  libxl: convert libxlDriverConfig to GObject
  hypervisor: convert virHostdevManager to GObject
  libxl: convert libxlMigrationDstArgs to GObject
  qemu: convert qemuBlockJobData to GObject
  qemu: convert virQEMUDriverConfig to GObject
  conf: convert virDomain*Private to GObject
  conf: convert virSaveCookie to GObject
  util: convert virStorageSource to GObject

 src/admin/admin_remote.c                |   9 +-
 src/admin/libvirt-admin.c               |   4 +-
 src/admin/libvirt_admin_private.syms    |   4 +-
 src/bhyve/bhyve_capabilities.c          |  19 +-
 src/bhyve/bhyve_conf.c                  |  36 +-
 src/bhyve/bhyve_driver.c                |  33 +-
 src/bhyve/bhyve_monitor.c               |  48 +-
 src/bhyve/bhyve_monitor.h               |   3 +-
 src/bhyve/bhyve_utils.h                 |  11 +-
 src/conf/capabilities.c                 |  51 +-
 src/conf/capabilities.h                 |   6 +-
 src/conf/domain_capabilities.c          |  48 +-
 src/conf/domain_capabilities.h          |  10 +-
 src/conf/domain_conf.c                  | 129 ++--
 src/conf/domain_conf.h                  |  36 +-
 src/conf/domain_event.c                 |  58 +-
 src/conf/network_conf.c                 |  24 +-
 src/conf/network_conf.h                 |  12 +-
 src/conf/network_event.c                |   7 +-
 src/conf/node_device_event.c            |  11 +-
 src/conf/node_device_util.c             |   4 +-
 src/conf/secret_event.c                 |  15 +-
 src/conf/snapshot_conf.c                |   2 +-
 src/conf/snapshot_conf.h                |   2 +-
 src/conf/storage_capabilities.c         |   4 +-
 src/conf/storage_event.c                |  15 +-
 src/conf/virchrdev.c                    |   4 +-
 src/conf/virconftypes.h                 |   3 +-
 src/conf/virdomaincheckpointobjlist.c   |   7 +-
 src/conf/virdomainsnapshotobjlist.c     |   7 +-
 src/conf/virinterfaceobj.c              |   5 +-
 src/conf/virnetworkobj.c                |  10 +-
 src/conf/virnodedeviceobj.c             |   3 +-
 src/conf/virnwfilterbindingobjlist.c    |   2 +-
 src/conf/virnwfilterobj.c               |   7 +-
 src/conf/virsavecookie.c                |  10 +-
 src/conf/virsavecookie.h                |  14 +-
 src/conf/virsecretobj.c                 |   2 +-
 src/conf/virstorageobj.c                |   4 +-
 src/datatypes.c                         | 977 ++++++++++++++++--------
 src/datatypes.h                         | 219 +++---
 src/esx/esx_driver.c                    |  33 +-
 src/hyperv/hyperv_driver.c              |   8 +-
 src/hypervisor/virhostdev.c             |  49 +-
 src/hypervisor/virhostdev.h             |  13 +-
 src/interface/interface_backend_netcf.c |   7 +-
 src/interface/interface_backend_udev.c  |   8 +-
 src/libvirt-domain-checkpoint.c         |   7 +-
 src/libvirt-domain-snapshot.c           |   7 +-
 src/libvirt-domain.c                    |   6 +-
 src/libvirt-interface.c                 |   6 +-
 src/libvirt-network.c                   |  14 +-
 src/libvirt-nodedev.c                   |   6 +-
 src/libvirt-nwfilter.c                  |  14 +-
 src/libvirt-secret.c                    |   7 +-
 src/libvirt-storage.c                   |  12 +-
 src/libvirt-stream.c                    |   7 +-
 src/libvirt_private.syms                |  35 +-
 src/libxl/libxl_capabilities.c          |  19 +-
 src/libxl/libxl_conf.c                  |  65 +-
 src/libxl/libxl_conf.h                  |  12 +-
 src/libxl/libxl_driver.c                | 175 ++---
 src/libxl/libxl_migration.c             | 103 +--
 src/libxl/xen_common.c                  |   3 +-
 src/locking/lock_daemon.c               |  28 +-
 src/locking/lock_driver_lockd.c         |  19 +-
 src/locking/sanlock_helper.c            |   5 +-
 src/logging/log_daemon.c                |  28 +-
 src/logging/log_manager.c               |  15 +-
 src/lxc/lxc_conf.c                      |  46 +-
 src/lxc/lxc_conf.h                      |  10 +-
 src/lxc/lxc_controller.c                |  20 +-
 src/lxc/lxc_driver.c                    |  98 +--
 src/lxc/lxc_monitor.c                   |   2 +-
 src/lxc/lxc_process.c                   |  35 +-
 src/network/bridge_driver.c             |  24 +-
 src/nwfilter/nwfilter_driver.c          |   3 +-
 src/openvz/openvz_conf.c                |   8 +-
 src/qemu/qemu_blockjob.c                | 130 ++--
 src/qemu/qemu_blockjob.h                |  15 +-
 src/qemu/qemu_capabilities.c            | 176 +++--
 src/qemu/qemu_capabilities.h            |   9 +-
 src/qemu/qemu_conf.c                    |  42 +-
 src/qemu/qemu_conf.h                    |  19 +-
 src/qemu/qemu_domain.c                  | 441 +++++------
 src/qemu/qemu_domain.h                  | 157 ++--
 src/qemu/qemu_driver.c                  |  34 +-
 src/qemu/qemu_hotplug.c                 |   3 +-
 src/qemu/qemu_migration.c               |  34 +-
 src/qemu/qemu_process.c                 |  20 +-
 src/qemu/qemu_virtiofs.c                |  12 +-
 src/remote/remote_daemon.c              |  52 +-
 src/remote/remote_daemon_dispatch.c     | 188 ++---
 src/remote/remote_daemon_stream.c       |   6 +-
 src/remote/remote_driver.c              | 178 ++---
 src/rpc/gendispatch.pl                  |  90 ++-
 src/rpc/virnetclient.c                  |   7 +-
 src/rpc/virnetclientprogram.c           |  29 +-
 src/rpc/virnetclientprogram.h           |  10 +-
 src/rpc/virnetclientstream.c            |   4 +-
 src/rpc/virnetserver.c                  |  21 +-
 src/rpc/virnetserverprogram.c           |  30 +-
 src/rpc/virnetserverprogram.h           |  17 +-
 src/rpc/virnetserverservice.c           | 103 ++-
 src/security/virt-aa-helper.c           |   9 +-
 src/storage/storage_backend.c           |   3 +-
 src/storage/storage_driver.c            |   7 +-
 src/storage/storage_util.c              |   4 +-
 src/test/test_driver.c                  |  33 +-
 src/util/virdnsmasq.c                   |  56 +-
 src/util/virdnsmasq.h                   |   6 +-
 src/util/virfdstream.c                  |   4 +-
 src/util/virfilecache.c                 |  43 +-
 src/util/virfilecache.h                 |  12 +-
 src/util/virobject.c                    |  24 +
 src/util/virobject.h                    |   4 +
 src/util/virresctrl.c                   | 164 ++--
 src/util/virresctrl.h                   |  15 +-
 src/util/virsecret.c                    |   3 +-
 src/util/virstoragefile.c               |  45 +-
 src/util/virstoragefile.h               |   9 +-
 src/vbox/vbox_common.c                  |  19 +-
 src/vmware/vmware_conf.c                |  13 +-
 src/vz/vz_driver.c                      |  33 +-
 src/vz/vz_sdk.c                         |  22 +-
 tests/bhyveargv2xmltest.c               |   4 +-
 tests/bhyvexml2argvtest.c               |   4 +-
 tests/bhyvexml2xmltest.c                |   4 +-
 tests/cputest.c                         |  48 +-
 tests/domaincapstest.c                  |   5 +-
 tests/domainconftest.c                  |   4 +-
 tests/genericxml2xmltest.c              |   4 +-
 tests/networkxml2conftest.c             |  10 +-
 tests/networkxml2xmltest.c              |   3 +-
 tests/openvzutilstest.c                 |   4 +-
 tests/qemublocktest.c                   |   3 +-
 tests/qemucapabilitiestest.c            |   9 +-
 tests/qemucaps2xmltest.c                |  29 +-
 tests/qemucapsprobe.c                   |   4 +-
 tests/qemuhotplugtest.c                 |   6 +-
 tests/qemumemlocktest.c                 |   3 +-
 tests/testutils.c                       |   4 +-
 tests/testutilslxc.c                    |  22 +-
 tests/testutilsqemu.c                   |  31 +-
 tests/testutilsxen.c                    |   7 +-
 tests/vircaps2xmltest.c                 |   6 +-
 tests/vircapstest.c                     |  14 +-
 tests/virfilecachetest.c                |  69 +-
 tests/virnetdaemontest.c                |   4 +-
 tests/virresctrltest.c                  |   6 +-
 tests/vmx2xmltest.c                     |  10 +-
 tests/xml2vmxtest.c                     |  12 +-
 152 files changed, 2804 insertions(+), 2712 deletions(-)

-- 
2.25.3


Re: [PATCH v2 00/40] convert virObjects to GObject
Posted by Daniel P. Berrangé 3 years, 12 months ago
On Tue, Apr 21, 2020 at 03:48:41PM +0200, Rafael Fonseca wrote:
>  This patch series convert various simple instances of virObject to a
>  GObject equivalent.
> 
>  virLockableObject and virObjects which are subclassed will be covered
>  in future patchsets.
> 
> New in v2:
>  - use *Dispose for unreffing objects and *Finalize for freeing data,
>  as suggested in the GLib documentation

Can you point to the docs with the rationale for that. Looking at the
patches the distinction looks pretty arbitary, creating extra methods
without an obvious benefit.


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 :|

Re: [PATCH v2 00/40] convert virObjects to GObject
Posted by Rafael Fonseca 3 years, 12 months ago
On Tue, Apr 21, 2020 at 4:03 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Tue, Apr 21, 2020 at 03:48:41PM +0200, Rafael Fonseca wrote:
> >  This patch series convert various simple instances of virObject to a
> >  GObject equivalent.
> >
> >  virLockableObject and virObjects which are subclassed will be covered
> >  in future patchsets.
> >
> > New in v2:
> >  - use *Dispose for unreffing objects and *Finalize for freeing data,
> >  as suggested in the GLib documentation
>
> Can you point to the docs with the rationale for that. Looking at the
> patches the distinction looks pretty arbitary, creating extra methods
> without an obvious benefit.

https://developer.gnome.org/gobject/stable/gobject-memory.html#gobject-memory-cycles

I did the changes as requested here:
https://www.redhat.com/archives/libvir-list/2020-April/msg00383.html


Att
-- 
Rafael Fonseca


Re: [PATCH v2 00/40] convert virObjects to GObject
Posted by Daniel P. Berrangé 3 years, 12 months ago
On Tue, Apr 21, 2020 at 04:12:09PM +0200, Rafael Fonseca wrote:
> On Tue, Apr 21, 2020 at 4:03 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
> >
> > On Tue, Apr 21, 2020 at 03:48:41PM +0200, Rafael Fonseca wrote:
> > >  This patch series convert various simple instances of virObject to a
> > >  GObject equivalent.
> > >
> > >  virLockableObject and virObjects which are subclassed will be covered
> > >  in future patchsets.
> > >
> > > New in v2:
> > >  - use *Dispose for unreffing objects and *Finalize for freeing data,
> > >  as suggested in the GLib documentation
> >
> > Can you point to the docs with the rationale for that. Looking at the
> > patches the distinction looks pretty arbitary, creating extra methods
> > without an obvious benefit.
> 
> https://developer.gnome.org/gobject/stable/gobject-memory.html#gobject-memory-cycles
> 
> I did the changes as requested here:
> https://www.redhat.com/archives/libvir-list/2020-April/msg00383.html

Sorry I didn't see that suggestion before, as I don't really agree with it.

Reading the GObject docs, I see this:

  "the destruction process is split in two phases: the first phase,
   executed in the dispose handler is supposed to release all 
   references to other member objects. The second phase, executed
   by the finalize handler is supposed to complete the object's 
   destruction process. Object methods should be able to run without
   program error in-between the two phases."

And this:

  "When dispose ends, the object should not hold any reference to
   any other member object. The object is also expected to be able
   to answer client method invocations (with possibly an error 
   code but no memory violation) until finalize is executed."

The existing libvirt code is written from the POV that everything is
released in one time, in a finalize method. Thus by definition our
current code has no cycle problems that would require the split
dispose/finalize approach.

More importantly though, I very much doubt we are able to to satisfy
the requirement for "dispose" wrt arbitrary object methods not having
memory violations. I'm sure our code expects the objects to be non-NULL
and would thus crash on a NULL pointer if run.

Overall I'm not convinced there's any benefit to using the separate
dispose method in libvirt.

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 :|

Re: [PATCH v2 00/40] convert virObjects to GObject
Posted by Jonathon Jongsma 3 years, 12 months ago
On Tue, 2020-04-21 at 15:26 +0100, Daniel P. Berrangé wrote:
> On Tue, Apr 21, 2020 at 04:12:09PM +0200, Rafael Fonseca wrote:
> > On Tue, Apr 21, 2020 at 4:03 PM Daniel P. Berrangé <
> > berrange@redhat.com> wrote:
> > > On Tue, Apr 21, 2020 at 03:48:41PM +0200, Rafael Fonseca wrote:
> > > >  This patch series convert various simple instances of
> > > > virObject to a
> > > >  GObject equivalent.
> > > > 
> > > >  virLockableObject and virObjects which are subclassed will be
> > > > covered
> > > >  in future patchsets.
> > > > 
> > > > New in v2:
> > > >  - use *Dispose for unreffing objects and *Finalize for freeing
> > > > data,
> > > >  as suggested in the GLib documentation
> > > 
> > > Can you point to the docs with the rationale for that. Looking at
> > > the
> > > patches the distinction looks pretty arbitary, creating extra
> > > methods
> > > without an obvious benefit.
> > 
> > https://developer.gnome.org/gobject/stable/gobject-memory.html#gobject-memory-cycles
> > 
> > I did the changes as requested here:
> > https://www.redhat.com/archives/libvir-list/2020-April/msg00383.html
> 
> Sorry I didn't see that suggestion before, as I don't really agree
> with it.
> 
> Reading the GObject docs, I see this:
> 
>   "the destruction process is split in two phases: the first phase,
>    executed in the dispose handler is supposed to release all 
>    references to other member objects. The second phase, executed
>    by the finalize handler is supposed to complete the object's 
>    destruction process. Object methods should be able to run without
>    program error in-between the two phases."
> 
> And this:
> 
>   "When dispose ends, the object should not hold any reference to
>    any other member object. The object is also expected to be able
>    to answer client method invocations (with possibly an error 
>    code but no memory violation) until finalize is executed."
> 
> The existing libvirt code is written from the POV that everything is
> released in one time, in a finalize method. Thus by definition our
> current code has no cycle problems that would require the split
> dispose/finalize approach.
> 
> More importantly though, I very much doubt we are able to to satisfy
> the requirement for "dispose" wrt arbitrary object methods not having
> memory violations. I'm sure our code expects the objects to be non-
> NULL
> and would thus crash on a NULL pointer if run.
> 
> Overall I'm not convinced there's any benefit to using the separate
> dispose method in libvirt.

Fair enough. I believe that this cycle issue tends to happen more often
in language bindings. For example, I'm pretty sure that I've seen cases
in the past where reference cycles are introduced between the base
GObject and language binding wrapper objects. So even if the base
library code doesn't have any reference cycles, bindings can introduce
them. But maybe this is not the case for us. I was just being (perhaps
overly) cautious.

Jonathon

Re: [PATCH v2 00/40] convert virObjects to GObject
Posted by Rafael Fonseca 3 years, 11 months ago
> On Tue, 2020-04-21 at 15:26 +0100, Daniel P. Berrangé wrote:
> > Overall I'm not convinced there's any benefit to using the separate
> > dispose method in libvirt.

I have an updated version with dispose merged back into finalize. I'm
just waiting for any other comments before sending the update.


Att
-- 
Rafael Fonseca


Re: [PATCH v2 00/40] convert virObjects to GObject
Posted by Daniel P. Berrangé 3 years, 11 months ago
On Mon, May 11, 2020 at 01:10:14PM +0200, Rafael Fonseca wrote:
> > On Tue, 2020-04-21 at 15:26 +0100, Daniel P. Berrangé wrote:
> > > Overall I'm not convinced there's any benefit to using the separate
> > > dispose method in libvirt.
> 
> I have an updated version with dispose merged back into finalize. I'm
> just waiting for any other comments before sending the update.

Go ahead and send it. The rest of the code looks pretty sane to me, but
there's a huge amount of it to review, so I'd rather just review a
v3 straight away, and then start to incrementally push patches as they
are reviewed.

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 :|