Skip to contentSkip to conversation

Misc patches to aid migration v2 Remus support

PATCH Superseded Andrew Cooper 4 participants 20 messages May 8, 2015 – May 11, 2015

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Misc patches to aid migration v2 Remus support

See individual patches for details.

Andrew Cooper (3):
[RFC] x86/hvm: Permit HVM_PARAM_IDENT_PT to be set more than once tools/libxc: Properly quote macro parameters libxc/migrationv2: Split {start,end}_of_stream() to make checkpoint
variants

 tools/libxc/include/xenctrl.h    |    8 +++----
 tools/libxc/xc_sr_common.h       |   25 +++++++++++++++------
 tools/libxc/xc_sr_save.c         |    8 +++++++
 tools/libxc/xc_sr_save_x86_hvm.c |   46 ++++++++++++++++++++++++--------------
 tools/libxc/xc_sr_save_x86_pv.c  |   46 +++++++++++++++++++++++++-------------
 xen/arch/x86/hvm/hvm.c           |   12 +++++-----
 6 files changed, 95 insertions(+), 50 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

RFC PATCH 1/3 x86/hvm: Permit HVM_PARAM_IDENT_PT to be set more than once

There is no conceptual problem with setting this parameter more than once. Checkpointed migration streams will typically set it once per checkpoint to the same value.

The parameter is only actually needed on early-generation VT-x which lacked the unrestricted guest capability, although it could plausibly be used on newer VT-x with unusual execution control settings. Short circuit the expensive operations on non VT-x hardware.

The parameter itself must always be latched to avoid issues if the VM eventually migrates to a host which needs to use the pagetable.

CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Yang Hongyang <[email protected]>
---
 xen/arch/x86/hvm/hvm.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
xen/arch/x86/hvm/hvm.c +6 -6
index 8140a27..5824e43 100644
@@ -5730,12 +5730,13 @@ static int hvmop_set_param(
             rc = -EINVAL;
         break;
     case HVM_PARAM_IDENT_PT:
-        rc = -EINVAL;
-        if ( d->arch.hvm_domain.params[a.index] != 0 )
-            break;
-
         rc = 0;
-        if ( !paging_mode_hap(d) )
+        d->arch.hvm_domain.params[a.index] = a.value;
+        /*
+         * Only actually required for VT-x lacking unrestricted_guest
+         * capabilities.  Short circuit the pause if possible.
+         */
+        if ( !paging_mode_hap(d) || !cpu_has_vmx )
             break;
 
         /*
@@ -5749,7 +5750,6 @@ static int hvmop_set_param(
 
         rc = 0;
         domain_pause(d);
-        d->arch.hvm_domain.params[a.index] = a.value;
         for_each_vcpu ( d, v )
             paging_update_cr3(v);
         domain_unpause(d);
Signature · 1 line
1.7.10.4
#2 lore raw

Re: [PATCH 1/3] [RFC] x86/hvm: Permit HVM_PARAM_IDENT_PT to be set more than once

Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 08.05.15 at 14:54, <[email protected]> wrote:

There is no conceptual problem with setting this parameter more than once. Checkpointed migration streams will typically set it once per checkpoint to the same value.

Quoted 7 lines

The parameter is only actually needed on early-generation VT-x which lacked the unrestricted guest capability, although it could plausibly be used on newer VT-x with unusual execution control settings. Short circuit the expensive operations on non VT-x hardware.

The parameter itself must always be latched to avoid issues if the VM eventually migrates to a host which needs to use the pagetable.

Reads all plausible, except that I think the way you carry out this last aspect needs adjustment:

Quoted 9 lines
xen/arch/x86/hvm/hvm.c +0 -3
@@ -5730,12 +5730,13 @@ static int hvmop_set_param(
             rc = -EINVAL;
         break;
     case HVM_PARAM_IDENT_PT:
-        rc = -EINVAL;
-        if ( d->arch.hvm_domain.params[a.index] != 0 )
-            break;

xen/arch/x86/hvm/hvm.c static int hvmop_set_param( · line 5740

Quoted 10 lines
xen/arch/x86/hvm/hvm.c +6 -2
-
         rc = 0;
-        if ( !paging_mode_hap(d) )
+        d->arch.hvm_domain.params[a.index] = a.value;
+        /*
+         * Only actually required for VT-x lacking unrestricted_guest
+         * capabilities.  Short circuit the pause if possible.
+         */
+        if ( !paging_mode_hap(d) || !cpu_has_vmx )
             break;

You should latch the new value inside this if()'s body and ...

xen/arch/x86/hvm/hvm.c static int hvmop_set_param( · line 5755

Quoted 8 lines
xen/arch/x86/hvm/hvm.c +0 -1
@@ -5749,7 +5750,6 @@ static int hvmop_set_param(
 
         rc = 0;
         domain_pause(d);
-        d->arch.hvm_domain.params[a.index] = a.value;
         for_each_vcpu ( d, v )
             paging_update_cr3(v);
         domain_unpause(d);

... leave this one alone so the use site in VMX code won't see the new value prematurely.

Jan

#3 lore raw

Re: [PATCH 1/3] [RFC] x86/hvm: Permit HVM_PARAM_IDENT_PT to be set more than once

Quoted 38 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 08.05.15 at 14:54, <[email protected]> wrote:

There is no conceptual problem with setting this parameter more than once. Checkpointed migration streams will typically set it once per checkpoint to the same value.

Quoted 7 lines

The parameter is only actually needed on early-generation VT-x which lacked the unrestricted guest capability, although it could plausibly be used on newer VT-x with unusual execution control settings. Short circuit the expensive operations on non VT-x hardware.

The parameter itself must always be latched to avoid issues if the VM eventually migrates to a host which needs to use the pagetable.

Reads all plausible, except that I think the way you carry out this last aspect needs adjustment:

Quoted 9 lines
xen/arch/x86/hvm/hvm.c +0 -3
@@ -5730,12 +5730,13 @@ static int hvmop_set_param(
             rc = -EINVAL;
         break;
     case HVM_PARAM_IDENT_PT:
-        rc = -EINVAL;
-        if ( d->arch.hvm_domain.params[a.index] != 0 )
-            break;

xen/arch/x86/hvm/hvm.c static int hvmop_set_param( · line 5740

Quoted 10 lines
xen/arch/x86/hvm/hvm.c +6 -2
-
         rc = 0;
-        if ( !paging_mode_hap(d) )
+        d->arch.hvm_domain.params[a.index] = a.value;
+        /*
+         * Only actually required for VT-x lacking unrestricted_guest
+         * capabilities.  Short circuit the pause if possible.
+         */
+        if ( !paging_mode_hap(d) || !cpu_has_vmx )
             break;

You should latch the new value inside this if()'s body and ...

Quoted 2 lines
xen/arch/x86/hvm/hvm.c +0 -0
@@ -5749,7 +5750,6 @@ static int hvmop_set_param(
 
Quoted 8 lines

xen/arch/x86/hvm/hvm.c static int hvmop_set_param( · line 5755

Quoted 6 lines
xen/arch/x86/hvm/hvm.c +0 -1
         rc = 0;
         domain_pause(d);
-        d->arch.hvm_domain.params[a.index] = a.value;
         for_each_vcpu ( d, v )
             paging_update_cr3(v);
         domain_unpause(d);

... leave this one alone so the use site in VMX code won't see the new value prematurely.

Good point - I will fix this up.

~Andrew

#4 lore raw

PATCH 2/3 tools/libxc: Properly quote macro parameters

In reply to Andrew Cooper
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Yang Hongyang <[email protected]>
---
 tools/libxc/include/xenctrl.h |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/libxc/include/xenctrl.h +4 -4
index 6994c51..fc880e1 100644
@@ -270,7 +270,7 @@ struct xc_hypercall_buffer {
  * transparently converted to the hypercall buffer as necessary.
  */
 #define DECLARE_HYPERCALL_BUFFER(_type, _name)                 \
-    _type *_name = NULL;                                       \
+    _type *(_name) = NULL;                                     \
     xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME(_name) = { \
         .hbuf = NULL,                                          \
         .param_shadow = NULL,                                  \
@@ -288,10 +288,10 @@ struct xc_hypercall_buffer {
  * required.
  */
 #define DECLARE_HYPERCALL_BUFFER_SHADOW(_type, _name, _hbuf)   \
-    _type *_name = _hbuf->hbuf;                                \
+    _type *(_name) = (_hbuf)->hbuf;                            \
     xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME(_name) = { \
         .hbuf = (void *)-1,                                    \
-        .param_shadow = _hbuf,                                 \
+        .param_shadow = (_hbuf),                               \
         HYPERCALL_BUFFER_INIT_NO_BOUNCE                        \
     }
 
@@ -302,7 +302,7 @@ struct xc_hypercall_buffer {
 #define DECLARE_HYPERCALL_BUFFER_ARGUMENT(_name)               \
     xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME(_name) = { \
         .hbuf = (void *)-1,                                    \
-        .param_shadow = _name,                                 \
+        .param_shadow = (_name),                               \
         HYPERCALL_BUFFER_INIT_NO_BOUNCE                        \
     }
 
Signature · 1 line
1.7.10.4
#5 lore raw

Re: [PATCH 2/3] tools/libxc: Properly quote macro parameters

And of course, I meant s/quote/bracket/ in the subject.

~Andrew

#6 lore raw

Re: [PATCH 2/3] tools/libxc: Properly quote macro parameters

Quoted 1 line · Andrew Cooper

And of course, I meant s/quote/bracket/ in the subject.

I fixed that and applied.

Ian.

Acked-by on v1 2/3
#7 lore raw

Re: [PATCH 2/3] tools/libxc: Properly quote macro parameters

In reply to Andrew Cooper
Quoted 23 lines · Andrew Cooper
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Yang Hongyang <[email protected]>
---
 tools/libxc/include/xenctrl.h |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/libxc/include/xenctrl.h +1 -1
index 6994c51..fc880e1 100644
@@ -270,7 +270,7 @@ struct xc_hypercall_buffer {
  * transparently converted to the hypercall buffer as necessary.
  */
 #define DECLARE_HYPERCALL_BUFFER(_type, _name)                 \
-    _type *_name = NULL;                                       \
+    _type *(_name) = NULL;                                     \
     xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME(_name) = { \
         .hbuf = NULL,                                          \
         .param_shadow = NULL,                                  \

tools/libxc/include/xenctrl.h struct xc_hypercall_buffer { · line 291

Quoted 5 lines
tools/libxc/include/xenctrl.h +1 -1
@@ -288,10 +288,10 @@ struct xc_hypercall_buffer {
  * required.
  */
 #define DECLARE_HYPERCALL_BUFFER_SHADOW(_type, _name, _hbuf)   \
-    _type *_name = _hbuf->hbuf;                                \
+    _type *(_name) = (_hbuf)->hbuf;                            \

This seems to be the only one which matters in practice, but it's good manners, so:

#8 lore raw

PATCH 3/3 libxc/migrationv2: Split {start, end}_of_stream() to make checkpoint variants

In reply to Andrew Cooper

This is in preparation for supporting checkpointed streams in migration v2.
- For PV guests, the VCPU context is moved to end_of_checkpoint().
- For HVM guests, the HVM context and params are moved to end_of_checkpoint().

For regular migration, this results in a reordering of the tail records, but no semantic change.

In addition fix a couple of stylistic issues and adjust some comments.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Yang Hongyang <[email protected]>

---
This patch has not tested yet, but is just some code shuffling and should have no observable effect from the guests point of view.

---
 tools/libxc/xc_sr_common.h       |   25 +++++++++++++++------
 tools/libxc/xc_sr_save.c         |    8 +++++++
 tools/libxc/xc_sr_save_x86_hvm.c |   46 ++++++++++++++++++++++++--------------
 tools/libxc/xc_sr_save_x86_pv.c  |   46 +++++++++++++++++++++++++-------------
 4 files changed, 85 insertions(+), 40 deletions(-)
tools/libxc/xc_sr_common.h +18 -7
index ef42412..56169ea 100644
@@ -61,17 +61,28 @@ struct xc_sr_save_ops
     int (*setup)(struct xc_sr_context *ctx);
 
     /**
-     * Write records which need to be at the start of the stream.  This is
-     * called after the Image and Domain headers are written.  (Any records
-     * which need to be ahead of the memory.)
+     * Send records which need to be at the start of the stream.  This is
+     * called once, after the Image and Domain headers are written.
      */
     int (*start_of_stream)(struct xc_sr_context *ctx);
 
     /**
-     * Write records which need to be at the end of the stream, following the
-     * complete memory contents.  The caller shall handle writing the END
-     * record into the stream.  (Any records which need to be after the memory
-     * is complete.)
+     * Send records which need to be at the start of a checkpoint.  This is
+     * called once, or once per checkpoint in a checkpointed stream, and is
+     * ahead of memory data.
+     */
+    int (*start_of_checkpoint)(struct xc_sr_context *ctx);
+
+    /**
+     * Send records which need to be at the end of the checkpoint.  This is
+     * called once, or once per checkpoint in a checkpointed stream, and is
+     * after the memory data.
+     */
+    int (*end_of_checkpoint)(struct xc_sr_context *ctx);
+
+    /**
+     * Send records which need to be at the end of the stream.  This is called
+     * once, before the END record is written.
      */
     int (*end_of_stream)(struct xc_sr_context *ctx);
 
tools/libxc/xc_sr_save.c +8 -0
index 5d9c267..49c65e9 100644
@@ -662,6 +662,10 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)
     if ( rc )
         goto err;
 
+    rc = ctx->save.ops.start_of_checkpoint(ctx);
+    if ( rc )
+        goto err;
+
     if ( ctx->save.live )
         rc = send_domain_memory_live(ctx);
     else
@@ -678,6 +682,10 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)
         goto err;
     }
 
+    rc = ctx->save.ops.end_of_checkpoint(ctx);
+    if ( rc )
+        goto err;
+
     xc_report_progress_single(xch, "End of stream");
 
     rc = ctx->save.ops.end_of_stream(ctx);
tools/libxc/xc_sr_save_x86_hvm.c +29 -17

73 lines not on this page · raw message

tools/libxc/xc_sr_save_x86_pv.c +30 -16

79 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#9 lore raw

Re: [PATCH 3/3] libxc/migrationv2: Split {start, end}_of_stream() to make checkpoint variants

Quoted 3 lines · Andrew Cooper

This is in preparation for supporting checkpointed streams in migration v2.
- For PV guests, the VCPU context is moved to end_of_checkpoint().
- For HVM guests, the HVM context and params are moved to end_of_checkpoint().

[...]

Quoted 12 lines
tools/libxc/xc_sr_common.h +10 -0
+    /**
+     * Send records which need to be at the end of the checkpoint.  This is
+     * called once, or once per checkpoint in a checkpointed stream, and is
+     * after the memory data.
+     */
+    int (*end_of_checkpoint)(struct xc_sr_context *ctx);
+
+    /**
+     * Send records which need to be at the end of the stream.  This is called
+     * once, before the END record is written.
      */
     int (*end_of_stream)(struct xc_sr_context *ctx);

[...]

tools/libxc/xc_sr_save_x86_hvm.c static int x86_hvm_start_of_stream(struct xc_sr_context *ctx) · line 224

Quoted 12 lines
tools/libxc/xc_sr_save_x86_hvm.c +7 -2
+static int x86_hvm_end_of_stream(struct xc_sr_context *ctx)
+{
+    int rc;
+
+    rc = write_tsc_info(ctx);
     if ( rc )
         return rc;
 
-    /* Write HVM_PARAMS record contains applicable HVM params. */
-    rc = write_hvm_params(ctx);
+#ifdef XG_LIBXL_HVM_COMPAT
+    rc = write_toolstack(ctx);

I'm not sure about this end_of_stream thing. In a check pointing for fault tolerance scenario (Remus or COLO) then failover happens when the sender has died for some reason, and therefore won't get the chance to send any end of stream stuff.

IOW I think everything in end_of_stream actually needs to be in end_of_checkpoint unless it is just for informational purposes in a regular migration or something (which write_toolstack surely isn't)

Ian.

#10 lore raw

Re: [PATCH 3/3] libxc/migrationv2: Split {start, end}_of_stream() to make checkpoint variants

Quoted 26 lines · Ian Campbell
Quoted 3 lines · Andrew Cooper

This is in preparation for supporting checkpointed streams in migration v2.
- For PV guests, the VCPU context is moved to end_of_checkpoint().
- For HVM guests, the HVM context and params are moved to end_of_checkpoint().

[...]

Quoted 12 lines
tools/libxc/xc_sr_common.h +10 -0
+    /**
+     * Send records which need to be at the end of the checkpoint.  This is
+     * called once, or once per checkpoint in a checkpointed stream, and is
+     * after the memory data.
+     */
+    int (*end_of_checkpoint)(struct xc_sr_context *ctx);
+
+    /**
+     * Send records which need to be at the end of the stream.  This is called
+     * once, before the END record is written.
      */
     int (*end_of_stream)(struct xc_sr_context *ctx);

[...]

Quoted 8 lines
tools/libxc/xc_sr_save_x86_hvm.c +5 -0
+static int x86_hvm_end_of_stream(struct xc_sr_context *ctx)
+{
+    int rc;
+
+    rc = write_tsc_info(ctx);
     if ( rc )
         return rc;
Quoted 8 lines

tools/libxc/xc_sr_save_x86_hvm.c static int x86_hvm_start_of_stream(struct xc_sr_context *ctx) · line 224

Quoted 4 lines
tools/libxc/xc_sr_save_x86_hvm.c +2 -2
-    /* Write HVM_PARAMS record contains applicable HVM params. */
-    rc = write_hvm_params(ctx);
+#ifdef XG_LIBXL_HVM_COMPAT
+    rc = write_toolstack(ctx);

I'm not sure about this end_of_stream thing. In a check pointing for fault tolerance scenario (Remus or COLO) then failover happens when the sender has died for some reason, and therefore won't get the chance to send any end of stream stuff.

Does Remus currently function if the sending toolstack suddenly disappears out of the mix?

Although on consideration, I do agree that end_of_stream() shouldn't really be a thing.

Quoted 4 lines

IOW I think everything in end_of_stream actually needs to be in end_of_checkpoint unless it is just for informational purposes in a regular migration or something (which write_toolstack surely isn't)

There are some side effects which I will have to work around, but I will see what I can do.

~Andrew

#11 lore raw

Re: [PATCH 3/3] libxc/migrationv2: Split {start, end}_of_stream() to make checkpoint variants

Quoted 2 lines · Andrew Cooper

Does Remus currently function if the sending toolstack suddenly disappears out of the mix?

I would assume so, that's its entire purpose...

Ian.

#12 lore raw

Re: [PATCH 3/3] libxc/migrationv2: Split {start, end}_of_stream() to make checkpoint variants

Quoted 4 lines · Ian Campbell
Quoted 2 lines · Andrew Cooper

Does Remus currently function if the sending toolstack suddenly disappears out of the mix?

I would assume so, that's its entire purpose...

But the signal to resume the domain properly involves setting last_checkpoint and wandering the recieve loop once more?

/me goes and checks the code more carefully.

~Andrew

#13 lore raw

Re: [PATCH 3/3] libxc/migrationv2: Split {start, end}_of_stream() to make checkpoint variants

Quoted 10 lines · Andrew Cooper
Quoted 4 lines · Ian Campbell
Quoted 2 lines · Andrew Cooper

Does Remus currently function if the sending toolstack suddenly disappears out of the mix?

I would assume so, that's its entire purpose...

But the signal to resume the domain properly involves setting last_checkpoint and wandering the recieve loop once more?

/me goes and checks the code more carefully.

I think there's supposed to be a read timeout in there somewhere, at which point the last checkpoint you did manage to get is the one which is used.

(The heartbeating and detection of this stuff bit of remus was always a bit underwhelming)

Ian.

#14 lore raw

Re: [PATCH 3/3] libxc/migrationv2: Split {start, end}_of_stream() to make checkpoint variants

In reply to Andrew Cooper
Quoted 8 lines · Andrew Cooper
Quoted 4 lines · Ian Campbell
Quoted 2 lines · Andrew Cooper

Does Remus currently function if the sending toolstack suddenly disappears out of the mix?

I would assume so, that's its entire purpose...

But the signal to resume the domain properly involves setting last_checkpoint and wandering the recieve loop once more?

Please see my previous explain about Remus checkpoint and failover
Message-ID: <[email protected]>

If the sending toolstack suddenly disappears out of the mix, secondary will recover from the last processed records which include the full toolstack record.

Quoted 6 lines

/me goes and checks the code more carefully.

~Andrew
.

Signature · 2 lines
Thanks,
Yang.
#15 lore raw

Re: [PATCH 3/3] libxc/migrationv2: Split {start, end}_of_stream() to make checkpoint variants

In reply to Ian Campbell
Quoted 37 lines · Ian Campbell
Quoted 3 lines · Andrew Cooper

This is in preparation for supporting checkpointed streams in migration v2.
- For PV guests, the VCPU context is moved to end_of_checkpoint().
- For HVM guests, the HVM context and params are moved to end_of_checkpoint().

[...]

Quoted 12 lines
tools/libxc/xc_sr_common.h +10 -0
+    /**
+     * Send records which need to be at the end of the checkpoint.  This is
+     * called once, or once per checkpoint in a checkpointed stream, and is
+     * after the memory data.
+     */
+    int (*end_of_checkpoint)(struct xc_sr_context *ctx);
+
+    /**
+     * Send records which need to be at the end of the stream.  This is called
+     * once, before the END record is written.
       */
      int (*end_of_stream)(struct xc_sr_context *ctx);

[...]

tools/libxc/xc_sr_save_x86_hvm.c static int x86_hvm_start_of_stream(struct xc_sr_context *ctx) · line 224

Quoted 12 lines
tools/libxc/xc_sr_save_x86_hvm.c +7 -2
+static int x86_hvm_end_of_stream(struct xc_sr_context *ctx)
+{
+    int rc;
+
+    rc = write_tsc_info(ctx);
      if ( rc )
          return rc;
 
-    /* Write HVM_PARAMS record contains applicable HVM params. */
-    rc = write_hvm_params(ctx);
+#ifdef XG_LIBXL_HVM_COMPAT
+    rc = write_toolstack(ctx);

I'm not sure about this end_of_stream thing. In a check pointing for fault tolerance scenario (Remus or COLO) then failover happens when the sender has died for some reason, and therefore won't get the chance to send any end of stream stuff.

Quoted 3 lines

IOW I think everything in end_of_stream actually needs to be in end_of_checkpoint unless it is just for informational purposes in a regular migration or something (which write_toolstack surely isn't)

Yes, all records should be sent at every checkpoint, except those only need to be sent once.

checkpoint:
You can see clearly from the patches a Remus migration explicit include two stage, first stage is live migration, the second is Checkpointed stream. The live migration is obvious, after the live migration, both primary and secondary are in the same state, the primary will continue to run until the next checkpoint, at checkpint, we sync the secondary state with the primary, so that both side are in the same state, so any record that could be changed while Guest is runing should be sent at checkpoint.

failover:
The handling of Checkpointed stream on restore side is also include two stage, first is buffer records, second is process records. This is because if master died when sending records, the secondary state will be inconsistent. So we have to make sure all records are received and then process the records. If master died, the secondary can recover from the last checkpoint state. Currently Remus failover relies on the migration channel. If the channel break, we presume master is dead, so we will failover. The "goto err_buf" is the failover path, with goto err_buf, we discard the current checkpoint records because it is imperfect, then resume the guest with last checkpoint state(the last processed records).

Quoted 5 lines

Ian.

.

Signature · 2 lines
Thanks,
Yang.
#16 lore raw

Re: [PATCH 3/3] libxc/migrationv2: Split {start, end}_of_stream() to make checkpoint variants

Quoted 60 lines · Hongyang Yang
Quoted 42 lines · Ian Campbell
Quoted 5 lines · Andrew Cooper

This is in preparation for supporting checkpointed streams in migration v2.
- For PV guests, the VCPU context is moved to end_of_checkpoint().
- For HVM guests, the HVM context and params are moved to
end_of_checkpoint().

[...]

Quoted 15 lines
(quoted diff) +2 -0
+    /**
+     * Send records which need to be at the end of the checkpoint. 

This is
+ * called once, or once per checkpoint in a checkpointed
stream, and is

tools/libxc/xc_sr_common.h +6 -0
+     * after the memory data.
+     */
+    int (*end_of_checkpoint)(struct xc_sr_context *ctx);
+
+    /**
+     * Send records which need to be at the end of the stream. 

This is called
+ * once, before the END record is written.

       */
      int (*end_of_stream)(struct xc_sr_context *ctx);

[...]

tools/libxc/xc_sr_save_x86_hvm.c static int x86_hvm_start_of_stream(struct xc_sr_context *ctx) · line 224

Quoted 12 lines
tools/libxc/xc_sr_save_x86_hvm.c +7 -2
+static int x86_hvm_end_of_stream(struct xc_sr_context *ctx)
+{
+    int rc;
+
+    rc = write_tsc_info(ctx);
      if ( rc )
          return rc;
 
-    /* Write HVM_PARAMS record contains applicable HVM params. */
-    rc = write_hvm_params(ctx);
+#ifdef XG_LIBXL_HVM_COMPAT
+    rc = write_toolstack(ctx);

I'm not sure about this end_of_stream thing. In a check pointing for fault tolerance scenario (Remus or COLO) then failover happens when the sender has died for some reason, and therefore won't get the chance to send any end of stream stuff.

Quoted 3 lines

IOW I think everything in end_of_stream actually needs to be in end_of_checkpoint unless it is just for informational purposes in a regular migration or something (which write_toolstack surely isn't)

Yes, all records should be sent at every checkpoint, except those only need to be sent once.

checkpoint:
You can see clearly from the patches a Remus migration explicit include two stage, first stage is live migration, the second is Checkpointed stream. The live migration is obvious, after the live migration, both primary and secondary are in the same state, the primary will continue to run until the next checkpoint, at checkpint, we sync the secondary state with the primary, so that both side are in the same state, so any record that could be changed while Guest is runing should be sent at checkpoint.

Quoted 16 lines

failover:
The handling of Checkpointed stream on restore side is also include two stage,
first is buffer records, second is process records. This is because if master
died when sending records, the secondary state will be inconsistent. So we
have to make sure all records are received and then process the records. If master died, the secondary can recover from the last checkpoint state. Currently Remus failover relies on the migration channel. If the channel break, we presume master is dead, so we will failover. The "goto err_buf" is
the failover path, with goto err_buf, we discard the current checkpoint records because it is imperfect, then resume the guest with last checkpoint
state(the last processed records).

Thankyou for the clarification.

It occurs to me that, despite things like 'last_iter', it is actually the first iteration which is actually special in Remus.

Is there a case where the primary decides to explicitly hand over to the secondary?

~Andrew

#17 lore raw

Re: [PATCH 3/3] libxc/migrationv2: Split {start, end}_of_stream() to make checkpoint variants

Quoted 78 lines · Andrew Cooper
Quoted 60 lines · Hongyang Yang
Quoted 42 lines · Ian Campbell
Quoted 5 lines · Andrew Cooper

This is in preparation for supporting checkpointed streams in migration v2.
- For PV guests, the VCPU context is moved to end_of_checkpoint().
- For HVM guests, the HVM context and params are moved to
end_of_checkpoint().

[...]

Quoted 15 lines
(quoted diff) +2 -0
+    /**
+     * Send records which need to be at the end of the checkpoint.

This is
+ * called once, or once per checkpoint in a checkpointed
stream, and is

tools/libxc/xc_sr_common.h +6 -0
+     * after the memory data.
+     */
+    int (*end_of_checkpoint)(struct xc_sr_context *ctx);
+
+    /**
+     * Send records which need to be at the end of the stream.

This is called
+ * once, before the END record is written.

        */
       int (*end_of_stream)(struct xc_sr_context *ctx);

[...]

tools/libxc/xc_sr_save_x86_hvm.c static int x86_hvm_start_of_stream(struct xc_sr_context *ctx) · line 224

Quoted 12 lines
tools/libxc/xc_sr_save_x86_hvm.c +7 -2
+static int x86_hvm_end_of_stream(struct xc_sr_context *ctx)
+{
+    int rc;
+
+    rc = write_tsc_info(ctx);
       if ( rc )
           return rc;
 
-    /* Write HVM_PARAMS record contains applicable HVM params. */
-    rc = write_hvm_params(ctx);
+#ifdef XG_LIBXL_HVM_COMPAT
+    rc = write_toolstack(ctx);

I'm not sure about this end_of_stream thing. In a check pointing for fault tolerance scenario (Remus or COLO) then failover happens when the sender has died for some reason, and therefore won't get the chance to send any end of stream stuff.

Quoted 3 lines

IOW I think everything in end_of_stream actually needs to be in end_of_checkpoint unless it is just for informational purposes in a regular migration or something (which write_toolstack surely isn't)

Yes, all records should be sent at every checkpoint, except those only need to be sent once.

checkpoint:
You can see clearly from the patches a Remus migration explicit include two stage, first stage is live migration, the second is Checkpointed stream. The live migration is obvious, after the live migration, both primary and secondary are in the same state, the primary will continue to run until the next checkpoint, at checkpint, we sync the secondary state with the primary, so that both side are in the same state, so any record that could be changed while Guest is runing should be sent at checkpoint.

Quoted 16 lines

failover:
The handling of Checkpointed stream on restore side is also include two stage,
first is buffer records, second is process records. This is because if master
died when sending records, the secondary state will be inconsistent. So we
have to make sure all records are received and then process the records. If master died, the secondary can recover from the last checkpoint state. Currently Remus failover relies on the migration channel. If the channel break, we presume master is dead, so we will failover. The "goto err_buf" is
the failover path, with goto err_buf, we discard the current checkpoint records because it is imperfect, then resume the guest with last checkpoint
state(the last processed records).

Quoted 4 lines

Thankyou for the clarification.

It occurs to me that, despite things like 'last_iter', it is actually the first iteration which is actually special in Remus.

yes, the 'last_iter' thing is actually suspend and send the dirty mem pages to secondary.

Quoted 3 lines

Is there a case where the primary decides to explicitly hand over to the secondary?

Currently there isn't, The secondary only starts on failover.

Quoted 4 lines

~Andrew
.

Signature · 2 lines
Thanks,
Yang.
#18 lore raw
In reply to Andrew Cooper
Quoted 1 line · Andrew Cooper

See individual patches for details.

Git tree available at:
git://xenbits.xen.org/people/andrewcoop/xen.git remus-migv2-v1

Yang: Please feel free to consume some of all of these patches as appropriate into your series, rather than both of us attempting to maintain different versions of the same series to support remus with migration v2.

~Andrew

Quoted 15 lines

Andrew Cooper (3):
[RFC] x86/hvm: Permit HVM_PARAM_IDENT_PT to be set more than once tools/libxc: Properly quote macro parameters libxc/migrationv2: Split {start,end}_of_stream() to make checkpoint
variants

 tools/libxc/include/xenctrl.h    |    8 +++----
 tools/libxc/xc_sr_common.h       |   25 +++++++++++++++------
 tools/libxc/xc_sr_save.c         |    8 +++++++
 tools/libxc/xc_sr_save_x86_hvm.c |   46 ++++++++++++++++++++++++--------------
 tools/libxc/xc_sr_save_x86_pv.c  |   46 +++++++++++++++++++++++++-------------
 xen/arch/x86/hvm/hvm.c           |   12 +++++-----
 6 files changed, 95 insertions(+), 50 deletions(-)
#19 lore raw
Quoted 10 lines · Andrew Cooper
Quoted 1 line · Andrew Cooper

See individual patches for details.

Git tree available at:
git://xenbits.xen.org/people/andrewcoop/xen.git remus-migv2-v1

Yang: Please feel free to consume some of all of these patches as appropriate into your series, rather than both of us attempting to maintain different versions of the same series to support remus with migration v2.

Sure, thank you for the effort on Remus support :)

Quoted 21 lines

~Andrew

Quoted 7 lines

Andrew Cooper (3):
[RFC] x86/hvm: Permit HVM_PARAM_IDENT_PT to be set more than once tools/libxc: Properly quote macro parameters libxc/migrationv2: Split {start,end}_of_stream() to make checkpoint
variants

Quoted 8 lines
  tools/libxc/include/xenctrl.h    |    8 +++----
  tools/libxc/xc_sr_common.h       |   25 +++++++++++++++------
  tools/libxc/xc_sr_save.c         |    8 +++++++
  tools/libxc/xc_sr_save_x86_hvm.c |   46 ++++++++++++++++++++++++--------------
  tools/libxc/xc_sr_save_x86_pv.c  |   46 +++++++++++++++++++++++++-------------
  xen/arch/x86/hvm/hvm.c           |   12 +++++-----
  6 files changed, 95 insertions(+), 50 deletions(-)

.

Signature · 2 lines
Thanks,
Yang.