From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: Ian.Jackson@eu.citrix.com, Ian.Campbell@citrix.com,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH v2 6/6] xl/libxl: implement QDISK libxl_device_disk_local_attach
Date: Wed, 11 Apr 2012 14:27:31 +0100 [thread overview]
Message-ID: <1334150851-8715-6-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1204111419050.15151@kaball-desktop>
- Spawn a QEMU instance at boot time to handle disk local attach
requests.
- Implement libxl_device_disk_local_attach for QDISKs in terms of a
regular disk attach with the frontend and backend running in the same
domain.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
tools/hotplug/Linux/init.d/sysconfig.xencommons | 3 +
tools/hotplug/Linux/init.d/xencommons | 3 +
tools/libxl/libxl_internal.c | 49 +++++++++++++++++-----
3 files changed, 44 insertions(+), 11 deletions(-)
diff --git a/tools/hotplug/Linux/init.d/sysconfig.xencommons b/tools/hotplug/Linux/init.d/sysconfig.xencommons
index 6543204..0f3b9ad 100644
--- a/tools/hotplug/Linux/init.d/sysconfig.xencommons
+++ b/tools/hotplug/Linux/init.d/sysconfig.xencommons
@@ -12,3 +12,6 @@
# Running xenbackendd in debug mode
#XENBACKENDD_DEBUG=[yes|on|1]
+
+# qemu path and log file
+#QEMU_XEN=/usr/lib/xen/bin/qemu-system-i386
diff --git a/tools/hotplug/Linux/init.d/xencommons b/tools/hotplug/Linux/init.d/xencommons
index 6c72dd8..3b579ae 100644
--- a/tools/hotplug/Linux/init.d/xencommons
+++ b/tools/hotplug/Linux/init.d/xencommons
@@ -103,6 +103,9 @@ do_start () {
xenconsoled --pid-file=$XENCONSOLED_PIDFILE $XENCONSOLED_ARGS
test -z "$XENBACKENDD_DEBUG" || XENBACKENDD_ARGS="-d"
test "`uname`" != "NetBSD" || xenbackendd $XENBACKENDD_ARGS
+ echo Starting QEMU as disk backend for dom0
+ test -z "$QEMU_XEN" && QEMU_XEN=/usr/lib/xen/bin/qemu-system-i386
+ $QEMU_XEN -xen-domid 0 -xen-attach -name dom0 -nographic -M xenpv -daemonize -monitor /dev/null
}
do_stop () {
echo Stopping xenconsoled
diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index 60de726..3ff2e06 100644
--- a/tools/libxl/libxl_internal.c
+++ b/tools/libxl/libxl_internal.c
@@ -550,13 +550,31 @@ _hidden char * libxl__device_disk_local_attach(libxl__gc *gc,
break;
case LIBXL_DISK_BACKEND_QDISK:
if (tmpdisk->format != LIBXL_DISK_FORMAT_RAW) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot locally"
- " attach a qdisk image if the format is not raw");
- break;
+ xs_transaction_t t;
+ do {
+ t = xs_transaction_start(ctx->xsh);
+ /* use 0 as the domid of the toolstack domain for now */
+ tmpdisk->vdev = libxl__alloc_vdev(gc, 0, blkdev_start, t);
+ if (tmpdisk->vdev == NULL) {
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+ "libxl__alloc_vdev failed\n");
+ xs_transaction_end(ctx->xsh, t, 1);
+ goto out;
+ }
+ if (libxl__device_disk_add_t(gc, 0, t, tmpdisk)) {
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+ "libxl_device_disk_add failed\n");
+ xs_transaction_end(ctx->xsh, t, 1);
+ goto out;
+ }
+ rc = xs_transaction_end(ctx->xsh, t, 0);
+ } while (rc == 0 && errno == EAGAIN);
+ dev = libxl__sprintf(gc, "/dev/%s", tmpdisk->vdev);
+ } else {
+ dev = tmpdisk->pdev_path;
}
LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "locally attaching qdisk %s\n",
- disk->pdev_path);
- dev = tmpdisk->pdev_path;
+ dev);
break;
default:
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk backend "
@@ -571,12 +589,21 @@ _hidden char * libxl__device_disk_local_attach(libxl__gc *gc,
_hidden int libxl__device_disk_local_detach(libxl__gc *gc,
libxl_device_disk *disk)
{
- /* Nothing to do for PHYSTYPE_PHY. */
-
- /*
- * For other device types assume that the blktap2 process is
- * needed by the soon to be started domain and do nothing.
- */
+ switch (disk->backend) {
+ case LIBXL_DISK_BACKEND_QDISK:
+ if (disk->format != LIBXL_DISK_FORMAT_RAW) {
+ libxl_device_disk_remove(gc->owner, 0, disk, 0);
+ return libxl_device_disk_destroy(gc->owner, 0, disk);
+ }
+ break;
+ default:
+ /*
+ * Nothing to do for PHYSTYPE_PHY.
+ * For other device types assume that the blktap2 process is
+ * needed by the soon to be started domain and do nothing.
+ */
+ break;
+ }
return 0;
}
--
1.7.2.5
prev parent reply other threads:[~2012-04-11 13:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-11 13:26 [PATCH v2 0/6] qdisk local attach Stefano Stabellini
2012-04-11 13:27 ` [PATCH v2 1/6] libxl: libxl__device_disk_local_attach return a new libxl_device_disk Stefano Stabellini
2012-04-11 13:27 ` [PATCH v2 2/6] libxl: add a transaction parameter to libxl__device_generic_add Stefano Stabellini
2012-04-11 13:27 ` [PATCH v2 3/6] libxl: introduce libxl__device_disk_add_t Stefano Stabellini
2012-04-11 13:27 ` [PATCH v2 4/6] xl/libxl: add a blkdev_start parameter Stefano Stabellini
2012-04-11 13:27 ` [PATCH v2 5/6] libxl: introduce libxl__alloc_vdev Stefano Stabellini
2012-04-11 13:27 ` Stefano Stabellini [this message]
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=1334150851-8715-6-git-send-email-stefano.stabellini@eu.citrix.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/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).