From: Juergen Gross <jgross@suse.com>
To: Olaf Hering <olaf@aepfle.de>, xen-devel@lists.xen.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>,
Ian Campbell <ian.campbell@citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [PATCH v12 1/2] libxl: add support for vscsi
Date: Thu, 14 Apr 2016 16:06:44 +0200 [thread overview]
Message-ID: <570FA3F4.1000109@suse.com> (raw)
In-Reply-To: <1460537820-15398-2-git-send-email-olaf@aepfle.de>
On 13/04/16 10:56, Olaf Hering wrote:
> Port pvscsi support from xend to libxl:
>
> vscsi=['pdev,vdev{,options}']
> xl scsi-attach
> xl scsi-detach
> xl scsi-list
>
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Cc: Ian Campbell <ian.campbell@citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
> ---
> docs/man/xl.cfg.pod.5 | 56 ++
> docs/man/xl.pod.1 | 18 +
> tools/libxl/Makefile | 2 +
> tools/libxl/libxl.c | 9 +
> tools/libxl/libxl.h | 42 ++
> tools/libxl/libxl_create.c | 41 +-
> tools/libxl/libxl_device.c | 2 +
> tools/libxl/libxl_internal.h | 8 +
> tools/libxl/libxl_types.idl | 53 ++
> tools/libxl/libxl_types_internal.idl | 1 +
> tools/libxl/libxl_vscsi.c | 1169 ++++++++++++++++++++++++++++++++++
> tools/libxl/libxlu_vscsi.c | 667 +++++++++++++++++++
> tools/libxl/libxlutil.h | 19 +
> tools/libxl/xl.h | 3 +
> tools/libxl/xl_cmdimpl.c | 225 ++++++-
> tools/libxl/xl_cmdtable.c | 15 +
> 16 files changed, 2326 insertions(+), 4 deletions(-)
>
...
> diff --git a/tools/libxl/libxl_vscsi.c b/tools/libxl/libxl_vscsi.c
> new file mode 100644
> index 0000000..fff8c7a
> --- /dev/null
> +++ b/tools/libxl/libxl_vscsi.c
...
> +static void vscsictrl_do_reconfigure_add_cb(libxl__egc *egc,
> + libxl__ev_devstate *ds,
> + int rc)
> +{
> + libxl__ao_device *aodev = CONTAINER_OF(ds, *aodev, backend_ds);
> + STATE_AO_GC(aodev->ao);
> + aodev->rc = rc;
> + aodev->callback(egc, aodev);
> +}
> +
> +static void vscsictrl_do_reconfigure_add(libxl__egc *egc,
> + libxl__ao_device *aodev,
> + libxl_device_vscsictrl *vscsictrl,
> + libxl_domain_config *d_config)
> +{
> + STATE_AO_GC(aodev->ao);
> + int rc, i, be_state, be_wait;
> + const char *be_path;
> + char *dev_path, *state_path, *state_val;
> + flexarray_t *back;
> + libxl_device_vscsidev *v;
> + xs_transaction_t t = XBT_NULL;
> + bool do_reconfigure = false;
> +
> + /* Prealloc key+value: 1 toplevel + 4 per device */
> + i = 2 * (1 + (4 * vscsictrl->num_vscsidevs));
> + back = flexarray_make(gc, i, 1);
Shouldn't be this in the loop below? Otherwise the array might be
expanded with the same entries several times in case of a transaction
collision.
I've found other places in libxl_vscsi.c with the same problem.
> +
> + be_path = libxl__device_backend_path(gc, aodev->dev);
> + state_path = GCSPRINTF("%s/state", be_path);
> +
> + for (;;) {
> + rc = libxl__xs_transaction_start(gc, &t);
> + if (rc) goto out;
> +
> + state_val = libxl__xs_read(gc, t, state_path);
> + LOG(DEBUG, "%s is %s", state_path, state_val);
> + if (!state_val) {
> + rc = ERROR_FAIL;
> + goto out;
> + }
> +
> + be_state = atoi(state_val);
> + switch (be_state) {
> + case XenbusStateUnknown:
> + case XenbusStateInitialising:
> + case XenbusStateClosing:
> + case XenbusStateClosed:
> + default:
> + /* The backend is in a bad state */
> + rc = ERROR_FAIL;
> + goto out;
> + case XenbusStateInitialised:
> + case XenbusStateReconfiguring:
> + case XenbusStateReconfigured:
> + /* Backend is still busy, caller has to retry */
> + rc = ERROR_NOT_READY;
> + goto out;
> + case XenbusStateInitWait:
> + /* The frontend did not connect yet */
> + be_wait = XenbusStateInitWait;
> + do_reconfigure = false;
> + break;
> + case XenbusStateConnected:
> + /* The backend can handle reconfigure */
> + be_wait = XenbusStateConnected;
> + flexarray_append_pair(back, "state", GCSPRINTF("%d", XenbusStateReconfiguring));
> + do_reconfigure = true;
> + break;
> + }
> +
> + /* Append new vscsidev or skip existing */
> + for (i = 0; i < vscsictrl->num_vscsidevs; i++) {
> + unsigned int nb = 0;
> + v = vscsictrl->vscsidevs + i;
> + dev_path = GCSPRINTF("%s/vscsi-devs/dev-%u", be_path, v->vscsidev_id);
> + if (libxl__xs_directory(gc, XBT_NULL, dev_path, &nb)) {
> + /* FIXME Sanity check */
> + LOG(DEBUG, "%s exists already with %u entries", dev_path, nb);
> + continue;
> + }
> + rc = vscsidev_backend_add(gc, v, back);
> + if (rc) goto out;
> + }
> +
> + if (aodev->update_json) {
> + rc = libxl__set_domain_configuration(gc, aodev->dev->domid, d_config);
> + if (rc) goto out;
> + }
> +
> + libxl__xs_writev(gc, t, be_path,
> + libxl__xs_kvs_of_flexarray(gc, back, back->count));
> +
> + rc = libxl__xs_transaction_commit(gc, &t);
> + if (!rc) break;
> + if (rc < 0) goto out;
> + }
> +
> + if (do_reconfigure) {
> + rc = libxl__ev_devstate_wait(ao, &aodev->backend_ds,
> + vscsictrl_do_reconfigure_add_cb,
> + state_path, be_wait,
> + LIBXL_INIT_TIMEOUT * 1000);
> + if (rc) goto out;
> + }
> + return;
> +
> +out:
> + libxl__xs_transaction_abort(gc, &t);
> + aodev->rc = rc;
> + aodev->callback(egc, aodev);
> +}
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-04-14 14:06 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-13 8:56 [PATCH v12 0/2] libxl: add support for pvscsi, iteration 12 Olaf Hering
2016-04-13 8:56 ` [PATCH v12 1/2] libxl: add support for vscsi Olaf Hering
2016-04-14 14:06 ` Juergen Gross [this message]
2016-04-14 14:27 ` Olaf Hering
2016-04-14 14:35 ` Juergen Gross
2016-04-14 14:43 ` Olaf Hering
2016-04-27 14:10 ` Wei Liu
2016-04-27 14:15 ` Olaf Hering
2016-04-13 8:57 ` [PATCH v12 2/2] Scripts to create and delete xen-scsiback nodes in Linux target framework Olaf Hering
2016-04-13 9:15 ` [PATCH libvirt v2 0/2] libxl: support vscsi Olaf Hering
2016-04-13 9:15 ` [PATCH libvirt v2 1/2] libxl: include a XLU_Config in _libxlDriverConfig Olaf Hering
2016-04-15 21:23 ` Jim Fehlig
2016-04-13 9:15 ` [PATCH libvirt v2 2/2] libxl: support vscsi Olaf Hering
2016-04-13 9:20 ` Olaf Hering
2016-04-15 22:20 ` Jim Fehlig
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=570FA3F4.1000109@suse.com \
--to=jgross@suse.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=olaf@aepfle.de \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.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).