From: Roger Pau Monne <roger.pau@citrix.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Ian Campbell <Ian.Campbell@citrix.com>
Subject: Re: [PATCH v6 05/11] libxl: introduce libxl__device_disk_add
Date: Fri, 18 May 2012 15:56:31 +0100 [thread overview]
Message-ID: <4FB6631F.9050004@citrix.com> (raw)
In-Reply-To: <1337350125-30394-5-git-send-email-stefano.stabellini@eu.citrix.com>
Stefano Stabellini wrote:
> Introduce libxl__device_disk_add that takes an additional
> xs_transaction_t paramter.
> Implement libxl_device_disk_add using libxl__device_disk_add.
>
> Signed-off-by: Stefano Stabellini<stefano.stabellini@eu.citrix.com>
> ---
> tools/libxl/libxl.c | 113 +---------------------------------------
> tools/libxl/libxl_internal.c | 119 ++++++++++++++++++++++++++++++++++++++++++
> tools/libxl/libxl_internal.h | 2 +
> 3 files changed, 122 insertions(+), 112 deletions(-)
>
> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> index 3f53da5..1bed2fe 100644
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -1284,118 +1284,7 @@ int libxl__device_disk_setdefault(libxl__gc *gc, libxl_device_disk *disk)
> int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk)
> {
> GC_INIT(ctx);
> - flexarray_t *front;
> - flexarray_t *back;
> - char *dev;
> - libxl__device device;
> - int major, minor, rc;
> -
> - rc = libxl__device_disk_setdefault(gc, disk);
> - if (rc) goto out;
> -
> - front = flexarray_make(16, 1);
> - if (!front) {
> - rc = ERROR_NOMEM;
> - goto out;
> - }
> - back = flexarray_make(16, 1);
> - if (!back) {
> - rc = ERROR_NOMEM;
> - goto out_free;
> - }
> -
> - if (disk->script) {
> - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "External block scripts"
> - " not yet supported, sorry");
> - rc = ERROR_INVAL;
> - goto out_free;
> - }
> -
> - rc = libxl__device_from_disk(gc, domid, disk,&device);
> - if (rc != 0) {
> - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Invalid or unsupported"
> - " virtual disk identifier %s", disk->vdev);
> - goto out_free;
> - }
> -
> - switch (disk->backend) {
> - case LIBXL_DISK_BACKEND_PHY:
> - dev = disk->pdev_path;
> - do_backend_phy:
> - libxl__device_physdisk_major_minor(dev,&major,&minor);
> - flexarray_append(back, "physical-device");
> - flexarray_append(back, libxl__sprintf(gc, "%x:%x", major, minor));
> -
> - flexarray_append(back, "params");
> - flexarray_append(back, dev);
> -
> - assert(device.backend_kind == LIBXL__DEVICE_KIND_VBD);
> - break;
> - case LIBXL_DISK_BACKEND_TAP:
> - dev = libxl__blktap_devpath(gc, disk->pdev_path, disk->format);
> - if (!dev) {
> - LOG(ERROR, "failed to get blktap devpath for %p\n",
> - disk->pdev_path);
> - rc = ERROR_FAIL;
> - goto out_free;
> - }
> - flexarray_append(back, "tapdisk-params");
> - flexarray_append(back, libxl__sprintf(gc, "%s:%s",
> - libxl__device_disk_string_of_format(disk->format),
> - disk->pdev_path));
> -
> - /* now create a phy device to export the device to the guest */
> - goto do_backend_phy;
> - case LIBXL_DISK_BACKEND_QDISK:
> - flexarray_append(back, "params");
> - flexarray_append(back, libxl__sprintf(gc, "%s:%s",
> - libxl__device_disk_string_of_format(disk->format), disk->pdev_path));
> - assert(device.backend_kind == LIBXL__DEVICE_KIND_QDISK);
> - break;
> - default:
> - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk backend type: %d\n", disk->backend);
> - rc = ERROR_INVAL;
> - goto out_free;
> - }
> -
> - flexarray_append(back, "frontend-id");
> - flexarray_append(back, libxl__sprintf(gc, "%d", domid));
> - flexarray_append(back, "online");
> - flexarray_append(back, "1");
> - flexarray_append(back, "removable");
> - flexarray_append(back, libxl__sprintf(gc, "%d", (disk->removable) ? 1 : 0));
> - flexarray_append(back, "bootable");
> - flexarray_append(back, libxl__sprintf(gc, "%d", 1));
> - flexarray_append(back, "state");
> - flexarray_append(back, libxl__sprintf(gc, "%d", 1));
> - flexarray_append(back, "dev");
> - flexarray_append(back, disk->vdev);
> - flexarray_append(back, "type");
> - flexarray_append(back, libxl__device_disk_string_of_backend(disk->backend));
> - flexarray_append(back, "mode");
> - flexarray_append(back, disk->readwrite ? "w" : "r");
> - flexarray_append(back, "device-type");
> - flexarray_append(back, disk->is_cdrom ? "cdrom" : "disk");
> -
> - flexarray_append(front, "backend-id");
> - flexarray_append(front, libxl__sprintf(gc, "%d", disk->backend_domid));
> - flexarray_append(front, "state");
> - flexarray_append(front, libxl__sprintf(gc, "%d", 1));
> - flexarray_append(front, "virtual-device");
> - flexarray_append(front, libxl__sprintf(gc, "%d", device.devid));
> - flexarray_append(front, "device-type");
> - flexarray_append(front, disk->is_cdrom ? "cdrom" : "disk");
> -
> - libxl__device_generic_add(gc, XBT_NULL,&device,
> - libxl__xs_kvs_of_flexarray(gc, back, back->count),
> - libxl__xs_kvs_of_flexarray(gc, front, front->count));
> -
> - rc = 0;
> -
> -out_free:
> - flexarray_free(back);
> - flexarray_free(front);
> -out:
> + int rc = libxl__device_disk_add(gc, domid, XBT_NULL, disk);
> GC_FREE;
> return rc;
> }
> diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
> index 276429c..70a8c4b 100644
> --- a/tools/libxl/libxl_internal.c
> +++ b/tools/libxl/libxl_internal.c
> @@ -323,6 +323,125 @@ out:
> return rc;
> }
>
> +int libxl__device_disk_add(libxl__gc *gc, uint32_t domid,
> + xs_transaction_t t, libxl_device_disk *disk)
As with the other patch, I think this should go to libxl_device.
> +{
> + flexarray_t *front;
> + flexarray_t *back;
> + char *dev;
> + libxl__device device;
> + int major, minor, rc;
> + libxl_ctx *ctx = gc->owner;
> +
> + rc = libxl__device_disk_setdefault(gc, disk);
> + if (rc) goto out;
> +
> + front = flexarray_make(16, 1);
> + if (!front) {
> + rc = ERROR_NOMEM;
> + goto out;
> + }
> + back = flexarray_make(16, 1);
> + if (!back) {
> + rc = ERROR_NOMEM;
> + goto out_free;
> + }
> +
> + if (disk->script) {
> + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "External block scripts"
> + " not yet supported, sorry");
> + rc = ERROR_INVAL;
> + goto out_free;
> + }
> +
> + rc = libxl__device_from_disk(gc, domid, disk,&device);
> + if (rc != 0) {
> + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Invalid or unsupported"
> + " virtual disk identifier %s", disk->vdev);
> + goto out_free;
> + }
> +
> + switch (disk->backend) {
> + case LIBXL_DISK_BACKEND_PHY:
> + dev = disk->pdev_path;
> + do_backend_phy:
> + libxl__device_physdisk_major_minor(dev,&major,&minor);
> + flexarray_append(back, "physical-device");
> + flexarray_append(back, libxl__sprintf(gc, "%x:%x", major, minor));
> +
> + flexarray_append(back, "params");
> + flexarray_append(back, dev);
> +
> + assert(device.backend_kind == LIBXL__DEVICE_KIND_VBD);
> + break;
> + case LIBXL_DISK_BACKEND_TAP:
> + dev = libxl__blktap_devpath(gc, disk->pdev_path, disk->format);
> + if (!dev) {
> + LOG(ERROR, "failed to get blktap devpath for %p\n",
> + disk->pdev_path);
> + rc = ERROR_FAIL;
> + goto out_free;
> + }
> + flexarray_append(back, "tapdisk-params");
> + flexarray_append(back, libxl__sprintf(gc, "%s:%s",
> + libxl__device_disk_string_of_format(disk->format),
> + disk->pdev_path));
> +
> + /* now create a phy device to export the device to the guest */
> + goto do_backend_phy;
> + case LIBXL_DISK_BACKEND_QDISK:
> + flexarray_append(back, "params");
> + flexarray_append(back, libxl__sprintf(gc, "%s:%s",
> + libxl__device_disk_string_of_format(disk->format), disk->pdev_path));
> + assert(device.backend_kind == LIBXL__DEVICE_KIND_QDISK);
> + break;
> + default:
> + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk backend type: %d\n", disk->backend);
> + rc = ERROR_INVAL;
> + goto out_free;
> + }
> +
> + flexarray_append(back, "frontend-id");
> + flexarray_append(back, libxl__sprintf(gc, "%d", domid));
> + flexarray_append(back, "online");
> + flexarray_append(back, "1");
> + flexarray_append(back, "removable");
> + flexarray_append(back, libxl__sprintf(gc, "%d", (disk->removable) ? 1 : 0));
> + flexarray_append(back, "bootable");
> + flexarray_append(back, libxl__sprintf(gc, "%d", 1));
> + flexarray_append(back, "state");
> + flexarray_append(back, libxl__sprintf(gc, "%d", 1));
> + flexarray_append(back, "dev");
> + flexarray_append(back, disk->vdev);
> + flexarray_append(back, "type");
> + flexarray_append(back, libxl__device_disk_string_of_backend(disk->backend));
> + flexarray_append(back, "mode");
> + flexarray_append(back, disk->readwrite ? "w" : "r");
> + flexarray_append(back, "device-type");
> + flexarray_append(back, disk->is_cdrom ? "cdrom" : "disk");
> +
> + flexarray_append(front, "backend-id");
> + flexarray_append(front, libxl__sprintf(gc, "%d", disk->backend_domid));
> + flexarray_append(front, "state");
> + flexarray_append(front, libxl__sprintf(gc, "%d", 1));
> + flexarray_append(front, "virtual-device");
> + flexarray_append(front, libxl__sprintf(gc, "%d", device.devid));
> + flexarray_append(front, "device-type");
> + flexarray_append(front, disk->is_cdrom ? "cdrom" : "disk");
> +
> + libxl__device_generic_add(gc, t,&device,
> + libxl__xs_kvs_of_flexarray(gc, back, back->count),
> + libxl__xs_kvs_of_flexarray(gc, front, front->count));
> +
> + rc = 0;
> +
> +out_free:
> + flexarray_free(back);
> + flexarray_free(front);
> +out:
> + return rc;
> +}
> +
> char * libxl__device_disk_local_attach(libxl__gc *gc,
> const libxl_device_disk *in_disk,
> libxl_device_disk *disk)
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 3578414..98f9762 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -1236,6 +1236,8 @@ _hidden void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path);
> _hidden int libxl__device_from_disk(libxl__gc *gc, uint32_t domid,
> libxl_device_disk *disk,
> libxl__device *device);
> +_hidden int libxl__device_disk_add(libxl__gc *gc, uint32_t domid,
> + xs_transaction_t t, libxl_device_disk *disk);
>
> /*
> * Make a disk available in this (the control) domain. Returns path to
> --
> 1.7.2.5
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2012-05-18 14:56 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-18 14:07 [PATCH v6 0/11] qdisk local attach Stefano Stabellini
2012-05-18 14:08 ` [PATCH v6 01/11] libxl: make libxl_device_disk_local_attach/detach internal functions Stefano Stabellini
2012-05-18 14:26 ` Ian Jackson
2012-05-18 14:08 ` [PATCH v6 02/11] libxl: libxl__device_disk_local_attach return a new libxl_device_disk Stefano Stabellini
2012-05-18 14:33 ` Ian Jackson
2012-05-21 16:34 ` Stefano Stabellini
2012-05-18 14:08 ` [PATCH v6 03/11] libxl: add a transaction parameter to libxl__device_generic_add Stefano Stabellini
2012-05-18 14:08 ` [PATCH v6 04/11] libxl: move libxl__device_from_disk to libxl_internal.c Stefano Stabellini
2012-05-18 14:34 ` Ian Jackson
2012-05-18 14:55 ` Roger Pau Monne
2012-05-18 15:02 ` Ian Campbell
2012-05-18 15:16 ` Roger Pau Monne
2012-05-18 15:23 ` Ian Jackson
2012-05-21 16:31 ` Stefano Stabellini
2012-05-18 15:25 ` Ian Campbell
2012-05-21 16:33 ` Stefano Stabellini
2012-05-21 16:34 ` Ian Campbell
2012-05-18 14:08 ` [PATCH v6 05/11] libxl: introduce libxl__device_disk_add Stefano Stabellini
2012-05-18 14:36 ` Ian Jackson
2012-05-18 14:42 ` Ian Campbell
2012-05-18 14:47 ` Ian Jackson
2012-05-21 16:30 ` Stefano Stabellini
2012-05-21 16:48 ` Ian Jackson
2012-05-18 14:56 ` Roger Pau Monne [this message]
2012-05-18 14:08 ` [PATCH v6 06/11] xl/libxl: add a blkdev_start parameter Stefano Stabellini
2012-05-18 14:08 ` [PATCH v6 07/11] libxl: introduce libxl__alloc_vdev Stefano Stabellini
2012-05-18 14:40 ` Ian Jackson
2012-05-21 17:50 ` Stefano Stabellini
2012-05-21 18:02 ` Stefano Stabellini
2012-05-22 11:11 ` Ian Jackson
2012-05-18 14:08 ` [PATCH v6 08/11] xl/libxl: implement QDISK libxl_device_disk_local_attach Stefano Stabellini
2012-05-18 14:42 ` Ian Jackson
2012-05-18 14:08 ` [PATCH v6 09/11] libxl__device_disk_local_attach: wait for state "connected" Stefano Stabellini
2012-05-18 14:44 ` Ian Jackson
2012-05-18 14:08 ` [PATCH v6 10/11] libxl_string_to_backend: add qdisk Stefano Stabellini
2012-05-18 14:44 ` Ian Jackson
2012-05-18 14:08 ` [PATCH v6 11/11] main_blockdetach: destroy the disk on successful removal Stefano Stabellini
2012-05-18 14:44 ` Ian Jackson
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=4FB6631F.9050004@citrix.com \
--to=roger.pau@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=stefano.stabellini@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).