Change in vdsm[ovirt-3.5]: lib: use weakmethod to break reference cycles

fromani at redhat.com fromani at redhat.com
Fri Jan 22 12:57:11 UTC 2016


Francesco Romani has submitted this change and it was merged.

Change subject: lib: use weakmethod to break reference cycles
......................................................................


lib: use weakmethod to break reference cycles

The libvirtconnection module replaces the methods
of libvirt.virDomain object (et. al.) to detect libvirt
errors, and to take action in presence of certain errors,
maybe dropping the connection, maybe killing Vdsm.

While the whole idea of this wrapping and how to properly
react to these events is debatable and should probably
rewritten, the immediate issue is that this wrapping is not safe,
and creates circular references in instance methods:

   +-------------------------------------+
   v                                     |
object -> wrapper -> tuple of arguments(self, method)

Since libvirt.virDomain defines the __del__ special method,
objects become uncollectable, and the net final effect is
a resource leak each time a VM is stopped.

This was observed for virDomain, but the wrapping of
virConnect has also the same problem.

This patch uses utils.weakmethod to break the reference cycle in a
backport-friandly manner, in order to make the objects collectable
again, and to avoid the leak.

The proper long-term fix is to rethink the wrapping done in
libvirtconnection.py, but this deserves more planning and
will be addressed in a future patch.

Change-Id: I06607e63d222bf3f8037f2bda115b48feb94cb1c
Bug-Url: https://bugzilla.redhat.com/1283999
Bug-Url: https://bugzilla.redhat.com/1269424
Backport-To: 3.6
Backport-To: 3.5
Reported-By: Eldad Marciano <emarcian at redhat.com>
Reported-By: Milan Zamazal <mzamazal at redhat.com>
Signed-off-by: Francesco Romani <fromani at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/51630
Reviewed-by: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Reviewed-by: Nir Soffer <nsoffer at redhat.com>
Continuous-Integration: Jenkins CI
Reviewed-on: https://gerrit.ovirt.org/52423
Reviewed-on: https://gerrit.ovirt.org/52558
---
M lib/vdsm/libvirtconnection.py
1 file changed, 5 insertions(+), 3 deletions(-)

Approvals:
  Piotr Kliczewski: Looks good to me, but someone else must approve
  Jenkins CI: Passed CI tests
  Francesco Romani: Verified; Looks good to me, approved



-- 
To view, visit https://gerrit.ovirt.org/52558
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I06607e63d222bf3f8037f2bda115b48feb94cb1c
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>


More information about the vdsm-patches mailing list