From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: [PATCH v2 5/6] tools/migration: Specification update for 'checkpointed' flag Date: Fri, 8 May 2015 22:14:34 +0100 Message-ID: <1431119675-23847-6-git-send-email-andrew.cooper3@citrix.com> References: <1431119675-23847-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1431119675-23847-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Wei Liu , Ian Campbell , Andrew Cooper , Ian Jackson , David Vrabel , Yang Hongyang List-Id: xen-devel@lists.xenproject.org From: Yang Hongyang This allows different types of streams to be distinguished from the Image Header alone, at the start of day. In addition, update the save and restore code to: * Collect checkpointed-ness from their callers * Use the new stream flag * Sanity check their environment Based on an eariler patch from Yang Hongyang Signed-off-by: Yang Hongyang Signed-off-by: Andrew Cooper CC: David Vrabel CC: Ian Campbell CC: Ian Jackson CC: Wei Liu --- docs/specs/libxc-migration-stream.pandoc | 5 ++++- tools/libxc/include/xenguest.h | 1 + tools/libxc/xc_sr_common.h | 6 ++++++ tools/libxc/xc_sr_restore.c | 9 +++++++++ tools/libxc/xc_sr_save.c | 8 +++++++- tools/libxc/xc_sr_stream_format.h | 6 +++++- tools/libxl/libxl_dom.c | 1 + 7 files changed, 33 insertions(+), 3 deletions(-) diff --git a/docs/specs/libxc-migration-stream.pandoc b/docs/specs/libxc-migration-stream.pandoc index fa501e7..031a1d5 100644 --- a/docs/specs/libxc-migration-stream.pandoc +++ b/docs/specs/libxc-migration-stream.pandoc @@ -131,7 +131,10 @@ version 0x00000002. The version of this specification. options bit 0: Endianness. 0 = little-endian, 1 = big-endian. - bit 1-15: Reserved. (Must be zero) + bit 1: Checkpointed. 0 = plain stream with single VM, + 1 = stream with VM checkpoints. + + bit 2-15: Reserved. (Must be zero) -------------------------------------------------------------------- The endianness shall be 0 (little-endian) for images generated on an diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h index 8e39075..7581263 100644 --- a/tools/libxc/include/xenguest.h +++ b/tools/libxc/include/xenguest.h @@ -30,6 +30,7 @@ #define XCFLAGS_HVM (1 << 2) #define XCFLAGS_STDVGA (1 << 3) #define XCFLAGS_CHECKPOINT_COMPRESS (1 << 4) +#define XCFLAGS_CHECKPOINTED (1 << 5) #define X86_64_B_SIZE 64 #define X86_32_B_SIZE 32 diff --git a/tools/libxc/xc_sr_common.h b/tools/libxc/xc_sr_common.h index c4fe92c..a16fe22 100644 --- a/tools/libxc/xc_sr_common.h +++ b/tools/libxc/xc_sr_common.h @@ -174,6 +174,9 @@ struct xc_sr_context /* Live migrate vs non live suspend. */ bool live; + /* Plain VM, or checkpoints over time. */ + bool checkpointed; + /* Further debugging information in the stream. */ bool debug; @@ -197,6 +200,9 @@ struct xc_sr_context /* From Image Header. */ uint32_t format_version; + /* Plain VM, or checkpoints over time. */ + bool checkpointed; + /* From Domain Header. */ uint32_t guest_type; uint32_t guest_page_size; diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c index 7d65a29..b815db9 100644 --- a/tools/libxc/xc_sr_restore.c +++ b/tools/libxc/xc_sr_restore.c @@ -48,6 +48,14 @@ static int read_headers(struct xc_sr_context *ctx) ERROR("Unable to handle big endian streams"); return -1; } + else if ( (ihdr.options & IHDR_OPT_CHECKPOINTED) != + ctx->restore.checkpointed ) + { + ERROR("Caller (%c) and stream (%c) disagree over checkpointed-ness", + (ihdr.options & IHDR_OPT_CHECKPOINTED) ? 'y' : 'n', + ctx->restore.checkpointed ? 'y' : 'n'); + return -1; + } ctx->restore.format_version = ihdr.version; @@ -589,6 +597,7 @@ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom, ctx.restore.console_domid = console_domid; ctx.restore.xenstore_evtchn = store_evtchn; ctx.restore.xenstore_domid = store_domid; + ctx.restore.checkpointed = checkpointed_stream; ctx.restore.callbacks = callbacks; IPRINTF("In experimental %s", __func__); diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c index 66fcd3e..2730000 100644 --- a/tools/libxc/xc_sr_save.c +++ b/tools/libxc/xc_sr_save.c @@ -15,7 +15,10 @@ static int write_headers(struct xc_sr_context *ctx, uint16_t guest_type) .marker = IHDR_MARKER, .id = htonl(IHDR_ID), .version = htonl(IHDR_VERSION), - .options = htons(IHDR_OPT_LITTLE_ENDIAN), + .options = htons( + IHDR_OPT_LITTLE_ENDIAN | + (ctx->save.checkpointed ? IHDR_OPT_CHECKPOINTED : 0) + ), }; struct xc_sr_dhdr dhdr = { @@ -732,6 +735,7 @@ int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom, ctx.save.callbacks = callbacks; ctx.save.live = !!(flags & XCFLAGS_LIVE); ctx.save.debug = !!(flags & XCFLAGS_DEBUG); + ctx.save.checkpointed = !!(flags & XCFLAGS_CHECKPOINTED); /* * TODO: Find some time to better tweak the live migration algorithm. @@ -745,6 +749,8 @@ int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom, /* Sanity checks for callbacks. */ if ( hvm ) assert(callbacks->switch_qemu_logdirty); + if ( ctx.save.checkpointed ) + assert(callbacks->checkpoint && callbacks->postcopy); IPRINTF("In experimental %s", __func__); DPRINTF("fd %d, dom %u, max_iters %u, max_factor %u, flags %u, hvm %d", diff --git a/tools/libxc/xc_sr_stream_format.h b/tools/libxc/xc_sr_stream_format.h index 9d8c128..c35dcbd 100644 --- a/tools/libxc/xc_sr_stream_format.h +++ b/tools/libxc/xc_sr_stream_format.h @@ -29,7 +29,11 @@ struct xc_sr_ihdr #define IHDR_OPT_LITTLE_ENDIAN (0 << _IHDR_OPT_ENDIAN) #define IHDR_OPT_BIG_ENDIAN (1 << _IHDR_OPT_ENDIAN) -#define IHDR_OPT_RSVD_MASK (~(IHDR_OPT_BIG_ENDIAN)) +#define _IHDR_OPT_CHECKPOINTED 1 +#define IHDR_OPT_CHECKPOINTED (1 << _IHDR_OPT_CHECKPOINTED) + +#define IHDR_OPT_RSVD_MASK (~(IHDR_OPT_BIG_ENDIAN | \ + IHDR_OPT_CHECKPOINTED)) /* * Domain Header diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index f408646..a0c9850 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -2003,6 +2003,7 @@ void libxl__domain_suspend(libxl__egc *egc, libxl__domain_suspend_state *dss) if (r_info != NULL) { dss->interval = r_info->interval; + dss->xcflags |= XCFLAGS_CHECKPOINTED; if (libxl_defbool_val(r_info->compression)) dss->xcflags |= XCFLAGS_CHECKPOINT_COMPRESS; } -- 1.7.10.4