From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH 1/2] libxl: correctly list disks served by driver domains in block-list
Date: Fri, 6 Sep 2013 12:36:25 +0200 [thread overview]
Message-ID: <1378463786-16230-2-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1378463786-16230-1-git-send-email-roger.pau@citrix.com>
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@citrix.com>
Reported-by: G.R. <firemeteor@users.sourceforge.net>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
---
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@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2013-09-06 10:38 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-06 10:36 [PATCH 0/2] libxl: fixes for driver domains Roger Pau Monne
2013-09-06 10:36 ` Roger Pau Monne [this message]
2013-09-10 10:11 ` [PATCH 1/2] libxl: correctly list disks served by driver domains in block-list Ian Campbell
2013-09-10 12:06 ` Roger Pau Monné
2013-09-10 12:54 ` Ian Campbell
2013-09-10 13:55 ` Roger Pau Monné
2013-09-10 14:23 ` Ian Campbell
2013-09-10 14:54 ` [PATCH] libxl: set permissions for xs frontend entry pointing to xs backend Roger Pau Monne
2013-09-10 15:02 ` Ian Campbell
2013-09-10 15:03 ` Roger Pau Monné
2013-09-10 15:06 ` Ian Campbell
2013-09-10 15:12 ` Ian Jackson
2013-09-10 15:16 ` Ian Campbell
2013-09-10 15:19 ` Ian Jackson
2013-09-10 15:23 ` Ian Campbell
2013-09-10 15:43 ` Ian Jackson
2013-09-10 15:19 ` Roger Pau Monné
2013-09-10 15:24 ` Ian Campbell
2013-09-06 10:36 ` [PATCH 2/2] libxl: fix libxl__device_disk_from_xs_be to parse backend domid Roger Pau Monne
2013-09-10 10:14 ` Ian Campbell
2013-09-10 12:08 ` Roger Pau Monné
2013-09-13 12:32 ` 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=1378463786-16230-2-git-send-email-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=ian.campbell@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/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).