# 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
|