[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 09/15] libxl: datacopier: provide "prefix data" facilit



In the subject: "facility"

On Wed, 2012-05-30 at 17:16 +0100, Ian Jackson wrote:
> This will be used to write the qemu data banner to the save/migration
> stream.
> 
> Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
> ---
>  tools/libxl/libxl_aoutils.c  |   15 +++++++++++++++
>  tools/libxl/libxl_internal.h |    6 ++++++
>  2 files changed, 21 insertions(+), 0 deletions(-)
> 
> diff --git a/tools/libxl/libxl_aoutils.c b/tools/libxl/libxl_aoutils.c
> index ee0df57..208b34b 100644
> --- a/tools/libxl/libxl_aoutils.c
> +++ b/tools/libxl/libxl_aoutils.c
> @@ -74,6 +74,21 @@ static void datacopier_check_state(libxl__egc *egc, 
> libxl__datacopier_state *dc)
>      }
>  }
>  
> +void libxl__datacopier_prefixdata(libxl__egc *egc, libxl__datacopier_state 
> *dc,
> +                                  const void *data, size_t len)
> +{
> +    libxl__datacopier_buf *buf;
> +
> +    assert(len < dc->maxsz - dc->used);
> +
> +    buf = libxl__zalloc(0, sizeof(*buf) - sizeof(buf->buf) + len);
> +    buf->used = len;
> +    memcpy(buf->buf, data, len);
> +
> +    dc->used += len;
> +    LIBXL_TAILQ_INSERT_TAIL(&dc->bufs, buf, entry);
> +}
> +
>  static void datacopier_readable(libxl__egc *egc, libxl__ev_fd *ev,
>                                  int fd, short events, short revents) {
>      libxl__datacopier_state *dc = CONTAINER_OF(ev, *dc, toread);
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 8f4f45d..b41e72f 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -1812,6 +1812,12 @@ _hidden void 
> libxl__datacopier_init(libxl__datacopier_state *dc);
>  _hidden void libxl__datacopier_kill(libxl__datacopier_state *dc);
>  _hidden int libxl__datacopier_start(libxl__datacopier_state *dc);
>  
> +/* Inserts literal data into the output stream.
> + * May safely be used only immediately after libxl__datacopier_start.

After datacopier_start the fds are registered, is there not a race
between those events firing (perhaps in another thread which has called
into libxl) and this thread?

Is the safe place not between datacopier_init and the rest of
datacopier_start?

> + * (But may be called multiple times.)  The data is copied.
> + * NB exceeding maxsz will fail an assertion! */
> +_hidden void libxl__datacopier_prefixdata(libxl__egc*, 
> libxl__datacopier_state*,
> +                                          const void *data, size_t len);
>  
>  /*----- Save/restore helper (used by creation and suspend) -----*/
>  



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.