connection: Call virConnectClose and log the return value

This can help us find object leaks within the code. virConnectClose
is just a deference and will return 1 if other references are still
floating around.
This commit is contained in:
Cole Robinson
2018-03-15 21:24:48 -04:00
parent 7e1cddef18
commit 6ad6f44920
3 changed files with 10 additions and 2 deletions
+5 -1
View File
@@ -986,7 +986,6 @@ class vmmConnection(vmmGObject):
self._storage_pool_cb_ids = []
self._node_device_cb_ids = []
self._backend.close()
self._stats = []
if self._init_object_event:
@@ -995,6 +994,11 @@ class vmmConnection(vmmGObject):
self._objects.cleanup()
self._objects = _ObjectList()
closeret = self._backend.close()
if closeret == 1 and self.config.test_leak_debug:
logging.debug("LEAK: conn close() returned 1, "
"meaning refs may have leaked.")
self._change_state(self._STATE_DISCONNECTED)
self._closing = False
+1 -1
View File
@@ -478,7 +478,7 @@ class vmmEngine(vmmGObject):
objs.remove(src.object_key)
for name in objs:
logging.debug("Leaked %s", name)
logging.debug("LEAK: %s", name)
logging.debug("Exiting app normally.")
self._application.quit()
+4
View File
@@ -118,9 +118,13 @@ class VirtualConnection(object):
return not bool(self._libvirtconn)
def close(self):
ret = 0
if self._libvirtconn:
ret = self._libvirtconn.close()
self._libvirtconn = None
self._uri = None
self._fetch_cache = {}
return ret
def fake_conn_predictable(self):
return self._fake_conn_predictable