All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Ross Lagerwall <ross.lagerwall@citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Wei Liu <wei.liu2@citrix.com>,
	Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH v2 5/6] tools/libxl: Extend datacopier to support reading into a buffer
Date: Wed, 11 Mar 2015 12:19:58 +0000	[thread overview]
Message-ID: <1426076398.21353.220.camel@citrix.com> (raw)
In-Reply-To: <1425668741-28003-6-git-send-email-andrew.cooper3@citrix.com>

On Fri, 2015-03-06 at 19:05 +0000, Andrew Cooper wrote:
> From: Ross Lagerwall <ross.lagerwall@citrix.com>
> 
> Currently a datacopier may source its data from an fd or local buffer, but its
> destination must be an fd.  For migration v2, libxl needs to read from the
> migration stream into a local buffer.
> 
> Implement a "read into local buffer" mode, invoked when readbuf is set and
> writefd is -1.  On success, the callback passes the number of bytes read.

> +        if (dc->readbuf) {
> +            r = read(ev->fd, dc->readbuf + dc->used, dc->maxread);

Should the final parameter not be maxread - used?

I assume the caller is expected to make maxread and the readbuf size
consistent (which could BTW be mentioned in an update to the comments
relating to this interface).

> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 22921c7..3e1d78a 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -2524,7 +2524,8 @@ _hidden void libxl__device_disk_local_initiate_detach(libxl__egc *egc,
>  
>  /* onwrite==1 means failure happened when writing, logged, errnoval is valid
>   * onwrite==0 means failure happened when reading
> - *     errnoval==0 means we got eof and all data was written
> + *     errnoval>=0 means we got eof and all data was written or number of bytes
> + *                 written when in read mode
>   *     errnoval!=0 means we had a read error, logged

Nit: the last should be errnoval < 0.

I'm not sure how I feel about using a field called errnoval to store
something other than an errno though. I suppose I can live with it.

>   * onwrite==-1 means some other internal failure, errnoval not valid, logged
>   * If we get POLLHUP, we call callback_pollhup(..., onwrite, -1);
> @@ -2553,6 +2554,7 @@ struct libxl__datacopier_state {
>      /* remaining fields are private to datacopier */
>      libxl__ev_fd toread, towrite;
>      ssize_t used;
> +    void *readbuf;
>      LIBXL_TAILQ_HEAD(libxl__datacopier_bufs, libxl__datacopier_buf) bufs;
>  };
>  

  reply	other threads:[~2015-03-11 12:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-06 19:05 [PATCH v2 0/6] tools/libxl: Improvements to libxl__datacopier Andrew Cooper
2015-03-06 19:05 ` [PATCH v2 1/6] tools/libxl: Introduce min and max macros Andrew Cooper
2015-03-11 12:07   ` Ian Campbell
2015-03-06 19:05 ` [PATCH v2 2/6] tools/libxl: Update datacopier to support sending data only Andrew Cooper
2015-03-11 12:07   ` Ian Campbell
2015-03-06 19:05 ` [PATCH v2 3/6] tools/libxl: Avoid overrunning static buffer with prefixdata Andrew Cooper
2015-03-11 12:09   ` Ian Campbell
2015-03-06 19:05 ` [PATCH v2 4/6] tools/libxl: Allow limiting amount copied by datacopier Andrew Cooper
2015-03-11 12:15   ` Ian Campbell
2015-03-11 12:23     ` Andrew Cooper
2015-03-11 12:31       ` Ian Campbell
2015-03-06 19:05 ` [PATCH v2 5/6] tools/libxl: Extend datacopier to support reading into a buffer Andrew Cooper
2015-03-11 12:19   ` Ian Campbell [this message]
2015-03-16 13:31     ` Ross Lagerwall
2015-03-06 19:05 ` [PATCH v2 6/6] tools/libxl: Adjust datacopiers POLLHUP handling when the fd is also readable Andrew Cooper
2015-03-11 12:21   ` Ian Campbell

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=1426076398.21353.220.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ross.lagerwall@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.