Change in vdsm[ovirt-3.5]: vmfex hook: hold a ref for a virDomain object

danken at redhat.com danken at redhat.com
Mon Feb 8 09:57:14 UTC 2016


Dan Kenigsberg has uploaded a new change for review.

Change subject: vmfex hook: hold a ref for a virDomain object
......................................................................

vmfex hook: hold a ref for a virDomain object

commit 93feb1c introduced a weakref to virDomain object to avoid
reference cycles. This causes a surprising behaviour: if we do not hold
a reference to virdomain.Notifying, the underlying virDomain is
garbage-collected before being accessed for the first time.

This patch quickly holds a named reference to the domain. I did not find
other pieces of code with the same problem, however, the mechanism seems
dangerously error-prone.

This bug is easily reproduced with

    from vdsm import libvirtconnection
    c = libvirtconnection.get()
    print(c.lookupByName('my-vm').XMLDesc(0))

and "solved" by

    from vdsm import libvirtconnection
    c = libvirtconnection.get()
    v = c.lookupByName('my-vm')
    print(v.XMLDesc(0))

Change-Id: Ida7488db5f8af51da5a2931d8b8a6c51d99c36f0
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1305338
Signed-off-by: Dan Kenigsberg <danken at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/53160
---
M vdsm_hooks/vmfex_dev/vmfex_vnic.py
1 file changed, 4 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/03/53203/1

diff --git a/vdsm_hooks/vmfex_dev/vmfex_vnic.py b/vdsm_hooks/vmfex_dev/vmfex_vnic.py
index b995644..3e4791b 100755
--- a/vdsm_hooks/vmfex_dev/vmfex_vnic.py
+++ b/vdsm_hooks/vmfex_dev/vmfex_vnic.py
@@ -80,8 +80,10 @@
 def qbhInUse(conn):
     """Returns whether there is already some VM with a 802.1Qbh (most likely to
     be vmfex)."""
-    for vm in conn.listDomainsID():
-        domxml = minidom.parseString(conn.lookupByID(vm).XMLDesc(0))
+    for vmid in conn.listDomainsID():
+        # FIXME: we have to hold a reference to domobj due to rhbz#1305338
+        domobj = conn.lookupByID(vmid)
+        domxml = minidom.parseString(domobj.XMLDesc(0))
         for vport in domxml.getElementsByTagName('virtualport'):
             if vport.getAttribute('type') == '802.1Qbh':
                 return True


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ida7488db5f8af51da5a2931d8b8a6c51d99c36f0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Dan Kenigsberg <danken at redhat.com>


More information about the vdsm-patches mailing list