|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxl: datacopier: provide "prefix data" facility
# HG changeset patch
# User Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
# Date 1340905403 -3600
# Node ID 59127c03d75c7d7e6556ec545c957660770bddfa
# Parent 1883e5c71a87797fbb841a3ee59f166b7a6af09d
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@xxxxxxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
diff -r 1883e5c71a87 -r 59127c03d75c tools/libxl/libxl_aoutils.c
--- a/tools/libxl/libxl_aoutils.c Thu Jun 28 18:43:23 2012 +0100
+++ b/tools/libxl/libxl_aoutils.c Thu Jun 28 18:43:23 2012 +0100
@@ -74,6 +74,28 @@ static void datacopier_check_state(libxl
}
}
+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);
diff -r 1883e5c71a87 -r 59127c03d75c tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Thu Jun 28 18:43:23 2012 +0100
+++ b/tools/libxl/libxl_internal.h Thu Jun 28 18:43:23 2012 +0100
@@ -1811,6 +1811,12 @@ _hidden void libxl__datacopier_init(libx
_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. The data is copied.
+ * May safely be used only immediately after libxl__datacopier_start
+ * (before the ctx is unlocked). But may be called multiple times.
+ * 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-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |