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

[Xen-changelog] [xen-unstable] xl daemon: fix some memory leaks



# HG changeset patch
# User Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
# Date 1297969965 0
# Node ID 2ad66067784da47eef7ce2d0a204fbeae0557ef1
# Parent  30baafb3250ac6c6d55192f601c4e2946edd803d
xl daemon: fix some memory leaks

If we are watching multiple disks we have to free multiple waiters.

Free the event before continuing the loop.

Destroy the disk device returned by libxl_event_get_disk_eject_info.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxl/xl_cmdimpl.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff -r 30baafb3250a -r 2ad66067784d tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu Feb 17 12:18:01 2011 +0000
+++ b/tools/libxl/xl_cmdimpl.c  Thu Feb 17 19:12:45 2011 +0000
@@ -1334,7 +1334,7 @@ static int create_domain(struct domain_c
     const char *restore_file = dom_info->restore_file;
     int migrate_fd = dom_info->migrate_fd;
 
-    int fd;
+    int fd, i;
     int need_daemon = 1;
     int ret, rc;
     libxl_waiter *w1 = NULL, *w2 = NULL;
@@ -1603,7 +1603,10 @@ start:
             case LIBXL_EVENT_DOMAIN_DEATH:
                 ret = libxl_event_get_domain_death_info(&ctx, domid, &event, 
&info);
 
-                if (ret < 0) continue;
+                if (ret < 0) {
+                    libxl_free_event(&event);
+                    continue;
+                }
 
                 LOG("Domain %d is dead", domid);
 
@@ -1619,7 +1622,8 @@ start:
                         /* Otherwise fall through and restart. */
                     case 1:
 
-                        libxl_free_waiter(w1);
+                        for (i = 0; i < d_config.num_disks; i++)
+                            libxl_free_waiter(&w1[i]);
                         libxl_free_waiter(w2);
                         free(w1);
                         free(w2);
@@ -1655,8 +1659,10 @@ start:
                 }
                 break;
             case LIBXL_EVENT_DISK_EJECT:
-                if (libxl_event_get_disk_eject_info(&ctx, domid, &event, 
&disk))
+                if (libxl_event_get_disk_eject_info(&ctx, domid, &event, 
&disk)) {
                     libxl_cdrom_insert(&ctx, domid, &disk);
+                    libxl_device_disk_destroy(&disk);
+                }
                 break;
         }
         libxl_free_event(&event);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.