[PATCH] lxc: monitor now holds a reference to the domain

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

 



If the monitor doesn't hold a reference to the domain object
the object may be destroyed before the monitor actually stops.
---
 src/lxc/lxc_monitor.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c
index d828d52..de63f9e 100644
--- a/src/lxc/lxc_monitor.c
+++ b/src/lxc/lxc_monitor.c
@@ -179,6 +179,7 @@ virLXCMonitorPtr virLXCMonitorNew(virDomainObjPtr vm,
     memcpy(&mon->cb, cb, sizeof(mon->cb));
 
     virObjectRef(mon);
+    virObjectRef(vm);
     virNetClientSetCloseCallback(mon->client, virLXCMonitorEOFNotify, mon,
                                  virLXCMonitorCloseFreeCallback);
 
@@ -188,6 +189,7 @@ virLXCMonitorPtr virLXCMonitorNew(virDomainObjPtr vm,
 
  error:
     virObjectUnref(mon);
+    virObjectUnref(vm);
     mon = NULL;
     goto cleanup;
 }
@@ -201,6 +203,7 @@ static void virLXCMonitorDispose(void *opaque)
     if (mon->cb.destroy)
         (mon->cb.destroy)(mon, mon->vm);
     virObjectUnref(mon->program);
+    virObjectUnref(mon->vm);
 }
 
 
-- 
2.10.2

--
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