From: Yang Hongyang <yanghy@cn.fujitsu.com>
To: xen-devel@lists.xen.org
Cc: wei.liu2@citrix.com, ian.campbell@citrix.com,
wency@cn.fujitsu.com, andrew.cooper3@citrix.com,
yunhong.jiang@intel.com, eddie.dong@intel.com,
guijianfeng@cn.fujitsu.com, rshriram@cs.ubc.ca,
ian.jackson@eu.citrix.com
Subject: [PATCH v7 COLO 03/18] tools/libxl: write colo_context records into the stream
Date: Thu, 25 Jun 2015 14:30:57 +0800 [thread overview]
Message-ID: <1435213872-10698-4-git-send-email-yanghy@cn.fujitsu.com> (raw)
In-Reply-To: <1435213872-10698-1-git-send-email-yanghy@cn.fujitsu.com>
From: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
tools/libxl/libxl_internal.h | 4 ++
tools/libxl/libxl_stream_write.c | 92 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 96 insertions(+)
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 7f591ee..1ef6fc8 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -2905,6 +2905,7 @@ struct libxl__stream_write_state {
size_t padding;
bool running;
bool in_checkpoint;
+ bool in_colo_context;
libxl__datacopier_state dc;
};
@@ -2913,6 +2914,9 @@ _hidden void libxl__stream_write_start(libxl__egc *egc,
_hidden void libxl__stream_write_start_checkpoint(
libxl__egc *egc, libxl__stream_write_state *stream);
+_hidden void libxl__stream_write_colo_context(
+ libxl__egc *egc, libxl__stream_write_state *stream,
+ libxl_sr_colo_context *colo_context);
_hidden void libxl__stream_write_abort(libxl__egc *egc,
libxl__stream_write_state *stream,
diff --git a/tools/libxl/libxl_stream_write.c b/tools/libxl/libxl_stream_write.c
index 3f981f0..a445189 100644
--- a/tools/libxl/libxl_stream_write.c
+++ b/tools/libxl/libxl_stream_write.c
@@ -107,6 +107,15 @@ static void checkpoint_end_record_done(libxl__egc *egc,
libxl__datacopier_state *dc,
int onwrite, int errnoval);
+static void write_colo_context(libxl__egc *egc,
+ libxl__stream_write_state *stream,
+ libxl_sr_colo_context *colo_context);
+static void write_colo_context_done(libxl__egc *egc,
+ libxl__datacopier_state *dc,
+ int onwrite, int errnoval);
+static void colo_context_done(libxl__egc *egc,
+ libxl__stream_write_state *stream, int rc);
+
void libxl__stream_write_start(libxl__egc *egc,
libxl__stream_write_state *stream)
{
@@ -154,11 +163,24 @@ void libxl__stream_write_start_checkpoint(libxl__egc *egc,
assert(stream->running);
assert(!stream->in_checkpoint);
assert(!stream->back_channel);
+ assert(!stream->in_colo_context);
stream->in_checkpoint = true;
write_toolstack_record(egc, stream);
}
+void libxl__stream_write_colo_context(libxl__egc *egc,
+ libxl__stream_write_state *stream,
+ libxl_sr_colo_context *colo_context)
+{
+ assert(stream->running);
+ assert(!stream->in_checkpoint);
+ assert(!stream->in_colo_context);
+ stream->in_colo_context = true;
+
+ write_colo_context(egc, stream, colo_context);
+}
+
void libxl__stream_write_abort(libxl__egc *egc,
libxl__stream_write_state *stream, int rc)
{
@@ -171,6 +193,7 @@ static void stream_success(libxl__egc *egc, libxl__stream_write_state *stream)
stream->running = false;
assert(!stream->in_checkpoint);
+ assert(!stream->in_colo_context);
stream_done(egc, stream);
}
@@ -189,6 +212,11 @@ static void stream_failed(libxl__egc *egc,
return;
}
+ if (stream->in_colo_context) {
+ colo_context_done(egc, stream, rc);
+ return;
+ }
+
if (stream->back_channel) {
stream->completion_callback(egc, stream, rc);
return;
@@ -207,6 +235,7 @@ static void stream_done(libxl__egc *egc,
assert(!stream->running);
assert(!stream->in_checkpoint);
+ assert(!stream->in_colo_context);
check_stream_finished(egc, dss, stream->rc, "stream");
}
@@ -544,6 +573,61 @@ static void emulator_padding_done(libxl__egc *egc,
stream_failed(egc, stream, ret);
}
+static void write_colo_context(libxl__egc *egc,
+ libxl__stream_write_state *stream,
+ libxl_sr_colo_context *colo_context)
+{
+ libxl__datacopier_state *dc = &stream->dc;
+ STATE_AO_GC(stream->ao);
+ struct libxl_sr_rec_hdr rec = { REC_TYPE_COLO_CONTEXT, 0 };
+ int ret = 0;
+ uint32_t padding_len;
+
+ dc->copywhat = "colo context record";
+ dc->writewhat = "save/migration stream";
+ dc->callback = write_colo_context_done;
+
+ ret = libxl__datacopier_start(dc);
+ if (ret)
+ goto err;
+
+ rec.length = sizeof(*colo_context);
+
+ libxl__datacopier_prefixdata(egc, dc, &rec, sizeof(rec));
+ libxl__datacopier_prefixdata(egc, dc, colo_context, rec.length);
+
+ padding_len = ROUNDUP(rec.length, REC_ALIGN_ORDER) - rec.length;
+ if (padding_len)
+ libxl__datacopier_prefixdata(egc, dc, zero_padding, padding_len);
+
+ return;
+
+ err:
+ assert(ret);
+ stream_failed(egc, stream, ret);
+}
+
+static void write_colo_context_done(libxl__egc *egc,
+ libxl__datacopier_state *dc,
+ int onwrite, int errnoval)
+{
+ libxl__stream_write_state *stream = CONTAINER_OF(dc, *stream, dc);
+ STATE_AO_GC(stream->ao);
+ int ret = 0;
+
+ if (onwrite || errnoval) {
+ ret = ERROR_FAIL;
+ goto err;
+ }
+
+ colo_context_done(egc, stream, 0);
+ return;
+
+ err:
+ assert(ret);
+ stream_failed(egc, stream, ret);
+}
+
static void write_end_record(libxl__egc *egc,
libxl__stream_write_state *stream)
{
@@ -645,6 +729,14 @@ static void checkpoint_end_record_done(libxl__egc *egc,
stream_failed(egc, stream, ret);
}
+static void colo_context_done(libxl__egc *egc,
+ libxl__stream_write_state *stream, int rc)
+{
+ assert(stream->in_colo_context);
+ stream->in_colo_context = false;
+ stream->write_records_callback(egc, stream, rc);
+}
+
/*
* Local variables:
* mode: C
--
1.9.1
next prev parent reply other threads:[~2015-06-25 6:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-25 6:30 [PATCH v7 COLO 00/18] COarse-grain LOck-stepping Virtual Machines for Non-stop Service Yang Hongyang
2015-06-25 6:30 ` [PATCH v7 COLO 01/18] docs: add colo readme Yang Hongyang
2015-07-14 15:15 ` Ian Campbell
2015-06-25 6:30 ` [PATCH v7 COLO 02/18] tools/libxl: handle colo_context records in a libxl migration v2 stream Yang Hongyang
2015-07-14 15:19 ` Ian Campbell
2015-07-15 0:34 ` Yang Hongyang
2015-06-25 6:30 ` Yang Hongyang [this message]
2015-06-25 6:30 ` [PATCH v7 COLO 04/18] secondary vm suspend/resume/checkpoint code Yang Hongyang
2015-06-25 6:30 ` [PATCH v7 COLO 05/18] primary " Yang Hongyang
2015-06-25 6:31 ` [PATCH v7 COLO 06/18] libxc/restore: support COLO restore Yang Hongyang
2015-06-25 6:31 ` [PATCH v7 COLO 07/18] libxc/restore: send dirty bitmap to primary when checkpoint under colo Yang Hongyang
2015-06-25 6:31 ` [PATCH v7 COLO 08/18] send store mfn and console mfn to xl before resuming secondary vm Yang Hongyang
2015-06-25 6:31 ` [PATCH v7 COLO 09/18] libxc/save: support COLO save Yang Hongyang
2015-06-25 6:31 ` [PATCH v7 COLO 10/18] implement the cmdline for COLO Yang Hongyang
2015-06-25 6:31 ` [PATCH v7 COLO 11/18] Support colo mode for qemu disk Yang Hongyang
2015-06-25 6:31 ` [PATCH v7 COLO 12/18] COLO: use qemu block replication Yang Hongyang
2015-06-25 6:31 ` [PATCH v7 COLO 13/18] COLO proxy: implement setup/teardown of COLO proxy module Yang Hongyang
2015-06-25 6:31 ` [PATCH v7 COLO 14/18] COLO proxy: preresume, postresume and checkpoint Yang Hongyang
2015-06-25 6:31 ` [PATCH v7 COLO 15/18] COLO nic: implement COLO nic subkind Yang Hongyang
2015-06-25 6:31 ` [PATCH v7 COLO 16/18] setup and control colo proxy on primary side Yang Hongyang
2015-06-25 6:31 ` [PATCH v7 COLO 17/18] setup and control colo proxy on secondary side Yang Hongyang
2015-06-25 6:31 ` [PATCH v7 COLO 18/18] cmdline switches and config vars to control colo-proxy Yang Hongyang
2015-07-14 15:55 ` [PATCH v7 COLO 00/18] COarse-grain LOck-stepping Virtual Machines for Non-stop Service Ian Campbell
2015-07-15 0:41 ` Yang Hongyang
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=1435213872-10698-4-git-send-email-yanghy@cn.fujitsu.com \
--to=yanghy@cn.fujitsu.com \
--cc=andrew.cooper3@citrix.com \
--cc=eddie.dong@intel.com \
--cc=guijianfeng@cn.fujitsu.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=rshriram@cs.ubc.ca \
--cc=wei.liu2@citrix.com \
--cc=wency@cn.fujitsu.com \
--cc=xen-devel@lists.xen.org \
--cc=yunhong.jiang@intel.com \
/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).