[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 04/13 V6] tools/libxl: introduce a new structure libxl__remus_state
From: Shriram Rajagopalan <rshriram@xxxxxxxxx> libxl_domain_remus_info only contains the argument of the command 'xl remus'. So introduce a new structure libxl__remus_state to save the remus state. Signed-off-by: Shriram Rajagopalan <rshriram@xxxxxxxxx> Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx> Reviewed-by: Wen Congyang <wency@xxxxxxxxxxxxxx> --- tools/libxl/libxl.c | 25 +++++++++++++++++++++++-- tools/libxl/libxl_dom.c | 12 ++++-------- tools/libxl/libxl_internal.h | 22 ++++++++++++++++++++-- 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 2845ca4..25af816 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -729,11 +729,32 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, dss->type = type; dss->live = 1; dss->debug = 0; - dss->remus = info; assert(info); - /* TBD: Remus setup - i.e. attach qdisc, enable disk buffering, etc */ + GCNEW(dss->remus_state); + + /* convenience shorthand */ + libxl__remus_state *remus_state = dss->remus_state; + remus_state->blackhole = info->blackhole; + remus_state->interval = info->interval; + remus_state->compression = info->compression; + remus_state->dss = dss; + libxl__ev_child_init(&remus_state->child); + + /* TODO: enable disk buffering */ + + /* Setup network buffering */ + if (info->netbuf) { + if (info->netbufscript) { + remus_state->netbufscript = + libxl__strdup(gc, info->netbufscript); + } else { + remus_state->netbufscript = + GCSPRINTF("%s/remus-netbuf-setup", + libxl__xen_script_dir_path()); + } + } /* Point of no return */ libxl__domain_suspend(egc, dss); diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 55f74b2..8d63f90 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -1290,7 +1290,7 @@ static void remus_checkpoint_dm_saved(libxl__egc *egc, /* REMUS TODO: Wait for disk and memory ack, release network buffer */ /* REMUS TODO: make this asynchronous */ assert(!rc); /* REMUS TODO handle this error properly */ - usleep(dss->interval * 1000); + usleep(dss->remus_state->interval * 1000); libxl__xc_domain_saverestore_async_callback_done(egc, &dss->shs, 1); } @@ -1308,7 +1308,6 @@ void libxl__domain_suspend(libxl__egc *egc, libxl__domain_suspend_state *dss) const libxl_domain_type type = dss->type; const int live = dss->live; const int debug = dss->debug; - const libxl_domain_remus_info *const r_info = dss->remus; libxl__srm_save_autogen_callbacks *const callbacks = &dss->shs.callbacks.save.a; @@ -1343,11 +1342,8 @@ void libxl__domain_suspend(libxl__egc *egc, libxl__domain_suspend_state *dss) dss->guest_responded = 0; dss->dm_savefile = libxl__device_model_savefile(gc, domid); - if (r_info != NULL) { - dss->interval = r_info->interval; - if (r_info->compression) - dss->xcflags |= XCFLAGS_CHECKPOINT_COMPRESS; - } + if (dss->remus_state && dss->remus_state->compression) + dss->xcflags |= XCFLAGS_CHECKPOINT_COMPRESS; dss->xce = xc_evtchn_open(NULL, 0); if (dss->xce == NULL) @@ -1366,7 +1362,7 @@ void libxl__domain_suspend(libxl__egc *egc, libxl__domain_suspend_state *dss) } memset(callbacks, 0, sizeof(*callbacks)); - if (r_info != NULL) { + if (dss->remus_state != NULL) { callbacks->suspend = libxl__remus_domain_suspend_callback; callbacks->postcopy = libxl__remus_domain_resume_callback; callbacks->checkpoint = libxl__remus_domain_checkpoint_callback; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 1bd23ff..9970780 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2292,6 +2292,25 @@ typedef struct libxl__logdirty_switch { libxl__ev_time timeout; } libxl__logdirty_switch; +typedef struct libxl__remus_state { + /* filled by the user */ + /* checkpoint interval */ + int interval; + int blackhole; + int compression; + /* Script to setup/teardown network buffers */ + const char *netbufscript; + libxl__domain_suspend_state *dss; + + /* private */ + int saved_rc; + int dev_id; + /* Opaque context containing network buffer related stuff */ + void *netbuf_state; + libxl__ev_time timeout; + libxl__ev_child child; +} libxl__remus_state; + struct libxl__domain_suspend_state { /* set by caller of libxl__domain_suspend */ libxl__ao *ao; @@ -2302,7 +2321,7 @@ struct libxl__domain_suspend_state { libxl_domain_type type; int live; int debug; - const libxl_domain_remus_info *remus; + libxl__remus_state *remus_state; /* private */ xc_evtchn *xce; /* event channel handle */ int suspend_eventchn; @@ -2310,7 +2329,6 @@ struct libxl__domain_suspend_state { int xcflags; int guest_responded; const char *dm_savefile; - int interval; /* checkpoint interval (for Remus) */ libxl__save_helper_state shs; libxl__logdirty_switch logdirty; /* private for libxl__domain_save_device_model */ -- 1.8.4.2 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |