Prerequisite patches for COLO
v8 cover Prerequisite patches for COLO
This patchset is Prerequisite for COLO feature. Refer to:
http://wiki.xen.org/wiki/COLO_-_Coarse_Grain_Lock_Stepping
Patch status:
1. Acked patches: patch 2-4, 6-13
2. Reviewd patches: all
3. New patches: none
Note:
1. Patch 1 and 7 is updated according to Wei Liu's comments
2. Patch 2-3 is updated because patch 1 is updated
3. Patch 8, 9, 11, 12 in v7 is moved to another series
4. Patch 13, 14 in v7 is fold into one patch(patch 9)
5. The commit message for patch 5 is not updated(wait the reply from Ian C, and Ian J)
You can get the codes from here:
https://github.com/wencongyang/xen/tree/colo_pre_v8
You can get the whole colo related patches from here:
https://github.com/wencongyang/xen/tree/colo_v10
v6->v7:
- Addressed comments from Konrad Rzeszutek Wilk
v5->v6:
- Fix some bugs found in the test
v4->v5:
- Rebased to the latest xen
- Addressed comments from last round
v3->v4:
- Rebased to the latest migration v2 branch
- Addressed comments from last round
v2->v3:
- Merge '[PATCH v2 0/6] Misc cleanups for libxl' into this patchset for easy review
- Addressed review comments
- Add back channel to libxc
- Introduce should_checkpoint callback
- Introduce DIRTY_BITMAP record on libxc side
- Introduce COLO_CONTEXT record on libxl side
- Ported to Libxl migration v2
v1->v2:
- Rebased to [PATCH v2 0/6] Misc cleanups for libxl
- Add a bugfix for the error handling of process_record
Wen Congyang (13):
libxl/remus: init checkpoint callback in Remus setup callback tools/libxl: move remus code into libxl_remus.c tools/libxl: move save/restore code into libxl_dom_save.c libxl/save: Refactor libxl__domain_suspend_state tools/libxc: support to resume uncooperative HVM guests tools/libxl: introduce enum type libxl_checkpointed_stream migration/save: pass checkpointed_stream from libxl to libxc tools/libxl: export logdirty_init
tools/libxl: rename remus device to checkpoint device tools/libxl: adjust the indentation
tools/libxl: store remus_ops in checkpoint device state tools/libxl: move remus state into a seperate structure tools/libxl: seperate device init/cleanup from checkpoint device layer
tools/libxc/include/xenguest.h | 6 +- tools/libxc/xc_nomigrate.c | 3 +- tools/libxc/xc_resume.c | 25 +- tools/libxc/xc_sr_common.h | 12 +- tools/libxc/xc_sr_save.c | 17 +- tools/libxl/Makefile | 4 +- tools/libxl/libxl.c | 81 +--- tools/libxl/libxl.h | 19 + tools/libxl/libxl_checkpoint_device.c | 282 +++++++++++++ tools/libxl/libxl_create.c | 44 +- tools/libxl/libxl_dom.c | 740 ---------------------------------- tools/libxl/libxl_dom_save.c | 521 ++++++++++++++++++++++++ tools/libxl/libxl_dom_suspend.c | 207 ++++++---- tools/libxl/libxl_internal.h | 217 ++++++---- tools/libxl/libxl_netbuffer.c | 117 +++--- tools/libxl/libxl_nonetbuffer.c | 10 +- tools/libxl/libxl_remus.c | 424 +++++++++++++++++++ tools/libxl/libxl_remus_device.c | 327 --------------- tools/libxl/libxl_remus_disk_drbd.c | 56 +-- tools/libxl/libxl_save_callout.c | 4 +- tools/libxl/libxl_save_helper.c | 3 +- tools/libxl/libxl_stream_read.c | 7 +- tools/libxl/libxl_stream_write.c | 18 +- tools/libxl/libxl_types.idl | 10 +- tools/libxl/xl_cmdimpl.c | 18 +- 25 files changed, 1709 insertions(+), 1463 deletions(-) create mode 100644 tools/libxl/libxl_checkpoint_device.c create mode 100644 tools/libxl/libxl_dom_save.c create mode 100644 tools/libxl/libxl_remus.c delete mode 100644 tools/libxl/libxl_remus_device.c
Signature · 1 line
2.5.0
PATCH v8 1/13 libxl/remus: init checkpoint callback in Remus setup callback
Init stream {read/write} state checkpoint_callback, suspend/resume/checkpoint callback in Remus setup callback.
There's no functional change, it's just refactoring so that we can move all remus code into one file.
--- tools/libxl/libxl.c | 8 ++++++++ tools/libxl/libxl_create.c | 18 ++++++++++++++---- tools/libxl/libxl_dom.c | 18 +++++------------- tools/libxl/libxl_internal.h | 7 +++++++ 4 files changed, 34 insertions(+), 17 deletions(-)
tools/libxl/libxl.c +8 -0
@@ -899,6 +899,8 @@ static void libxl__remus_setup(libxl__egc *egc,/* Convenience aliases */ libxl__remus_devices_state *const rds = &dss->rds;const libxl_domain_remus_info *const info = dss->remus; +libxl__srm_save_autogen_callbacks *const callbacks = + &dss->sws.shs.callbacks.save.a;STATE_AO_GC (dss->ao);
@@ -917,6 +919,12 @@ static void libxl__remus_setup(libxl__egc *egc, rds->domid = dss->domid; rds->callback = remus_setup_done; + dss->sws.checkpoint_callback = remus_checkpoint_stream_written; + + callbacks->suspend = libxl__remus_domain_suspend_callback; + callbacks->postcopy = libxl__remus_domain_resume_callback; + callbacks->checkpoint = libxl__remus_domain_save_checkpoint_callback; +libxl__remus_devices_setup (egc, rds);return ;
tools/libxl/libxl_create.c +14 -4
@@ -730,6 +730,17 @@ static void remus_checkpoint_stream_done(libxl__xc_domain_saverestore_async_callback_done (egc, &stream->shs, rc); } +static void libxl__remus_restore_setup (libxl__egc *egc, +libxl__domain_create_state *dcs) +{ +/* Convenience aliases */ +libxl__srm_restore_autogen_callbacks *const callbacks = + &dcs->srs.shs.callbacks.restore.a; + + callbacks->checkpoint = libxl__remus_domain_restore_checkpoint_callback; + dcs->srs.checkpoint_callback = remus_checkpoint_stream_done; +} +/*----- main domain creation -----*/ /* We have a linear control flow; only one event callback is
@@ -1014,8 +1025,7 @@ static void domcreate_bootloader_done(libxl__egc *egc,libxl_domain_config *const d_config = dcs->guest_config;const int restore_fd = dcs->restore_fd;libxl__domain_build_state *const state = &dcs->build_state; -libxl__srm_restore_autogen_callbacks *const callbacks = - &dcs->srs.shs.callbacks.restore.a; +const int checkpointed_stream = dcs->restore_params.checkpointed_stream;if (rc) {domcreate_rebuild_done (egc, dcs, rc);
@@ -1043,7 +1053,6 @@ static void domcreate_bootloader_done(libxl__egc *egc, }/* Restore */ - callbacks->checkpoint = libxl__remus_domain_restore_checkpoint_callback; rc =libxl__build_pre (gc, domid, d_config, state);if (rc)
@@ -1054,9 +1063,10 @@ static void domcreate_bootloader_done(libxl__egc *egc, dcs->srs.fd = restore_fd; dcs->srs.legacy = (dcs->restore_params.stream_version ==1 ); dcs->srs.completion_callback = domcreate_stream_done; - dcs->srs.checkpoint_callback = remus_checkpoint_stream_done;if (restore_fd >=0 ) { +if (checkpointed_stream) +libxl__remus_restore_setup (egc, dcs);libxl__stream_read_start (egc, &dcs->srs);return ; }
tools/libxl/libxl_dom.c +5 -13
@@ -1489,7 +1489,7 @@ static void remus_devices_preresume_cb(libxl__egc *egc,libxl__remus_devices_state *rds, int rc); -static void libxl__remus_domain_suspend_callback (void *data) +void libxl__remus_domain_suspend_callback (void *data) {libxl__save_helper_state *shs = data;libxl__egc *egc = shs->egc;
@@ -1532,7 +1532,7 @@ out:libxl__xc_domain_saverestore_async_callback_done (egc, &dss->sws.shs, !rc); } -static void libxl__remus_domain_resume_callback (void *data) +void libxl__remus_domain_resume_callback (void *data) {libxl__save_helper_state *shs = data;libxl__egc *egc = shs->egc;
@@ -1569,8 +1569,6 @@ out:/*----- remus asynchronous checkpoint callback -----*/ -static void remus_checkpoint_stream_written ( -libxl__egc *egc,libxl__stream_write_state *sws,int rc);static void remus_devices_commit_cb (libxl__egc *egc,libxl__remus_devices_state *rds,int rc);
@@ -1578,7 +1576,7 @@ static void remus_next_checkpoint(libxl__egc *egc, libxl__ev_time *ev,const struct timeval *requested_abs, int rc); -static void libxl__remus_domain_save_checkpoint_callback (void *data) +void libxl__remus_domain_save_checkpoint_callback (void *data) {libxl__save_helper_state *shs = data;libxl__domain_suspend_state *dss = shs->caller_state;
@@ -1588,7 +1586,7 @@ static void libxl__remus_domain_save_checkpoint_callback(void *data)libxl__stream_write_start_checkpoint (egc, &dss->sws); } -static void remus_checkpoint_stream_written ( +void remus_checkpoint_stream_written (libxl__egc *egc,libxl__stream_write_state *sws,int rc) {libxl__domain_suspend_state *dss =CONTAINER_OF (sws, *dss, sws);
@@ -1756,13 +1754,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_suspend_state *dss) } } -memset (callbacks,0 ,sizeof (*callbacks)); -if (r_info !=NULL ) { - callbacks->suspend = libxl__remus_domain_suspend_callback; - callbacks->postcopy = libxl__remus_domain_resume_callback; - callbacks->checkpoint = libxl__remus_domain_save_checkpoint_callback; - dss->sws.checkpoint_callback = remus_checkpoint_stream_written; - }else +if (r_info ==NULL ) callbacks->suspend = libxl__domain_suspend_callback; callbacks->switch_qemu_logdirty = libxl__domain_suspend_common_switch_qemu_logdirty;
tools/libxl/libxl_internal.h +7 -0
@@ -3508,6 +3508,13 @@ _hidden void libxl__domain_suspend(libxl__egc *egc,/* used by libxc to suspend the guest during migration */ _hidden void libxl__domain_suspend_callback(void *data); +/* Remus callbacks for save */ +_hidden void remus_checkpoint_stream_written( +libxl__egc *egc,libxl__stream_write_state *sws,int rc); +_hidden void libxl__remus_domain_suspend_callback(void *data); +_hidden void libxl__remus_domain_resume_callback(void *data); +_hidden void libxl__remus_domain_save_checkpoint_callback(void *data); +/* * Convenience macros.
Signature · 1 line
2.5.0
Re: [PATCH v8 01/13] libxl/remus: init checkpoint callback in Remus setup callback
Quoted 5 lines · Wen Congyang
Init stream {read/write} state
checkpoint_callback, suspend/resume/checkpoint callback in Remus setup callback.
There's no functional change, it's just refactoring so that we can move all remus code into one file.
Quoted 7 lines
Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>CC Andrew Cooper <[email protected]>CC Ian Campbell <[email protected]>CC Ian Jackson <[email protected]>CC Wei Liu <[email protected]>Reviewed-by Konrad Rzeszutek Wilk <[email protected]>
PATCH v8 2/13 tools/libxl: move remus code into libxl_remus.c
In reply to Wen CongyangAfter previous refactoring, we are now able to move all remus code into a separate file libxl_remus.c.
Export following functions for internal use:
- setup/teardown Remus:
* libxl__remus_setup
* libxl__remus_teardown
* libxl__remus_restore_setup
--- tools/libxl/Makefile | 2 +- tools/libxl/libxl.c | 75 --------- tools/libxl/libxl_create.c | 32 ---- tools/libxl/libxl_dom.c | 223 -------------------------- tools/libxl/libxl_internal.h | 14 +- tools/libxl/libxl_remus.c | 362 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 371 insertions(+), 337 deletions(-) create mode 100644 tools/libxl/libxl_remus.c
tools/libxl/Makefile +1 -1
@@ -64,7 +64,7 @@ else LIBXL_OBJS-y += libxl_no_convert_callout.o endif -LIBXL_OBJS-y += libxl_remus_device.o libxl_remus_disk_drbd.o +LIBXL_OBJS-y += libxl_remus.o libxl_remus_device.o libxl_remus_disk_drbd.o LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
tools/libxl/libxl.c +0 -75
87 lines not on this page · raw message
tools/libxl/libxl_create.c +0 -32
@@ -709,38 +709,6 @@ static int store_libxl_entry(libxl__gc *gc, uint32_t domid, libxl_device_model_version_to_string(b_info->device_model_version)); } -/*----- remus asynchronous checkpoint callback -----*/ - -static void remus_checkpoint_stream_done ( -libxl__egc *egc,libxl__stream_read_state *srs,int rc); - -static void libxl__remus_domain_restore_checkpoint_callback (void *data) -{ -libxl__save_helper_state *shs = data; -libxl__domain_create_state *dcs = shs->caller_state; -libxl__egc *egc = shs->egc; -STATE_AO_GC (dcs->ao); - -libxl__stream_read_start_checkpoint (egc, &dcs->srs); -} - -static void remus_checkpoint_stream_done ( -libxl__egc *egc,libxl__stream_read_state *stream,int rc) -{ -libxl__xc_domain_saverestore_async_callback_done (egc, &stream->shs, rc); -} - -static void libxl__remus_restore_setup (libxl__egc *egc, -libxl__domain_create_state *dcs) -{ -/* Convenience aliases */ -libxl__srm_restore_autogen_callbacks *const callbacks = - &dcs->srs.shs.callbacks.restore.a; - - callbacks->checkpoint = libxl__remus_domain_restore_checkpoint_callback; - dcs->srs.checkpoint_callback = remus_checkpoint_stream_done; -} -/*----- main domain creation -----*/ /* We have a linear control flow; only one event callback is
tools/libxl/libxl_dom.c +0 -223
241 lines not on this page · raw message
tools/libxl/libxl_internal.h +8 -6
@@ -3508,12 +3508,14 @@ _hidden void libxl__domain_suspend(libxl__egc *egc,/* used by libxc to suspend the guest during migration */ _hidden void libxl__domain_suspend_callback(void *data); -/* Remus callbacks for save */ -_hidden void remus_checkpoint_stream_written( -libxl__egc *egc,libxl__stream_write_state *sws,int rc); -_hidden void libxl__remus_domain_suspend_callback(void *data); -_hidden void libxl__remus_domain_resume_callback(void *data); -_hidden void libxl__remus_domain_save_checkpoint_callback(void *data); +/* Remus setup and teardown */ +_hidden void libxl__remus_setup(libxl__egc *egc, +libxl__domain_suspend_state *dss); +_hidden void libxl__remus_teardown(libxl__egc *egc, +libxl__domain_suspend_state *dss, +int rc); +_hidden void libxl__remus_restore_setup(libxl__egc *egc, +libxl__domain_create_state *dcs);/*
tools/libxl/libxl_remus.c new file +362 -0
362 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v8 3/13 tools/libxl: move save/restore code into libxl_dom_save.c
In reply to Wen CongyangThis is purely code motion.
--- tools/libxl/Makefile | 2 +- tools/libxl/libxl_dom.c | 509 ---------------------------------------- tools/libxl/libxl_dom_save.c | 538 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 539 insertions(+), 510 deletions(-) create mode 100644 tools/libxl/libxl_dom_save.c
tools/libxl/Makefile +1 -1
@@ -105,7 +105,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \ libxl_stream_read.o libxl_stream_write.o \ libxl_save_callout.o _libxl_save_msgs_callout.o \ libxl_qmp.o libxl_event.o libxl_fork.o \ - libxl_dom_suspend.o $(LIBXL_OBJS-y) + libxl_dom_suspend.o libxl_dom_save.o $(LIBXL_OBJS-y) LIBXL_OBJS += libxl_genid.o LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
tools/libxl/libxl_dom.c +0 -509
521 lines not on this page · raw message
tools/libxl/libxl_dom_save.c new file +538 -0
538 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v8 4/13 libxl/save: Refactor libxl__domain_suspend_state
In reply to Wen CongyangCurrently struct libxl__domain_suspend_state contains 2 type of states, one is save state, another is suspend state. This patch separates those two out.
The motivation of this is that COLO will need to do suspend/resume continuously, we need a more common suspend state.
After this change, dss stands for libxl__domain_save_state, dsps stands for libxl__domain_suspend_state.
Also introduce libxl__domain_suspend_init to initialise the libxl__domain_suspend_state.
--- tools/libxl/libxl.c | 10 +- tools/libxl/libxl_create.c | 10 +- tools/libxl/libxl_dom_save.c | 61 ++++-------- tools/libxl/libxl_dom_suspend.c | 207 ++++++++++++++++++++++++--------------- tools/libxl/libxl_internal.h | 61 +++++++----- tools/libxl/libxl_netbuffer.c | 2 +- tools/libxl/libxl_remus.c | 37 +++---- tools/libxl/libxl_save_callout.c | 2 +- tools/libxl/libxl_stream_write.c | 16 +-- 9 files changed, 227 insertions(+), 179 deletions(-)
tools/libxl/libxl.c +5 -5
@@ -832,7 +832,7 @@ out: }static void remus_failover_cb (libxl__egc *egc, -libxl__domain_suspend_state *dss,int rc); +libxl__domain_save_state *dss,int rc);/* TODO: Explicit Checkpoint acknowledgements via recv_fd. */ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
@@ -840,7 +840,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, const libxl_asyncop_how *ao_how) {AO_CREATE (ctx, domid, ao_how); -libxl__domain_suspend_state *dss; +libxl__domain_save_state *dss;int rc;libxl_domain_type type =libxl__domain_type (gc, domid);
@@ -888,7 +888,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, }static void remus_failover_cb (libxl__egc *egc, -libxl__domain_suspend_state *dss,int rc) +libxl__domain_save_state *dss,int rc) {STATE_AO_GC (dss->ao);/*
@@ -900,7 +900,7 @@ static void remus_failover_cb(libxl__egc *egc, }static void domain_suspend_cb (libxl__egc *egc, -libxl__domain_suspend_state *dss,int rc) +libxl__domain_save_state *dss,int rc) {STATE_AO_GC (dss->ao);int flrc;
@@ -925,7 +925,7 @@ int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd, int flags, goto out_err; } -libxl__domain_suspend_state *dss; +libxl__domain_save_state *dss;GCNEW (dss); dss->ao = ao;
tools/libxl/libxl_create.c +5 -5
@@ -1558,7 +1558,7 @@ typedef struct {typedef struct {libxl__app_domain_create_state cdcs;libxl__domain_destroy_state dds; -libxl__domain_suspend_state dss; +libxl__domain_save_state dss;char *toolstack_buf;uint32_t toolstack_len; }libxl__domain_soft_reset_state ;
@@ -1653,7 +1653,7 @@ static int do_domain_soft_reset(libxl_ctx *ctx,libxl__app_domain_create_state *cdcs;libxl__domain_create_state *dcs;libxl__domain_build_state *state; -libxl__domain_suspend_state *dss; +libxl__domain_save_state *dss;char *dom_path, *xs_store_mfn, *xs_console_mfn;uint32_t domid_out;int rc;
@@ -1697,8 +1697,8 @@ static int do_domain_soft_reset(libxl_ctx *ctx, dss->ao = ao; dss->domid = domid_soft_reset; - dss->dm_savefile =GCSPRINTF (LIBXL_DEVICE_MODEL_SAVE_FILE ".%d" , - domid_soft_reset); + dss->dsps.dm_savefile =GCSPRINTF (LIBXL_DEVICE_MODEL_SAVE_FILE ".%d" , + domid_soft_reset); rc =libxl__save_emulator_xenstore_data (dss, &srs->toolstack_buf, &srs->toolstack_len);
@@ -1707,7 +1707,7 @@ static int do_domain_soft_reset(libxl_ctx *ctx, goto out; } - rc =libxl__domain_suspend_device_model (gc, dss); + rc =libxl__domain_suspend_device_model (gc, &dss->dsps);if (rc) {LOG (ERROR ,"failed to suspend device model." ); goto out;
tools/libxl/libxl_dom_save.c +20 -41
158 lines not on this page · raw message
tools/libxl/libxl_dom_suspend.c +128 -79
401 lines not on this page · raw message
tools/libxl/libxl_internal.h +39 -22
128 lines not on this page · raw message
tools/libxl/libxl_netbuffer.c +1 -1
@@ -41,7 +41,7 @@ int libxl__netbuffer_enabled(libxl__gc *gc)int init_subkind_nic (libxl__remus_devices_state *rds) {int rc, ret; -libxl__domain_suspend_state *dss =CONTAINER_OF (rds, *dss, rds); +libxl__domain_save_state *dss =CONTAINER_OF (rds, *dss, rds);STATE_AO_GC (rds->ao);
tools/libxl/libxl_remus.c +20 -17
@@ -31,7 +31,7 @@ static void libxl__remus_domain_resume_callback(void *data);static void libxl__remus_domain_save_checkpoint_callback (void *data);void libxl__remus_setup (libxl__egc *egc, -libxl__domain_suspend_state *dss) +libxl__domain_save_state *dss) {/* Convenience aliases */ libxl__remus_devices_state *const rds = &dss->rds;
@@ -72,7 +72,7 @@ out:static void remus_setup_done (libxl__egc *egc,libxl__remus_devices_state *rds,int rc) { -libxl__domain_suspend_state *dss =CONTAINER_OF (rds, *dss, rds); +libxl__domain_save_state *dss =CONTAINER_OF (rds, *dss, rds);STATE_AO_GC (dss->ao);if (!rc) {
@@ -89,7 +89,7 @@ static void remus_setup_done(libxl__egc *egc,static void remus_setup_failed (libxl__egc *egc,libxl__remus_devices_state *rds,int rc) { -libxl__domain_suspend_state *dss =CONTAINER_OF (rds, *dss, rds); +libxl__domain_save_state *dss =CONTAINER_OF (rds, *dss, rds);STATE_AO_GC (dss->ao);if (rc)
@@ -103,7 +103,7 @@ static void remus_teardown_done(libxl__egc *egc,libxl__remus_devices_state *rds, int rc);void libxl__remus_teardown (libxl__egc *egc, -libxl__domain_suspend_state *dss, +libxl__domain_save_state *dss,int rc) {EGC_GC ;
@@ -118,7 +118,7 @@ static void remus_teardown_done(libxl__egc *egc, libxl__remus_devices_state *rds, int rc) { -libxl__domain_suspend_state *dss =CONTAINER_OF (rds, *dss, rds); +libxl__domain_save_state *dss =CONTAINER_OF (rds, *dss, rds);STATE_AO_GC (dss->ao);if (rc)
@@ -131,7 +131,7 @@ static void remus_teardown_done(libxl__egc *egc,/*---------------------- remus callbacks (save) -----------------------*/ static void remus_domain_suspend_callback_common_done (libxl__egc *egc, -libxl__domain_suspend_state *dss,int ok); +libxl__domain_suspend_state *dsps,int ok);static void remus_devices_postsuspend_cb (libxl__egc *egc,libxl__remus_devices_state *rds,int rc);
@@ -143,15 +143,18 @@ static void libxl__remus_domain_suspend_callback(void *data) {libxl__save_helper_state *shs = data;libxl__egc *egc = shs->egc; -libxl__domain_suspend_state *dss = shs->caller_state; +libxl__domain_save_state *dss = shs->caller_state; +libxl__domain_suspend_state *dsps = &dss->dsps; - dss->callback_common_done = remus_domain_suspend_callback_common_done; -libxl__domain_suspend (egc, dss); + dsps->callback_common_done = remus_domain_suspend_callback_common_done; +libxl__domain_suspend (egc, dsps); }static void remus_domain_suspend_callback_common_done (libxl__egc *egc, -libxl__domain_suspend_state *dss,int rc) +libxl__domain_suspend_state *dsps,int rc) { +libxl__domain_save_state *dss =CONTAINER_OF (dsps, *dss, dsps); +if (rc) goto out;
@@ -169,7 +172,7 @@ static void remus_devices_postsuspend_cb(libxl__egc *egc, libxl__remus_devices_state *rds, int rc) { -libxl__domain_suspend_state *dss =CONTAINER_OF (rds, *dss, rds); +libxl__domain_save_state *dss =CONTAINER_OF (rds, *dss, rds);if (rc) goto out;
@@ -186,7 +189,7 @@ static void libxl__remus_domain_resume_callback(void *data) {libxl__save_helper_state *shs = data;libxl__egc *egc = shs->egc; -libxl__domain_suspend_state *dss = shs->caller_state; +libxl__domain_save_state *dss = shs->caller_state;STATE_AO_GC (dss->ao);libxl__remus_devices_state *const rds = &dss->rds;
@@ -198,7 +201,7 @@ static void remus_devices_preresume_cb(libxl__egc *egc, libxl__remus_devices_state *rds, int rc) { -libxl__domain_suspend_state *dss =CONTAINER_OF (rds, *dss, rds); +libxl__domain_save_state *dss =CONTAINER_OF (rds, *dss, rds);STATE_AO_GC (dss->ao);if (rc)
@@ -229,7 +232,7 @@ static void remus_next_checkpoint(libxl__egc *egc, libxl__ev_time *ev,static void libxl__remus_domain_save_checkpoint_callback (void *data) {libxl__save_helper_state *shs = data; -libxl__domain_suspend_state *dss = shs->caller_state; +libxl__domain_save_state *dss = shs->caller_state;libxl__egc *egc = shs->egc;STATE_AO_GC (dss->ao);
@@ -239,7 +242,7 @@ static void libxl__remus_domain_save_checkpoint_callback(void *data)static void remus_checkpoint_stream_written (libxl__egc *egc,libxl__stream_write_state *sws,int rc) { -libxl__domain_suspend_state *dss =CONTAINER_OF (sws, *dss, sws); +libxl__domain_save_state *dss =CONTAINER_OF (sws, *dss, sws);/* Convenience aliases */ libxl__remus_devices_state *const rds = &dss->rds;
@@ -264,7 +267,7 @@ static void remus_devices_commit_cb(libxl__egc *egc, libxl__remus_devices_state *rds, int rc) { -libxl__domain_suspend_state *dss =CONTAINER_OF (rds, *dss, rds); +libxl__domain_save_state *dss =CONTAINER_OF (rds, *dss, rds);STATE_AO_GC (dss->ao);
@@ -299,7 +302,7 @@ static void remus_next_checkpoint(libxl__egc *egc, libxl__ev_time *ev,const struct timeval *requested_abs, int rc) { - libxl__domain_suspend_state *dss = + libxl__domain_save_state *dss =CONTAINER_OF (ev, *dss, checkpoint_timeout);STATE_AO_GC (dss->ao);
tools/libxl/libxl_save_callout.c +1 -1
@@ -75,7 +75,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs, argnums, ARRAY_SIZE(argnums)); } -void libxl__xc_domain_save (libxl__egc *egc,libxl__domain_suspend_state *dss, +void libxl__xc_domain_save (libxl__egc *egc,libxl__domain_save_state *dss,libxl__save_helper_state *shs) {STATE_AO_GC (dss->ao);
tools/libxl/libxl_stream_write.c +8 -8
@@ -216,7 +216,7 @@ void libxl__stream_write_start(libxl__egc *egc, libxl__stream_write_state *stream) {libxl__datacopier_state *dc = &stream->dc; -libxl__domain_suspend_state *dss = stream->dss; +libxl__domain_save_state *dss = stream->dss;STATE_AO_GC (stream->ao);struct libxl__sr_hdr hdr;int rc =0 ;
@@ -324,7 +324,7 @@ static void libxc_header_done(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__domain_save_state *dss = dss_void;libxl__stream_write_state *stream = &dss->sws;STATE_AO_GC (dss->ao);
@@ -333,10 +333,10 @@ void libxl__xc_domain_save_done(libxl__egc *egc, void *dss_void,if (retval) {LOGEV (ERROR , errnoval,"saving domain: %s" , - dss->guest_responded ? + dss->dsps.guest_responded ?"domain responded to suspend request" :"domain did not respond to suspend request" ); -if (!dss->guest_responded) +if (!dss->dsps.guest_responded) rc =ERROR_GUEST_TIMEDOUT ;else if (dss->rc) rc = dss->rc;
@@ -371,7 +371,7 @@ void libxl__xc_domain_save_done(libxl__egc *egc, void *dss_void,static void write_emulator_xenstore_record (libxl__egc *egc,libxl__stream_write_state *stream) { -libxl__domain_suspend_state *dss = stream->dss; +libxl__domain_save_state *dss = stream->dss;STATE_AO_GC (stream->ao);struct libxl__sr_rec_hdr rec;int rc;
@@ -410,7 +410,7 @@ static void write_emulator_xenstore_record(libxl__egc *egc,static void emulator_xenstore_record_done (libxl__egc *egc,libxl__stream_write_state *stream) { -libxl__domain_suspend_state *dss = stream->dss; +libxl__domain_save_state *dss = stream->dss;if (dss->type ==LIBXL_DOMAIN_TYPE_HVM )write_emulator_context_record (egc, stream);
@@ -425,7 +425,7 @@ static void emulator_xenstore_record_done(libxl__egc *egc,static void write_emulator_context_record (libxl__egc *egc,libxl__stream_write_state *stream) { -libxl__domain_suspend_state *dss = stream->dss; +libxl__domain_save_state *dss = stream->dss;libxl__datacopier_state *dc = &stream->emu_dc;STATE_AO_GC (stream->ao);struct libxl__sr_rec_hdr *rec = &stream->emu_rec_hdr;
@@ -440,7 +440,7 @@ static void write_emulator_context_record(libxl__egc *egc, }/* Convenience aliases */ -const char *const filename = dss->dm_savefile; +const char *const filename = dss->dsps.dm_savefile;libxl__carefd_begin ();int readfd =open (filename,O_RDONLY );
Signature · 1 line
2.5.0
PATCH v8 5/13 tools/libxc: support to resume uncooperative HVM guests
In reply to Wen CongyangBefore this patch:
1. suspend
a. PVHVM and PV: we use the same way to suspend the guest (send the suspend
request to the guest). If the guest doesn't support evtchn, the xenstore variant will be used, suspending the guest via XenBus control node.
b. pure HVM: we call xc_domain_shutdown(..., SHUTDOWN_suspend) to suspend
the guest
2. Resume:
a. fast path(fast=1)
Do not change the guest state. We call libxl__domain_resume(.., 1) which calls xc_domain_resume(..., 1 /* fast=1*/) to resume the guest.
PV: modify the return code to 1, and than call the domctl:
XEN_DOMCTL_resumedomain
PVHVM: same with PV
pure HVM: do nothing in modify_returncode, and than call the domctl:
XEN_DOMCTL_resumedomain
b. slow
Used when the guest's state have been changed. Will call libxl__domain_resume(..., 0) to resume the guest.
PV: update start info, and reset all secondary CPU states. Than call
the domctl: XEN_DOMCTL_resumedomain
PVHVM: can not be resumed. You will get the following error message:
"Cannot resume uncooperative HVM guests"
pure HVM: same with PVHVM
After this patch:
1. suspend
unchanged
2. Resume
a. fast path:
unchanged
b. slow
PV: unchanged
PVHVM: call XEN_DOMCTL_resumedomain to resume the guest. Because we
don't modify the return code, the PV driver will disconnect and reconnect.
The guest ends up doing the XENMAPSPACE_shared_info XENMEM_add_to_physmap hypercall and resetting all of its CPU states to point to the shared_info(well except the ones past 32). That is the Linux kernel does that - regardless whether the SCHEDOP_shutdown:SHUTDOWN_suspend returns 1 or not.
Pure HVM: call XEN_DOMCTL_resumedomain to resume the guest.
Under COLO, we will update the guest's state(modify memory, cpu's registers, device status...). In this case, we cannot use the fast path to resume it. Keep the return code 0, and use a slow path to resume the guest. While resuming HVM using slow path is not supported currently, this patch is to make the resume call to not fail.
--- tools/libxc/xc_resume.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)
tools/libxc/xc_resume.c +21 -4
@@ -108,6 +108,26 @@ static int xc_domain_resume_cooperative(xc_interface *xch, uint32_t domid)return do_domctl (xch, &domctl); } +static int xc_domain_resume_hvm (xc_interface *xch,uint32_t domid) +{ +DECLARE_DOMCTL ; + +/* +* The domctl XEN_DOMCTL_resumedomain unpause each vcpu. After +* the domctl, the guest will run. +* +* If it is PVHVM, the guest called the hypercall +* SCHEDOP_shutdown:SHUTDOWN_suspend +* to suspend itself. We don't modify the return code, so the PV driver +* will disconnect and reconnect. +* +* If it is a HVM, the guest will continue running. +*/ + domctl.cmd = XEN_DOMCTL_resumedomain; + domctl.domain = domid; +return do_domctl (xch, &domctl); +} +static int xc_domain_resume_any (xc_interface *xch,uint32_t domid) {DECLARE_DOMCTL ;
@@ -137,10 +157,7 @@ static int xc_domain_resume_any(xc_interface *xch, uint32_t domid)*/ #if defined(__i386__) || defined(__x86_64__)if ( info.hvm ) - { -ERROR ("Cannot resume uncooperative HVM guests" ); -return rc; - } +return xc_domain_resume_hvm (xch, domid);if (xc_domain_get_guest_width (xch, domid, &dinfo->guest_width) !=0 ) {
Signature · 1 line
2.5.0
Re: [PATCH v8 05/13] tools/libxc: support to resume uncooperative HVM guests
Quoted 51 lines · Wen Congyang
Before this patch:
1. suspend
a. PVHVM and PV: we use the same way to suspend the guest (send the suspend
request to the guest). If the guest doesn't support evtchn, the xenstore variant will be used, suspending the guest via XenBus control node.
b. pure HVM: we callxc_domain_shutdown(..., SHUTDOWN_suspend)to suspend
the guest2. Resume:
a. fast path(fast=1)
Do not change the guest state. We calllibxl__domain_resume(.., 1)which callsxc_domain_resume(..., 1 /* fast=1*/)to resume the guest.
PV: modify the return code to 1, and than call the domctl:
XEN_DOMCTL_resumedomain
PVHVM: same with PV
pure HVM: do nothing inmodify_returncode, and than call the domctl:
XEN_DOMCTL_resumedomain
b. slow
Used when the guest's state have been changed. Will calllibxl__domain_resume(..., 0)to resume the guest.
PV: update start info, and reset all secondary CPU states. Than call
the domctl:XEN_DOMCTL_resumedomain
PVHVM: can not be resumed. You will get the following error message:
"Cannot resume uncooperative HVM guests"
pure HVM: same with PVHVMAfter this patch:
1. suspend
unchanged2. Resume
a. fast path:
unchanged
b. slow
PV: unchanged
PVHVM: callXEN_DOMCTL_resumedomainto resume the guest. Because we
don't modify the return code, the PV driver will disconnect and reconnect.
The guest ends up doing theXENMAPSPACE_shared_infoXENMEM_add_to_physmaphypercall and resetting all of its CPU states to point to theshared_info(well except the ones past 32). That is the Linux kernel does that - regardless whether the SCHEDOP_shutdown:SHUTDOWN_suspend returns 1 or not.
Pure HVM: callXEN_DOMCTL_resumedomainto resume the guest.Under COLO, we will update the guest's
state(modify memory, cpu's registers, device status...). In this case, we cannot use the fast path to resume it. Keep the return code 0, and use a slow path to resume the guest. While resuming HVM using slow path is not supported currently, this patch is to make the resume call to not fail.
Quoted 3 lines
Signed-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>Reviewed-by Konrad Rzeszutek Wilk <[email protected]>
I proposed an alternative commit log in a previous reply:
===
Use XEN_DOMCTL_resumedomain to resume (PV)HVM guest in slow path
Previously it was not possible to resume PVHVM or pure HVM guest in slow path because libxc didn't support that.
Using XEN_DOMCTL_resumedomain without modifying guest return code to resume a guest is considered to be always safe. Introduce a function to do that for (PV)HVM guests in slow path resume.
This patch fixes a bug that denies (PV)HVM slow path resume. This will enable COLO to work properly: COLO requires HVM guest to start in the new context that has been set up by COLO, hence slow path resume is required.
===
Note that I fix one place in this version from "guest state" to "guest return code" in the second paragraph. And that sentence is a big big assumption that I don't know whether it is true or not -- reverse-engineer from comment before xc_domain_resume and what Linux does.
But the more I think the more I'm not sure if I'm writing the right thing. I also can't judge what is the right behaviour on the Linux side.
Konrad, can you fact-check the commit message a bit? And maybe you can help answer the following questions?
1. If we use fast=0 on PVHVM guest, will it work?
2. If we use fast=0 on HVM guest, will it work?
What is worse, when I say "work" I actually have no clear definition of it. There doesn't seem to be a defined state that the guest needs to be.
Wei.
Re: [PATCH v8 05/13] tools/libxc: support to resume uncooperative HVM guests
Quoted 80 lines · Wei Liu
Quoted 51 lines · Wen Congyang
Before this patch:
1. suspend
a. PVHVM and PV: we use the same way to suspend the guest (send the suspend
request to the guest). If the guest doesn't support evtchn, the xenstore variant will be used, suspending the guest via XenBus control node.
b. pure HVM: we callxc_domain_shutdown(..., SHUTDOWN_suspend)to suspend
the guest2. Resume:
a. fast path(fast=1)
Do not change the guest state. We calllibxl__domain_resume(.., 1)which callsxc_domain_resume(..., 1 /* fast=1*/)to resume the guest.
PV: modify the return code to 1, and than call the domctl:
XEN_DOMCTL_resumedomain
PVHVM: same with PV
pure HVM: do nothing inmodify_returncode, and than call the domctl:
XEN_DOMCTL_resumedomain
b. slow
Used when the guest's state have been changed. Will calllibxl__domain_resume(..., 0)to resume the guest.
PV: update start info, and reset all secondary CPU states. Than call
the domctl:XEN_DOMCTL_resumedomain
PVHVM: can not be resumed. You will get the following error message:
"Cannot resume uncooperative HVM guests"
pure HVM: same with PVHVMAfter this patch:
1. suspend
unchanged2. Resume
a. fast path:
unchanged
b. slow
PV: unchanged
PVHVM: callXEN_DOMCTL_resumedomainto resume the guest. Because we
don't modify the return code, the PV driver will disconnect and reconnect.
The guest ends up doing theXENMAPSPACE_shared_infoXENMEM_add_to_physmaphypercall and resetting all of its CPU states to point to theshared_info(well except the ones past 32). That is the Linux kernel does that - regardless whether the SCHEDOP_shutdown:SHUTDOWN_suspend returns 1 or not.
Pure HVM: callXEN_DOMCTL_resumedomainto resume the guest.Under COLO, we will update the guest's
state(modify memory, cpu's registers, device status...). In this case, we cannot use the fast path to resume it. Keep the return code 0, and use a slow path to resume the guest. While resuming HVM using slow path is not supported currently, this patch is to make the resume call to not fail.Quoted 3 lines
Signed-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>Reviewed-by Konrad Rzeszutek Wilk <[email protected]>I proposed an alternative commit log in a previous reply:
===
UseXEN_DOMCTL_resumedomainto resume (PV)HVM guest in slow pathPreviously it was not possible to resume PVHVM or pure HVM guest in slow path because libxc didn't support that.
Using
XEN_DOMCTL_resumedomainwithout modifying guest return code to resume a guest is considered to be always safe. Introduce a function to do that for (PV)HVM guests in slow path resume.This patch fixes a bug that denies (PV)HVM slow path resume. This will enable COLO to work properly: COLO requires HVM guest to start in the new context that has been set up by COLO, hence slow path resume is required.
===Note that I fix one place in this version from "guest state" to "guest return code" in the second paragraph. And that sentence is a big big assumption that I don't know whether it is true or not -- reverse-engineer from comment before
xc_domain_resumeand what Linux does.
Quoted 7 lines
But the more I think the more I'm not sure if I'm writing the right thing. I also can't judge what is the right behaviour on the Linux side.
Konrad, can you fact-check the commit message a bit? And maybe you can help answer the following questions?
1. If we use fast=0 on PVHVM guest, will it work?
Yes.
Quoted 1 line
2. If we use fast=0 on HVM guest, will it work?
Yes.
Quoted 3 lines
What is worse, when I say "work" I actually have no clear definition of it. There doesn't seem to be a defined state that the guest needs to be.
For PVHVM guests, fast = 0, requires that the guest makes an hypercall to SCHEDOP_shutdown(SHUTDOWN_suspend). After the hypercall has completed (so Xen has suspended the guest then later resumed it), it would be the guest responsibility to setup Xen infrastructure. As in retrieve the shared_info (XENMAPSPACE_shared_info), setup XenBus, etc.
For HVM guests, fast = 0, suspends the guests without the guest making any hypercalls. It is in effect the hypervisor injecting an S3 suspend. Afterwards the guest is resumed and continues as usual. No PV drivers - hence no need to re-establish Xen PV infrastructure.
Hope this helps.
Quoted 2 lines
Wei.
Re: [PATCH v8 05/13] tools/libxc: support to resume uncooperative HVM guests
Quoted 104 lines · Konrad Rzeszutek Wilk
Quoted 80 lines · Wei Liu
Quoted 51 lines · Wen Congyang
Before this patch:
1. suspend
a. PVHVM and PV: we use the same way to suspend the guest (send the suspend
request to the guest). If the guest doesn't support evtchn, the xenstore variant will be used, suspending the guest via XenBus control node.
b. pure HVM: we callxc_domain_shutdown(..., SHUTDOWN_suspend)to suspend
the guest2. Resume:
a. fast path(fast=1)
Do not change the guest state. We calllibxl__domain_resume(.., 1)which callsxc_domain_resume(..., 1 /* fast=1*/)to resume the guest.
PV: modify the return code to 1, and than call the domctl:
XEN_DOMCTL_resumedomain
PVHVM: same with PV
pure HVM: do nothing inmodify_returncode, and than call the domctl:
XEN_DOMCTL_resumedomain
b. slow
Used when the guest's state have been changed. Will calllibxl__domain_resume(..., 0)to resume the guest.
PV: update start info, and reset all secondary CPU states. Than call
the domctl:XEN_DOMCTL_resumedomain
PVHVM: can not be resumed. You will get the following error message:
"Cannot resume uncooperative HVM guests"
pure HVM: same with PVHVMAfter this patch:
1. suspend
unchanged2. Resume
a. fast path:
unchanged
b. slow
PV: unchanged
PVHVM: callXEN_DOMCTL_resumedomainto resume the guest. Because we
don't modify the return code, the PV driver will disconnect and reconnect.
The guest ends up doing theXENMAPSPACE_shared_infoXENMEM_add_to_physmaphypercall and resetting all of its CPU states to point to theshared_info(well except the ones past 32). That is the Linux kernel does that - regardless whether the SCHEDOP_shutdown:SHUTDOWN_suspend returns 1 or not.
Pure HVM: callXEN_DOMCTL_resumedomainto resume the guest.Under COLO, we will update the guest's
state(modify memory, cpu's registers, device status...). In this case, we cannot use the fast path to resume it. Keep the return code 0, and use a slow path to resume the guest. While resuming HVM using slow path is not supported currently, this patch is to make the resume call to not fail.Quoted 3 lines
Signed-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>Reviewed-by Konrad Rzeszutek Wilk <[email protected]>I proposed an alternative commit log in a previous reply:
===
UseXEN_DOMCTL_resumedomainto resume (PV)HVM guest in slow pathPreviously it was not possible to resume PVHVM or pure HVM guest in slow path because libxc didn't support that.
Using
XEN_DOMCTL_resumedomainwithout modifying guest return code to resume a guest is considered to be always safe. Introduce a function to do that for (PV)HVM guests in slow path resume.This patch fixes a bug that denies (PV)HVM slow path resume. This will enable COLO to work properly: COLO requires HVM guest to start in the new context that has been set up by COLO, hence slow path resume is required.
===Note that I fix one place in this version from "guest state" to "guest return code" in the second paragraph. And that sentence is a big big assumption that I don't know whether it is true or not -- reverse-engineer from comment before
xc_domain_resumeand what Linux does.Quoted 7 lines
But the more I think the more I'm not sure if I'm writing the right thing. I also can't judge what is the right behaviour on the Linux side.
Konrad, can you fact-check the commit message a bit? And maybe you can help answer the following questions?
1. If we use fast=0 on PVHVM guest, will it work?
Yes.
Quoted 1 line
2. If we use fast=0 on HVM guest, will it work?
Yes.
Quoted 3 lines
What is worse, when I say "work" I actually have no clear definition of it. There doesn't seem to be a defined state that the guest needs to be.
For PVHVM guests, fast = 0, requires that the guest makes an hypercall to
SCHEDOP_shutdown(SHUTDOWN_suspend). After the hypercall has completed (so Xen has suspended the guest then later resumed it), it would be the guest responsibility to setup Xen infrastructure. As in retrieve theshared_info(XENMAPSPACE_shared_info), setup XenBus, etc.
Quoted 5 lines
For HVM guests, fast = 0, suspends the guests without the guest making any hypercalls. It is in effect the hypervisor injecting an S3 suspend. Afterwards the guest is resumed and continues as usual. No PV drivers - hence no need to re-establish Xen PV infrastructure.
Wait, isn't this function about resuming a guest? I'm confused because you talk about HV injecting S3 suspend. I guess you wrote the wrong thing?
My guess is below, from the perspective of resuming a guest
PVHVM guest would have used SCHEDOP_shutdown(SHUTDOWN_suspend) to suspend. So when toolstack uses fast=0, the guest resumes from the hypercall with return code unmodified. Guest then re-setup Xen infrastructure.
HVM guest would have used S3 suspend to suspend itself. So when toolstack uses fast=0 case, hypervisor injects S3 resume and guest would just take the normal path like a real machine does.
Does that make sense?
Wei.
Quoted 3 lines
Hope this helps.
Quoted 2 lines
Wei.
Re: [PATCH v8 05/13] tools/libxc: support to resume uncooperative HVM guests
Quoted 142 lines · Wei Liu
Quoted 131 lines · Konrad Rzeszutek Wilk
Quoted 107 lines · Wei Liu
Quoted 68 lines · Wen Congyang
Before this patch:
1. suspend
a. PVHVM and PV: we use the same way to suspend the guest (send the suspend
request to the guest). If the guest doesn't support evtchn, the xenstore
variant will be used, suspending the guest via XenBus control node.
b. pure HVM: we callxc_domain_shutdown(..., SHUTDOWN_suspend)to suspend
the guest2. Resume:
a. fast path(fast=1)
Do not change the guest state. We call libxl__domain_resume(..,
1) which
callsxc_domain_resume(..., 1 /* fast=1*/)to resume the guest. PV: modify the return code to 1, and than call the domctl:
XEN_DOMCTL_resumedomain
PVHVM: same with PV
pure HVM: do nothing inmodify_returncode, and than call the domctl:
XEN_DOMCTL_resumedomain
b. slow
Used when the guest's state have been changed. Will calllibxl__domain_resume(..., 0)to resume the guest.
PV: update start info, and reset all secondary CPU states. Than call
the domctl:XEN_DOMCTL_resumedomain
PVHVM: can not be resumed. You will get the following error message:
"Cannot resume uncooperative HVM guests" pure HVM: same with PVHVMAfter this patch:
1. suspend
unchanged2. Resume
a. fast path:
unchanged
b. slow
PV: unchanged
PVHVM: callXEN_DOMCTL_resumedomainto resume the guest. Because we
don't modify the return code, the PV driver will disconnect
and reconnect.
The guest ends up doing theXENMAPSPACE_shared_infoXENMEM_add_to_physmaphypercall and resetting all of its CPU
states to point to theshared_info(well except the ones past 32).
That is the Linux kernel does that - regardless whether the
SCHEDOP_shutdown:SHUTDOWN_suspend returns 1 or not. Pure HVM: callXEN_DOMCTL_resumedomainto resume the guest.Under COLO, we will update the guest's state(modify memory, cpu's registers,
device status...). In this case, we cannot use the fast path to resume it.
Keep the return code 0, and use a slow path to resume the guest. While
resuming HVM using slow path is not supported currently, this patch is to
make the resume call to not fail.Quoted 3 lines
Signed-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>Reviewed-by Konrad Rzeszutek Wilk <[email protected]>I proposed an alternative commit log in a previous reply:
===
UseXEN_DOMCTL_resumedomainto resume (PV)HVM guest in slow pathPreviously it was not possible to resume PVHVM or pure HVM guest in slow
path because libxc didn't support that.Using
XEN_DOMCTL_resumedomainwithout modifying guest return code to resume a
guest is considered to be always safe. Introduce a function to do that for
(PV)HVM guests in slow path resume.This patch fixes a bug that denies (PV)HVM slow path resume. This will
enable COLO to work properly: COLO requires HVM guest to start in the
new context that has been set up by COLO, hence slow path resume is required.
===Note that I fix one place in this version from "guest state" to "guest
return code" in the second paragraph. And that sentence is a big big assumption that I don't know whether it is true or not -- reverse-engineer from comment beforexc_domain_resumeand what Linux does.But the more I think the more I'm not sure if I'm writing the right thing. I also can't judge what is the right behaviour on the Linux side.
Quoted 5 lines
Konrad, can you fact-check the commit message a bit? And maybe you can
help answer the following questions?1. If we use fast=0 on PVHVM guest, will it work?
Yes.
Quoted 1 line
2. If we use fast=0 on HVM guest, will it work?
Yes.
Quoted 5 lines
What is worse, when I say "work" I actually have no clear definition of
it. There doesn't seem to be a defined state that the guest needs to be.For PVHVM guests, fast = 0, requires that the guest makes an hypercall to SCHEDOP_shutdown(SHUTDOWN_suspend). After the hypercall has completed (so Xen has suspended the guest then later resumed it), it would be the guest responsibility to setup Xen infrastructure. As in retrieve the
shared_info(XENMAPSPACE_shared_info), setup XenBus, etc.Quoted 5 lines
For HVM guests, fast = 0, suspends the guests without the guest making any hypercalls. It is in effect the hypervisor injecting an S3 suspend. Afterwards the guest is resumed and continues as usual. No PV drivers - hence no need to re-establish Xen PV infrastructure.
Wait, isn't this function about resuming a guest? I'm confused because you talk about HV injecting S3 suspend. I guess you wrote the wrong thing?
Quoted 6 lines
My guess is below, from the perspective of resuming a guest
PVHVM guest would have used
SCHEDOP_shutdown(SHUTDOWN_suspend)to suspend. So when toolstack uses fast=0, the guest resumes from the hypercall with return code unmodified. Guest then re-setup Xen infrastructure.
Who or what has torn down the existing infrastructure from the guest's life before the suspend in this case? AFAI Remember a guest expects to return from SCHEDOP_shutdown(SHUTDOWN_suspend) with return code == 0 in a freshly minted new domain, but in the resume case it is actually resuming in the original domain, complete with any evtchn's and grant tables mappings etc still intact from before it slept.
Perhaps I'm misremembering and the guest is expected to deal with the possibility of resources already being in place when it re-sets up the infra?
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v8 05/13] tools/libxc: support to resume uncooperative HVM guests
Quoted 157 lines · Ian Campbell
Quoted 142 lines · Wei Liu
Quoted 131 lines · Konrad Rzeszutek Wilk
Quoted 107 lines · Wei Liu
Quoted 68 lines · Wen Congyang
Before this patch:
1. suspend
a. PVHVM and PV: we use the same way to suspend the guest (send the suspend
request to the guest). If the guest doesn't support evtchn, the xenstore
variant will be used, suspending the guest via XenBus control node.
b. pure HVM: we callxc_domain_shutdown(..., SHUTDOWN_suspend)to suspend
the guest2. Resume:
a. fast path(fast=1)
Do not change the guest state. We call libxl__domain_resume(..,
1) which
callsxc_domain_resume(..., 1 /* fast=1*/)to resume the guest. PV: modify the return code to 1, and than call the domctl:
XEN_DOMCTL_resumedomain
PVHVM: same with PV
pure HVM: do nothing inmodify_returncode, and than call the domctl:
XEN_DOMCTL_resumedomain
b. slow
Used when the guest's state have been changed. Will calllibxl__domain_resume(..., 0)to resume the guest.
PV: update start info, and reset all secondary CPU states. Than call
the domctl:XEN_DOMCTL_resumedomain
PVHVM: can not be resumed. You will get the following error message:
"Cannot resume uncooperative HVM guests" pure HVM: same with PVHVMAfter this patch:
1. suspend
unchanged2. Resume
a. fast path:
unchanged
b. slow
PV: unchanged
PVHVM: callXEN_DOMCTL_resumedomainto resume the guest. Because we
don't modify the return code, the PV driver will disconnect
and reconnect.
The guest ends up doing theXENMAPSPACE_shared_infoXENMEM_add_to_physmaphypercall and resetting all of its CPU
states to point to theshared_info(well except the ones past 32).
That is the Linux kernel does that - regardless whether the
SCHEDOP_shutdown:SHUTDOWN_suspend returns 1 or not. Pure HVM: callXEN_DOMCTL_resumedomainto resume the guest.Under COLO, we will update the guest's state(modify memory, cpu's registers,
device status...). In this case, we cannot use the fast path to resume it.
Keep the return code 0, and use a slow path to resume the guest. While
resuming HVM using slow path is not supported currently, this patch is to
make the resume call to not fail.Quoted 3 lines
Signed-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>Reviewed-by Konrad Rzeszutek Wilk <[email protected]>I proposed an alternative commit log in a previous reply:
===
UseXEN_DOMCTL_resumedomainto resume (PV)HVM guest in slow pathPreviously it was not possible to resume PVHVM or pure HVM guest in slow
path because libxc didn't support that.Using
XEN_DOMCTL_resumedomainwithout modifying guest return code to resume a
guest is considered to be always safe. Introduce a function to do that for
(PV)HVM guests in slow path resume.This patch fixes a bug that denies (PV)HVM slow path resume. This will
enable COLO to work properly: COLO requires HVM guest to start in the
new context that has been set up by COLO, hence slow path resume is required.
===Note that I fix one place in this version from "guest state" to "guest
return code" in the second paragraph. And that sentence is a big big assumption that I don't know whether it is true or not -- reverse-engineer from comment beforexc_domain_resumeand what Linux does.But the more I think the more I'm not sure if I'm writing the right thing. I also can't judge what is the right behaviour on the Linux side.
Quoted 5 lines
Konrad, can you fact-check the commit message a bit? And maybe you can
help answer the following questions?1. If we use fast=0 on PVHVM guest, will it work?
Yes.
Quoted 1 line
2. If we use fast=0 on HVM guest, will it work?
Yes.
Quoted 5 lines
What is worse, when I say "work" I actually have no clear definition of
it. There doesn't seem to be a defined state that the guest needs to be.For PVHVM guests, fast = 0, requires that the guest makes an hypercall to SCHEDOP_shutdown(SHUTDOWN_suspend). After the hypercall has completed (so Xen has suspended the guest then later resumed it), it would be the guest responsibility to setup Xen infrastructure. As in retrieve the
shared_info(XENMAPSPACE_shared_info), setup XenBus, etc.Quoted 5 lines
For HVM guests, fast = 0, suspends the guests without the guest making any hypercalls. It is in effect the hypervisor injecting an S3 suspend. Afterwards the guest is resumed and continues as usual. No PV drivers - hence no need to re-establish Xen PV infrastructure.
Wait, isn't this function about resuming a guest? I'm confused because you talk about HV injecting S3 suspend. I guess you wrote the wrong thing?
Quoted 6 lines
My guess is below, from the perspective of resuming a guest
PVHVM guest would have used
SCHEDOP_shutdown(SHUTDOWN_suspend)to suspend. So when toolstack uses fast=0, the guest resumes from the hypercall with return code unmodified. Guest then re-setup Xen infrastructure.Who or what has torn down the existing infrastructure from the guest's life before the suspend in this case? AFAI Remember a guest expects to return from SCHEDOP_shutdown(SHUTDOWN_suspend) with return code == 0 in a freshly minted new domain, but in the resume case it is actually resuming in the original domain, complete with any evtchn's and grant tables mappings etc still intact from before it slept.
Quoted 4 lines
Perhaps I'm misremembering and the guest is expected to deal with the possibility of resources already being in place when it re-sets up the infra?
Sigh, this is that sort of things that get to my nerves. I should try to write something down when we come to a conclusion. I would be happy to have any definite answer to the expected behaviour of guest. Extrapolation is not very helpful in the face of some many different versions of Linux'es and BSDs.
But, if the confusion is only about PVHVM guest with fast=0, we can forbid that specific combination for now. That should be enough to move COLO forward.
Wei.
Quoted 2 lines
Ian.
Re: [PATCH v8 05/13] tools/libxc: support to resume uncooperative HVM guests
Quoted 140 lines · Wei Liu
Quoted 139 lines · Ian Campbell
Quoted 138 lines · Wei Liu
Quoted 136 lines · Konrad Rzeszutek Wilk
Quoted 107 lines · Wei Liu
Quoted 68 lines · Wen Congyang
Before this patch:
1. suspend
a. PVHVM and PV: we use the same way to suspend the guest (send the suspend
request to the guest). If the guest doesn't support evtchn, the xenstore
variant will be used, suspending the guest via XenBus control node.
b. pure HVM: we callxc_domain_shutdown(..., SHUTDOWN_suspend)to suspend
the guest2. Resume:
a. fast path(fast=1)
Do not change the guest state. We call libxl__domain_resume(..,
1) which
callsxc_domain_resume(..., 1 /* fast=1*/)to resume the guest. PV: modify the return code to 1, and than call the domctl:
XEN_DOMCTL_resumedomain
PVHVM: same with PV
pure HVM: do nothing inmodify_returncode, and than call the domctl:
XEN_DOMCTL_resumedomain
b. slow
Used when the guest's state have been changed. Will calllibxl__domain_resume(..., 0)to resume the guest.
PV: update start info, and reset all secondary CPU states. Than call
the domctl:XEN_DOMCTL_resumedomain
PVHVM: can not be resumed. You will get the following error message:
"Cannot resume uncooperative HVM guests" pure HVM: same with PVHVMAfter this patch:
1. suspend
unchanged2. Resume
a. fast path:
unchanged
b. slow
PV: unchanged
PVHVM: callXEN_DOMCTL_resumedomainto resume the guest. Because we
don't modify the return code, the PV driver will disconnect
and reconnect.
The guest ends up doing theXENMAPSPACE_shared_infoXENMEM_add_to_physmaphypercall and resetting all of its CPU
states to point to theshared_info(well except the ones past 32).
That is the Linux kernel does that - regardless whether the
SCHEDOP_shutdown:SHUTDOWN_suspend returns 1 or not. Pure HVM: callXEN_DOMCTL_resumedomainto resume the guest.Under COLO, we will update the guest's state(modify memory, cpu's registers,
device status...). In this case, we cannot use the fast path to resume it.
Keep the return code 0, and use a slow path to resume the guest. While
resuming HVM using slow path is not supported currently, this patch is to
make the resume call to not fail.Quoted 3 lines
Signed-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>Reviewed-by Konrad Rzeszutek Wilk <[email protected]>I proposed an alternative commit log in a previous reply:
===
UseXEN_DOMCTL_resumedomainto resume (PV)HVM guest in slow pathPreviously it was not possible to resume PVHVM or pure HVM guest in slow
path because libxc didn't support that.Using
XEN_DOMCTL_resumedomainwithout modifying guest return code to resume a
guest is considered to be always safe. Introduce a function to do that for
(PV)HVM guests in slow path resume.This patch fixes a bug that denies (PV)HVM slow path resume. This will
enable COLO to work properly: COLO requires HVM guest to start in the
new context that has been set up by COLO, hence slow path resume is required.
===Note that I fix one place in this version from "guest state" to "guest
return code" in the second paragraph. And that sentence is a big big assumption that I don't know whether it is true or not -- reverse-engineer from comment beforexc_domain_resumeand what Linux does.But the more I think the more I'm not sure if I'm writing the right thing. I also can't judge what is the right behaviour on the Linux side.
Quoted 5 lines
Konrad, can you fact-check the commit message a bit? And maybe you can
help answer the following questions?1. If we use fast=0 on PVHVM guest, will it work?
Yes.
Quoted 1 line
2. If we use fast=0 on HVM guest, will it work?
Yes.
Quoted 5 lines
What is worse, when I say "work" I actually have no clear definition of
it. There doesn't seem to be a defined state that the guest needs to be.For PVHVM guests, fast = 0, requires that the guest makes an hypercall to SCHEDOP_shutdown(SHUTDOWN_suspend). After the hypercall has completed (so Xen has suspended the guest then later resumed it), it would be the guest responsibility to setup Xen infrastructure. As in retrieve the
shared_info(XENMAPSPACE_shared_info), setup XenBus, etc.For HVM guests, fast = 0, suspends the guests without the guest making any hypercalls. It is in effect the hypervisor injecting an S3 suspend. Afterwards the guest is resumed and continues as usual. No PV drivers - hence no need to re-establish Xen PV infrastructure.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Wait, isn't this function about resuming a guest? I'm confused because you talk about HV injecting S3 suspend. I guess you wrote the wrong thing?
I was writing the whole chain - suspend, and then resume. This patch is about resume - but to get to resume you need to suspend first.
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
My guess is below, from the perspective of resuming a guest
PVHVM guest would have used
SCHEDOP_shutdown(SHUTDOWN_suspend)to suspend. So when toolstack uses fast=0, the guest resumes from the hypercall with return code unmodified. Guest then re-setup Xen infrastructure.Who or what has torn down the existing infrastructure from the guest's life before the suspend in this case? AFAI Remember a guest expects to return
The guest. Or it can ignore it and and just re-init all its settings.
Quoted 8 lines
Quoted 8 lines
from SCHEDOP_shutdown(SHUTDOWN_suspend) with return code == 0 in a freshly minted new domain, but in the resume case it is actually resuming in the original domain, complete with any evtchn's and grant tables mappings etc still intact from before it slept.
Perhaps I'm misremembering and the guest is expected to deal with the possibility of resources already being in place when it re-sets up the infra?
Correct - albeit all of them are stale. Thought on some off-chance they may be set correctly.
Quoted 11 lines
Quoted 1 line
Sigh, this is that sort of things that get to my nerves. I should try to write something down when we come to a conclusion. I would be happy to have any definite answer to the expected behaviour of guest. Extrapolation is not very helpful in the face of some many different versions of Linux'es and BSDs.
But, if the confusion is only about PVHVM guest with fast=0, we can forbid that specific combination for now. That should be enough to move COLO forward.
.. forbid what? PVHVM resuming with fast=0? Why? Because the guest may fall on its face?
Quoted 5 lines
Wei.
Quoted 2 lines
Ian.
Re: [PATCH v8 05/13] tools/libxc: support to resume uncooperative HVM guests
On Fri, Feb 19, 2016 at 11:20:08AM -0500, Konrad Rzeszutek Wilk wrote:
[...]
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 41 lines
Quoted 13 lines
===
Note that I fix one place in this version from "guest state" to "guest
return code" in the second paragraph. And that sentence is a big big assumption that I don't know whether it is true or not -- reverse-engineer from comment beforexc_domain_resumeand what Linux does.But the more I think the more I'm not sure if I'm writing the right thing. I also can't judge what is the right behaviour on the Linux side.
Quoted 5 lines
Konrad, can you fact-check the commit message a bit? And maybe you can
help answer the following questions?1. If we use fast=0 on PVHVM guest, will it work?
Yes.
Quoted 1 line
2. If we use fast=0 on HVM guest, will it work?
Yes.
Quoted 5 lines
What is worse, when I say "work" I actually have no clear definition of
it. There doesn't seem to be a defined state that the guest needs to be.For PVHVM guests, fast = 0, requires that the guest makes an hypercall to SCHEDOP_shutdown(SHUTDOWN_suspend). After the hypercall has completed (so Xen has suspended the guest then later resumed it), it would be the guest responsibility to setup Xen infrastructure. As in retrieve the
shared_info(XENMAPSPACE_shared_info), setup XenBus, etc.For HVM guests, fast = 0, suspends the guests without the guest making any hypercalls. It is in effect the hypervisor injecting an S3 suspend. Afterwards the guest is resumed and continues as usual. No PV drivers - hence no need to re-establish Xen PV infrastructure.
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Wait, isn't this function about resuming a guest? I'm confused because you talk about HV injecting S3 suspend. I guess you wrote the wrong thing?
I was writing the whole chain - suspend, and then resume. This patch is about resume - but to get to resume you need to suspend first.
Yes, of course. I was thinking more about writing it down as comment for xc_domain_resume, so I wrote something from the perspective of resuming.
If you don't disagree with my extrapolation in previous email we don't need to quibble about the wording anymore.
Quoted 33 lines
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
My guess is below, from the perspective of resuming a guest
PVHVM guest would have used
SCHEDOP_shutdown(SHUTDOWN_suspend)to suspend. So when toolstack uses fast=0, the guest resumes from the hypercall with return code unmodified. Guest then re-setup Xen infrastructure.Who or what has torn down the existing infrastructure from the guest's life before the suspend in this case? AFAI Remember a guest expects to return
The guest. Or it can ignore it and and just re-init all its settings.
Quoted 8 lines
Quoted 8 lines
from SCHEDOP_shutdown(SHUTDOWN_suspend) with return code == 0 in a freshly minted new domain, but in the resume case it is actually resuming in the original domain, complete with any evtchn's and grant tables mappings etc still intact from before it slept.
Perhaps I'm misremembering and the guest is expected to deal with the possibility of resources already being in place when it re-sets up the infra?
Correct - albeit all of them are stale. Thought on some off-chance they may be set correctly.
Quoted 8 lines
Quoted 1 line
Sigh, this is that sort of things that get to my nerves. I should try to write something down when we come to a conclusion. I would be happy to have any definite answer to the expected behaviour of guest. Extrapolation is not very helpful in the face of some many different versions of Linux'es and BSDs.
Quoted 6 lines
Quoted 3 lines
But, if the confusion is only about PVHVM guest with fast=0, we can forbid that specific combination for now. That should be enough to move COLO forward.
.. forbid what? PVHVM resuming with fast=0? Why? Because the guest may fall on its face?
Yes, forbid resuming PVHVM with fast=0 if we have no clear definition of how it works. It's not because guest would fall, it's because we can't tell which side (the guest or the toolstack) is buggy when the guest falls.
But it looks like we (you ;-) ) have clear idea of how it works, we (you) just need to write it down.
Wei.
Quoted 5 lines
Quoted 5 lines
Wei.
Quoted 2 lines
Ian.
Re: [PATCH v8 05/13] tools/libxc: support to resume uncooperative HVM guests
Quoted 10 lines
Quoted 2 lines
.. forbid what? PVHVM resuming with fast=0? Why? Because the guest may fall on its face?
Yes, forbid resuming PVHVM with fast=0 if we have no clear definition of how it works. It's not because guest would fall, it's because we can't tell which side (the guest or the toolstack) is buggy when the guest falls.
But it looks like we (you ;-) ) have clear idea of how it works, we (you) just need to write it down.
Where? The header file where SHUTDOWN_suspend is introduced?
Or the libxc ones?
Re: [PATCH v8 05/13] tools/libxc: support to resume uncooperative HVM guests
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 8 lines
Quoted 2 lines
.. forbid what? PVHVM resuming with fast=0? Why? Because the guest may fall on its face?
Yes, forbid resuming PVHVM with fast=0 if we have no clear definition of how it works. It's not because guest would fall, it's because we can't tell which side (the guest or the toolstack) is buggy when the guest falls.
Quoted 7 lines
Quoted 2 lines
But it looks like we (you ;-) ) have clear idea of how it works, we (you) just need to write it down.
Where? The header file where
SHUTDOWN_suspendis introduced?Or the libxc ones?
I have no opinion whether Xen public header should contain such text, but I do wish to have better document for xc_domain_resume. Basically it is just turning what you wrote in this thread to comment for xc_domain_resume.
Wei.
PATCH v8 6/13 tools/libxl: introduce enum type libxl_checkpointed_stream
In reply to Wen CongyangIntroduce enum type libxl_checkpointed_stream in IDL. rename the last argument of migrate_receive from "remus" to "checkpointed" since the semantics of this parameter has changed.
NOTE:
libxl_domain_restore_params and domain_create aren't changed here, checkpointed_stream is still an int. Because we will pass the value from libxl to libxc.
--- tools/libxl/libxl.h | 7 +++++++ tools/libxl/libxl_create.c | 8 ++++++-- tools/libxl/libxl_stream_read.c | 7 +++++-- tools/libxl/libxl_types.idl | 5 +++++ tools/libxl/xl_cmdimpl.c | 18 ++++++++++++------ 5 files changed, 35 insertions(+), 10 deletions(-)
tools/libxl/libxl.h +7 -0
@@ -876,6 +876,13 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src);*/ #define LIBXL_HAVE_DEVICE_MODEL_VERSION_NONE 1 +/* +* LIBXL_HAVE_CHECKPOINTED_STREAM +* +* If this is defined, then libxl_checkpointed_stream exists. +*/ +#define LIBXL_HAVE_CHECKPOINTED_STREAM 1 +typedef char **libxl_string_list ;void libxl_string_list_dispose (libxl_string_list *sl);int libxl_string_list_length (const libxl_string_list *sl);
tools/libxl/libxl_create.c +6 -2
@@ -1033,9 +1033,13 @@ static void domcreate_bootloader_done(libxl__egc *egc, dcs->srs.completion_callback = domcreate_stream_done;if (restore_fd >=0 ) { -if (checkpointed_stream) +switch (checkpointed_stream) { +case LIBXL_CHECKPOINTED_STREAM_REMUS :libxl__remus_restore_setup (egc, dcs); -libxl__stream_read_start (egc, &dcs->srs); +/* fall through */ +case LIBXL_CHECKPOINTED_STREAM_NONE : +libxl__stream_read_start (egc, &dcs->srs); + }return ; }
tools/libxl/libxl_stream_read.c +5 -2
@@ -794,19 +794,22 @@ void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void,* If the stream is not still alive, we must not continue any work. */ if (libxl__stream_read_inuse (stream)) { -if (checkpointed_stream) { +switch (checkpointed_stream) { +case LIBXL_CHECKPOINTED_STREAM_REMUS :/* * Failover from primary. Domain state is currently at a * consistent checkpoint, complete the stream, and call * stream->completion_callback() to resume the guest. */ stream_complete (egc, stream,0 ); - }else { +break ; +case LIBXL_CHECKPOINTED_STREAM_NONE :/* * Libxc has indicated that it is done with the stream. * Resume reading libxl records from it. */ stream_continue (egc, stream); +break ; } } }
tools/libxl/libxl_types.idl +5 -0
@@ -228,6 +228,11 @@ libxl_hdtype = Enumeration("hdtype", [ (2, "AHCI"), ], init_val = "LIBXL_HDTYPE_IDE") +libxl_checkpointed_stream = Enumeration("checkpointed_stream", [ + (0, "NONE"), + (1, "REMUS"), + ]) + # # Complex libxl types #
tools/libxl/xl_cmdimpl.c +12 -6
@@ -4426,7 +4426,8 @@ static void migrate_domain(uint32_t domid, const char *rune, int debug, }static void migrate_receive (int debug,int daemonize,int monitor, -int send_fd,int recv_fd,int remus) +int send_fd,int recv_fd, +libxl_checkpointed_stream checkpointed) {uint32_t domid;int rc, rc2;
@@ -4451,7 +4452,7 @@ static void migrate_receive(int debug, int daemonize, int monitor, dom_info.paused =1 ; dom_info.migrate_fd = recv_fd; dom_info.migration_domname_r = &migration_domname; - dom_info.checkpointed_stream = remus; + dom_info.checkpointed_stream = checkpointed; rc =create_domain (&dom_info);if (rc <0 ) {
@@ -4462,7 +4463,8 @@ static void migrate_receive(int debug, int daemonize, int monitor, domid = rc; -if (remus) { +switch (checkpointed) { +case LIBXL_CHECKPOINTED_STREAM_REMUS :/* If we are here, it means that the sender (primary) has crashed. * TODO: Split-Brain Check. */
@@ -4495,6 +4497,9 @@ static void migrate_receive(int debug, int daemonize, int monitor, common_domname, domid, rc);exit (rc ? -ERROR_FAIL :0 ); +default : +/* do nothing */ +break ; } fprintf(stderr, "migration target: Transfer complete,"
@@ -4632,7 +4637,8 @@ int main_restore(int argc, char **argv)int main_migrate_receive (int argc,char **argv) { -int debug =0 , daemonize =1 , monitor =1 , remus =0 ; +int debug =0 , daemonize =1 , monitor =1 ; +libxl_checkpointed_stream checkpointed =LIBXL_CHECKPOINTED_STREAM_NONE ;int opt; SWITCH_FOREACH_OPT(opt, "Fedr", NULL, "migrate-receive", 0) {
@@ -4647,7 +4653,7 @@ int main_migrate_receive(int argc, char **argv) debug =1 ;break ;case 'r' : - remus =1 ; + checkpointed =LIBXL_CHECKPOINTED_STREAM_REMUS ;break ; }
@@ -4657,7 +4663,7 @@ int main_migrate_receive(int argc, char **argv) }migrate_receive (debug, daemonize, monitor,STDOUT_FILENO ,STDIN_FILENO , - remus); + checkpointed);return 0 ; }
Signature · 1 line
2.5.0
PATCH v8 7/13 migration/save: pass checkpointed_stream from libxl to libxc
In reply to Wen CongyangPass checkpointed_stream from libxl to libxc.
It won't affact legacy migration because legacy migration won't use this param.
--- tools/libxc/include/xenguest.h | 6 ++++-- tools/libxc/xc_nomigrate.c | 3 ++- tools/libxc/xc_sr_common.h | 12 +++++++++++- tools/libxc/xc_sr_save.c | 17 +++++++++++------ tools/libxl/libxl.c | 2 ++ tools/libxl/libxl_dom_save.c | 11 ++++++++--- tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_save_callout.c | 2 +- tools/libxl/libxl_save_helper.c | 3 ++- tools/libxl/libxl_stream_write.c | 2 +- tools/libxl/libxl_types.idl | 1 + 11 files changed, 44 insertions(+), 16 deletions(-)
tools/libxc/include/xenguest.h +4 -2
@@ -29,7 +29,6 @@#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
@@ -82,11 +81,14 @@ struct save_callbacks {* @parm xch a handle to an open hypervisor interface * @parm fd the file descriptor to save a domain to * @parm dom the id of the domain +* @param checkpointed_stream MIG_STREAM_NONE if the far end of the stream +* doesn't use checkpointing * @return 0 on success, -1 on failure */ 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); +struct save_callbacks * callbacks,int hvm, +int checkpointed_stream);/* callbacks provided by xc_domain_restore */ struct restore_callbacks {
tools/libxc/xc_nomigrate.c +2 -1
@@ -22,7 +22,8 @@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) +struct save_callbacks * callbacks,int hvm, +int checkpointed_stream) { errno =ENOSYS ;return -1 ;
tools/libxc/xc_sr_common.h +11 -1
@@ -180,6 +180,16 @@ struct xc_sr_contextxc_dominfo_t dominfo; +/* +* migration stream +* 0: Plain VM +* 1: Remus +*/ +enum { +MIG_STREAM_NONE ,/* plain stream */ +MIG_STREAM_REMUS , + } migration_stream; +union /* Common save or restore data. */ { struct /* Save data. */
@@ -191,7 +201,7 @@ struct xc_sr_contextbool live;/* Plain VM, or checkpoints over time. */ -bool checkpointed; +int checkpointed;/* Further debugging information in the stream. */ bool debug;
tools/libxc/xc_sr_save.c +11 -6
@@ -629,7 +629,7 @@ static int send_domain_memory_live(struct xc_sr_context *ctx)if ( rc ) goto out; -if ( ctx->save.debug && !ctx->save.checkpointed ) +if ( ctx->save.debug && ctx->save.checkpointed !=MIG_STREAM_NONE ) { rc =verify_frames (ctx);if ( rc )
@@ -758,7 +758,7 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)if ( ctx->save.live ) rc =send_domain_memory_live (ctx); -else if ( ctx->save.checkpointed ) +else if ( ctx->save.checkpointed !=MIG_STREAM_NONE ) rc =send_domain_memory_checkpointed (ctx);else rc =send_domain_memory_nonlive (ctx);
@@ -778,7 +778,7 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)if ( rc ) goto err; -if ( ctx->save.checkpointed ) +if ( ctx->save.checkpointed !=MIG_STREAM_NONE ) {/* * We have now completed the initial live portion of the checkpoint
@@ -799,7 +799,7 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)if ( rc <=0 ) goto err; } - }while ( ctx->save.checkpointed ); + }while ( ctx->save.checkpointed !=MIG_STREAM_NONE );xc_report_progress_single (xch,"End of stream" );
@@ -829,7 +829,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 max_iters,uint32_t max_factor,uint32_t flags, -struct save_callbacks * callbacks,int hvm) +struct save_callbacks * callbacks,int hvm, +int checkpointed_stream) {struct xc_sr_context ctx = {
@@ -841,7 +842,11 @@ int xc_domain_save(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 ); + ctx.save.checkpointed = checkpointed_stream; + +/* If altering migration_stream update this assert too. */ +assert (checkpointed_stream ==MIG_STREAM_NONE || + checkpointed_stream ==MIG_STREAM_REMUS );/* * TODO: Find some time to better tweak the live migration algorithm.
tools/libxl/libxl.c +2 -0
@@ -876,6 +876,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, dss->live =1 ; dss->debug =0 ; dss->remus = info; + dss->checkpointed_stream =LIBXL_CHECKPOINTED_STREAM_REMUS ;assert (info);
@@ -936,6 +937,7 @@ int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd, int flags, dss->type = type; dss->live = flags &LIBXL_SUSPEND_LIVE ; dss->debug = flags &LIBXL_SUSPEND_DEBUG ; + dss->checkpointed_stream =LIBXL_CHECKPOINTED_STREAM_NONE ; rc = libxl__fd_flags_modify_save(gc, dss->fd, ~(O_NONBLOCK|O_NDELAY), 0,
tools/libxl/libxl_dom_save.c +8 -3
@@ -338,6 +338,12 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss)unsigned int nr_vnodes =0 , nr_vmemranges =0 , nr_vcpus =0 ;libxl__domain_suspend_state *dsps = &dss->dsps; +if (dss->checkpointed_stream !=LIBXL_CHECKPOINTED_STREAM_NONE && !r_info) { +LOG (ERROR ,"Migration stream is checkpointed, but there's no " +"checkpoint info!" ); + goto out; + } + dss->rc =0 ;logdirty_init (&dss->logdirty); dsps->ao = ao;
@@ -376,14 +382,13 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) goto out; } -if (r_info !=NULL ) { +if (dss->checkpointed_stream ==LIBXL_CHECKPOINTED_STREAM_REMUS ) { dss->interval = r_info->interval; - dss->xcflags |=XCFLAGS_CHECKPOINTED ;if (libxl_defbool_val (r_info->compression)) dss->xcflags |=XCFLAGS_CHECKPOINT_COMPRESS ; } -if (r_info ==NULL ) +if (dss->checkpointed_stream ==LIBXL_CHECKPOINTED_STREAM_NONE ) callbacks->suspend = libxl__domain_suspend_callback; callbacks->switch_qemu_logdirty = libxl__domain_suspend_common_switch_qemu_logdirty;
tools/libxl/libxl_internal.h +1 -0
@@ -3113,6 +3113,7 @@ struct libxl__domain_save_state {libxl_domain_type type;int live;int debug; +int checkpointed_stream;const libxl_domain_remus_info *remus;/* private */ int rc;
tools/libxl/libxl_save_callout.c +1 -1
@@ -85,7 +85,7 @@ void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_save_state *dss,const unsigned long argnums[] = { dss->domid,0 ,0 , dss->xcflags, dss->hvm, - cbflags, + cbflags, dss->checkpointed_stream, }; shs->ao = ao;
tools/libxl/libxl_save_helper.c +2 -1
@@ -253,6 +253,7 @@ int main(int argc, char **argv)uint32_t flags =strtoul (NEXTARG ,0 ,10 );int hvm =atoi (NEXTARG );unsigned cbflags =strtoul (NEXTARG ,0 ,10 ); +int checkpointed_stream =strtoul (NEXTARG ,0 ,10 );assert (!*++argv);helper_setcallbacks_save (&helper_save_callbacks, cbflags);
@@ -261,7 +262,7 @@ int main(int argc, char **argv)setup_signals (save_signal_handler); r =xc_domain_save (xch, io_fd, dom, max_iters, max_factor, flags, - &helper_save_callbacks, hvm); + &helper_save_callbacks, hvm, checkpointed_stream);complete (r); }else if (!strcmp (mode,"--restore-domain" )) {
tools/libxl/libxl_stream_write.c +1 -1
@@ -355,7 +355,7 @@ void libxl__xc_domain_save_done(libxl__egc *egc, void *dss_void,* If the stream is not still alive, we must not continue any work. */ if (libxl__stream_write_inuse (stream)) { -if (dss->remus) +if (dss->checkpointed_stream !=LIBXL_CHECKPOINTED_STREAM_NONE )/* * For remus, if libxl__xc_domain_save_done() completes, * there was an error sending data to the secondary.
tools/libxl/libxl_types.idl +1 -0
@@ -228,6 +228,7 @@ libxl_hdtype = Enumeration("hdtype", [ (2, "AHCI"), ], init_val = "LIBXL_HDTYPE_IDE") +# Consistent with the values defined for migration_stream. libxl_checkpointed_stream = Enumeration("checkpointed_stream", [ (0, "NONE"), (1, "REMUS"),
Signature · 1 line
2.5.0
PATCH v8 8/13 tools/libxl: export logdirty_init
In reply to Wen CongyangWe need to enable logdirty on secondary, so we export logdirty_init for internal use. Rename it to libxl__logdirty_init.
--- tools/libxl/libxl_dom_save.c | 4 ++-- tools/libxl/libxl_internal.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)
tools/libxl/libxl_dom_save.c +2 -2
@@ -44,7 +44,7 @@ static void switch_logdirty_xswatch(libxl__egc *egc, libxl__ev_xswatch*,static void switch_logdirty_done (libxl__egc *egc,libxl__domain_save_state *dss,int rc); -static void logdirty_init (libxl__logdirty_switch *lds) +void libxl__logdirty_init (libxl__logdirty_switch *lds) { lds->cmd_path =0 ;libxl__ev_xswatch_init (&lds->watch);
@@ -345,7 +345,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) } dss->rc =0 ; -logdirty_init (&dss->logdirty); +libxl__logdirty_init (&dss->logdirty); dsps->ao = ao; dsps->domid = domid; rc =libxl__domain_suspend_init (egc, dsps, type);
tools/libxl/libxl_internal.h +2 -0
@@ -3078,6 +3078,8 @@ typedef struct libxl__logdirty_switch {libxl__ev_time timeout; } libxl__logdirty_switch; +_hidden void libxl__logdirty_init(libxl__logdirty_switch *lds); +struct libxl__domain_suspend_state {/* set by caller of libxl__domain_suspend_init */ libxl__ao *ao;
Signature · 1 line
2.5.0
PATCH v8 9/13 tools/libxl: rename remus device to checkpoint device
In reply to Wen CongyangThis patch is auto generated by the following commands:
1. git mv tools/libxl/libxl_remus_device.c tools/libxl/libxl_checkpoint_device.c
2. perl -pi -e 's/libxl_remus_device/libxl_checkpoint_device/g' tools/libxl/Makefile
3. perl -pi -e 's/\blibxl__remus_devices/libxl__checkpoint_devices/g' tools/libxl/*.[ch]
4. perl -pi -e 's/\blibxl__remus_device\b/libxl__checkpoint_device/g' tools/libxl/*.[ch]
5. perl -pi -e 's/\blibxl__remus_device_instance_ops\b/libxl__checkpoint_device_instance_ops/g' tools/libxl/*.[ch]
6. perl -pi -e 's/\blibxl__remus_callback\b/libxl__checkpoint_callback/g' tools/libxl/*.[ch]
7. perl -pi -e 's/\bremus_device_init\b/checkpoint_device_init/g' tools/libxl/*.[ch]
8. perl -pi -e 's/\bremus_devices_setup\b/checkpoint_devices_setup/g' tools/libxl/*.[ch]
9. perl -pi -e 's/\bdefine_remus_checkpoint_api\b/define_checkpoint_api/g' tools/libxl/*.[ch]
10. perl -pi -e 's/\brds\b/cds/g' tools/libxl/*.[ch]
11. perl -pi -e 's/REMUS_DEVICE/CHECKPOINT_DEVICE/g' tools/libxl/*.[ch] tools/libxl/*.idl
12. perl -pi -e 's/REMUS_DEVOPS/CHECKPOINT_DEVOPS/g' tools/libxl/*.[ch] tools/libxl/*.idl
13. perl -pi -e 's/\bremus\b/checkpoint/g' tools/libxl/libxl_checkpoint_device.[ch]
14. perl -pi -e 's/\bremus device/checkpoint device/g' tools/libxl/libxl_internal.h
15. perl -pi -e 's/\bRemus device/checkpoint device/g' tools/libxl/libxl_internal.h
16. perl -pi -e 's/\bremus abstract/checkpoint abstract/g' tools/libxl/libxl_internal.h
17. perl -pi -e 's/\bremus invocation/checkpoint invocation/g' tools/libxl/libxl_internal.h
18. perl -pi -e 's/\blibxl__remus_device_\(/libxl__checkpoint_device_(/g' tools/libxl/libxl_internal.h
The patch also fixes the following backword compatibility:
The error code ERROR_REMUS_XXX was introduced in Xen 4.5, and changed to ERROR_CHECKPOINT_XXX after previous renaming.
---
tools/libxl/Makefile | 2 +-
tools/libxl/libxl.h | 12 ++
...xl_remus_device.c => libxl_checkpoint_device.c} | 198 ++++++++++-----------
tools/libxl/libxl_internal.h | 112 ++++++------
tools/libxl/libxl_netbuffer.c | 108 +++++------
tools/libxl/libxl_nonetbuffer.c | 10 +-
tools/libxl/libxl_remus.c | 76 ++++----
tools/libxl/libxl_remus_disk_drbd.c | 52 +++---
tools/libxl/libxl_types.idl | 4 +-
9 files changed, 293 insertions(+), 281 deletions(-)
rename tools/libxl/{libxl_remus_device.c => libxl_checkpoint_device.c} (52%)tools/libxl/Makefile +1 -1
@@ -64,7 +64,7 @@ else LIBXL_OBJS-y += libxl_no_convert_callout.o endif -LIBXL_OBJS-y += libxl_remus.o libxl_remus_device.o libxl_remus_disk_drbd.o +LIBXL_OBJS-y += libxl_remus.o libxl_checkpoint_device.o libxl_remus_disk_drbd.o LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
tools/libxl/libxl.h +12 -0
@@ -883,6 +883,18 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src);*/ #define LIBXL_HAVE_CHECKPOINTED_STREAM 1 +/* +* ERROR_REMUS_XXX error code only exists from Xen 4.5, Xen 4.6 and it +* is changed to ERROR_CHECKPOINT_XXX in Xen 4.7 +*/ +#if defined(LIBXL_API_VERSION ) &&LIBXL_API_VERSION >=0x040500 \ + &&LIBXL_API_VERSION <0x040700 +#define ERROR_REMUS_DEVOPS_DOES_NOT_MATCH \ + ERROR_CHECKPOINT_DEVOPS_DOES_NOT_MATCH +#define ERROR_REMUS_DEVICE_NOT_SUPPORTED \ + ERROR_CHECKPOINT_DEVICE_NOT_SUPPORTED +#endif +typedef char **libxl_string_list ;void libxl_string_list_dispose (libxl_string_list *sl);int libxl_string_list_length (const libxl_string_list *sl);
tools/libxl/libxl_checkpoint_device.c renamed from tools/libxl/libxl_remus_device.c +99 -99
359 lines not on this page · raw message
tools/libxl/libxl_internal.h +56 -56
214 lines not on this page · raw message
tools/libxl/libxl_netbuffer.c +54 -54
300 lines not on this page · raw message
tools/libxl/libxl_nonetbuffer.c +5 -5
@@ -22,25 +22,25 @@ int libxl__netbuffer_enabled(libxl__gc *gc)return 0 ; } -int init_subkind_nic (libxl__remus_devices_state *rds) +int init_subkind_nic (libxl__checkpoint_devices_state *cds) {return 0 ; } -void cleanup_subkind_nic (libxl__remus_devices_state *rds) +void cleanup_subkind_nic (libxl__checkpoint_devices_state *cds) {return ; } -static void nic_setup (libxl__egc *egc,libxl__remus_device *dev) +static void nic_setup (libxl__egc *egc,libxl__checkpoint_device *dev) { -STATE_AO_GC (dev->rds->ao); +STATE_AO_GC (dev->cds->ao); dev->aodev.rc =ERROR_FAIL ; dev->aodev.callback (egc, &dev->aodev); } -const libxl__remus_device_instance_ops remus_device_nic = { +const libxl__checkpoint_device_instance_ops remus_device_nic = { .kind =LIBXL__DEVICE_KIND_VIF , .setup = nic_setup, };
tools/libxl/libxl_remus.c +38 -38
198 lines not on this page · raw message
tools/libxl/libxl_remus_disk_drbd.c +26 -26
152 lines not on this page · raw message
tools/libxl/libxl_types.idl +2 -2
@@ -61,8 +61,8 @@ libxl_error = Enumeration("error", [ (-15, "LOCK_FAIL"), (-16, "JSON_CONFIG_EMPTY"), (-17, "DEVICE_EXISTS"), - (-18, "REMUS_DEVOPS_DOES_NOT_MATCH"), - (-19, "REMUS_DEVICE_NOT_SUPPORTED"), + (-18, "CHECKPOINT_DEVOPS_DOES_NOT_MATCH"), + (-19, "CHECKPOINT_DEVICE_NOT_SUPPORTED"), (-20, "VNUMA_CONFIG_INVALID"), (-21, "DOMAIN_NOTFOUND"), (-22, "ABORTED"),
Signature · 1 line
2.5.0
PATCH v8 10/13 tools/libxl: adjust the indentation
In reply to Wen CongyangThis is just tidying up after the "tools/libxl: rename remus device to checkpoint device" patch automatic renaming.
--- tools/libxl/libxl_checkpoint_device.c | 21 +++++++++++---------- tools/libxl/libxl_internal.h | 19 +++++++++++-------- 2 files changed, 22 insertions(+), 18 deletions(-)
tools/libxl/libxl_checkpoint_device.c +11 -10
@@ -73,9 +73,9 @@ static void devices_teardown_cb(libxl__egc *egc,/* checkpoint device setup and teardown */ static libxl__checkpoint_device *checkpoint_device_init (libxl__egc *egc, -libxl__checkpoint_devices_state *cds, -libxl__device_kind kind, -void *libxl_dev) +libxl__checkpoint_devices_state *cds, +libxl__device_kind kind, +void *libxl_dev) {libxl__checkpoint_device *dev =NULL ;
@@ -89,9 +89,10 @@ static libxl__checkpoint_device* checkpoint_device_init(libxl__egc *egc, }static void checkpoint_devices_setup (libxl__egc *egc, -libxl__checkpoint_devices_state *cds); +libxl__checkpoint_devices_state *cds); -void libxl__checkpoint_devices_setup (libxl__egc *egc,libxl__checkpoint_devices_state *cds) +void libxl__checkpoint_devices_setup (libxl__egc *egc, +libxl__checkpoint_devices_state *cds) {int i, rc;
@@ -137,7 +138,7 @@ out: }static void checkpoint_devices_setup (libxl__egc *egc, -libxl__checkpoint_devices_state *cds) +libxl__checkpoint_devices_state *cds) {int i, rc;
@@ -285,12 +286,12 @@ static void devices_checkpoint_cb(libxl__egc *egc,/* API implementations */ -#define define_checkpoint_api (api) \ -void libxl__checkpoint_devices_##api(libxl__egc *egc, \ - libxl__checkpoint_devices_state *cds) \ +#define define_checkpoint_api (api) \ +void libxl__checkpoint_devices_##api(libxl__egc *egc, \ + libxl__checkpoint_devices_state *cds) \ { \ int i; \ - libxl__checkpoint_device *dev; \ + libxl__checkpoint_device *dev; \ \ STATE_AO_GC(cds->ao); \ \
tools/libxl/libxl_internal.h +11 -8
@@ -2818,7 +2818,8 @@ typedef struct libxl__save_helper_state {* Each device type needs to implement the interfaces specified in * the libxl__checkpoint_device_instance_ops if it wishes to support Remus. * -* The high-level control flow through the checkpoint device layer is shown below: +* The high-level control flow through the checkpoint device layer is shown +* below: * * xl remus * |-> libxl_domain_remus_start
@@ -2879,7 +2880,8 @@ int init_subkind_drbd_disk(libxl__checkpoint_devices_state *cds);void cleanup_subkind_drbd_disk (libxl__checkpoint_devices_state *cds);typedef void libxl__checkpoint_callback (libxl__egc *, -libxl__checkpoint_devices_state *,int rc); +libxl__checkpoint_devices_state *, +int rc);/* * State associated with a checkpoint invocation, including parameters
@@ -2887,7 +2889,7 @@ typedef void libxl__checkpoint_callback(libxl__egc *,* save/restore machinery. */ struct libxl__checkpoint_devices_state { -/*---- must be set by caller of libxl__checkpoint_device_(setup|teardown) ----*/ +/*-- must be set by caller of libxl__checkpoint_device_(setup|teardown) --*/ libxl__ao *ao;uint32_t domid;
@@ -2900,7 +2902,8 @@ struct libxl__checkpoint_devices_state {/* * this array is allocated before setup the checkpoint devices by the * checkpoint abstract layer. -* devs may be NULL, means there's no checkpoint devices that has been set up. +* devs may be NULL, means there's no checkpoint devices that has been +* set up. * the size of this array is 'num_devices', which is the total number * of libxl nic devices and disk devices(num_nics + num_disks). */
@@ -2962,13 +2965,13 @@ struct libxl__checkpoint_device { _hidden void libxl__checkpoint_devices_setup(libxl__egc *egc,libxl__checkpoint_devices_state *cds); _hidden void libxl__checkpoint_devices_teardown(libxl__egc *egc, -libxl__checkpoint_devices_state *cds); +libxl__checkpoint_devices_state *cds); _hidden void libxl__checkpoint_devices_postsuspend(libxl__egc *egc, -libxl__checkpoint_devices_state *cds); +libxl__checkpoint_devices_state *cds); _hidden void libxl__checkpoint_devices_preresume(libxl__egc *egc, -libxl__checkpoint_devices_state *cds); +libxl__checkpoint_devices_state *cds); _hidden void libxl__checkpoint_devices_commit(libxl__egc *egc, -libxl__checkpoint_devices_state *cds); +libxl__checkpoint_devices_state *cds); _hidden int libxl__netbuffer_enabled(libxl__gc *gc);/*----- Legacy conversion helper -----*/
Signature · 1 line
2.5.0
PATCH v8 11/13 tools/libxl: store remus_ops in checkpoint device state
In reply to Wen CongyangCheckpoint device is an abstract layer to do checkpoint. COLO can also use it to do checkpoint. But there are still some codes in checkpoint device which touch remus.
This patch and:
tools/libxl: move remus state into a seperate structure tools/libxl: seperate device init/cleanup from checkpoint device layer
will seperate remus from checkpoint device layer.
We use remus ops directly in checkpoint device. Store it in checkpoint device state so that we do not aware of remus_ops in the checkpoint device layer.
It is pure refactoring and no functional changes.
--- tools/libxl/libxl_checkpoint_device.c | 10 +--------- tools/libxl/libxl_internal.h | 2 ++ tools/libxl/libxl_remus.c | 9 +++++++++ 3 files changed, 12 insertions(+), 9 deletions(-)
tools/libxl/libxl_checkpoint_device.c +1 -9
@@ -17,14 +17,6 @@#include "libxl_internal.h" -extern const libxl__checkpoint_device_instance_ops remus_device_nic; -extern const libxl__checkpoint_device_instance_ops remus_device_drbd_disk; -static const libxl__checkpoint_device_instance_ops *remus_ops[] = { - &remus_device_nic, - &remus_device_drbd_disk, -NULL , -}; -/*----- helper functions -----*/ static int init_device_subkind (libxl__checkpoint_devices_state *cds)
@@ -172,7 +164,7 @@ static void device_setup_iterate(libxl__egc *egc, libxl__ao_device *aodev) goto out; do { - dev->ops = remus_ops[++dev->ops_index]; + dev->ops = dev->cds->ops[++dev->ops_index]; if (!dev->ops) { libxl_device_nic * nic = NULL; libxl_device_disk * disk = NULL;
tools/libxl/libxl_internal.h +2 -0
@@ -2895,6 +2895,8 @@ struct libxl__checkpoint_devices_state {uint32_t domid;libxl__checkpoint_callback *callback;int device_kind_flags; +/* The ops must be pointer array, and the last ops must be NULL. */ +const libxl__checkpoint_device_instance_ops **ops;/*----- private for abstract layer only -----*/
tools/libxl/libxl_remus.c +9 -0
@@ -18,6 +18,14 @@#include "libxl_internal.h" +extern const libxl__checkpoint_device_instance_ops remus_device_nic; +extern const libxl__checkpoint_device_instance_ops remus_device_drbd_disk; +static const libxl__checkpoint_device_instance_ops *remus_ops[] = { + &remus_device_nic, + &remus_device_drbd_disk, +NULL , +}; +/*-------------------- Remus setup and teardown ---------------------*/ static void remus_setup_done(libxl__egc *egc,
@@ -55,6 +63,7 @@ void libxl__remus_setup(libxl__egc *egc, cds->ao = ao; cds->domid = dss->domid; cds->callback = remus_setup_done; + cds->ops = remus_ops; dss->sws.checkpoint_callback = remus_checkpoint_stream_written;
Signature · 1 line
2.5.0
PATCH v8 12/13 tools/libxl: move remus state into a seperate structure
In reply to Wen CongyangAdd a new structure remus state, and move concrete layer's private member to remus state.
it is pure refactoring and no functional changes.
Init interval in libxl__remus_setup(). It is safe to move this initialisation, because this value is only used for remus, and remus will use this value after libxl__remus_setup().
--- tools/libxl/libxl.c | 2 +- tools/libxl/libxl_dom_save.c | 3 +-- tools/libxl/libxl_internal.h | 35 +++++++++++++++----------- tools/libxl/libxl_netbuffer.c | 49 +++++++++++++++++++++---------------- tools/libxl/libxl_remus.c | 24 ++++++++++++------ tools/libxl/libxl_remus_disk_drbd.c | 8 +++--- 6 files changed, 72 insertions(+), 49 deletions(-)
tools/libxl/libxl.c +1 -1
@@ -881,7 +881,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,assert (info);/* Point of no return */ -libxl__remus_setup (egc, dss); +libxl__remus_setup (egc, &dss->rs);return AO_INPROGRESS ; out:
tools/libxl/libxl_dom_save.c +1 -2
@@ -383,7 +383,6 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) }if (dss->checkpointed_stream ==LIBXL_CHECKPOINTED_STREAM_REMUS ) { - dss->interval = r_info->interval;if (libxl_defbool_val (r_info->compression)) dss->xcflags |=XCFLAGS_CHECKPOINT_COMPRESS ; }
@@ -433,7 +432,7 @@ static void domain_save_done(libxl__egc *egc,* from sending checkpoints. Teardown the network buffers and * release netlink resources. This is an async op. */ -libxl__remus_teardown (egc, dss, rc); +libxl__remus_teardown (egc, &dss->rs, rc);return ; }
tools/libxl/libxl_internal.h +21 -14
@@ -2894,6 +2894,7 @@ struct libxl__checkpoint_devices_state {libxl__ao *ao;uint32_t domid;libxl__checkpoint_callback *callback; +void *concrete_data;int device_kind_flags;/* The ops must be pointer array, and the last ops must be NULL. */ const libxl__checkpoint_device_instance_ops **ops;
@@ -2917,16 +2918,6 @@ struct libxl__checkpoint_devices_state {int num_disks;libxl__multidev multidev; - -/*----- private for concrete (device-specific) layer only -----*/ - -/* private for nic device subkind ops */ -char *netbufscript; -struct nl_sock *nlsock; -struct nl_cache *qdisc_cache; - -/* private for drbd disk subkind ops */ -char *drbd_probe_script; };/*
@@ -2974,6 +2965,23 @@ _hidden void libxl__checkpoint_devices_preresume(libxl__egc *egc, libxl__checkpoint_devices_state *cds); _hidden void libxl__checkpoint_devices_commit(libxl__egc *egc,libxl__checkpoint_devices_state *cds); + +/*----- Remus related state structure -----*/ +typedef struct libxl__remus_state libxl__remus_state ; +struct libxl__remus_state { +/* private */ +libxl__ev_time checkpoint_timeout;/* used for Remus checkpoint */ +int interval;/* checkpoint interval */ + +/*----- private for concrete (device-specific) layer only -----*/ +/* private for nic device subkind ops */ +char *netbufscript; +struct nl_sock *nlsock; +struct nl_cache *qdisc_cache; + +/* private for drbd disk subkind ops */ +char *drbd_probe_script; +}; _hidden int libxl__netbuffer_enabled(libxl__gc *gc);/*----- Legacy conversion helper -----*/
@@ -3127,9 +3135,8 @@ struct libxl__domain_save_state {int hvm;int xcflags;libxl__domain_suspend_state dsps; +libxl__remus_state rs;libxl__checkpoint_devices_state cds; -libxl__ev_time checkpoint_timeout;/* used for Remus checkpoint */ -int interval;/* checkpoint interval (for Remus) */ libxl__stream_write_state sws;libxl__logdirty_switch logdirty; };
@@ -3535,9 +3542,9 @@ _hidden void libxl__domain_suspend_callback(void *data);/* Remus setup and teardown */ _hidden void libxl__remus_setup(libxl__egc *egc, -libxl__domain_save_state *dss); +libxl__remus_state *rs); _hidden void libxl__remus_teardown(libxl__egc *egc, -libxl__domain_save_state *dss, +libxl__remus_state *rs,int rc); _hidden void libxl__remus_restore_setup(libxl__egc *egc,libxl__domain_create_state *dcs);
tools/libxl/libxl_netbuffer.c +28 -21
146 lines not on this page · raw message
tools/libxl/libxl_remus.c +16 -8
@@ -38,9 +38,10 @@ static void libxl__remus_domain_suspend_callback(void *data);static void libxl__remus_domain_resume_callback (void *data);static void libxl__remus_domain_save_checkpoint_callback (void *data); -void libxl__remus_setup (libxl__egc *egc, -libxl__domain_save_state *dss) +void libxl__remus_setup (libxl__egc *egc,libxl__remus_state *rs) { +libxl__domain_save_state *dss =CONTAINER_OF (rs, *dss, rs); +/* Convenience aliases */ libxl__checkpoint_devices_state *const cds = &dss->cds;const libxl_domain_remus_info *const info = dss->remus;
@@ -64,6 +65,8 @@ void libxl__remus_setup(libxl__egc *egc, cds->domid = dss->domid; cds->callback = remus_setup_done; cds->ops = remus_ops; + cds->concrete_data = rs; + rs->interval = info->interval; dss->sws.checkpoint_callback = remus_checkpoint_stream_written;
@@ -112,15 +115,20 @@ static void remus_teardown_done(libxl__egc *egc,libxl__checkpoint_devices_state *cds, int rc);void libxl__remus_teardown (libxl__egc *egc, -libxl__domain_save_state *dss, +libxl__remus_state *rs,int rc) { +libxl__domain_save_state *dss =CONTAINER_OF (rs, *dss, rs); + +/* Convenience aliases */ +libxl__checkpoint_devices_state *const cds = &dss->cds; +EGC_GC ;LOG (WARN ,"Remus: Domain suspend terminated with rc %d," " teardown Remus devices..." , rc); - dss->cds.callback = remus_teardown_done; -libxl__checkpoint_devices_teardown (egc, &dss->cds); + cds->callback = remus_teardown_done; +libxl__checkpoint_devices_teardown (egc, cds); } static void remus_teardown_done(libxl__egc *egc,
@@ -294,9 +302,9 @@ static void remus_devices_commit_cb(libxl__egc *egc,*/ /* Set checkpoint interval timeout */ - rc =libxl__ev_time_register_rel (ao, &dss->checkpoint_timeout, + rc =libxl__ev_time_register_rel (ao, &dss->rs.checkpoint_timeout, remus_next_checkpoint, - dss->interval); + dss->rs.interval);if (rc) goto out;
@@ -312,7 +320,7 @@ static void remus_next_checkpoint(libxl__egc *egc, libxl__ev_time *ev, int rc) {libxl__domain_save_state *dss = -CONTAINER_OF (ev, *dss, checkpoint_timeout); +CONTAINER_OF (ev, *dss, rs.checkpoint_timeout);STATE_AO_GC (dss->ao);
tools/libxl/libxl_remus_disk_drbd.c +5 -3
@@ -28,10 +28,11 @@ typedef struct libxl__remus_drbd_disk {int init_subkind_drbd_disk (libxl__checkpoint_devices_state *cds) { +libxl__remus_state *rs = cds->concrete_data;STATE_AO_GC (cds->ao); - cds->drbd_probe_script =GCSPRINTF ("%s/block-drbd-probe" , -libxl__xen_script_dir_path ()); + rs->drbd_probe_script =GCSPRINTF ("%s/block-drbd-probe" , +libxl__xen_script_dir_path ());return 0 ; }
@@ -96,6 +97,7 @@ static void match_async_exec(libxl__egc *egc, libxl__checkpoint_device *dev)int arraysize, nr =0 , rc;const libxl_device_disk *disk = dev->backend_dev;libxl__async_exec_state *aes = &dev->aodev.aes; +libxl__remus_state *rs = dev->cds->concrete_data;STATE_AO_GC (dev->cds->ao);/* setup env & args */
@@ -107,7 +109,7 @@ static void match_async_exec(libxl__egc *egc, libxl__checkpoint_device *dev) arraysize =3 ; nr =0 ;GCNEW_ARRAY (aes->args, arraysize); - aes->args[nr++] = dev->cds->drbd_probe_script; + aes->args[nr++] = rs->drbd_probe_script; aes->args[nr++] = disk->pdev_path; aes->args[nr++] =NULL ;assert (nr <= arraysize);
Signature · 1 line
2.5.0
PATCH v8 13/13 tools/libxl: seperate device init/cleanup from checkpoint device layer
In reply to Wen Congyangwe call (init|cleanup)_subkind_nic and (init|cleanup)_subkind_drbd_disk directly in checkpoint device. Move them to libxl_remus.c, Call them before calling libxl__checkpoint_devices_setup() or after calling libxl__checkpoint_devices_teardown().
it is pure refactoring and no functional changes.
--- tools/libxl/libxl_checkpoint_device.c | 42 ++--------------------------------- tools/libxl/libxl_remus.c | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 40 deletions(-)
tools/libxl/libxl_checkpoint_device.c +2 -40
@@ -17,38 +17,6 @@#include "libxl_internal.h" -/*----- helper functions -----*/ - -static int init_device_subkind (libxl__checkpoint_devices_state *cds) -{ -/* init device subkind-specific state in the libxl ctx */ -int rc; -STATE_AO_GC (cds->ao); - -if (libxl__netbuffer_enabled (gc)) { - rc =init_subkind_nic (cds); -if (rc) goto out; - } - - rc =init_subkind_drbd_disk (cds); -if (rc) goto out; - - rc =0 ; -out: -return rc; -} - -static void cleanup_device_subkind (libxl__checkpoint_devices_state *cds) -{ -/* cleanup device subkind-specific state in the libxl ctx */ -STATE_AO_GC (cds->ao); - -if (libxl__netbuffer_enabled (gc)) -cleanup_subkind_nic (cds); - -cleanup_subkind_drbd_disk (cds); -} -/*----- setup() and teardown() -----*/ /* callbacks */
@@ -86,14 +54,10 @@ static void checkpoint_devices_setup(libxl__egc *egc,void libxl__checkpoint_devices_setup (libxl__egc *egc,libxl__checkpoint_devices_state *cds) { -int i, rc; +int i;STATE_AO_GC (cds->ao); - rc =init_device_subkind (cds); -if (rc) - goto out; - cds->num_devices =0 ; cds->num_nics =0 ; cds->num_disks =0 ;
@@ -126,7 +90,7 @@ void libxl__checkpoint_devices_setup(libxl__egc *egc,return ; out: - cds->callback (egc, cds, rc); + cds->callback (egc, cds,0 ); } static void checkpoint_devices_setup(libxl__egc *egc,
@@ -263,8 +227,6 @@ static void devices_teardown_cb(libxl__egc *egc, cds->disks =NULL ; cds->num_disks =0 ; -cleanup_device_subkind (cds); - cds->callback (egc, cds, rc); }
tools/libxl/libxl_remus.c +42 -0
66 lines not on this page · raw message
Signature · 1 line
2.5.0
I've prepared a branch for this series (sans patch #5) and run compile test on every commit.
Please pull from
git://xenbits.xen.org/people/liuw/xen.git colo-prep-v8-base..colo-prep-v8
Patch #5 needs a bit more work. Note that Wen you don't need to resubmit #5 just yet. We will come back to it next week.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 6 lines · Wei Liu
I've prepared a branch for this series (sans patch #5) and run compile test on every commit.
Please pull from
git://xenbits.xen.org/people/liuw/xen.gitcolo-prep-v8-base..colo-prep-v8
I've applied:
Wen Congyang (12):
libxl/remus: init checkpoint callback in Remus setup callback tools/libxl: move remus code into libxl_remus.c tools/libxl: move save/restore code into libxl_dom_save.c libxl/save: Refactor libxl__domain_suspend_state tools/libxl: introduce enum type libxl_checkpointed_stream migration/save: pass checkpointed_stream from libxl to libxc tools/libxl: export logdirty_init
tools/libxl: rename remus device to checkpoint device tools/libxl: adjust the indentation
tools/libxl: store remus_ops in checkpoint device state tools/libxl: move remus state into a seperate structure tools/libxl: seperate device init/cleanup from checkpoint device layer
to staging.
Will revist #5 next week and submit an patch explaining the xc_domain_resume .. shortcuts it can take.
Quoted 5 lines
Patch #5 needs a bit more work. Note that Wen you don't need to resubmit #5 just yet. We will come back to it next week.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel