libxl: fix libxl__device_disk_from_xs_be to parse backend domid
authorRoger Pau Monne <roger.pau@citrix.com>
Fri, 6 Sep 2013 10:36:26 +0000 (12:36 +0200)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 13 Sep 2013 12:13:31 +0000 (13:13 +0100)
libxl__device_disk_from_xs_be was ignoring the backend domid, setting
it to 0 by default. Fix this by parsing the backend disk path in order
to fetch the backend domid.

This fixes the issue reported when trying to block-detach disks that
have it's backend on a driver domain.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reported-by: G.R. <firemeteor@users.sourceforge.net>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl.c

index 1bce4bb46fd1084fc98e32127767f32829abf3e6..7a7aaf90fe97acd24a4428a3077c21b7b3398fb1 100644 (file)
@@ -2234,9 +2234,16 @@ static int libxl__device_disk_from_xs_be(libxl__gc *gc,
     libxl_ctx *ctx = libxl__gc_owner(gc);
     unsigned int len;
     char *tmp;
+    int rc;
 
     libxl_device_disk_init(disk);
 
+    rc = sscanf(be_path, "/local/domain/%d/", &disk->backend_domid);
+    if (rc != 1) {
+        LOG(ERROR, "Unable to fetch device backend domid from %s", be_path);
+        goto cleanup;
+    }
+
     /* "params" may not be present; but everything else must be. */
     tmp = xs_read(ctx->xsh, XBT_NULL,
                   libxl__sprintf(gc, "%s/params", be_path), &len);