libvirt/src/openvz
John Ferlan b04629b629 conf: Clean up object referencing for Add and Remove
When adding a new object to the domain object list, there should
have been 2 virObjectRef calls made one for each list into which
the object was placed to match the 2 virObjectUnref calls that
would occur during Remove as part of virHashRemoveEntry when
virObjectFreeHashData is called when the element is removed from
the hash table as set up in virDomainObjListNew.

Some drivers (libxl, lxc, qemu, and vz) handled this inconsistency
by calling virObjectRef upon successful return from virDomainObjListAdd
in order to use virDomainObjEndAPI when done with the returned @vm.
While others (bhyve, openvz, test, and vmware) handled this via only
calling virObjectUnlock upon successful return from virDomainObjListAdd.

This patch will "unify" the approach to use virDomainObjEndAPI
for any @vm successfully returned from virDomainObjListAdd.

Because list removal is so tightly coupled with list addition,
this patch fixes the list removal algorithm to return the object
as entered - "locked and reffed".  This way, the callers can then
decide how to uniformly handle add/remove success and failure.
This removes the onus on the caller to "specially handle" the
@vm during removal processing.

The Add/Remove logic allows for some logic simplification such
as in libxl where we can Remove the @vm directly rather than
needing to set a @remove_dom boolean and removing after the
libxlDomainObjEndJob completes as the @vm is locked/reffed.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-05-03 19:09:03 -04:00
..
Makefile.inc.am make: split openvz driver build rules into openvz/Makefile.inc.am 2018-02-23 13:14:26 +00:00
openvz_conf.c conf: Clean up object referencing for Add and Remove 2018-05-03 19:09:03 -04:00
openvz_conf.h openvz: Ditch openvzGetNodeCPUs 2017-03-27 13:13:29 +02:00
openvz_driver.c conf: Clean up object referencing for Add and Remove 2018-05-03 19:09:03 -04:00
openvz_driver.h Remove backslash alignment attempts 2017-11-03 13:24:12 +01:00
openvz_util.c Make tests independant of system page size 2015-02-02 20:27:43 +00:00
openvz_util.h Change file names in comments to match the files they are in 2014-03-10 14:26:04 +01:00