aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2011-10-18 13:36:15 +0100
committerIan Campbell <ian.campbell@citrix.com>2011-10-18 13:36:15 +0100
commitbcea3858dd4ec793dd2c30fe60571402a4b1d669 (patch)
tree80c561c0c785c8b8b37563f8d9dade8e09c1da60 /tools
parent992b71cf41cc3882e627b004af5259c0df9cdd72 (diff)
downloadxen-bcea3858dd4ec793dd2c30fe60571402a4b1d669.tar.gz
xen-bcea3858dd4ec793dd2c30fe60571402a4b1d669.tar.bz2
xen-bcea3858dd4ec793dd2c30fe60571402a4b1d669.zip
libxl: do not read f.e. xenstore dir in disk list function
Instead store a duplicate of the "device-type" node in the backend dir and use that instead. This maintains the invariant that the list function is always "safe". Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson.citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/libxl/libxl.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 8c42e3f0a9..3d74344131 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1018,6 +1018,8 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
flexarray_append(back, libxl__device_disk_string_of_backend(disk->backend));
flexarray_append(back, "mode");
flexarray_append(back, disk->readwrite ? "w" : "r");
+ flexarray_append(back, "device-type");
+ flexarray_append(back, disk->is_cdrom ? "cdrom" : "disk");
flexarray_append(front, "backend-id");
flexarray_append(front, libxl__sprintf(&gc, "%d", disk->backend_domid));
@@ -1512,7 +1514,6 @@ static void libxl__device_disk_from_xs_be(libxl__gc *gc,
libxl_ctx *ctx = libxl__gc_owner(gc);
unsigned int len;
char *tmp;
- const char *fe_path; /* XXX unsafe */
memset(disk, 0, sizeof(*disk));
@@ -1544,10 +1545,8 @@ static void libxl__device_disk_from_xs_be(libxl__gc *gc,
else
disk->readwrite = 0;
- fe_path = libxl__xs_read(gc, XBT_NULL,
- libxl__sprintf(gc, "%s/frontend", be_path));
tmp = libxl__xs_read(gc, XBT_NULL,
- libxl__sprintf(gc, "%s/device-type", fe_path));
+ libxl__sprintf(gc, "%s/device-type", be_path));
disk->is_cdrom = !strcmp(tmp, "cdrom");
disk->format = LIBXL_DISK_FORMAT_UNKNOWN;