migration/remus: bug fix and cleanup
v4 cover migration/remus: bug fix and cleanup
Wen Congyang (5):
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_save.c | 6 ++- tools/libxl/libxl.c | 9 ++-- tools/libxl/libxl_dom.c | 91 ---------------------------------------- tools/libxl/libxl_internal.h | 6 --- tools/libxl/libxl_stream_read.c | 35 +++++++++++++--- tools/libxl/libxl_stream_write.c | 14 ++++++- 6 files changed, 50 insertions(+), 111 deletions(-)
Signature · 1 line
2.5.0
PATCH v4 1/5 remus: don't call stream_continue() when doing failover
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.
--- tools/libxl/libxl_stream_read.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-)
tools/libxl/libxl_stream_read.c +30 -5
@@ -101,6 +101,19 @@* - stream_write_emulator_done() * - stream_continue() * +* 4) Failover for remus +* - we buffer all records until a CHECKPOINT_END record is received +* - we will use the records when a CHECKPOINT_END record is received +* - if we find some internal error, the 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, the rc and retval are 0 +* in libxl__xc_domain_restore_done(). In this case, the buffered state +* will be dropped, because we don't receive a CHECKPOINT_END record, +* and it is a inconsistent state. In libxl__xc_domain_restore_done(), +* we just complete the stream and stream->completion_callback() will +* be called to resume the guest +* * 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.
@@ -758,6 +771,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 +793,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 v4 1/5] remus: don't call stream_continue() when doing failover
Quoted 17 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]>---
tools/libxl/libxl_stream_read.c | 35 ++++++++++++++++++++++++++++++-----1 file changed, 30 insertions(+), 5 deletions(-)tools/libxl/libxl_stream_read.c +0
-0
tools/libxl/libxl_stream_read.c line 104
Quoted 4 lines
tools/libxl/libxl_stream_read.c +1
-0@@ -101,6 +101,19 @@ * - stream_write_emulator_done() * - stream_continue() * + * 4) Failover for remus
I don't think this is really #4 in the list which precedes it. I think a section "Failover for remus" would be absolutely fine right that the end of this comment block though, i.e. right after the "Depending on the contents..." paragraph.
Andy?
tools/libxl/libxl_stream_read.c line 106
Quoted 2 lines
tools/libxl/libxl_stream_read.c +2
-0+ * - we buffer all records until a CHECKPOINT_END record is received + * - we will use the records when a CHECKPOINT_END record is received
"we will consume the buffered records..."
tools/libxl/libxl_stream_read.c line 107
Quoted 1 line
tools/libxl/libxl_stream_read.c +1
-0+ * - if we find some internal error, the rc or retval is not 0 in
s/the/then/
tools/libxl/libxl_stream_read.c line 110
Quoted 3 lines
tools/libxl/libxl_stream_read.c +3
-0+ * libxl__xc_domain_restore_done(). In this case, we don't resume the + * guest + * - if we need to do failover from primary, the rc and retval are 0
s/the/then/ again and I would say "are both 0" for clarity (assuming that is indeed the requirement).
tools/libxl/libxl_stream_read.c line 112
Quoted 2 lines
tools/libxl/libxl_stream_read.c +2
-0+ * in libxl__xc_domain_restore_done(). In this case, the buffered state + * will be dropped, because we don't receive a CHECKPOINT_END record,
haven't received
tools/libxl/libxl_stream_read.c line 113
Quoted 1 line
tools/libxl/libxl_stream_read.c +1
-0+ * and it is a inconsistent state. In libxl__xc_domain_restore_done(),
"an inconsistent".
I think I would say "... and therefore the buffered state is inconsistent".
- stream_continue(egc, stream);
tools/libxl/libxl_stream_read.c void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void, · line 802
Quoted 7 lines
tools/libxl/libxl_stream_read.c +7
-0+ 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);
Is it possible to get here having never received a single CHECKPOINT_END?
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v4 1/5] remus: don't call stream_continue() when doing failover
Quoted 50 lines · Ian Campbell
Quoted 17 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]>--- tools/libxl/libxl_stream_read.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-)tools/libxl/libxl_stream_read.c +0
-0tools/libxl/libxl_stream_read.c line 104
Quoted 4 lines
tools/libxl/libxl_stream_read.c +1
-0@@ -101,6 +101,19 @@* - stream_write_emulator_done() * - stream_continue() * +* 4) Failover for remus I don't think this is really #4 in the list which precedes it. I think a section "Failover for remus" would be absolutely fine right that the end of this comment block though, i.e. right after the "Depending on the contents..." paragraph.
Andy?
tools/libxl/libxl_stream_read.c line 106
Quoted 2 lines
tools/libxl/libxl_stream_read.c +2
-0+* - we buffer all records until a CHECKPOINT_END record is received +* - we will use the records when a CHECKPOINT_END record is received "we will consume the buffered records..."
tools/libxl/libxl_stream_read.c line 107
Quoted 1 line
tools/libxl/libxl_stream_read.c +1
-0+* - if we find some internal error, the rc or retval is not 0 in s/the/then/
tools/libxl/libxl_stream_read.c line 110
Quoted 3 lines
tools/libxl/libxl_stream_read.c +3
-0+* libxl__xc_domain_restore_done(). In this case, we don't resume the +* guest +* - if we need to do failover from primary, the rc and retval are 0 s/the/then/ again and I would say "are both 0" for clarity (assuming that is indeed the requirement).
tools/libxl/libxl_stream_read.c line 112
Quoted 2 lines
tools/libxl/libxl_stream_read.c +2
-0+* in libxl__xc_domain_restore_done(). In this case, the buffered state +* will be dropped, because we don't receive a CHECKPOINT_END record,
Quoted 7 lines
haven't received
tools/libxl/libxl_stream_read.c line 113
Quoted 1 line
tools/libxl/libxl_stream_read.c +1
-0+* and it is a inconsistent state. In libxl__xc_domain_restore_done(), "an inconsistent".
I think I would say "... and therefore the buffered state is inconsistent".
Sorry for may poor English... I will fix it in the next version.
Quoted 11 lines
-
stream_continue(egc, stream);tools/libxl/libxl_stream_read.c void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void, · line 802
Quoted 7 lines
tools/libxl/libxl_stream_read.c +7
-0+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 );Is it possible to get here having never received a single
CHECKPOINT_END?
I will check the code first. I think xc_domain_restore() should not return 0 if it doesn't receive a single CHECKPOINT_END.
Thanks
Wen Congyang
Quoted 6 lines
Ian.
.
PATCH v4 2/5 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.c | 5 ++++- tools/libxl/libxl_stream_write.c | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-)
tools/libxl/libxl.c +4 -1
@@ -884,7 +884,10 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,assert (info); -/* Point of no return */ +/* +* This function doesn't return until something is wrong, and +* we need to do failover from secondary. +*/ libxl__remus_setup (egc, dss);return AO_INPROGRESS ;
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 v4 2/5] remus: resume immediately if libxl__xc_domain_save_done() completes
Quoted 5 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.
What if the secondary host isn't actually down but just communication has failed for some reason? Won't both primary and secondary start their respective versions of the domain? What are the consequences of that? (Corruption?)
I suppose this is a consequence of the lack of STONITH or splitbrain handling within Remus. Are there any plans to address this?
Quoted 13 lines
Signed-off-by Wen Congyang <[email protected]>Reviewed-by Andrew Cooper <[email protected]>---
tools/libxl/libxl.c | 5 ++++-tools/libxl/libxl_stream_write.c| 14 ++++++++++++--2 files changed, 16 insertions(+), 3 deletions(-)tools/libxl/libxl.c +0
-0@@ -884,7 +884,10 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
Quoted 7 lines
assert(info);
- /* Point of no return */
+ /*
+ * This function doesn't return until something is wrong, and + * we need to do failover from secondary.
I was actually hoping for user/API documentation (i.e. in a public header) rather than a code comment, I suppose this will do though.
Quoted 6 lines
+ if (
dss->remus)
+ /*
+ * For remus, iflibxl__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 + * returnvalue(Please refer to libxl__remus_teardown())
There should usually be a space before a ( in text/prose (also in the changelog).
Quoted 8 lines
+ */
+ stream_complete(egc, stream, 0);
+ else
+ write_emulator_xenstore_record(egc, stream); + }
}
static void write_emulator_xenstore_record(libxl__egc *egc,
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v4 2/5] remus: resume immediately if libxl__xc_domain_save_done() completes
Quoted 7 lines · Ian Campbell
Quoted 5 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.
Quoted 7 lines
What if the secondary host isn't actually down but just communication has failed for some reason? Won't both primary and secondary start their respective versions of the domain? What are the consequences of that? (Corruption?)
I suppose this is a consequence of the lack of STONITH or splitbrain handling within Remus. Are there any plans to address this?
IIRC, Shriram Rajagopalan has some ideas about it(check the external heartbeat?). There is no way to avoid splitbrain unless we have more than two hosts(at least three hosts). If we want to avoid splitbrain, we may need to destroy both primary and secondary guests.
An example:
judge host
/ \
1 2
/ \primary host <-3-> secondary host
If connection 3 has problem:
case A: connection 1 and 2 is OK, we can select one to run, and another one will
be destroyed (we have a judge host)
case B: one of connection 1 and is OK, the another connection has problem. The
guest on the host that can connects to judge host will continue to run. The another guest will be destroyed.
case C: both connection 1 and 2 have problem. The two guest will be destroyed.
Quoted 17 lines
Quoted 17 lines
Signed-off-by Wen Congyang <[email protected]>Reviewed-by Andrew Cooper <[email protected]>--- tools/libxl/libxl.c | 5 ++++- tools/libxl/libxl_stream_write.c | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-)tools/libxl/libxl.c +0
-0@@ -884,7 +884,10 @@ int libxl_domain_remus_start(libxl_ctx *ctx,libxl_domain_remus_info *info,assert (info );
Quoted 7 lines
tools/libxl/libxl.c int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, · line 889
Quoted 4 lines
tools/libxl/libxl.c +3
-1-/* Point of no return */ +/* +* This function doesn't return until something is wrong, and +* we need to do failover from secondary. I was actually hoping for user/API documentation (i.e. in a public header) rather than a code comment, I suppose this will do though.
OK, I will fix it.
Quoted 11 lines
tools/libxl/libxl.c int libxl_domain_remus_start(libxl_ctx *ctx,
Quoted 8 lines
tools/libxl/libxl.c +6
-0+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()) There should usually be a space before a ( in text/prose (also in the changelog).
OK, I will fix it.
Quoted 13 lines
tools/libxl/libxl.c
Quoted 9 lines
tools/libxl/libxl.c +5
-0+*/ +stream_complete (egc, stream,0 ); + else +write_emulator_xenstore_record (egc ,stream ); + } } static void write_emulator_xenstore_record(libxl__egc *egc,.
Re: [PATCH v4 2/5] remus: resume immediately if libxl__xc_domain_save_done() completes
Quoted 17 lines · Wen Congyang
Quoted 16 lines · Ian Campbell
Quoted 8 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.What if the secondary host isn't actually down but just communication has
failed for some reason? Won't both primary and secondary start their respective versions of the domain? What are the consequences of that? (Corruption?)
Quoted 7 lines
Quoted 2 lines
I suppose this is a consequence of the lack of STONITH or splitbrain handling within Remus. Are there any plans to address this?
IIRC, Shriram Rajagopalan has some ideas about it(check the external heartbeat?). There is no way to avoid splitbrain unless we have more than two hosts(at least three hosts). If we want to avoid splitbrain, we may need to destroy both primary and secondary guests.
I think there's plenty of existing systems for taking care of this side of fault-tolerance/HA (e.g. linux-ha, Pacemaker, Corosync, etc), we don't need (or want) to reinvent that particular wheel here.
I think we just need a story on how one would integrate with such a system in order to say that Remus is properly usable in real world scenarios (i.e. before we can remove the "proof-of-concept" wording from the man page).
That might just be a documentation exercise, or it might require some hooks etc adding to (lib)xl in order to allow such integrations, I'm not sure what's needed.
IIRC Ian expressed a similar sentiment when Remus support was first added to libxl.
Ian.
PATCH v4 3/5 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
Re: [PATCH v4 3/5] tools/libxc: don't send end record if remus fails
Quoted 2 lines · Wen Congyang
Signed-off-by Wen Congyang <[email protected]>Reviewed-by Andrew Cooper <[email protected]>
What was the outcoming of Andy's comment on v1 regarding error handling for ->postcopy?
Quoted 12 lines
---
tools/libxc/xc_sr_save.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)tools/libxc/xc_sr_save.c +0
-0@@ -795,7 +795,7 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)
rc = ctx->save.callbacks->checkpoint(ctx->save.callbacks-
Quoted 7 lines
Quoted 1 line
data);
if ( rc <= 0 )
- ctx->save.checkpointed = false;
+ goto err;
}
} while (ctx->save.checkpointed);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v4 3/5] tools/libxc: don't send end record if remus fails
Quoted 3 lines · Ian Campbell
What was the outcoming of Andy's comment on v1 regarding error handling for ->postcopy?
Ignore this, I saw just too late that it was in #4.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v4 4/5 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
Re: [PATCH v4 4/5] tools/libxc: error handling for the postcopy() callback
Quoted 2 lines · Wen Congyang
Signed-off-by Wen Congyang <[email protected]>Reviewed-by Andrew Cooper <[email protected]>
PATCH v4 5/5 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
@@ -1552,10 +1552,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