aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>2012-05-29 16:36:51 +0100
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>2012-05-29 16:36:51 +0100
commit9ad60ac58df44d69c81c63cdd09ae43d6f41e1e8 (patch)
treea2262ed06a983bd92ff32046c268893725199efc /tools
parent38c65b140ef885c9868a5ff8f5963f7aa4b5e997 (diff)
downloadxen-9ad60ac58df44d69c81c63cdd09ae43d6f41e1e8.tar.gz
xen-9ad60ac58df44d69c81c63cdd09ae43d6f41e1e8.tar.bz2
xen-9ad60ac58df44d69c81c63cdd09ae43d6f41e1e8.zip
xl/libxl: implement QDISK libxl_device_disk_local_attach
- 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> Acked-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/hotplug/Linux/init.d/sysconfig.xencommons3
-rw-r--r--tools/hotplug/Linux/init.d/xencommons3
-rw-r--r--tools/libxl/libxl.c63
3 files changed, 57 insertions, 12 deletions
diff --git a/tools/hotplug/Linux/init.d/sysconfig.xencommons b/tools/hotplug/Linux/init.d/sysconfig.xencommons
index 6543204597..38ea85a699 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
+#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 2f81ea2d90..9dda6e22ba 100644
--- a/tools/hotplug/Linux/init.d/xencommons
+++ b/tools/hotplug/Linux/init.d/xencommons
@@ -104,6 +104,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.c b/tools/libxl/libxl.c
index c7a1976706..44e6dece72 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1783,7 +1783,8 @@ char * libxl__device_disk_local_attach(libxl__gc *gc,
libxl_ctx *ctx = gc->owner;
char *dev = NULL;
char *ret = NULL;
- int rc;
+ int rc, xs_ret;
+ xs_transaction_t t = XBT_NULL;
if (in_disk->pdev_path == NULL)
return NULL;
@@ -1827,12 +1828,34 @@ char * libxl__device_disk_local_attach(libxl__gc *gc,
break;
case LIBXL_DISK_BACKEND_QDISK:
if (disk->format != LIBXL_DISK_FORMAT_RAW) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot locally"
- " attach a qdisk image if the format is not raw");
- break;
+ do {
+ t = xs_transaction_start(ctx->xsh);
+ if (t == XBT_NULL) {
+ LOG(ERROR, "failed to start a xenstore transaction");
+ goto out;
+ }
+ disk->vdev = libxl__alloc_vdev(gc, blkdev_start, t);
+ if (disk->vdev == NULL) {
+ LOG(ERROR, "libxl__alloc_vdev failed");
+ goto out;
+ }
+ if (libxl__device_disk_add(gc, LIBXL_TOOLSTACK_DOMID,
+ t, disk)) {
+ LOG(ERROR, "libxl_device_disk_add failed");
+ goto out;
+ }
+ xs_ret = xs_transaction_end(ctx->xsh, t, 0);
+ } while (xs_ret == 0 && errno == EAGAIN);
+ t = XBT_NULL;
+ if (xs_ret == 0) {
+ LOGE(ERROR, "xenstore transaction failed");
+ goto out;
+ }
+ dev = GCSPRINTF("/dev/%s", disk->vdev);
+ } else {
+ dev = disk->pdev_path;
}
- LOG(DEBUG, "locally attaching qdisk %s", in_disk->pdev_path);
- dev = disk->pdev_path;
+ LOG(DEBUG, "locally attaching qdisk %s", dev);
break;
default:
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk backend "
@@ -1841,6 +1864,8 @@ char * libxl__device_disk_local_attach(libxl__gc *gc,
}
out:
+ if (t != XBT_NULL)
+ xs_transaction_end(ctx->xsh, t, 1);
if (dev != NULL)
ret = strdup(dev);
return ret;
@@ -1848,14 +1873,28 @@ char * libxl__device_disk_local_attach(libxl__gc *gc,
int libxl__device_disk_local_detach(libxl__gc *gc, libxl_device_disk *disk)
{
- /* Nothing to do for PHYSTYPE_PHY. */
+ int rc = 0;
- /*
- * 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->vdev != NULL) {
+ libxl_device_disk_remove(gc->owner, LIBXL_TOOLSTACK_DOMID,
+ disk, 0);
+ rc = libxl_device_disk_destroy(gc->owner,
+ LIBXL_TOOLSTACK_DOMID, 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;
+
+ return rc;
}
/******************************************************************************/