WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 21 of 26] libxl/xl: use libxl_diskinfo_destroy and li

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 21 of 26] libxl/xl: use libxl_diskinfo_destroy and libxl_device_disk_destroy
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Mon, 16 Aug 2010 15:33:45 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Mon, 16 Aug 2010 07:58:19 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1281969204@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1281969065 -3600
# Node ID b37efbc62265ee7e0967ae856bfff9e9953f62f4
# Parent  dd25ac29c0f74a2d909df3e3d072ed5d59320312
libxl/xl: use libxl_diskinfo_destroy and libxl_device_disk_destroy

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r dd25ac29c0f7 -r b37efbc62265 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Aug 16 15:31:05 2010 +0100
+++ b/tools/libxl/libxl.c       Mon Aug 16 15:31:05 2010 +0100
@@ -1348,8 +1348,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);
         }
+        libxl_device_disk_destroy(&disks[i]);
     }
-    /* FIXME: leaks disk paths */
     free(disks);
     flexarray_set(dm_args, num++, NULL);
     return (char **) flexarray_contents(dm_args);
@@ -2578,6 +2578,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 = "";
@@ -2591,9 +2592,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);
@@ -2604,9 +2607,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 dd25ac29c0f7 -r b37efbc62265 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Mon Aug 16 15:31:05 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Mon Aug 16 15:31:05 2010 +0100
@@ -4259,7 +4259,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;
 
@@ -4289,14 +4289,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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>