From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xensource.com
Cc: Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 21 of 26] libxl/xl: use libxl_diskinfo_destroy and libxl_device_disk_destroy
Date: Mon, 16 Aug 2010 15:33:45 +0100 [thread overview]
Message-ID: <b37efbc62265ee7e0967.1281969225@localhost.localdomain> (raw)
In-Reply-To: <patchbomb.1281969204@localhost.localdomain>
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# 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@citrix.com>
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;
}
next prev parent reply other threads:[~2010-08-16 14:33 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-16 14:33 [PATCH 00 of 26] libxl: autogenerate type definitions and destructor functions Ian Campbell
2010-08-16 14:33 ` [PATCH 01 of 26] xl: use the regular implicit rules to build the xl .o files Ian Campbell
2010-08-16 14:33 ` [PATCH 02 of 26] libxl: define specific types for string list and key, value list Ian Campbell
2010-08-16 14:33 ` [PATCH 03 of 26] libxl: move various enum and #defines above datastructure definitions Ian Campbell
2010-08-16 14:33 ` [PATCH 04 of 26] libxl: add specific type for cpumap Ian Campbell
2010-08-16 14:33 ` [PATCH 05 of 26] libxl: add specific type for hwcaps Ian Campbell
2010-08-16 14:33 ` [PATCH 06 of 26] libxl: make libxl_console_reader type opaque to users of libxl Ian Campbell
2010-08-16 14:33 ` [PATCH 07 of 26] lbixl: make libxl_device_model_starting " Ian Campbell
2010-08-16 14:33 ` [PATCH 08 of 26] libxl: ensure result of libxl_poolid_to_name is always dynamically allocated Ian Campbell
2010-08-16 14:33 ` [PATCH 09 of 26] libxl: move type definitions into _libxl_types.h Ian Campbell
2010-08-16 14:33 ` [PATCH 10 of 26] libxl: tweak formatting/whitespace of _libxl_types.h Ian Campbell
2010-08-16 14:33 ` [PATCH 11 of 26] libxl: autogenerate _libxl_types.h Ian Campbell
2010-08-17 11:53 ` Stefano Stabellini
2010-08-17 12:20 ` Ian Campbell
2010-08-16 14:33 ` [PATCH 12 of 26] libxl: generate destructors for each libxl defined type Ian Campbell
2010-08-16 14:33 ` [PATCH 13 of 26] libxl: libxl_device_console.build_state is const Ian Campbell
2010-08-16 14:33 ` [PATCH 14 of 26] libxl: build info bootloader{, _args} are not const Ian Campbell
2010-08-16 14:33 ` [PATCH 15 of 26] libxl: do not generate a destructor for data types which do not require one Ian Campbell
2010-08-16 14:33 ` [PATCH 16 of 26] libxl: implement destroy for libxl_file_reference builtin type Ian Campbell
2010-08-16 14:33 ` [PATCH 17 of 26] xl: free the libxl types contained in struct domain_config Ian Campbell
2010-08-16 14:33 ` [PATCH 18 of 26] libxl: use libxl_version_info_destroy instead of hand-coded do_free_version_info Ian Campbell
2010-08-16 14:33 ` [PATCH 19 of 26] xl: destroy device model info after creation Ian Campbell
2010-08-16 14:33 ` [PATCH 20 of 26] xl: free all data on exit from the domain monitor daemon Ian Campbell
2010-08-17 12:27 ` Stefano Stabellini
2010-08-17 12:33 ` Ian Campbell
2010-08-17 15:11 ` Ian Jackson
2010-08-17 15:12 ` Ian Campbell
2010-08-16 14:33 ` Ian Campbell [this message]
2010-08-16 14:33 ` [PATCH 22 of 26] libxl/xl: Use libxl_device_nic_destroy and libxl_nicinfo_destroy Ian Campbell
2010-08-16 14:33 ` [PATCH 23 of 26] libxl/xl: Use libxl_vcpuinfo_destroy Ian Campbell
2010-08-16 14:33 ` [PATCH 24 of 26] xl: use libxl_device_pci_destroy Ian Campbell
2010-08-16 14:33 ` [PATCH 25 of 26] libxl: do not GC data returned to the caller by libxl_device_disk_getinfo Ian Campbell
2010-08-16 14:33 ` [PATCH 26 of 26] libxl: xs_read accepts NULL for *len parameter Ian Campbell
2010-08-17 12:14 ` [PATCH 00 of 26] libxl: autogenerate type definitions and destructor functions Gianni Tedesco
2010-08-17 12:25 ` Ian Campbell
2010-08-17 12:24 ` Gianni Tedesco
2010-08-17 12:34 ` Stefano Stabellini
2010-08-17 12:37 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b37efbc62265ee7e0967.1281969225@localhost.localdomain \
--to=ian.campbell@citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).