migration/remus: bug fix and cleanup
v5 cover migration/remus: bug fix and cleanup
Wen Congyang (6):
remus: don't do failover if we don't have an consistent state
remus: don't call stream_continue() when doing failover
remus: resume immediately if libxl__xc_domain_save_done() completes tools/libxc: don't send end record if remus fails tools/libxc: error handling for the postcopy() callback tools/libxl: remove unused function libxl__domain_save_device_model()
tools/libxc/xc_sr_restore.c | 6 ++- tools/libxc/xc_sr_save.c | 6 ++- tools/libxl/libxl.c | 4 -- tools/libxl/libxl.h | 4 ++ tools/libxl/libxl_dom.c | 91 ---------------------------------------- tools/libxl/libxl_internal.h | 6 --- tools/libxl/libxl_stream_read.c | 36 +++++++++++++--- tools/libxl/libxl_stream_write.c | 14 ++++++- 8 files changed, 56 insertions(+), 111 deletions(-)
Signature · 1 line
2.5.0
PATCH v5 1/6 remus: don't do failover if we don't have an consistent state
We will have an consistent state when a CHECKPOINT_END record
is received. After the first CHECKPOINT_END record is received, we will buffer all records until the next CHECKPOINT_END record is received. So if the checkpoint() callback returns XGR_CHECKPOINT_FAILOVER, we only can do failover if ctx->restore.buffer_all_records is true.
--- tools/libxc/xc_sr_restore.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/libxc/xc_sr_restore.c +5 -1
@@ -493,7 +493,11 @@ static int handle_checkpoint(struct xc_sr_context *ctx)break ;case XGR_CHECKPOINT_FAILOVER : - rc =BROKEN_CHANNEL ; +if ( ctx->restore.buffer_all_records ) + rc =BROKEN_CHANNEL ; +else +/* We don't have an consistent state */ + rc =-1 ; goto err;default :/* Other fatal error */
Signature · 1 line
2.5.0
Re: [PATCH v5 1/6] remus: don't do failover if we don't have an consistent state
Quoted 1 line · Wen Congyang
We will have an consistent state when a
CHECKPOINT_ENDrecord
"a consistent ..." (and in the subject too).
Quoted 9 lines
is received. After the first
CHECKPOINT_ENDrecord is received, we will buffer all records until the nextCHECKPOINT_ENDrecord is received. So if thecheckpoint()callback returnsXGR_CHECKPOINT_FAILOVER,
we only can do failover ifctx->restore.buffer_all_recordsis true.Signed-off-by Wen Congyang <[email protected]>---
Please can you get into the habit of writing a delta from the previous version here. e.g. in this case:
v5: New patch.
Putting it after the --- means it doesn't go into the actual commit ("git am" will strip it) but it is very useful for reviewers to know what changed in each iteration.
See also http://wiki.xen.org/wiki/Submitting_Xen_Patches#Review.2C_Rinse_.26_Repeat
Quoted 10 lines
tools/libxc/xc_sr_restore.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)tools/libxc/xc_sr_restore.c +0
-0@@ -493,7 +493,11 @@ static int handle_checkpoint(struct xc_sr_context *ctx) break;
Quoted 7 lines
caseXGR_CHECKPOINT_FAILOVER:
- rc =BROKEN_CHANNEL;
+ if (ctx->restore.buffer_all_records) + rc =BROKEN_CHANNEL;
+ else
+ /* We don't have an consistent state */
"a" not "an" again.
I can s/an/a/ in all 3 places upon commit, so no need to resend for just those.
I'll give Andy a chance to comment before committing though.
Quoted 4 lines
+ rc = -1;
goto err;
default: /* Other fatal error */
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Andrew Cooper
Reviewed-byRe: [PATCH v5 1/6] remus: don't do failover if we don't have an consistent state
Quoted 43 lines · Ian Campbell
Quoted 1 line · Wen Congyang
We will have an consistent state when a
CHECKPOINT_ENDrecord"a consistent ..." (and in the subject too).
Quoted 9 lines
is received. After the first
CHECKPOINT_ENDrecord is received, we will buffer all records until the nextCHECKPOINT_ENDrecord is received. So if thecheckpoint()callback returnsXGR_CHECKPOINT_FAILOVER,
we only can do failover ifctx->restore.buffer_all_recordsis true.Signed-off-by Wen Congyang <[email protected]>---
Please can you get into the habit of writing a delta from the previous version here. e.g. in this case:
v5: New patch.
Putting it after the --- means it doesn't go into the actual commit ("git am" will strip it) but it is very useful for reviewers to know what changed in each iteration.
See also http://wiki.xen.org/wiki/Submitting_Xen_Patches#Review.2C_Rinse_.26_Repeat
Quoted 8 lines
tools/libxc/xc_sr_restore.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tools/libxc/xc_sr_restore.c +0
-0tools/libxc/xc_sr_restore.c static int handle_checkpoint(struct xc_sr_context · line 500
Quoted 9 lines
tools/libxc/xc_sr_restore.c +4
-1@@ -493,7 +493,11 @@ static int handle_checkpoint(struct xc_sr_context *ctx)break ;case XGR_CHECKPOINT_FAILOVER : - rc =BROKEN_CHANNEL ; +if ( ctx->restore.buffer_all_records ) + rc =BROKEN_CHANNEL ; +else +/* We don't have an consistent state */ "a" not "an" again.
Quoted 4 lines
I can s/an/a/ in all 3 places upon commit, so no need to resend for just those.
Acked-by Ian Campbell <[email protected]>
corrections
Quoted 7 lines
I'll give Andy a chance to comment before committing though.
Quoted 4 lines
tools/libxc/xc_sr_restore.c +1
-0+ rc =-1 ; goto err;default: /* Other fatal error */
Re: [PATCH v5 1/6] remus: don't do failover if we don't have an consistent state
In reply to Ian CampbellQuoted 46 lines · Ian Campbell
Quoted 1 line · Wen Congyang
We will have an consistent state when a
CHECKPOINT_ENDrecord"a consistent ..." (and in the subject too).
Quoted 9 lines
is received. After the first
CHECKPOINT_ENDrecord is received, we will buffer all records until the nextCHECKPOINT_ENDrecord is received. So if thecheckpoint()callback returnsXGR_CHECKPOINT_FAILOVER,
we only can do failover ifctx->restore.buffer_all_recordsis true.Signed-off-by Wen Congyang <[email protected]>---
Please can you get into the habit of writing a delta from the previous version here. e.g. in this case:
v5: New patch.
Putting it after the --- means it doesn't go into the actual commit ("git am" will strip it) but it is very useful for reviewers to know what changed in each iteration.
See also http://wiki.xen.org/wiki/Submitting_Xen_Patches#Review.2C_Rinse_.26_Repeat
Quoted 8 lines
tools/libxc/xc_sr_restore.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tools/libxc/xc_sr_restore.c +0
-0tools/libxc/xc_sr_restore.c static int handle_checkpoint(struct xc_sr_context · line 500
Quoted 9 lines
tools/libxc/xc_sr_restore.c +4
-1@@ -493,7 +493,11 @@ static int handle_checkpoint(struct xc_sr_context *ctx)break ;case XGR_CHECKPOINT_FAILOVER : - rc =BROKEN_CHANNEL ; +if ( ctx->restore.buffer_all_records ) + rc =BROKEN_CHANNEL ; +else +/* We don't have an consistent state */ "a" not "an" again.
Quoted 2 lines
I can s/an/a/ in all 3 places upon commit, so no need to resend for just those.
OK, thanks for your help
Wen Congyang
Quoted 13 lines
Acked-by Ian Campbell <[email protected]>I'll give Andy a chance to comment before committing though.
Quoted 4 lines
tools/libxc/xc_sr_restore.c +1
-0+ rc =-1 ; goto err;default: /* Other fatal error */
.
PATCH v5 2/6 remus: don't call stream_continue() when doing failover
In reply to Wen Congyangstream_continue() is used for migration to read emulator xenstore data and emulator context. For remus, if we do failover, we have read it in the checkpoint cycle, and we only need to complete the stream.
--- tools/libxl/libxl_stream_read.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-)
tools/libxl/libxl_stream_read.c +31 -5
@@ -104,6 +104,20 @@* Depending on the contents of the stream, there are likely to be several * parallel tasks being managed. check_all_finished() is used to join all * tasks in both success and error cases. +* +* Failover for remus +* - We buffer all records until a CHECKPOINT_END record is received +* - We will consume the buffered records when a CHECKPOINT_END record +* is received +* - If we find some internal error, then rc or retval is not 0 in +* libxl__xc_domain_restore_done(). In this case, we don't resume the +* guest +* - If we need to do failover from primary, then rc and retval are both +* 0 in libxl__xc_domain_restore_done(). In this case, the buffered +* state will be dropped, because we haven't received a CHECKPOINT_END +* record, and therefore the buffered state is inconsistent. In +* libxl__xc_domain_restore_done(), we just complete the stream and +* stream->completion_callback() will be called to resume the guest */ /* Success/error/cleanup handling. */
@@ -758,6 +772,9 @@ void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void,libxl__stream_read_state *stream = &dcs->srs;STATE_AO_GC (dcs->ao); +/* convenience aliases */ +const int checkpointed_stream = dcs->restore_params.checkpointed_stream; +if (rc) goto err;
@@ -777,11 +794,20 @@ 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)) { -/* -* Libxc has indicated that it is done with the stream. Resume reading -* libxl records from it. -*/ -stream_continue (egc, stream); +if (checkpointed_stream) { +/* +* 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 { +/* +* Libxc has indicated that it is done with the stream. +* Resume reading libxl records from it. +*/ +stream_continue (egc, stream); + } } }
Signature · 1 line
2.5.0
Re: [PATCH v5 2/6] remus: don't call stream_continue() when doing failover
Quoted 7 lines · Wen Congyang
stream_continue()is used for migration to read emulator xenstore data and emulator context. For remus, if we do failover, we have read it in the checkpoint cycle, and we only need to complete the stream.Signed-off-by Wen Congyang <[email protected]>Reviewed-by Andrew Cooper <[email protected]>
PATCH v5 3/6 remus: resume immediately if libxl__xc_domain_save_done() completes
In reply to Wen CongyangFor example: if the secondary host is down, and we fail to send the data to the secondary host. xc_domain_save() returns 0. So in the function libxl__xc_domain_save_done(), rc is 0 (the helper program exits normally), and retval is 0 (it is xc_domain_save()'s return value). In such case, we just need to complete the stream.
--- tools/libxl/libxl.h | 4 ++++ tools/libxl/libxl_stream_write.c | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-)
tools/libxl/libxl.h +4 -0
@@ -1215,6 +1215,10 @@ int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid, int suspend_cancel, const libxl_asyncop_how *ao_how)LIBXL_EXTERNAL_CALLERS_ONLY ; +/* +* This function doesn't return until something is wrong, and we need to +* do failover from secondary. +*/ int libxl_domain_remus_start (libxl_ctx *ctx,libxl_domain_remus_info *info,uint32_t domid,int send_fd,int recv_fd,const libxl_asyncop_how *ao_how)
tools/libxl/libxl_stream_write.c +12 -2
@@ -354,8 +354,18 @@ void libxl__xc_domain_save_done(libxl__egc *egc, void *dss_void,* alive, and check_all_finished() may have torn it down around us. * If the stream is not still alive, we must not continue any work. */ -if (libxl__stream_write_inuse (stream)) -write_emulator_xenstore_record (egc, stream); +if (libxl__stream_write_inuse (stream)) { +if (dss->remus) +/* +* For remus, if libxl__xc_domain_save_done() completes, +* there was an error sending data to the secondary. +* Resume the primary ASAP. The caller doesn't care of the +* return value (Please refer to libxl__remus_teardown()) +*/ +stream_complete (egc, stream,0 ); +else +write_emulator_xenstore_record (egc, stream); + } } static void write_emulator_xenstore_record(libxl__egc *egc,
Signature · 1 line
2.5.0
Re: [PATCH v5 3/6] remus: resume immediately if libxl__xc_domain_save_done() completes
Quoted 23 lines · Wen Congyang
For example: if the secondary host is down, and we fail to send the data to
the secondary host.xc_domain_save()returns 0. So in the functionlibxl__xc_domain_save_done(), rc is 0 (the helper program exits normally),
and retval is 0 (it is xc_domain_save()'s return value). In such case, we just need to complete the stream.Signed-off-by Wen Congyang <[email protected]>Reviewed-by Andrew Cooper <[email protected]>---
tools/libxl/libxl.h | 4 ++++tools/libxl/libxl_stream_write.c| 14 ++++++++++++--2 files changed, 16 insertions(+), 2 deletions(-)tools/libxl/libxl.h +0
-0@@ -1215,6 +1215,10 @@ int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid, int suspend_cancel, const libxl_asyncop_how *ao_how) LIBXL_EXTERNAL_CALLERS_ONLY;
Quoted 4 lines
+/*
+ * This function doesn't return until something is wrong, and we need to
+ * do failover from secondary.
This function runs on the primary, doesn't it? and failover would be from primary to secondary.
So I think a more accurate wording would be:
/*
* This function doesn't return unless something has gone wrong with the
* replication to the secondary. If this function returns then the caller
* should resume the (primary) domain.
*/
I'm happy to edit the text on commit if you agree with the proposed wording. The code looks good.
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v5 3/6] remus: resume immediately if libxl__xc_domain_save_done() completes
Quoted 25 lines · Ian Campbell
Quoted 24 lines · Wen Congyang
For example: if the secondary host is down, and we fail to send the data to
the secondary host.xc_domain_save()returns 0. So in the functionlibxl__xc_domain_save_done(), rc is 0 (the helper program exits normally),
and retval is 0 (it is xc_domain_save()'s return value). In such case, we just need to complete the stream.Signed-off-by Wen Congyang <[email protected]>Reviewed-by Andrew Cooper <[email protected]>--- tools/libxl/libxl.h | 4 ++++ tools/libxl/libxl_stream_write.c | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-)tools/libxl/libxl.h +0
-0@@ -1215,6 +1215,10 @@ int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid, int suspend_cancel, const libxl_asyncop_how *ao_how)LIBXL_EXTERNAL_CALLERS_ONLY ;
Quoted 6 lines
tools/libxl/libxl.h int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid, int suspend_cancel, · line 1220
Quoted 3 lines
tools/libxl/libxl.h +3
-0+/* +* This function doesn't return until something is wrong, and we need to +* do failover from secondary. This function runs on the primary, doesn't it? and failover would be from primary to secondary.
Yes, it runs on the primary
Quoted 11 lines
So I think a more accurate wording would be:
/*
* This function doesn't return unless something has gone wrong with the
* replication to the secondary. If this function returns then the caller
* should resume the (primary) domain.
*/I'm happy to edit the text on commit if you agree with the proposed wording. The code looks good.
I agree with that.
Thanks
Wen Congyang
Quoted 8 lines
Thanks,
Ian..
PATCH v5 4/6 tools/libxc: don't send end record if remus fails
In reply to Wen Congyang--- tools/libxc/xc_sr_save.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxc/xc_sr_save.c +1 -1
@@ -795,7 +795,7 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type) rc = ctx->save.callbacks->checkpoint (ctx->save.callbacks->data);if ( rc <=0 ) - ctx->save.checkpointed = false; + goto err; } }while ( ctx->save.checkpointed );
Signature · 1 line
2.5.0
PATCH v5 5/6 tools/libxc: error handling for the postcopy() callback
In reply to Wen Congyang--- tools/libxc/xc_sr_save.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/libxc/xc_sr_save.c +3 -1
@@ -791,7 +791,9 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)if ( rc ) goto err; - ctx->save.callbacks->postcopy (ctx->save.callbacks->data); + rc = ctx->save.callbacks->postcopy (ctx->save.callbacks->data); +if ( rc <=0 ) + goto err; rc = ctx->save.callbacks->checkpoint (ctx->save.callbacks->data);if ( rc <=0 )
Signature · 1 line
2.5.0
PATCH v5 6/6 tools/libxl: remove unused function libxl__domain_save_device_model()
In reply to Wen CongyangAfter the commit d77570e7, libxl__domain_save_device_model() is completely unused and can be dropped.
--- tools/libxl/libxl.c | 4 -- tools/libxl/libxl_dom.c | 91 -------------------------------------------- tools/libxl/libxl_internal.h | 6 --- 3 files changed, 101 deletions(-)
tools/libxl/libxl.c +0 -4
@@ -1550,10 +1550,6 @@ static void stubdom_destroy_callback(libxl__egc *egc, dds->stubdom_finished =1 ; savefile =libxl__device_model_savefile (gc, dis->domid); rc =libxl__remove_file (gc, savefile); -/* -* On suspend libxl__domain_save_device_model will have already -* unlinked the save file. -*/ if (rc) {LOG (ERROR ,"failed to remove device-model savefile %s" , savefile); }
tools/libxl/libxl_dom.c +0 -91
97 lines not on this page · raw message
tools/libxl/libxl_internal.h +0 -6
@@ -3103,9 +3103,6 @@ struct libxl__domain_suspend_state {libxl__logdirty_switch logdirty;void (*callback_common_done)(libxl__egc *,struct libxl__domain_suspend_state *,int ok); -/* private for libxl__domain_save_device_model */ -libxl__save_device_model_cb *save_dm_callback; -libxl__datacopier_state save_dm_datacopier; };
@@ -3498,9 +3495,6 @@ static inline bool libxl__save_helper_inuse(const libxl__save_helper_state *shs)/* Each time the dm needs to be saved, we must call suspend and then save */ _hidden int libxl__domain_suspend_device_model(libxl__gc *gc,libxl__domain_suspend_state *dss); -_hidden void libxl__domain_save_device_model(libxl__egc *egc, -libxl__domain_suspend_state *dss, -libxl__save_device_model_cb *callback); _hidden const char *libxl__device_model_savefile(libxl__gc *gc, uint32_t domid);
Signature · 1 line
2.5.0
Quoted 7 lines · Wen Congyang
Wen Congyang (6):
remus: don't do failover if we don't have an consistent state
remus: don't callstream_continue()when doing failover
remus: resume immediately iflibxl__xc_domain_save_done()completestools/libxc: don't send end record if remus failstools/libxc: error handling for thepostcopy()callbacktools/libxl: remove unused functionlibxl__domain_save_device_model()
I've now pushed all of these with the minor changes discussed, thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel