lxc: monitor now holds a reference to the domain

If the monitor doesn't hold a reference to the domain object
the object may be destroyed before the monitor actually stops.
This commit is contained in:
Cédric Bosdonnat 2016-12-06 14:20:13 +01:00
parent ce937d3710
commit 3cd556d486

View File

@ -175,7 +175,7 @@ virLXCMonitorPtr virLXCMonitorNew(virDomainObjPtr vm,
mon->program) < 0)
goto error;
mon->vm = vm;
mon->vm = virObjectRef(vm);
memcpy(&mon->cb, cb, sizeof(mon->cb));
virObjectRef(mon);
@ -201,6 +201,7 @@ static void virLXCMonitorDispose(void *opaque)
if (mon->cb.destroy)
(mon->cb.destroy)(mon, mon->vm);
virObjectUnref(mon->program);
virObjectUnref(mon->vm);
}