[PATCHv2 3/3] util: avoid VM object to be disposed before unlock in close callback.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Probably causes 'vm' to be disposed in execute qemuProcessAutoDestroy
callback function, reference 'vm' avoid unlock disposed object.

Signed-off-by: Wang King <king.wang@xxxxxxxxxx>
---
 src/util/virclosecallbacks.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/util/virclosecallbacks.c b/src/util/virclosecallbacks.c
index 633b22c..ab11e95 100644
--- a/src/util/virclosecallbacks.c
+++ b/src/util/virclosecallbacks.c
@@ -337,18 +337,20 @@ virCloseCallbacksRun(virCloseCallbacksPtr closeCallbacks,
 
     for (i = 0; i < list->nentries; i++) {
         virDomainObjPtr vm;
+        virDomainObjPtr dom;
 
-        if (!(vm = virDomainObjListFindByUUID(domains,
-                                              list->entries[i].uuid))) {
+        if (!(vm = virDomainObjListFindByUUIDRef(domains,
+                                                 list->entries[i].uuid))) {
             char uuidstr[VIR_UUID_STRING_BUFLEN];
             virUUIDFormat(list->entries[i].uuid, uuidstr);
             VIR_DEBUG("No domain object with UUID %s", uuidstr);
             continue;
         }
 
-        vm = list->entries[i].callback(vm, conn, opaque);
-        if (vm)
-            virObjectUnlock(vm);
+        dom = list->entries[i].callback(vm, conn, opaque);
+        if (dom)
+            virObjectUnlock(dom);
+        virObjectUnref(vm);
     }
 
     virObjectLock(closeCallbacks);
-- 
2.8.3


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux