From patchwork Thu Jan 21 10:21:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 8079661 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C4AA59F744 for ; Thu, 21 Jan 2016 10:23:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED8EA2054B for ; Thu, 21 Jan 2016 10:23:37 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1331420522 for ; Thu, 21 Jan 2016 10:23:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aMCMY-0000aq-V9; Thu, 21 Jan 2016 10:21:10 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aMCMX-0000ac-Cv for xen-devel@lists.xen.org; Thu, 21 Jan 2016 10:21:09 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id 93/B9-24494-411B0A65; Thu, 21 Jan 2016 10:21:08 +0000 X-Env-Sender: joao.m.martins@oracle.com X-Msg-Ref: server-8.tower-206.messagelabs.com!1453371666!16966350!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16568 invoked from network); 21 Jan 2016 10:21:07 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-8.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 21 Jan 2016 10:21:07 -0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u0LAL5Gt007803 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 21 Jan 2016 10:21:06 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u0LAL46J007254 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 21 Jan 2016 10:21:04 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.13.8) with ESMTP id u0LAL4Ue003130; Thu, 21 Jan 2016 10:21:04 GMT Received: from localhost.localdomain (/87.196.251.223) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 21 Jan 2016 02:21:04 -0800 From: Joao Martins To: libvir-list@redhat.com, jfehlig@suse.com Date: Thu, 21 Jan 2016 10:21:10 +0000 Message-Id: <1453371670-3513-1-git-send-email-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.1.4 X-Source-IP: aserv0022.oracle.com [141.146.126.234] Cc: Joao Martins , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH v2] libxl: dispose libxl_dominfo after libxl_domain_info() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);