[libvirt] [PATCH 3/3] Fix memory leak of monitor character device

Daniel P. Berrange berrange at redhat.com
Wed Aug 26 14:59:09 UTC 2009


* src/qemu_driver.c: Free the vm->monitor_chr field at VM shutdown.
  Unlink the UNIX domain socket at VM shutdown to avoid littering
  FS with old sockets
---
 src/qemu_driver.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 0342627..b30971c 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -2239,6 +2239,13 @@ static void qemudShutdownVMDaemon(virConnectPtr conn,
         close(vm->monitor);
     vm->monitor = -1;
 
+    if (vm->monitor_chr) {
+        if (vm->monitor_chr->type == VIR_DOMAIN_CHR_TYPE_UNIX)
+            unlink(vm->monitor_chr->data.nix.path);
+        virDomainChrDefFree(vm->monitor_chr);
+        vm->monitor_chr = NULL;
+    }
+
     /* shut it off for sure */
     virKillProcess(vm->pid, SIGKILL);
 
-- 
1.6.2.5




More information about the libvir-list mailing list