All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olaf Hering <olaf@aepfle.de>
To: Ian Campbell <ian.campbell@citrix.com>,
	Ian Jackson <ian.jackson@citrix.com>,
	Wei Liu <wei.liu2@citrix.com>
Cc: xen-devel@lists.xen.org
Subject: Re: [PATCH 3/5] libxl: add support for vscsi
Date: Wed, 27 Jan 2016 11:00:12 +0100	[thread overview]
Message-ID: <20160127100012.GA6631@gmail.com> (raw)
In-Reply-To: <1447415999-22003-4-git-send-email-olaf@aepfle.de>

On Fri, Nov 13, Olaf Hering wrote:

> Port pvscsi support from xend to libxl:

How should code which converts devices from xenstore to json handle
devices which got marked as "to be removed"?

In my pvscsi code I set XenbusStateClosing in the vscsidev, then
XenbusStateReconfiguring in vscsictrl. This causes the backend/frontend
to reevaluate the vscsi bus. During that timeframe some other code can
walk xenstore and find such a device. In libxl__vscsi_fill_host below
such device gets the ->remove flag. This flag is handled elsewhere to
indicate that its not an active device anymore. IanC asked to remove the
flag and I'm converting the code to work without such flag. The question
still stands what to do with such devices when filling the list of
vscsidevs on a vscsictrl. Is it up to the caller to inspect the state of
each vscsidev to decide what to do with it? Or should the function below
just skip the device right away?

I think in the current state the device would endup in d_config and in json.

Olaf


> +static void libxl__vscsi_fill_host(libxl__gc *gc,
> +                                   const char *devs_path,
> +                                   char **dev_dirs,
> +                                   unsigned int ndev_dirs,
> +                                   libxl_device_vscsi *v_hst)
> +{
> +    libxl_vscsi_dev *v_dev;
> +    bool parsed_ok;
> +    char *c, *p, *v, *s, *dev;
> +    unsigned int vscsi_dev_id;
> +    int i, r;
> +
> +    v_hst->vscsi_devs = libxl__malloc(NOGC, ndev_dirs * sizeof(*v_dev));
> +    v_hst->num_vscsi_devs = ndev_dirs;
> +    /* Fill each device connected to the host */
> +    for (i = 0; i < ndev_dirs; i++, dev_dirs++) {
> +        v_dev = v_hst->vscsi_devs + i;
> +        libxl_vscsi_dev_init(v_dev);
> +        parsed_ok = false;
> +        r = sscanf(*dev_dirs, "dev-%u", &vscsi_dev_id);
> +        if (r != 1) {
> +            LOG(ERROR, "expected dev-N, got '%s'", *dev_dirs);
> +            continue;
> +        }
> +
> +        dev = GCSPRINTF("%s/%s", devs_path, *dev_dirs);
> +        c = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/p-devname", dev));
> +        p = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/p-dev", dev));
> +        v = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/v-dev", dev));
> +        s = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/state", dev));
> +        LOG(DEBUG, "%s/state is %s", dev, s);
> +        if (!(c && p && v && s)) {
> +            LOG(ERROR, "p-devname '%s' p-dev '%s' v-dev '%s'", c, p, v);
> +            continue;
> +        }
> +
> +        parsed_ok = vscsi_parse_pdev(gc, v_dev, c, p, v);
> +        switch (atoi(s)) {
> +            case XenbusStateUnknown:
> +            case XenbusStateInitialising:
> +            case XenbusStateInitWait:
> +            case XenbusStateInitialised:
> +            case XenbusStateConnected:
> +            case XenbusStateReconfiguring:
> +            case XenbusStateReconfigured:
> +                break;
> +            case XenbusStateClosing:
> +            case XenbusStateClosed:
> +                v_dev->remove = true;
> +                break;
> +        }

  reply	other threads:[~2016-01-27 10:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-13 11:59 [PATCH 0/5] libbxl: add support for pvscsi, iteration 6 Olaf Hering
2015-11-13 11:59 ` [PATCH 1/5] vscsiif.h: fix WWN notation for p-dev property Olaf Hering
2015-11-13 11:59 ` [PATCH 2/5] docs: add vscsi to xenstore-paths.markdown Olaf Hering
2015-11-13 11:59 ` [PATCH 3/5] libxl: add support for vscsi Olaf Hering
2016-01-27 10:00   ` Olaf Hering [this message]
2016-02-03 14:36     ` Wei Liu
2016-02-03 14:42       ` Wei Liu
2016-02-03 16:24       ` Olaf Hering
2015-11-13 11:59 ` [PATCH 4/5] vscsiif.h: add some notes about xenstore layout Olaf Hering
2015-11-13 11:59 ` [PATCH 5/5] Scripts to create and delete xen-scsiback nodes in Linux target framework Olaf Hering

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=20160127100012.GA6631@gmail.com \
    --to=olaf@aepfle.de \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.