[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 21/27] tools/libxc+libxl+xl: Save v2 streams
This is a complicated set of changes which must be done together for bisectability. * libxl-save-helper is updated to unconditionally use libxc migration v2. * libxl compatibility workarounds in libxc are disabled for save operations. * libxl__stream_write_start() is logically spliced into the event location where libxl__xc_domain_save() used to reside. * xl is updated to indicate that the stream is now v2 Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CC: Ian Campbell <Ian.Campbell@xxxxxxxxxx> CC: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> CC: Wei Liu <wei.liu2@xxxxxxxxxx> --- tools/libxc/Makefile | 2 -- tools/libxl/libxl.h | 2 ++ tools/libxl/libxl_dom.c | 46 +++++++++----------------------------- tools/libxl/libxl_save_helper.c | 2 +- tools/libxl/libxl_stream_write.c | 35 +++++++++++++++++++++++++++-- tools/libxl/xl_cmdimpl.c | 1 + 6 files changed, 47 insertions(+), 41 deletions(-) diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile index 2cd0b1a..1aec848 100644 --- a/tools/libxc/Makefile +++ b/tools/libxc/Makefile @@ -64,8 +64,6 @@ GUEST_SRCS-$(CONFIG_X86) += xc_sr_save_x86_hvm.c GUEST_SRCS-y += xc_sr_restore.c GUEST_SRCS-y += xc_sr_save.c GUEST_SRCS-y += xc_offline_page.c xc_compression.c -xc_sr_save_x86_hvm.o: CFLAGS += -DXG_LIBXL_HVM_COMPAT -xc_sr_save_x86_hvm.opic: CFLAGS += -DXG_LIBXL_HVM_COMPAT else GUEST_SRCS-y += xc_nomigrate.c endif diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index e64a606..4f24e5f 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -812,6 +812,8 @@ * * If this is defined, then the libxl_domain_create_restore() interface takes * a "stream_version" parameter and supports a value of 2. + * + * libxl_domain_suspend() will produce a v2 stream. */ #define LIBXL_HAVE_STREAM_V2 1 diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 8642192..de05124 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -1153,6 +1153,8 @@ int libxl__toolstack_restore(uint32_t domid, const uint8_t *ptr, /*==================== Domain suspend (save) ====================*/ +static void stream_done(libxl__egc *egc, + libxl__stream_write_state *sws, int rc); static void domain_suspend_done(libxl__egc *egc, libxl__domain_suspend_state *dss, int rc); static void domain_suspend_callback_common_done(libxl__egc *egc, @@ -2117,50 +2119,22 @@ void libxl__domain_suspend(libxl__egc *egc, libxl__domain_suspend_state *dss) callbacks->switch_qemu_logdirty = libxl__domain_suspend_common_switch_qemu_logdirty; dss->shs.callbacks.save.toolstack_save = libxl__toolstack_save; - libxl__xc_domain_save(egc, dss); + dss->sws.fd = dss->fd; + dss->sws.ao = dss->ao; + dss->sws.completion_callback = stream_done; + + libxl__stream_write_start(egc, &dss->sws); return; out: domain_suspend_done(egc, dss, rc); } -void libxl__xc_domain_save_done(libxl__egc *egc, void *dss_void, - int rc, int retval, int errnoval) +static void stream_done(libxl__egc *egc, + libxl__stream_write_state *sws, int rc) { - libxl__domain_suspend_state *dss = dss_void; - STATE_AO_GC(dss->ao); - - /* Convenience aliases */ - const libxl_domain_type type = dss->type; - - if (rc) - goto out; - - if (retval) { - LOGEV(ERROR, errnoval, "saving domain: %s", - dss->guest_responded ? - "domain responded to suspend request" : - "domain did not respond to suspend request"); - if ( !dss->guest_responded ) - rc = ERROR_GUEST_TIMEDOUT; - else if (dss->rc) - rc = dss->rc; - else - rc = ERROR_FAIL; - goto out; - } - - if (type == LIBXL_DOMAIN_TYPE_HVM) { - rc = libxl__domain_suspend_device_model(gc, dss); - if (rc) goto out; + libxl__domain_suspend_state *dss = CONTAINER_OF(sws, *dss, sws); - libxl__domain_save_device_model(egc, dss, domain_suspend_done); - return; - } - - rc = 0; - -out: domain_suspend_done(egc, dss, rc); } diff --git a/tools/libxl/libxl_save_helper.c b/tools/libxl/libxl_save_helper.c index efbe2eb..f196786 100644 --- a/tools/libxl/libxl_save_helper.c +++ b/tools/libxl/libxl_save_helper.c @@ -286,7 +286,7 @@ int main(int argc, char **argv) startup("save"); setup_signals(save_signal_handler); - r = xc_domain_save(xch, io_fd, dom, max_iters, max_factor, flags, + r = xc_domain_save2(xch, io_fd, dom, max_iters, max_factor, flags, &helper_save_callbacks, hvm); complete(r); diff --git a/tools/libxl/libxl_stream_write.c b/tools/libxl/libxl_stream_write.c index bf568ad..331173f 100644 --- a/tools/libxl/libxl_stream_write.c +++ b/tools/libxl/libxl_stream_write.c @@ -276,8 +276,39 @@ static void libxc_header_done(libxl__egc *egc, libxl__xc_domain_save(egc, dss); } -static void __attribute__((unused)) -write_toolstack_record(libxl__egc *egc, +void libxl__xc_domain_save_done(libxl__egc *egc, void *dss_void, + int rc, int retval, int errnoval) +{ + libxl__domain_suspend_state *dss = dss_void; + libxl__stream_write_state *stream = &dss->sws; + STATE_AO_GC(dss->ao); + + if (rc) + goto err; + + if (retval) { + LOGEV(ERROR, errnoval, "saving domain: %s", + dss->guest_responded ? + "domain responded to suspend request" : + "domain did not respond to suspend request"); + if ( !dss->guest_responded ) + rc = ERROR_GUEST_TIMEDOUT; + else if (dss->rc) + rc = dss->rc; + else + rc = ERROR_FAIL; + goto err; + } + + write_toolstack_record(egc, stream); + return; + + err: + assert(rc); + check_stream_finished(egc, stream, rc, "save/restore helper"); +} + +static void write_toolstack_record(libxl__egc *egc, libxl__stream_write_state *stream) { libxl__domain_suspend_state *dss = CONTAINER_OF(stream, *dss, sws); diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 71a22b8..13e154d 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -3922,6 +3922,7 @@ static void save_domain_core_writeconfig(int fd, const char *source, memset(&hdr, 0, sizeof(hdr)); memcpy(hdr.magic, savefileheader_magic, sizeof(hdr.magic)); hdr.byteorder = SAVEFILE_BYTEORDER_VALUE; + hdr.mandatory_flags = XL_MANDATORY_FLAG_STREAMv2; optdata_begin= 0; -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |