[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxl: fix cd insert/eject
# HG changeset patch # User Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> # Date 1298041459 0 # Node ID fb83c89d80cbddb4b678047e639a7624d74e3a80 # Parent d12a28ef91b98f702f3155dcb963f9f7f1194165 libxl: fix cd insert/eject When multiple disks are passed to libxl_wait_for_disk_ejects, watch the correct disk paths. Parse the backend type and backend domid from xenstore in libxl_event_get_disk_eject_info. libxl_event_get_disk_eject_info must return a valid string in disk->vdev, while at the moment is free'ed before returning. Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- diff -r d12a28ef91b9 -r fb83c89d80cb tools/libxl/libxl.c --- a/tools/libxl/libxl.c Fri Feb 18 10:21:19 2011 +0000 +++ b/tools/libxl/libxl.c Fri Feb 18 15:04:19 2011 +0000 @@ -37,6 +37,9 @@ #include "flexarray.h" #define PAGE_TO_MEMKB(pages) ((pages) * 4) +#define BACKEND_STRING_SIZE 5 +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) int libxl_ctx_init(libxl_ctx *ctx, int version, xentoollog_logger *lg) { @@ -592,7 +595,7 @@ goto out; if (asprintf(&(waiter[i].token), "%d", LIBXL_EVENT_DISK_EJECT) < 0) goto out; - xs_watch(ctx->xsh, waiter->path, waiter->token); + xs_watch(ctx->xsh, waiter[i].path, waiter[i].token); } rc = 0; out: @@ -654,6 +657,7 @@ char *path; char *backend; char *value; + char backend_type[BACKEND_STRING_SIZE+1]; value = libxl__xs_read(&gc, XBT_NULL, event->path); @@ -666,12 +670,22 @@ path[strlen(path) - 6] = '\0'; backend = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/backend", path)); - disk->backend_domid = 0; + sscanf(backend, + "/local/domain/%d/backend/%" TOSTRING(BACKEND_STRING_SIZE) "[a-z]/%*d/%*d", + &disk->backend_domid, backend_type); + if (!strcmp(backend_type, "tap") || !strcmp(backend_type, "vbd")) { + disk->backend = DISK_BACKEND_TAP; + } else if (!strcmp(backend_type, "qdisk")) { + disk->backend = DISK_BACKEND_QDISK; + } else { + disk->backend = DISK_BACKEND_UNKNOWN; + } + disk->domid = domid; disk->pdev_path = strdup(""); disk->format = DISK_FORMAT_EMPTY; /* this value is returned to the user: do not free right away */ - disk->vdev = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/dev", backend)); + disk->vdev = xs_read(ctx->xsh, XBT_NULL, libxl__sprintf(&gc, "%s/dev", backend), NULL); disk->unpluggable = 1; disk->readwrite = 0; disk->is_cdrom = 1; _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |