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 13 of 16] libxl/xl: use libxl_diskinfo_destroy and li

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 13 of 16] libxl/xl: use libxl_diskinfo_destroy and libxl_device_disk_destroy
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Wed, 18 Aug 2010 16:44:36 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Wed, 18 Aug 2010 08:57:58 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1282146263@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 1282143678 -3600
# Node ID 96473378234f500d368fa5afe8230d608272b852
# Parent  893c1c066ce97cb56cdc4498f95f243163c1e056
libxl/xl: use libxl_diskinfo_destroy and libxl_device_disk_destroy

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

diff -r 893c1c066ce9 -r 96473378234f tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Wed Aug 18 16:01:18 2010 +0100
+++ b/tools/libxl/libxl.c       Wed Aug 18 16:01:18 2010 +0100
@@ -1347,8 +1347,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);
@@ -2554,6 +2554,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 = "";
@@ -2567,9 +2568,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);
@@ -2580,9 +2583,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 893c1c066ce9 -r 96473378234f tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Wed Aug 18 16:01:18 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Wed Aug 18 16:01:18 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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

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