Re: [Xen-devel] libvirt libxl driver leaking libxl_event's?

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

 



On 04/11/2013 07:09 AM, Ian Campbell wrote:
On Thu, 2013-04-11 at 13:46 +0100, Ian Campbell wrote:
Hi Jim,

I don't see any calls to libxl_event_dispose in libvirt.git,
actually I think I meant libxl_event_free, but I can't see that either.

Right. I confirmed that was needed with Ian J. a few weeks (months) back, but then never submitted a patch. I've attached one, but noticed that the prototype of the event_occurs callback defines the event parameter as const, causing this error without the lame cast

cc1: warnings being treated as errors
libxl/libxl_driver.c: In function 'libxlEventHandler':
libxl/libxl_driver.c:760: error: passing argument 2 of 'libxl_event_free' discards qualifiers from pointer target type

Shouldn't the callback in libxl_event.h just be

    void (*event_occurs)(void *user, libxl_event *event);

But I suppose we can't change that. BTW, the const'ness of event led me to believe it didn't need freed.

Regards,
Jim



libxl_event.h says in relation to the event_occurs callback:
    * event becomes owned by the application and must be freed, either
    * by event_occurs or later.
so does this mean the memory referenced by event is leaked by
libxlEventHandler?

libxl_event only contains dynamic allocations for
LIBXL_EVENT_TYPE_DISK_EJECT which you don't seem to register for so the
issue is probably benign but worth noting I think.

Ian.


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel



diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 9980b38..b9e3f4d 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -697,9 +697,10 @@ libxlVmReap(libxlDriverPrivatePtr driver,
  * Handle previously registered event notification from libxenlight
  */
 static void
-libxlEventHandler(void *data ATTRIBUTE_UNUSED, const libxl_event *event)
+libxlEventHandler(void *data, const libxl_event *event)
 {
     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;
@@ -756,6 +757,7 @@ cleanup:
         libxlDomainEventQueue(driver, dom_event);
         libxlDriverUnlock(driver);
     }
+    libxl_event_free(priv->ctx, (libxl_event *)event);
 }
 
 static const struct libxl_event_hooks ev_hooks = {
--
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]