From: Bruno Alvisio <bruno.alvisio@gmail.com>
To: xen-devel@lists.xen.org, wei.liu2@citrix.com, dave@recoil.org,
ian.jackson@eu.citrix.com
Subject: [PATCH RFC v3 RESEND 11/12] Migration with Local Disks Mirroring: libxl write stream support for stream phase type
Date: Sat, 23 Dec 2017 14:03:35 +0000 [thread overview]
Message-ID: <1514037816-40864-12-git-send-email-bruno.alvisio@gmail.com> (raw)
In-Reply-To: <1514037816-40864-1-git-send-email-bruno.alvisio@gmail.com>
The libxl stream write receives stream phase type (DEFAULT, PRE_MIRROR_DISKS or
POST_MIRROR_DISKS) and registers the appropiate callback to the
libxl_save_helper. If the stream phase == PRE_MIRROR_DISKS the stream skips
writing the context record since it is written at a later time by the
POST_MIRROR_DISKS libxl stream.
Signed-off-by: Bruno Alvisio <bruno.alvisio@gmail.com>
---
tools/libxc/include/xenguest.h | 3 +-
tools/libxc/xc_nomigrate.c | 3 +-
tools/libxc/xc_sr_save.c | 3 +-
tools/libxl/libxl_internal.h | 12 +++++--
tools/libxl/libxl_save_callout.c | 10 ++++--
tools/libxl/libxl_save_helper.c | 3 +-
tools/libxl/libxl_stream_write.c | 67 +++++++++++++++++++++++++++++-----------
7 files changed, 73 insertions(+), 28 deletions(-)
diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h
index 014dee0..743294b 100644
--- a/tools/libxc/include/xenguest.h
+++ b/tools/libxc/include/xenguest.h
@@ -134,7 +134,8 @@ typedef enum {
int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom,
uint32_t flags /* XCFLAGS_xxx */,
struct save_callbacks* callbacks, int hvm,
- xc_migration_stream_t stream_type, int recv_fd);
+ xc_migration_stream_t stream_type, int recv_fd,
+ int stream_phase);
/* callbacks provided by xc_domain_restore */
struct restore_callbacks {
diff --git a/tools/libxc/xc_nomigrate.c b/tools/libxc/xc_nomigrate.c
index 75fe560..ab2d744 100644
--- a/tools/libxc/xc_nomigrate.c
+++ b/tools/libxc/xc_nomigrate.c
@@ -22,7 +22,8 @@
int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t flags,
struct save_callbacks* callbacks, int hvm,
- xc_migration_stream_t stream_type, int recv_fd)
+ xc_migration_stream_t stream_type, int recv_fd,
+ int stream_phase)
{
errno = ENOSYS;
return -1;
diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c
index 5a40e58..b7498e3 100644
--- a/tools/libxc/xc_sr_save.c
+++ b/tools/libxc/xc_sr_save.c
@@ -967,7 +967,8 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)
int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom,
uint32_t flags, struct save_callbacks* callbacks,
- int hvm, xc_migration_stream_t stream_type, int recv_fd)
+ int hvm, xc_migration_stream_t stream_type, int recv_fd,
+ int stream_phase)
{
struct xc_sr_context ctx =
{
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 0a3215f..320c97d 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -3799,12 +3799,18 @@ _hidden void libxl__domain_save(libxl__egc *egc,
/* calls libxl__xc_domain_suspend_done when done */
_hidden void libxl__xc_domain_save(libxl__egc *egc,
libxl__domain_save_state *dss,
- libxl__save_helper_state *shs);
+ libxl__save_helper_state *shs,
+ int stream_phase);
/* If rc==0 then retval is the return value from xc_domain_save
* and errnoval is the errno value it provided.
* If rc!=0, retval and errnoval are undefined. */
-_hidden void libxl__xc_domain_save_done(libxl__egc*, void *dss_void,
- int rc, int retval, int errnoval);
+_hidden void libxl__xc_domain_save_returned(libxl__egc*, void *dss_void,
+ int rc, int retval, int errnoval);
+
+_hidden void libxl__xc_mirror_disks_save_returned(libxl__egc *egc,
+ void *dss_void,
+ int rc, int retval,
+ int errnoval);
/* Used by asynchronous callbacks: ie ones which xc regards as
* returning a value, but which we want to handle asynchronously.
diff --git a/tools/libxl/libxl_save_callout.c b/tools/libxl/libxl_save_callout.c
index 0ff9a01..090d50b 100644
--- a/tools/libxl/libxl_save_callout.c
+++ b/tools/libxl/libxl_save_callout.c
@@ -86,7 +86,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs,
}
void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_save_state *dss,
- libxl__save_helper_state *shs)
+ libxl__save_helper_state *shs, int stream_phase)
{
STATE_AO_GC(dss->ao);
@@ -95,13 +95,17 @@ void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_save_state *dss,
const unsigned long argnums[] = {
dss->domid, dss->xcflags, dss->hvm, cbflags,
- dss->checkpointed_stream,
+ dss->checkpointed_stream, stream_phase,
};
shs->ao = ao;
shs->domid = dss->domid;
shs->recv_callback = libxl__srm_callout_received_save;
- shs->completion_callback = libxl__xc_domain_save_done;
+ if ( stream_phase != LIBXL_STREAM_PHASE_PRE_MIRROR_DISKS )
+ shs->completion_callback = libxl__xc_domain_save_returned;
+ else
+ shs->completion_callback = libxl__xc_mirror_disks_save_returned;
+
shs->caller_state = dss;
shs->need_results = 0;
diff --git a/tools/libxl/libxl_save_helper.c b/tools/libxl/libxl_save_helper.c
index f1e8dca..53b4d78 100644
--- a/tools/libxl/libxl_save_helper.c
+++ b/tools/libxl/libxl_save_helper.c
@@ -255,6 +255,7 @@ int main(int argc, char **argv)
int hvm = atoi(NEXTARG);
unsigned cbflags = strtoul(NEXTARG,0,10);
xc_migration_stream_t stream_type = strtoul(NEXTARG,0,10);
+ int stream_phase = atoi(NEXTARG);
assert(!*++argv);
helper_setcallbacks_save(&helper_save_callbacks, cbflags);
@@ -263,7 +264,7 @@ int main(int argc, char **argv)
setup_signals(save_signal_handler);
r = xc_domain_save(xch, io_fd, dom, flags, &helper_save_callbacks,
- hvm, stream_type, recv_fd);
+ hvm, stream_type, recv_fd, stream_phase);
complete(r);
} else if (!strcmp(mode,"--restore-domain")) {
diff --git a/tools/libxl/libxl_stream_write.c b/tools/libxl/libxl_stream_write.c
index 634f324..0ff096a 100644
--- a/tools/libxl/libxl_stream_write.c
+++ b/tools/libxl/libxl_stream_write.c
@@ -330,31 +330,43 @@ static void stream_header_done(libxl__egc *egc,
static void libxc_header_done(libxl__egc *egc,
libxl__stream_write_state *stream)
{
- libxl__xc_domain_save(egc, stream->dss, &stream->shs);
+ int save_mirror_disks = stream->dss->mirror_disks;
+ libxl__xc_domain_save(egc, stream->dss, &stream->shs,
+ save_mirror_disks + stream->mirror_disks);
}
-void libxl__xc_domain_save_done(libxl__egc *egc, void *dss_void,
- int rc, int retval, int errnoval)
+static void libxl__xc_domain_save_done(libxl__egc *egc, void *dss_void,
+ libxl__stream_write_state *stream,
+ int rc, int retval, int errnoval)
{
libxl__domain_save_state *dss = dss_void;
- libxl__stream_write_state *stream = &dss->sws;
STATE_AO_GC(dss->ao);
if (rc)
goto err;
if (retval) {
- LOGEVD(ERROR, errnoval, dss->domid, "saving domain: %s",
- dss->dsps.guest_responded ?
- "domain responded to suspend request" :
- "domain did not respond to suspend request");
- if (!dss->dsps.guest_responded)
- rc = ERROR_GUEST_TIMEDOUT;
- else if (dss->rc)
- rc = dss->rc;
- else
- rc = ERROR_FAIL;
- goto err;
+ if (!stream->mirror_disks) {
+ LOGEVD(ERROR, errnoval, dss->domid, "saving domain: %s",
+ dss->dsps.guest_responded ?
+ "domain responded to suspend request" :
+ "domain did not respond to suspend request");
+ if (!dss->dsps.guest_responded)
+ rc = ERROR_GUEST_TIMEDOUT;
+ else if (dss->rc)
+ rc = dss->rc;
+ else
+ rc = ERROR_FAIL;
+ goto err;
+ } else {
+ LOGEVD(ERROR, errnoval, dss->domid, "saving domain: Error occurred "
+ "in libxc pre mirror phase stream");
+ if (dss->rc)
+ rc = dss->rc;
+ else
+ rc = ERROR_FAIL;
+ goto err;
+ }
}
err:
@@ -380,6 +392,22 @@ void libxl__xc_domain_save_done(libxl__egc *egc, void *dss_void,
}
}
+void libxl__xc_mirror_disks_save_returned(libxl__egc *egc, void *dss_void,
+ int rc, int retval, int errnoval)
+{
+ libxl__domain_save_state *dss = dss_void;
+ libxl__stream_write_state *stream = &dss->sws_mirror_disks;
+ libxl__xc_domain_save_done(egc, dss_void, stream, rc, retval, errnoval);
+}
+
+void libxl__xc_domain_save_returned(libxl__egc *egc, void *dss_void,
+ int rc, int retval, int errnoval)
+{
+ libxl__domain_save_state *dss = dss_void;
+ libxl__stream_write_state *stream = &dss->sws;
+ libxl__xc_domain_save_done(egc, dss_void, stream, rc, retval, errnoval);
+}
+
static void write_emulator_xenstore_record(libxl__egc *egc,
libxl__stream_write_state *stream)
{
@@ -424,9 +452,12 @@ static void emulator_xenstore_record_done(libxl__egc *egc,
{
libxl__domain_save_state *dss = stream->dss;
- if (dss->type == LIBXL_DOMAIN_TYPE_HVM)
- write_emulator_context_record(egc, stream);
- else {
+ if (dss->type == LIBXL_DOMAIN_TYPE_HVM) {
+ if (!stream->mirror_disks)
+ write_emulator_context_record(egc, stream);
+ else
+ write_end_record(egc, stream);
+ } else {
if (stream->in_checkpoint)
write_checkpoint_end_record(egc, stream);
else
--
2.3.2 (Apple Git-55)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2017-12-23 14:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-23 14:03 [PATCH RFC v3 RESEND 00/12] Migration with Local Disks Mirroring Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 01/12] Migration with Local Disks Mirroring: Added support in libxl to handle QMP events Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 02/12] Migration with Local Disks Mirroring: Added QMP commands used for mirroring disks Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 03/12] Migration with Local Disks Mirroring: Refactored migrate_read_fixedmessage Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 04/12] Migration with Local Disks Mirroring: Added a new '-q' flag to xl migrate for disk mirorring Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 05/12] Migration with Local Disks Mirroring: QEMU process is started with '-incoming defer' option Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 06/12] Migration with Local Disks Mirroring: Added 'mirror_disks' field to domain_create_state Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 07/12] Migration with Local Disks Mirroring: Added new libxl_read_stream and callbacks in restore flow Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 08/12] Migration with Local Disks Mirroring: New stream phase type for libxl streams Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 09/12] Migration with Local Disks Mirroring: New stream phase type for libxc streams Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 10/12] Migration with Local Disks Mirroring: libxl save flow support Bruno Alvisio
2017-12-23 14:03 ` Bruno Alvisio [this message]
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 12/12] Migration with Local Disks Mirroring: Introduce pre_mirror_disks_stream_phase op to xc_sr_save_ops Bruno Alvisio
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=1514037816-40864-12-git-send-email-bruno.alvisio@gmail.com \
--to=bruno.alvisio@gmail.com \
--cc=dave@recoil.org \
--cc=ian.jackson@eu.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 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).