[PATCH 2/2] libxl: fix leaking libxl events

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

 



libxl expects the event handler to free the event passed to it.  From
libxl_event.h:

   event becomes owned by the application and must be freed, either
   by event_occurs or later
---
 src/libxl/libxl_driver.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 74e8331..7b21b3d 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -700,7 +700,7 @@ libxlVmReap(libxlDriverPrivatePtr driver,
  * Handle previously registered event notification from libxenlight
  */
 static void
-libxlEventHandler(void *data ATTRIBUTE_UNUSED,
+libxlEventHandler(void *data,
 #ifdef LIBXL_HAVE_NONCONST_EVENT_OCCURS_EVENT_ARG
                   libxl_event *event)
 #else
@@ -708,6 +708,7 @@ libxlEventHandler(void *data ATTRIBUTE_UNUSED,
 #endif
 {
     libxlDriverPrivatePtr driver = libxl_driver;
+    libxlDomainObjPrivatePtr priv = ((virDomainObjPtr)data)->privateData;
     virDomainObjPtr vm = NULL;
     virDomainEventPtr dom_event = NULL;
     libxl_shutdown_reason xl_reason = event->u.domain_shutdown.shutdown_reason;
@@ -764,6 +765,11 @@ cleanup:
         libxlDomainEventQueue(driver, dom_event);
         libxlDriverUnlock(driver);
     }
+#ifdef LIBXL_HAVE_NONCONST_EVENT_OCCURS_EVENT_ARG
+    libxl_event_free(priv->ctx, event);
+#else
+    libxl_event_free(priv->ctx, (libxl_event *)event);
+#endif
 }
 
 static const struct libxl_event_hooks ev_hooks = {
-- 
1.7.7

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