[PATCH 00/36] convert virObjects to GObject

Rafael Fonseca posted 36 patches 4 years ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20200403151604.106616-1-r4f4rfs@gmail.com
There is a newer version of this series
src/admin/admin_remote.c                |  10 +-
src/admin/libvirt-admin.c               |   4 +-
src/admin/libvirt_admin_private.syms    |   2 -
src/bhyve/bhyve_capabilities.c          |  19 +-
src/bhyve/bhyve_conf.c                  |  34 +-
src/bhyve/bhyve_driver.c                |  36 +-
src/bhyve/bhyve_monitor.c               |  35 +-
src/bhyve/bhyve_monitor.h               |   3 +-
src/bhyve/bhyve_utils.h                 |  11 +-
src/conf/capabilities.c                 |  42 +-
src/conf/capabilities.h                 |   6 +-
src/conf/domain_capabilities.c          |  48 +-
src/conf/domain_capabilities.h          |  10 +-
src/conf/domain_conf.c                  | 126 ++---
src/conf/domain_conf.h                  |  36 +-
src/conf/network_conf.c                 |  31 +-
src/conf/network_conf.h                 |  12 +-
src/conf/network_event.c                |   2 +-
src/conf/node_device_event.c            |   9 +-
src/conf/node_device_util.c             |   4 +-
src/conf/secret_event.c                 |   9 +-
src/conf/snapshot_conf.c                |   3 +-
src/conf/snapshot_conf.h                |   2 +-
src/conf/storage_capabilities.c         |   5 +-
src/conf/storage_event.c                |  15 +-
src/conf/virchrdev.c                    |   5 +-
src/conf/virconftypes.h                 |   3 +-
src/conf/virdomaincheckpointobjlist.c   |   6 +-
src/conf/virdomainsnapshotobjlist.c     |   6 +-
src/conf/virinterfaceobj.c              |   7 +-
src/conf/virnetworkobj.c                |  14 +-
src/conf/virnodedeviceobj.c             |  10 +-
src/conf/virnwfilterbindingobjlist.c    |   6 +-
src/conf/virnwfilterobj.c               |   6 +-
src/conf/virsavecookie.c                |  10 +-
src/conf/virsavecookie.h                |  14 +-
src/conf/virsecretobj.c                 |   8 +-
src/conf/virstorageobj.c                |  16 +-
src/datatypes.c                         | 601 +++++++++++++++---------
src/datatypes.h                         | 199 ++++----
src/esx/esx_driver.c                    |  28 +-
src/hypervisor/virhostdev.c             |  31 +-
src/hypervisor/virhostdev.h             |  13 +-
src/interface/interface_backend_netcf.c |   2 +-
src/interface/interface_backend_udev.c  |   2 +-
src/libvirt-domain-checkpoint.c         |   7 +-
src/libvirt-domain-snapshot.c           |   7 +-
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                |  11 -
src/libxl/libxl_capabilities.c          |  19 +-
src/libxl/libxl_conf.c                  |  57 ++-
src/libxl/libxl_conf.h                  |  12 +-
src/libxl/libxl_driver.c                | 178 +++----
src/libxl/libxl_migration.c             |  80 ++--
src/libxl/xen_common.c                  |   2 +-
src/locking/lock_daemon.c               |  28 +-
src/locking/lock_driver_lockd.c         |  23 +-
src/logging/log_daemon.c                |  28 +-
src/logging/log_manager.c               |  17 +-
src/lxc/lxc_conf.c                      |  47 +-
src/lxc/lxc_conf.h                      |  10 +-
src/lxc/lxc_controller.c                |  25 +-
src/lxc/lxc_driver.c                    | 102 ++--
src/lxc/lxc_monitor.c                   |   3 +-
src/lxc/lxc_process.c                   |  36 +-
src/network/bridge_driver.c             |  23 +-
src/nwfilter/nwfilter_driver.c          |   3 +-
src/openvz/openvz_conf.c                |  10 +-
src/qemu/qemu_blockjob.c                | 126 +++--
src/qemu/qemu_blockjob.h                |  15 +-
src/qemu/qemu_capabilities.c            | 133 +++---
src/qemu/qemu_capabilities.h            |   9 +-
src/qemu/qemu_conf.c                    |  44 +-
src/qemu/qemu_conf.h                    |  19 +-
src/qemu/qemu_domain.c                  | 435 ++++++++---------
src/qemu/qemu_domain.h                  | 157 +++++--
src/qemu/qemu_driver.c                  |  32 +-
src/qemu/qemu_migration.c               |  12 +-
src/qemu/qemu_process.c                 |  21 +-
src/qemu/qemu_virtiofs.c                |  12 +-
src/remote/remote_daemon.c              |  52 +-
src/remote/remote_daemon_dispatch.c     |  35 +-
src/remote/remote_daemon_stream.c       |   8 +-
src/remote/remote_driver.c              |  71 +--
src/rpc/gendispatch.pl                  |   4 +-
src/rpc/virnetclient.c                  |   4 +-
src/rpc/virnetclientprogram.c           |  29 +-
src/rpc/virnetclientprogram.h           |  10 +-
src/rpc/virnetclientstream.c            |   5 +-
src/rpc/virnetserver.c                  |  18 +-
src/rpc/virnetserverprogram.c           |  30 +-
src/rpc/virnetserverprogram.h           |  17 +-
src/rpc/virnetserverservice.c           |  87 ++--
src/security/virt-aa-helper.c           |  11 +-
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                  |   5 +-
src/util/virfilecache.c                 |  13 +-
src/util/virresctrl.c                   | 137 +++---
src/util/virresctrl.h                   |  15 +-
src/util/virsecret.c                    |   3 +-
src/util/virstoragefile.c               |  41 +-
src/util/virstoragefile.h               |   9 +-
src/vbox/vbox_common.c                  |  10 +-
src/vmware/vmware_conf.c                |  15 +-
src/vz/vz_driver.c                      |  30 +-
src/vz/vz_sdk.c                         |  22 +-
tests/bhyveargv2xmltest.c               |   4 +-
tests/bhyvexml2argvtest.c               |   4 +-
tests/bhyvexml2xmltest.c                |   4 +-
tests/cputest.c                         |  49 +-
tests/domaincapstest.c                  |   6 +-
tests/domainconftest.c                  |   6 +-
tests/genericxml2xmltest.c              |   6 +-
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                    |  24 +-
tests/testutilsqemu.c                   |  35 +-
tests/testutilsxen.c                    |   9 +-
tests/vircaps2xmltest.c                 |   6 +-
tests/vircapstest.c                     |  14 +-
tests/virfilecachetest.c                |  53 +--
tests/virnetdaemontest.c                |   4 +-
tests/virresctrltest.c                  |   6 +-
tests/vmx2xmltest.c                     |  11 +-
tests/xml2vmxtest.c                     |  15 +-
144 files changed, 2243 insertions(+), 2188 deletions(-)
[PATCH 00/36] convert virObjects to GObject
Posted by Rafael Fonseca 4 years ago
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.

Rafael Fonseca (36):
  util: virresctrl: convert classes to GObject
  conf: capabilities: convert virCaps to GOBject
  qemu: convert virQEMUCaps to GObject
  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
  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
  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                |  10 +-
 src/admin/libvirt-admin.c               |   4 +-
 src/admin/libvirt_admin_private.syms    |   2 -
 src/bhyve/bhyve_capabilities.c          |  19 +-
 src/bhyve/bhyve_conf.c                  |  34 +-
 src/bhyve/bhyve_driver.c                |  36 +-
 src/bhyve/bhyve_monitor.c               |  35 +-
 src/bhyve/bhyve_monitor.h               |   3 +-
 src/bhyve/bhyve_utils.h                 |  11 +-
 src/conf/capabilities.c                 |  42 +-
 src/conf/capabilities.h                 |   6 +-
 src/conf/domain_capabilities.c          |  48 +-
 src/conf/domain_capabilities.h          |  10 +-
 src/conf/domain_conf.c                  | 126 ++---
 src/conf/domain_conf.h                  |  36 +-
 src/conf/network_conf.c                 |  31 +-
 src/conf/network_conf.h                 |  12 +-
 src/conf/network_event.c                |   2 +-
 src/conf/node_device_event.c            |   9 +-
 src/conf/node_device_util.c             |   4 +-
 src/conf/secret_event.c                 |   9 +-
 src/conf/snapshot_conf.c                |   3 +-
 src/conf/snapshot_conf.h                |   2 +-
 src/conf/storage_capabilities.c         |   5 +-
 src/conf/storage_event.c                |  15 +-
 src/conf/virchrdev.c                    |   5 +-
 src/conf/virconftypes.h                 |   3 +-
 src/conf/virdomaincheckpointobjlist.c   |   6 +-
 src/conf/virdomainsnapshotobjlist.c     |   6 +-
 src/conf/virinterfaceobj.c              |   7 +-
 src/conf/virnetworkobj.c                |  14 +-
 src/conf/virnodedeviceobj.c             |  10 +-
 src/conf/virnwfilterbindingobjlist.c    |   6 +-
 src/conf/virnwfilterobj.c               |   6 +-
 src/conf/virsavecookie.c                |  10 +-
 src/conf/virsavecookie.h                |  14 +-
 src/conf/virsecretobj.c                 |   8 +-
 src/conf/virstorageobj.c                |  16 +-
 src/datatypes.c                         | 601 +++++++++++++++---------
 src/datatypes.h                         | 199 ++++----
 src/esx/esx_driver.c                    |  28 +-
 src/hypervisor/virhostdev.c             |  31 +-
 src/hypervisor/virhostdev.h             |  13 +-
 src/interface/interface_backend_netcf.c |   2 +-
 src/interface/interface_backend_udev.c  |   2 +-
 src/libvirt-domain-checkpoint.c         |   7 +-
 src/libvirt-domain-snapshot.c           |   7 +-
 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                |  11 -
 src/libxl/libxl_capabilities.c          |  19 +-
 src/libxl/libxl_conf.c                  |  57 ++-
 src/libxl/libxl_conf.h                  |  12 +-
 src/libxl/libxl_driver.c                | 178 +++----
 src/libxl/libxl_migration.c             |  80 ++--
 src/libxl/xen_common.c                  |   2 +-
 src/locking/lock_daemon.c               |  28 +-
 src/locking/lock_driver_lockd.c         |  23 +-
 src/logging/log_daemon.c                |  28 +-
 src/logging/log_manager.c               |  17 +-
 src/lxc/lxc_conf.c                      |  47 +-
 src/lxc/lxc_conf.h                      |  10 +-
 src/lxc/lxc_controller.c                |  25 +-
 src/lxc/lxc_driver.c                    | 102 ++--
 src/lxc/lxc_monitor.c                   |   3 +-
 src/lxc/lxc_process.c                   |  36 +-
 src/network/bridge_driver.c             |  23 +-
 src/nwfilter/nwfilter_driver.c          |   3 +-
 src/openvz/openvz_conf.c                |  10 +-
 src/qemu/qemu_blockjob.c                | 126 +++--
 src/qemu/qemu_blockjob.h                |  15 +-
 src/qemu/qemu_capabilities.c            | 133 +++---
 src/qemu/qemu_capabilities.h            |   9 +-
 src/qemu/qemu_conf.c                    |  44 +-
 src/qemu/qemu_conf.h                    |  19 +-
 src/qemu/qemu_domain.c                  | 435 ++++++++---------
 src/qemu/qemu_domain.h                  | 157 +++++--
 src/qemu/qemu_driver.c                  |  32 +-
 src/qemu/qemu_migration.c               |  12 +-
 src/qemu/qemu_process.c                 |  21 +-
 src/qemu/qemu_virtiofs.c                |  12 +-
 src/remote/remote_daemon.c              |  52 +-
 src/remote/remote_daemon_dispatch.c     |  35 +-
 src/remote/remote_daemon_stream.c       |   8 +-
 src/remote/remote_driver.c              |  71 +--
 src/rpc/gendispatch.pl                  |   4 +-
 src/rpc/virnetclient.c                  |   4 +-
 src/rpc/virnetclientprogram.c           |  29 +-
 src/rpc/virnetclientprogram.h           |  10 +-
 src/rpc/virnetclientstream.c            |   5 +-
 src/rpc/virnetserver.c                  |  18 +-
 src/rpc/virnetserverprogram.c           |  30 +-
 src/rpc/virnetserverprogram.h           |  17 +-
 src/rpc/virnetserverservice.c           |  87 ++--
 src/security/virt-aa-helper.c           |  11 +-
 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                  |   5 +-
 src/util/virfilecache.c                 |  13 +-
 src/util/virresctrl.c                   | 137 +++---
 src/util/virresctrl.h                   |  15 +-
 src/util/virsecret.c                    |   3 +-
 src/util/virstoragefile.c               |  41 +-
 src/util/virstoragefile.h               |   9 +-
 src/vbox/vbox_common.c                  |  10 +-
 src/vmware/vmware_conf.c                |  15 +-
 src/vz/vz_driver.c                      |  30 +-
 src/vz/vz_sdk.c                         |  22 +-
 tests/bhyveargv2xmltest.c               |   4 +-
 tests/bhyvexml2argvtest.c               |   4 +-
 tests/bhyvexml2xmltest.c                |   4 +-
 tests/cputest.c                         |  49 +-
 tests/domaincapstest.c                  |   6 +-
 tests/domainconftest.c                  |   6 +-
 tests/genericxml2xmltest.c              |   6 +-
 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                    |  24 +-
 tests/testutilsqemu.c                   |  35 +-
 tests/testutilsxen.c                    |   9 +-
 tests/vircaps2xmltest.c                 |   6 +-
 tests/vircapstest.c                     |  14 +-
 tests/virfilecachetest.c                |  53 +--
 tests/virnetdaemontest.c                |   4 +-
 tests/virresctrltest.c                  |   6 +-
 tests/vmx2xmltest.c                     |  11 +-
 tests/xml2vmxtest.c                     |  15 +-
 144 files changed, 2243 insertions(+), 2188 deletions(-)

-- 
2.25.1


Re: [PATCH 00/36] convert virObjects to GObject
Posted by Rafael Fonseca 4 years ago
On Fri, Apr 3, 2020 at 5:16 PM Rafael Fonseca <r4f4rfs@gmail.com> wrote:
> virDomain is still WIP because it causes some linking problem I am still
> investigating.

Gonna ask here since you guys might have some idea from the top of
your heads to help me.

I converted virDomain to GObject. However, when linking I get the
following error:

  CC       libvirt_lxc_la-libvirt-lxc.lo
  CCLD     libvirt-lxc.la
  CC       libvirt_qemu_la-libvirt-qemu.lo
  CCLD     libvirt-qemu.la
  CCLD     virtvboxd
/usr/bin/ld: ./.libs/libvirt-lxc.so: undefined reference to
`vir_domain_get_type'
collect2: error: ld returned 1 exit status

If I add `$(DATATYPES_SOURCES)` to `libvirt_lxc_la_SOURCES` in
`src/Makefile.am`, then the compilation is successful but virsh tools
fail with:

$: tools/virsh --connect test:///default list

(process:1086311): GLib-GObject-WARNING **: 00:59:47.905: cannot
register existing type 'virDomain'

(process:1086311): GLib-CRITICAL **: 00:59:47.905: g_once_init_leave:
assertion 'result != 0' failed
^C

I thought that by linking with libvirt.so, the `vir_domain_get_type`
symbol should be found. What am I missing?


Att
-- 
Rafael Fonseca


Re: [PATCH 00/36] convert virObjects to GObject
Posted by Daniel P. Berrangé 4 years ago
On Mon, Apr 06, 2020 at 01:26:02PM +0200, Rafael Fonseca wrote:
> On Fri, Apr 3, 2020 at 5:16 PM Rafael Fonseca <r4f4rfs@gmail.com> wrote:
> > virDomain is still WIP because it causes some linking problem I am still
> > investigating.
> 
> Gonna ask here since you guys might have some idea from the top of
> your heads to help me.
> 
> I converted virDomain to GObject. However, when linking I get the
> following error:
> 
>   CC       libvirt_lxc_la-libvirt-lxc.lo
>   CCLD     libvirt-lxc.la
>   CC       libvirt_qemu_la-libvirt-qemu.lo
>   CCLD     libvirt-qemu.la
>   CCLD     virtvboxd
> /usr/bin/ld: ./.libs/libvirt-lxc.so: undefined reference to
> `vir_domain_get_type'
> collect2: error: ld returned 1 exit status

You'll need to add the vir_$OBJECT_get_type  methods to the file
src/libvirt_private.syms as you convert each type/


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 00/36] convert virObjects to GObject
Posted by Daniel P. Berrangé 4 years ago
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...



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 00/36] convert virObjects to GObject
Posted by Jonathon Jongsma 4 years ago
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?

Re: [PATCH 00/36] convert virObjects to GObject
Posted by Daniel P. Berrangé 4 years ago
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 :|