We need to send secondary's dirty page pfns back to primary. Primary will then send pages that are both dirtied on primary/secondary to secondary. in this way the secondary's memory will be consistent with primary.
We do this on libxc side, so we need to introduce back channel to libxc. Signed-off-by: Yang Hongyang <yan...@cn.fujitsu.com> CC: Ian Campbell <ian.campb...@citrix.com> CC: Ian Jackson <ian.jack...@eu.citrix.com> CC: Wei Liu <wei.l...@citrix.com> CC: Andrew Cooper <andrew.coop...@citrix.com> --- tools/libxc/include/xenguest.h | 8 ++++---- tools/libxc/xc_domain_restore.c | 4 ++-- tools/libxc/xc_domain_save.c | 4 ++-- tools/libxc/xc_sr_restore.c | 2 +- tools/libxc/xc_sr_save.c | 2 +- tools/libxl/libxl_save_callout.c | 23 +++++++++++++++++------ tools/libxl/libxl_save_helper.c | 8 ++++++-- 7 files changed, 33 insertions(+), 18 deletions(-) diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h index d7c8fe4..3e48a97 100644 --- a/tools/libxc/include/xenguest.h +++ b/tools/libxc/include/xenguest.h @@ -91,13 +91,13 @@ struct save_callbacks { int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters, uint32_t max_factor, uint32_t flags /* XCFLAGS_xxx */, struct save_callbacks* callbacks, int hvm, - int checkpointed_stream); + int checkpointed_stream, int back_fd); /* Domain Save v2 */ int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters, uint32_t max_factor, uint32_t flags, struct save_callbacks* callbacks, int hvm, - int checkpointed_stream); + int checkpointed_stream, int back_fd); /* callbacks provided by xc_domain_restore */ struct restore_callbacks { @@ -136,7 +136,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, unsigned long *console_mfn, domid_t console_domid, unsigned int hvm, unsigned int pae, int superpages, int checkpointed_stream, - struct restore_callbacks *callbacks); + struct restore_callbacks *callbacks, int back_fd); /* Domain Restore v2 */ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom, @@ -145,7 +145,7 @@ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom, unsigned long *console_mfn, domid_t console_domid, unsigned int hvm, unsigned int pae, int superpages, int checkpointed_stream, - struct restore_callbacks *callbacks); + struct restore_callbacks *callbacks, int back_fd); /** * xc_domain_restore writes a file to disk that contains the device * model saved state. diff --git a/tools/libxc/xc_domain_restore.c b/tools/libxc/xc_domain_restore.c index 3cd3483..63d1e6b 100644 --- a/tools/libxc/xc_domain_restore.c +++ b/tools/libxc/xc_domain_restore.c @@ -1515,7 +1515,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, unsigned long *console_mfn, domid_t console_domid, unsigned int hvm, unsigned int pae, int superpages, int checkpointed_stream, - struct restore_callbacks *callbacks) + struct restore_callbacks *callbacks, int back_fd) { DECLARE_DOMCTL; xc_dominfo_t info; @@ -1578,7 +1578,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, return xc_domain_restore2( xch, io_fd, dom, store_evtchn, store_mfn, store_domid, console_evtchn, console_mfn, console_domid, - hvm, pae, superpages, checkpointed_stream, callbacks); + hvm, pae, superpages, checkpointed_stream, callbacks, back_fd); } DPRINTF("%s: starting restore of new domid %u", __func__, dom); diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c index c76980e..de2f852 100644 --- a/tools/libxc/xc_domain_save.c +++ b/tools/libxc/xc_domain_save.c @@ -803,7 +803,7 @@ static int save_tsc_info(xc_interface *xch, uint32_t dom, int io_fd) int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters, uint32_t max_factor, uint32_t flags, struct save_callbacks* callbacks, int hvm, - int checkpointed_stream) + int checkpointed_stream, int back_fd) { xc_dominfo_t info; DECLARE_DOMCTL; @@ -899,7 +899,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter { return xc_domain_save2(xch, io_fd, dom, max_iters, max_factor, flags, callbacks, hvm, - checkpointed_stream); + checkpointed_stream, back_fd); } DPRINTF("%s: starting save of domid %u", __func__, dom); diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c index d5645e0..f8b6f2f 100644 --- a/tools/libxc/xc_sr_restore.c +++ b/tools/libxc/xc_sr_restore.c @@ -710,7 +710,7 @@ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom, unsigned long *console_gfn, domid_t console_domid, unsigned int hvm, unsigned int pae, int superpages, int checkpointed_stream, - struct restore_callbacks *callbacks) + struct restore_callbacks *callbacks, int back_fd) { struct xc_sr_context ctx = { diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c index 6102b66..d12e5b1 100644 --- a/tools/libxc/xc_sr_save.c +++ b/tools/libxc/xc_sr_save.c @@ -821,7 +821,7 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type) int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters, uint32_t max_factor, uint32_t flags, struct save_callbacks* callbacks, int hvm, - int checkpointed_stream) + int checkpointed_stream, int back_fd) { xen_pfn_t nr_pfns; struct xc_sr_context ctx = diff --git a/tools/libxl/libxl_save_callout.c b/tools/libxl/libxl_save_callout.c index 12cc57e..25817d6 100644 --- a/tools/libxl/libxl_save_callout.c +++ b/tools/libxl/libxl_save_callout.c @@ -27,7 +27,7 @@ */ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs, const char *mode_arg, - int stream_fd, + int stream_fd, int back_fd, const int *preserve_fds, int num_preserve_fds, const unsigned long *argnums, int num_argnums); @@ -70,8 +70,8 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs, dcs->shs.need_results = 1; dcs->shs.toolstack_data_file = 0; - run_helper(egc, &dcs->shs, "--restore-domain", restore_fd, 0,0, - argnums, ARRAY_SIZE(argnums)); + run_helper(egc, &dcs->shs, "--restore-domain", restore_fd, dcs->send_fd, + 0,0, argnums, ARRAY_SIZE(argnums)); } void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_save_state *dss) @@ -93,7 +93,7 @@ void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_save_state *dss) dss->shs.caller_state = dss; dss->shs.need_results = 0; - run_helper(egc, &dss->shs, "--save-domain", dss->fd, + run_helper(egc, &dss->shs, "--save-domain", dss->fd, dss->recv_fd, NULL, 0, argnums, ARRAY_SIZE(argnums)); return; @@ -111,12 +111,12 @@ void libxl__xc_domain_saverestore_async_callback_done(libxl__egc *egc, /*----- helper execution -----*/ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs, - const char *mode_arg, int stream_fd, + const char *mode_arg, int stream_fd, int back_fd, const int *preserve_fds, int num_preserve_fds, const unsigned long *argnums, int num_argnums) { STATE_AO_GC(shs->ao); - const char *args[4 + num_argnums]; + const char *args[5 + num_argnums]; const char **arg = args; int i, rc; @@ -140,6 +140,7 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs, *arg++ = getenv("LIBXL_SAVE_HELPER") ?: LIBEXEC_BIN "/" "libxl-save-helper"; *arg++ = mode_arg; const char **stream_fd_arg = arg++; + const char **back_fd_arg = arg++; for (i=0; i<num_argnums; i++) *arg++ = GCSPRINTF("%lu", argnums[i]); *arg++ = 0; @@ -174,6 +175,16 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs, libxl_fd_set_cloexec(CTX, stream_fd, 0); *stream_fd_arg = GCSPRINTF("%d", stream_fd); + if (back_fd <= 2) { + back_fd = dup(back_fd); + if (back_fd < 0) { + LOGE(ERROR,"dup migration back channel"); + exit(-1); + } + } + libxl_fd_set_cloexec(CTX, back_fd, 0); + *back_fd_arg = GCSPRINTF("%d", back_fd); + for (i=0; i<num_preserve_fds; i++) if (preserve_fds[i] >= 0) { assert(preserve_fds[i] > 2); diff --git a/tools/libxl/libxl_save_helper.c b/tools/libxl/libxl_save_helper.c index 9d2cbf6..81498bd 100644 --- a/tools/libxl/libxl_save_helper.c +++ b/tools/libxl/libxl_save_helper.c @@ -233,6 +233,7 @@ static struct restore_callbacks helper_restore_callbacks; int main(int argc, char **argv) { int r; + int back_fd; #define NEXTARG (++argv, assert(*argv), *argv) @@ -242,6 +243,7 @@ int main(int argc, char **argv) if (!strcmp(mode,"--save-domain")) { io_fd = atoi(NEXTARG); + back_fd = atoi(NEXTARG); uint32_t dom = strtoul(NEXTARG,0,10); uint32_t max_iters = strtoul(NEXTARG,0,10); uint32_t max_factor = strtoul(NEXTARG,0,10); @@ -257,12 +259,14 @@ int main(int argc, char **argv) setup_signals(save_signal_handler); r = xc_domain_save2(xch, io_fd, dom, max_iters, max_factor, flags, - &helper_save_callbacks, hvm, checkpointed_stream); + &helper_save_callbacks, hvm, checkpointed_stream, + back_fd); complete(r); } else if (!strcmp(mode,"--restore-domain")) { io_fd = atoi(NEXTARG); + back_fd = atoi(NEXTARG); uint32_t dom = strtoul(NEXTARG,0,10); unsigned store_evtchn = strtoul(NEXTARG,0,10); domid_t store_domid = strtoul(NEXTARG,0,10); @@ -287,7 +291,7 @@ int main(int argc, char **argv) store_domid, console_evtchn, &console_mfn, console_domid, hvm, pae, superpages, checkpointed, - &helper_restore_callbacks); + &helper_restore_callbacks, back_fd); helper_stub_restore_results(store_mfn,console_mfn,0); complete(r); -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel