xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: Paul Durrant <paul.durrant@citrix.com>
Cc: xen-devel@lists.xenproject.org,
	Stefano Stabellini <sstabellini@kernel.org>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [PATCH v3 1/8] xen_backend: add grant table helpers
Date: Wed, 16 May 2018 14:50:20 +0100	[thread overview]
Message-ID: <20180516135020.GF2057@perard.uk.xensource.com> (raw)
In-Reply-To: <1525461967-32174-2-git-send-email-paul.durrant@citrix.com>

On Fri, May 04, 2018 at 08:26:00PM +0100, Paul Durrant wrote:
> This patch adds grant table helper functions to the xen_backend code to
> localize error reporting and use of xen_domid.
> 
> The patch also defers the call to xengnttab_open() until just before the
> initialise method in XenDevOps is invoked. This method is responsible for
> mapping the shared ring. No prior method requires access to the grant table.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> ---
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> 
> v2:
>  - New in v2
> ---
>  hw/xen/xen_backend.c         | 123 ++++++++++++++++++++++++++++++++++++++-----
>  include/hw/xen/xen_backend.h |  33 ++++++++++++
>  2 files changed, 144 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c
> index 7445b50..50412d6 100644
> --- a/hw/xen/xen_backend.c
> +++ b/hw/xen/xen_backend.c
> @@ -106,6 +106,103 @@ int xen_be_set_state(struct XenDevice *xendev, enum xenbus_state state)
>      return 0;
>  }
>  
> +void xen_be_set_max_grant_refs(struct XenDevice *xendev,
> +                               unsigned int nr_refs)

Is it fine to ignore error from set_max_grants and continue ? xen_disk.c
seems to fail the initialisation if set_max_grants call fails. On the
other end, xen-usb.c just keep going.

> +{
> +    assert(xendev->ops->flags & DEVOPS_FLAG_NEED_GNTDEV);
> +
> +    if (xengnttab_set_max_grants(xendev->gnttabdev, nr_refs)) {
> +        xen_pv_printf(xendev, 0, "xengnttab_set_max_grants failed: %s\n",
> +                      strerror(errno));
> +    }
> +}
> +

> +int xen_be_copy_grant_refs(struct XenDevice *xendev,
> +                           bool to_domain,
> +                           XenGrantCopySegment segs[],
> +                           unsigned int nr_segs)
> +{
> +    xengnttab_grant_copy_segment_t *xengnttab_segs;
> +    unsigned int i;
> +    int rc;
> +
> +    assert(xendev->ops->flags & DEVOPS_FLAG_NEED_GNTDEV);
> +
> +    xengnttab_segs = g_new0(xengnttab_grant_copy_segment_t, nr_segs);
> +
> +    for (i = 0; i < nr_segs; i++) {
> +        XenGrantCopySegment *seg = &segs[i];
> +        xengnttab_grant_copy_segment_t *xengnttab_seg = &xengnttab_segs[i];
> +
> +        if (to_domain) {
> +            xengnttab_seg->flags = GNTCOPY_dest_gref;
> +            xengnttab_seg->dest.foreign.domid = xen_domid;
> +            xengnttab_seg->dest.foreign.ref = seg->dest.foreign.ref;
> +            xengnttab_seg->dest.foreign.offset = seg->dest.foreign.offset;
> +            xengnttab_seg->source.virt = seg->source.virt;
> +        } else {
> +            xengnttab_seg->flags = GNTCOPY_source_gref;
> +            xengnttab_seg->source.foreign.domid = xen_domid;
> +            xengnttab_seg->source.foreign.ref = seg->source.foreign.ref;
> +            xengnttab_seg->source.foreign.offset =
> +                seg->source.foreign.offset;
> +            xengnttab_seg->dest.virt = seg->dest.virt;
> +        }

That's not going to work because xengnttab_grant_copy_segment_t doesn't
exist on Xen 4.7.

> +
> +        xengnttab_seg->len = seg->len;
> +    }
> +
> +    rc = xengnttab_grant_copy(xendev->gnttabdev, nr_segs, xengnttab_segs);

Thanks,

-- 
Anthony PERARD

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-05-16 13:50 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1525461967-32174-1-git-send-email-paul.durrant@citrix.com>
2018-05-04 19:26 ` [PATCH v3 1/8] xen_backend: add grant table helpers Paul Durrant
2018-05-04 19:26 ` [PATCH v3 2/8] xen_disk: remove open-coded use of libxengnttab Paul Durrant
2018-05-04 19:26 ` [PATCH v3 3/8] xen: remove other " Paul Durrant
2018-05-04 19:26 ` [PATCH v3 4/8] xen_backend: add an emulation of grant copy Paul Durrant
2018-05-04 19:26 ` [PATCH v3 5/8] xen_disk: remove use of grant map/unmap Paul Durrant
2018-05-04 19:26 ` [PATCH v3 6/8] xen_backend: make the xen_feature_grant_copy flag private Paul Durrant
2018-05-17 10:31   ` Anthony PERARD
2018-05-04 19:26 ` [PATCH v3 7/8] xen_disk: use a single entry iovec Paul Durrant
2018-05-04 19:26 ` [PATCH v3 8/8] xen_disk: be consistent with use of xendev and blkdev->xendev Paul Durrant
     [not found] ` <1525461967-32174-2-git-send-email-paul.durrant@citrix.com>
2018-05-16 13:50   ` Anthony PERARD [this message]
2018-05-16 14:00     ` [PATCH v3 1/8] xen_backend: add grant table helpers Paul Durrant
     [not found] ` <1525461967-32174-3-git-send-email-paul.durrant@citrix.com>
2018-05-16 14:02   ` [PATCH v3 2/8] xen_disk: remove open-coded use of libxengnttab Anthony PERARD
     [not found] ` <1525461967-32174-4-git-send-email-paul.durrant@citrix.com>
2018-05-16 14:14   ` [PATCH v3 3/8] xen: remove other " Anthony PERARD
     [not found]   ` <20180516141424.GH2057@perard.uk.xensource.com>
2018-05-16 14:22     ` Paul Durrant
     [not found] ` <1525461967-32174-5-git-send-email-paul.durrant@citrix.com>
2018-05-16 14:30   ` [PATCH v3 4/8] xen_backend: add an emulation of grant copy Anthony PERARD
2018-05-16 14:34     ` Paul Durrant
     [not found] ` <1525461967-32174-6-git-send-email-paul.durrant@citrix.com>
2018-05-17 10:31   ` [PATCH v3 5/8] xen_disk: remove use of grant map/unmap Anthony PERARD
     [not found] ` <1525461967-32174-8-git-send-email-paul.durrant@citrix.com>
2018-05-17 10:59   ` [PATCH v3 7/8] xen_disk: use a single entry iovec Anthony PERARD
     [not found] ` <1525461967-32174-9-git-send-email-paul.durrant@citrix.com>
2018-05-17 11:07   ` [PATCH v3 8/8] xen_disk: be consistent with use of xendev and blkdev->xendev Anthony PERARD

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=20180516135020.GF2057@perard.uk.xensource.com \
    --to=anthony.perard@citrix.com \
    --cc=paul.durrant@citrix.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.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).