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

[Xen-changelog] [xen-unstable] libxl/xl: use libxl_diskinfo_destroy and libxl_device_disk_destroy



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1282228306 -3600
# Node ID 597da2edfe301d1f46a0f093fbc4f017045b984d
# Parent  dc381437e19d5df2152da0676f264ed8e226b7e4
libxl/xl: use libxl_diskinfo_destroy and libxl_device_disk_destroy

[PATCH 13 of 16 of
 libxl: autogenerate type definitions and destructor functions]

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxl/libxl.c      |   19 ++++++++++++-------
 tools/libxl/xl_cmdimpl.c |   11 +++++++----
 2 files changed, 19 insertions(+), 11 deletions(-)

diff -r dc381437e19d -r 597da2edfe30 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Thu Aug 19 15:31:14 2010 +0100
+++ b/tools/libxl/libxl.c       Thu Aug 19 15:31:46 2010 +0100
@@ -1355,8 +1355,8 @@ static char ** libxl_build_device_model_
             flexarray_set(dm_args, num++, libxl_sprintf(gc, "-%s", 
disks[i].virtpath));
             flexarray_set(dm_args, num++, disks[i].physpath);
         }
-    }
-    /* FIXME: leaks disk paths */
+        libxl_device_disk_destroy(&disks[i]);
+    }
     free(disks);
     flexarray_set(dm_args, num++, NULL);
     return (char **) flexarray_contents(dm_args);
@@ -2562,6 +2562,7 @@ int libxl_cdrom_insert(libxl_ctx *ctx, u
     int num, i;
     uint32_t stubdomid;
     libxl_device_disk *disks;
+    int ret = ERROR_FAIL;
 
     if (!disk->physpath) {
         disk->physpath = "";
@@ -2575,9 +2576,11 @@ int libxl_cdrom_insert(libxl_ctx *ctx, u
     }
     if (i == num) {
         XL_LOG(ctx, XL_LOG_ERROR, "Virtual device not found");
-        free(disks);
-        return ERROR_FAIL;
-    }
+        goto out;
+    }
+
+    ret = 0;
+
     libxl_device_disk_del(ctx, disks + i, 1);
     libxl_device_disk_add(ctx, domid, disk);
     stubdomid = libxl_get_stubdom_id(ctx, domid);
@@ -2588,9 +2591,11 @@ int libxl_cdrom_insert(libxl_ctx *ctx, u
         libxl_device_disk_add(ctx, stubdomid, disk);
         disk->domid = domid;
     }
-    /* FIXME: leaks disk paths */
+out:
+    for (i = 0; i < num; i++)
+        libxl_device_disk_destroy(&disks[i]);
     free(disks);
-    return 0;
+    return ret;
 }
 
 
/******************************************************************************/
diff -r dc381437e19d -r 597da2edfe30 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu Aug 19 15:31:14 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Thu Aug 19 15:31:46 2010 +0100
@@ -4261,7 +4261,7 @@ int main_blocklist(int argc, char **argv
 int main_blocklist(int argc, char **argv)
 {
     int opt;
-    int nb;
+    int i, nb;
     libxl_device_disk *disks;
     libxl_diskinfo diskinfo;
 
@@ -4291,14 +4291,17 @@ int main_blocklist(int argc, char **argv
         if (!disks) {
             continue;
         }
-        for (; nb > 0; --nb, ++disks) {
-            if (!libxl_device_disk_getinfo(&ctx, domid, disks, &diskinfo)) {
+        for (i=0; i<nb; i++) {
+            if (!libxl_device_disk_getinfo(&ctx, domid, &disks[i], &diskinfo)) 
{
                 /*      Vdev BE   hdl  st   evch rref BE-path*/
                 printf("%-5d %-3d %-6d %-5d %-6d %-8d %-30s\n",
                        diskinfo.devid, diskinfo.backend_id, 
diskinfo.frontend_id,
                        diskinfo.state, diskinfo.evtch, diskinfo.rref, 
diskinfo.backend);
+                libxl_diskinfo_destroy(&diskinfo);
             }
-        }
+            libxl_device_disk_destroy(&disks[i]);
+        }
+        free(disks);
     }
     return 0;
 }

_______________________________________________
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®.