diff options
author | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-06-28 18:43:23 +0100 |
---|---|---|
committer | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-06-28 18:43:23 +0100 |
commit | 2602bfcf679e4a9e0641f21be0c2f2b2d4c47a3b (patch) | |
tree | c79d251b0a64abbd2d696224553a2ec01d68bc54 /tools/libxl/libxl_aoutils.c | |
parent | 0d176cc71600d74b2bd7dcb437ce4ce8c0033275 (diff) | |
download | xen-2602bfcf679e4a9e0641f21be0c2f2b2d4c47a3b.tar.gz xen-2602bfcf679e4a9e0641f21be0c2f2b2d4c47a3b.tar.bz2 xen-2602bfcf679e4a9e0641f21be0c2f2b2d4c47a3b.zip |
libxl: datacopier: provide "prefix data" facility
This will be used to write the qemu data banner to the save/migration
stream.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/libxl/libxl_aoutils.c')
-rw-r--r-- | tools/libxl/libxl_aoutils.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/libxl/libxl_aoutils.c b/tools/libxl/libxl_aoutils.c index ee0df57ff5..7f8d6d3bf6 100644 --- a/tools/libxl/libxl_aoutils.c +++ b/tools/libxl/libxl_aoutils.c @@ -74,6 +74,28 @@ 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; + /* + * It is safe for this to be called immediately after _start, as + * is documented in the public comment. _start's caller must have + * the ctx locked, so other threads don't get to mess with the + * contents, and the fd events cannot happen reentrantly. So we + * are guaranteed to beat the first data from the read fd. + */ + + 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); |