[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/2] libxl: correctly list disks served by driver domains in block-list
The block-list command was not able to lists disks with backends running on domains different than Dom0, because it was only looking on the backend xenstore path of Dom0. Fix this by instead fetching the disks from the DomU xenstore entries. Signed-off-by: Roger Pau Monnà <roger.pau@xxxxxxxxxx> Reported-by: G.R. <firemeteor@xxxxxxxxxxxxxxxxxxxxx> Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> Cc: Ian Campbell <ian.campbell@xxxxxxxxxx> --- tools/libxl/libxl.c | 72 +++++++++++++++++--------------------------------- 1 files changed, 25 insertions(+), 47 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 81785df..4aa2fe3 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -2324,61 +2324,39 @@ out: return rc; } - -static int libxl__append_disk_list_of_type(libxl__gc *gc, - uint32_t domid, - const char *type, - libxl_device_disk **disks, - int *ndisks) -{ - char *be_path = NULL; - char **dir = NULL; - unsigned int n = 0; - libxl_device_disk *pdisk = NULL, *pdisk_end = NULL; - int rc=0; - int initial_disks = *ndisks; - - be_path = libxl__sprintf(gc, "%s/backend/%s/%d", - libxl__xs_get_dompath(gc, 0), type, domid); - dir = libxl__xs_directory(gc, XBT_NULL, be_path, &n); - if (dir) { - libxl_device_disk *tmp; - tmp = realloc(*disks, sizeof (libxl_device_disk) * (*ndisks + n)); - if (tmp == NULL) - return ERROR_NOMEM; - *disks = tmp; - pdisk = *disks + initial_disks; - pdisk_end = *disks + initial_disks + n; - for (; pdisk < pdisk_end; pdisk++, dir++) { - const char *p; - p = libxl__sprintf(gc, "%s/%s", be_path, *dir); - if ((rc=libxl__device_disk_from_xs_be(gc, p, pdisk))) - goto out; - pdisk->backend_domid = 0; - *ndisks += 1; - } - } -out: - return rc; -} - libxl_device_disk *libxl_device_disk_list(libxl_ctx *ctx, uint32_t domid, int *num) { GC_INIT(ctx); libxl_device_disk *disks = NULL; - int rc; + int rc, i; + unsigned int xs_num; + char *fe_path, **devs; + const char *be_path; *num = 0; - rc = libxl__append_disk_list_of_type(gc, domid, "vbd", &disks, num); - if (rc) goto out_err; - - rc = libxl__append_disk_list_of_type(gc, domid, "tap", &disks, num); - if (rc) goto out_err; - - rc = libxl__append_disk_list_of_type(gc, domid, "qdisk", &disks, num); - if (rc) goto out_err; + fe_path = libxl__sprintf(gc, "/local/domain/%d/device/vbd", domid); + devs = libxl__xs_directory(gc, XBT_NULL, fe_path, &xs_num); + if (!devs) + /* Domain has no disks */ + goto out; + disks = libxl__calloc(NOGC, xs_num, sizeof(*disks)); + if (!disks) + goto out_err; + for (i = 0; i < xs_num; i++) { + fe_path = GCSPRINTF("/local/domain/%d/device/vbd/%s/backend", + domid, devs[i]); + rc = libxl__xs_read_checked(gc, XBT_NULL, fe_path, &be_path); + if (rc) + goto out_err; + rc = libxl__device_disk_from_xs_be(gc, be_path, &disks[*num]); + if (rc) + goto out_err; + (*num)++; + assert(*num <= xs_num); + } +out: GC_FREE; return disks; -- 1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |