[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC v3 11/12] Migration with Local Disks Mirroring: libxl write stream support for stream phase type
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@xxxxxxxxx> --- 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@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |