From: Joao Martins <joao.m.martins@oracle.com>
To: libvir-list@redhat.com, jfehlig@suse.com
Cc: Joao Martins <joao.m.martins@oracle.com>, xen-devel@lists.xen.org
Subject: [PATCH v2] libxl: dispose libxl_dominfo after libxl_domain_info()
Date: Thu, 21 Jan 2016 10:21:10 +0000 [thread overview]
Message-ID: <1453371670-3513-1-git-send-email-joao.m.martins@oracle.com> (raw)
As suggested in a previous thread [0] this patch adds some missing calls
to libxl_dominfo_{init,dispose} when doing some of the libxl_domain_info
operations which would otherwise lead to memory leaks.
[0]
https://www.redhat.com/archives/libvir-list/2015-September/msg00519.html
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
---
Changes since v1:
- Add missing libxl_dominfo_init() on MemoryStats and GetInfo()
---
src/libxl/libxl_driver.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 73ed448..560f2a6 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -358,6 +358,8 @@ libxlReconnectDomain(virDomainObjPtr vm,
virObjectLock(vm);
+ libxl_dominfo_init(&d_info);
+
/* Does domain still exist? */
rc = libxl_domain_info(cfg->ctx, &d_info, vm->def->id);
if (rc == ERROR_INVAL) {
@@ -389,11 +391,13 @@ libxlReconnectDomain(virDomainObjPtr vm,
/* Enable domain death events */
libxl_evenable_domain_death(cfg->ctx, vm->def->id, 0, &priv->deathW);
+ libxl_dominfo_dispose(&d_info);
virObjectUnlock(vm);
virObjectUnref(cfg);
return 0;
out:
+ libxl_dominfo_dispose(&d_info);
libxlDomainCleanup(driver, vm);
if (!vm->persistent)
virDomainObjListRemoveLocked(driver->domains, vm);
@@ -1589,6 +1593,8 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
info->memory = vm->def->mem.cur_balloon;
info->maxMem = virDomainDefGetMemoryActual(vm->def);
} else {
+ libxl_dominfo_init(&d_info);
+
if (libxl_domain_info(cfg->ctx, &d_info, vm->def->id) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("libxl_domain_info failed for domain '%d'"),
@@ -1598,6 +1604,8 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
info->cpuTime = d_info.cpu_time;
info->memory = d_info.current_memkb;
info->maxMem = d_info.max_memkb;
+
+ libxl_dominfo_dispose(&d_info);
}
info->state = virDomainObjGetState(vm, NULL);
@@ -4791,6 +4799,7 @@ libxlDomainMemoryStats(virDomainPtr dom,
virCheckFlags(0, -1);
+ libxl_dominfo_init(&d_info);
cfg = libxlDriverConfigGet(driver);
if (!(vm = libxlDomObjFromDomain(dom)))
@@ -4822,13 +4831,12 @@ libxlDomainMemoryStats(virDomainPtr dom,
ret = i;
- libxl_dominfo_dispose(&d_info);
-
endjob:
if (!libxlDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
+ libxl_dominfo_dispose(&d_info);
if (vm)
virObjectUnlock(vm);
virObjectUnref(cfg);
--
2.1.4
next reply other threads:[~2016-01-21 10:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-21 10:21 Joao Martins [this message]
2016-01-21 16:58 ` [PATCH v2] libxl: dispose libxl_dominfo after libxl_domain_info() Jim Fehlig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1453371670-3513-1-git-send-email-joao.m.martins@oracle.com \
--to=joao.m.martins@oracle.com \
--cc=jfehlig@suse.com \
--cc=libvir-list@redhat.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).