提交 cda52dbf 编写于 作者: J Jim Fehlig

libxl: fix leaking libxlDomainObjPrivate

When libxl registers an FD with the libxl driver, the refcnt of the
associated libxlDomainObjPrivate object is incremented. The refcnt
is decremented when libxl deregisters the FD.  But some FDs are only
deregistered when their libxl ctx is freed, which unfortunately is
done in the libxlDomainObjPrivate dispose function.  With references
held by the FDs, libxlDomainObjPrivate is never disposed.

I added the ref/unref in FD registration/deregistration when adding
the same in timer registration/deregistration.  For timers, this
is a simple approach to ensuring the libxlDomainObjPrivate is not
disposed prior to their expirtation, which libxl guarantees will
occur.  It is not needed for FDs, and only causes
libxlDomainObjPrivate to leak.

This patch removes the reference on libxlDomainObjPrivate for FD
registrations, but retains them for timer registrations.  Tested on
the latest releases of Xen supported by the libxl driver:  4.2.3,
4.3.1, and 4.4.0 RC3.
Signed-off-by: NJim Fehlig <jfehlig@suse.com>
上级 0778fc1a
/*
* libxl_domain.c: libxl domain object private state
*
* Copyright (C) 2011-2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
* Copyright (C) 2011-2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -92,7 +92,13 @@ libxlDomainObjPrivateOnceInit(void)
VIR_ONCE_GLOBAL_INIT(libxlDomainObjPrivate)
static void
libxlDomainObjEventHookInfoFree(void *obj)
libxlDomainObjFDEventHookInfoFree(void *obj)
{
VIR_FREE(obj);
}
static void
libxlDomainObjTimerEventHookInfoFree(void *obj)
{
libxlEventHookInfoPtr info = obj;
......@@ -138,12 +144,6 @@ libxlDomainObjFDRegisterEventHook(void *priv,
return -1;
info->priv = priv;
/*
* Take a reference on the domain object. Reference is dropped in
* libxlDomainObjEventHookInfoFree, ensuring the domain object outlives
* the fd event objects.
*/
virObjectRef(info->priv);
info->xl_priv = xl_priv;
if (events & POLLIN)
......@@ -152,9 +152,8 @@ libxlDomainObjFDRegisterEventHook(void *priv,
vir_events |= VIR_EVENT_HANDLE_WRITABLE;
info->id = virEventAddHandle(fd, vir_events, libxlDomainObjFDEventCallback,
info, libxlDomainObjEventHookInfoFree);
info, libxlDomainObjFDEventHookInfoFree);
if (info->id < 0) {
virObjectUnref(info->priv);
VIR_FREE(info);
return -1;
}
......@@ -259,7 +258,7 @@ libxlDomainObjTimeoutRegisterEventHook(void *priv,
timeout = res.tv_sec * 1000 + (res.tv_usec + 999) / 1000;
}
info->id = virEventAddTimeout(timeout, libxlDomainObjTimerCallback,
info, libxlDomainObjEventHookInfoFree);
info, libxlDomainObjTimerEventHookInfoFree);
if (info->id < 0) {
virObjectUnref(info->priv);
VIR_FREE(info);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册