|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v5 7/8] xl/libxl: implement QDISK libxl_device_disk_local_attach
On Fri, 2012-05-04 at 12:13 +0100, Stefano Stabellini wrote:
> - 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.
>
> Chanegs in v5:
> - replace LIBXL__LOG with LOG.
>
> Changes on v4:
> - improve error handling and exit paths in libxl__device_disk_local_attach.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
> ---
> tools/hotplug/Linux/init.d/sysconfig.xencommons | 3 +
> tools/hotplug/Linux/init.d/xencommons | 3 +
> tools/libxl/libxl_internal.c | 58 ++++++++++++++++++----
> 3 files changed, 53 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
What does "and log file" mean?
Apart from that:
Acked-by:Ian Campbell <ian.campbell@xxxxxxxxxx>
> +#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 2f81ea2..9dda6e2 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_internal.c b/tools/libxl/libxl_internal.c
> index 7a1e017..e180498 100644
> --- a/tools/libxl/libxl_internal.c
> +++ b/tools/libxl/libxl_internal.c
> @@ -519,6 +519,7 @@ char * libxl__device_disk_local_attach(libxl__gc *gc,
> libxl_ctx *ctx = gc->owner;
> char *dev = NULL;
> int rc;
> + xs_transaction_t t = XBT_NULL;
> libxl_device_disk *disk = libxl__zalloc(gc, sizeof(libxl_device_disk));
>
> memcpy(disk, in_disk, sizeof(libxl_device_disk));
> @@ -561,13 +562,35 @@ 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;
> + }
> + rc = xs_transaction_end(ctx->xsh, t, 0);
> + } while (rc == 0 && errno == EAGAIN);
> + t = XBT_NULL;
> + if (rc == 0) {
> + LOGE(ERROR, "xenstore transaction failed");
> + goto out;
> + }
> + dev = GCSPRINTF("/dev/%s", disk->vdev);
> + } else {
> + dev = disk->pdev_path;
> }
> LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "locally attaching qdisk %s\n",
> - in_disk->pdev_path);
> - dev = disk->pdev_path;
> + dev);
> break;
> default:
> LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk backend "
> @@ -576,18 +599,31 @@ char * libxl__device_disk_local_attach(libxl__gc *gc,
> }
>
> out:
> + if (t != XBT_NULL)
> + xs_transaction_end(ctx->xsh, t, 1);
> *new_disk = disk;
> return dev;
> }
>
> 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->vdev != NULL) {
> + libxl_device_disk_remove(gc->owner, LIBXL_TOOLSTACK_DOMID,
> + disk, 0);
> + return 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;
> }
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |