[PATCH 7/n] qemu: plug memory leak

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

 



* src/qemu/qemu_driver.c (qemudShutdown): Free all strings and the
ebtables structure.
* src/libvirt_private.syms (ebtablesContextFree): Export missing
symbol.
* src/util/ebtables.c (ebtablesContextFree): Allow early exit.
---

This leak triggers on every start/stop of a qemu domain, although
it typically accounts for less than 1k leak per sequence.

 src/libvirt_private.syms |    1 +
 src/qemu/qemu_driver.c   |   13 ++++++++++---
 src/util/ebtables.c      |    2 ++
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ef33f86..43df955 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -325,6 +325,7 @@ virDomainConfVMNWFilterTeardown;
 # ebtables.h
 ebtablesAddForwardAllowIn;
 ebtablesAddForwardPolicyReject;
+ebtablesContextFree;
 ebtablesContextNew;
 ebtablesRemoveForwardAllowIn;

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f00d8a3..faab42a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2068,10 +2068,9 @@ qemudShutdown(void) {

     virSysinfoDefFree(qemu_driver->hostsysinfo);

-    VIR_FREE(qemu_driver->securityDriverName);
-    VIR_FREE(qemu_driver->logDir);
     VIR_FREE(qemu_driver->configDir);
     VIR_FREE(qemu_driver->autostartDir);
+    VIR_FREE(qemu_driver->logDir);
     VIR_FREE(qemu_driver->stateDir);
     VIR_FREE(qemu_driver->libDir);
     VIR_FREE(qemu_driver->cacheDir);
@@ -2081,10 +2080,18 @@ qemudShutdown(void) {
     VIR_FREE(qemu_driver->vncListen);
     VIR_FREE(qemu_driver->vncPassword);
     VIR_FREE(qemu_driver->vncSASLdir);
-    VIR_FREE(qemu_driver->saveImageFormat);
+    VIR_FREE(qemu_driver->spiceTLSx509certdir);
+    VIR_FREE(qemu_driver->spiceListen);
+    VIR_FREE(qemu_driver->spicePassword);
     VIR_FREE(qemu_driver->hugetlbfs_mount);
     VIR_FREE(qemu_driver->hugepage_path);

+    VIR_FREE(qemu_driver->securityDriverName);
+    VIR_FREE(qemu_driver->saveImageFormat);
+    VIR_FREE(qemu_driver->dumpImageFormat);
+
+    ebtablesContextFree(qemu_driver->ebtables);
+
     if (qemu_driver->cgroupDeviceACL) {
         for (i = 0 ; qemu_driver->cgroupDeviceACL[i] != NULL ; i++)
             VIR_FREE(qemu_driver->cgroupDeviceACL[i]);
diff --git a/src/util/ebtables.c b/src/util/ebtables.c
index f707756..e3b8da4 100644
--- a/src/util/ebtables.c
+++ b/src/util/ebtables.c
@@ -300,6 +300,8 @@ ebtablesContextNew(const char *driver)
 void
 ebtablesContextFree(ebtablesContext *ctx)
 {
+    if (!ctx)
+        return;
     if (ctx->input_filter)
         ebtRulesFree(ctx->input_filter);
     if (ctx->forward_filter)
-- 
1.7.3.2

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