[PATCH] libxl: dispose libxl_dominfo after libxl_domain_info()

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

 



As suggested in a previous thread [0] this patch adds some missing calls
to libxl_dominfo_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@xxxxxxxxxx>
---
 src/libxl/libxl_driver.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 73ed448..a449730 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);
@@ -1598,6 +1602,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);
-- 
2.1.4

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