Skip to contentSkip to conversation

Prerequisite patches for COLO

PATCH Superseded Yang Hongyang 8 participants 106 messages Jun 8, 2015 – Jun 25, 2015

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Prerequisite patches for COLO

This patchset is Prerequisite for COLO feature. For what COLO is, refer to http://wiki.xen.org/wiki/COLO_-_Coarse_Grain_Lock_Stepping

This patchset is based on:
[PATCH v2 0/6] Misc cleanups for libxl

You can also get the patchset from:
https://github.com/macrosheep/xen/tree/colo-v6

v1->v2:
- Rebased to [PATCH v2 0/6] Misc cleanups for libxl
- Add a bugfix for the error handling of process_record

Wen Congyang (4):
tools/libxc: support to resume uncooperative HVM guests tools/libxl: Introduce a new internal API libxl__domain_unpause() tools/libxl: Update libxl_save_msgs_gen.pl to support return data from
xl to xc
tools/libxl: Add back channel to allow migration target send data back

Yang Hongyang (9):
libxc/restore: fix error handle of process_record libxc/restore: zero ioreq page only one time
tools/libxc: export xc_bitops.h
tools/libxl: introduce a new API libxl__domain_restore() to load qemu
state
tools/libxl: Update libxl__domain_unpause() to support qemu-xen tools/libxl: introduce libxl__domain_common_switch_qemu_logdirty() tools/libxl: rename remus device to checkpoint device tools/libxl: adjust the indentation
tools/libxl: don't touch remus in checkpoint_device

 tools/libxc/include/xc_bitops.h       |  76 ++++++++
 tools/libxc/xc_bitops.h               |  76 --------
 tools/libxc/xc_resume.c               |  22 ++-
 tools/libxc/xc_sr_restore.c           |  28 +--
 tools/libxc/xc_sr_restore_x86_hvm.c   |   3 +-
 tools/libxl/Makefile                  |   2 +-
 tools/libxl/libxl.c                   |  62 +++++--
 tools/libxl/libxl_checkpoint_device.c | 282 +++++++++++++++++++++++++++++
 tools/libxl/libxl_create.c            |  14 +-
 tools/libxl/libxl_dom_save.c          | 128 +++++++++----
 tools/libxl/libxl_internal.h          | 171 ++++++++++--------
 tools/libxl/libxl_netbuffer.c         | 117 ++++++------
 tools/libxl/libxl_nonetbuffer.c       |  10 +-
 tools/libxl/libxl_qmp.c               |  10 ++
 tools/libxl/libxl_remus.c             | 140 ++++++++++-----
 tools/libxl/libxl_remus_device.c      | 327 ----------------------------------
 tools/libxl/libxl_remus_disk_drbd.c   |  56 +++---
 tools/libxl/libxl_save_callout.c      |  31 ++++
 tools/libxl/libxl_save_helper.c       |  17 ++
 tools/libxl/libxl_save_msgs_gen.pl    |  65 ++++++-
 tools/libxl/libxl_types.idl           |  11 +-
 tools/libxl/xl_cmdimpl.c              |   7 +
 22 files changed, 970 insertions(+), 685 deletions(-)
 create mode 100644 tools/libxc/include/xc_bitops.h
 delete mode 100644 tools/libxc/xc_bitops.h
 create mode 100644 tools/libxl/libxl_checkpoint_device.c
 delete mode 100644 tools/libxl/libxl_remus_device.c
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/13 libxc/restore: fix error handle of process_record

If the err is RECORD_NOT_PROCESSED, and it is an optional record, restore will still fail. The patch fix this.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Andrew Cooper <[email protected]>
---
 tools/libxc/xc_sr_restore.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
tools/libxc/xc_sr_restore.c +14 -14
index 9e27dba..2d2edd3 100644
@@ -560,19 +560,6 @@ static int process_record(struct xc_sr_context *ctx, struct xc_sr_record *rec)
     free(rec->data);
     rec->data = NULL;
 
-    if ( rc == RECORD_NOT_PROCESSED )
-    {
-        if ( rec->type & REC_TYPE_OPTIONAL )
-            DPRINTF("Ignoring optional record %#x (%s)",
-                    rec->type, rec_type_to_str(rec->type));
-        else
-        {
-            ERROR("Mandatory record %#x (%s) not handled",
-                  rec->type, rec_type_to_str(rec->type));
-            rc = -1;
-        }
-    }
-
     return rc;
 }
 
@@ -678,7 +665,20 @@ static int restore(struct xc_sr_context *ctx)
         else
         {
             rc = process_record(ctx, &rec);
-            if ( rc )
+            if ( rc == RECORD_NOT_PROCESSED )
+            {
+                if ( rec.type & REC_TYPE_OPTIONAL )
+                    DPRINTF("Ignoring optional record %#x (%s)",
+                            rec.type, rec_type_to_str(rec.type));
+                else
+                {
+                    ERROR("Mandatory record %#x (%s) not handled",
+                          rec.type, rec_type_to_str(rec.type));
+                    rc = -1;
+                    goto err;
+                }
+            }
+            else if ( rc )
                 goto err;
         }
 
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH v2 COLOPre 01/13] libxc/restore: fix error handle of process_record

Quoted 17 lines · Yang Hongyang

If the err is RECORD_NOT_PROCESSED, and it is an optional record, restore will still fail. The patch fix this.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Andrew Cooper <[email protected]>
---
 tools/libxc/xc_sr_restore.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
tools/libxc/xc_sr_restore.c +0 -0
index 9e27dba..2d2edd3 100644

tools/libxc/xc_sr_restore.c static int process_record(struct xc_sr_context *ctx, struct xc_sr_record *rec) · line 567

Quoted 8 lines
tools/libxc/xc_sr_restore.c +0 -5
@@ -560,19 +560,6 @@ static int process_record(struct xc_sr_context *ctx, struct xc_sr_record *rec)
     free(rec->data);
     rec->data = NULL;
 
-    if ( rc == RECORD_NOT_PROCESSED )
-    {
-        if ( rec->type & REC_TYPE_OPTIONAL )
-            DPRINTF("Ignoring optional record %#x (%s)",
-                    rec->type, rec_type_to_str(rec->type));

You would be best setting rc to 0 here, rather than moving the logic out of process_record().

~Andrew

Quoted 33 lines
tools/libxc/xc_sr_restore.c +14 -9
-        else
-        {
-            ERROR("Mandatory record %#x (%s) not handled",
-                  rec->type, rec_type_to_str(rec->type));
-            rc = -1;
-        }
-    }
-
     return rc;
 }
 
@@ -678,7 +665,20 @@ static int restore(struct xc_sr_context *ctx)
         else
         {
             rc = process_record(ctx, &rec);
-            if ( rc )
+            if ( rc == RECORD_NOT_PROCESSED )
+            {
+                if ( rec.type & REC_TYPE_OPTIONAL )
+                    DPRINTF("Ignoring optional record %#x (%s)",
+                            rec.type, rec_type_to_str(rec.type));
+                else
+                {
+                    ERROR("Mandatory record %#x (%s) not handled",
+                          rec.type, rec_type_to_str(rec.type));
+                    rc = -1;
+                    goto err;
+                }
+            }
+            else if ( rc )
                 goto err;
         }
 
#3 lore raw

Re: [PATCH v2 COLOPre 01/13] libxc/restore: fix error handle of process_record

Quoted 21 lines · Andrew Cooper
Quoted 20 lines · Yang Hongyang

If the err is RECORD_NOT_PROCESSED, and it is an optional record, restore will still fail. The patch fix this.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Andrew Cooper <[email protected]>
---
  tools/libxc/xc_sr_restore.c | 28 ++++++++++++++--------------
  1 file changed, 14 insertions(+), 14 deletions(-)
tools/libxc/xc_sr_restore.c +0 -0
index 9e27dba..2d2edd3 100644
@@ -560,19 +560,6 @@ static int process_record(struct xc_sr_context *ctx, struct xc_sr_record *rec)
      free(rec->data);
      rec->data = NULL;
 
Quoted 8 lines

tools/libxc/xc_sr_restore.c static int process_record(struct xc_sr_context *ctx, struct xc_sr_record *rec) · line 567

Quoted 5 lines
tools/libxc/xc_sr_restore.c +0 -5
-    if ( rc == RECORD_NOT_PROCESSED )
-    {
-        if ( rec->type & REC_TYPE_OPTIONAL )
-            DPRINTF("Ignoring optional record %#x (%s)",
-                    rec->type, rec_type_to_str(rec->type));

You would be best setting rc to 0 here, rather than moving the logic out of process_record().

There will be another error type in COLO, which indicates a failover, that needs to be handled in restore(), so I moved the error handling down to avoid duplex code...Otherwise, in process_record, RECORD_NOT_PROCESSED is handled, and in restore another error type returned from process_record is handled...

Quoted 39 lines

~Andrew

Quoted 23 lines
tools/libxc/xc_sr_restore.c +7 -9
-        else
-        {
-            ERROR("Mandatory record %#x (%s) not handled",
-                  rec->type, rec_type_to_str(rec->type));
-            rc = -1;
-        }
-    }
-
      return rc;
  }
 
@@ -678,7 +665,20 @@ static int restore(struct xc_sr_context *ctx)
          else
          {
              rc = process_record(ctx, &rec);
-            if ( rc )
+            if ( rc == RECORD_NOT_PROCESSED )
+            {
+                if ( rec.type & REC_TYPE_OPTIONAL )
+                    DPRINTF("Ignoring optional record %#x (%s)",
+                            rec.type, rec_type_to_str(rec.type));
+                else
+                {

tools/libxc/xc_sr_restore.c static int restore(struct xc_sr_context *ctx) · line 684

Quoted 10 lines
tools/libxc/xc_sr_restore.c +7 -0
+                    ERROR("Mandatory record %#x (%s) not handled",
+                          rec.type, rec_type_to_str(rec.type));
+                    rc = -1;
+                    goto err;
+                }
+            }
+            else if ( rc )
                  goto err;
          }
 

.

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

Re: [PATCH v2 COLOPre 01/13] libxc/restore: fix error handle of process_record

Quoted 34 lines · Yang Hongyang
Quoted 22 lines · Andrew Cooper
Quoted 21 lines · Yang Hongyang

If the err is RECORD_NOT_PROCESSED, and it is an optional record, restore will still fail. The patch fix this.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Andrew Cooper <[email protected]>
---
  tools/libxc/xc_sr_restore.c | 28 ++++++++++++++--------------
  1 file changed, 14 insertions(+), 14 deletions(-)
tools/libxc/xc_sr_restore.c +0 -0
index 9e27dba..2d2edd3 100644
@@ -560,19 +560,6 @@ static int process_record(struct xc_sr_context
 *ctx, struct xc_sr_record *rec)
      free(rec->data);
      rec->data = NULL;
 
Quoted 8 lines

tools/libxc/xc_sr_restore.c static int process_record(struct xc_sr_context *ctx, struct xc_sr_record *rec) · line 567

Quoted 5 lines
tools/libxc/xc_sr_restore.c +0 -5
-    if ( rc == RECORD_NOT_PROCESSED )
-    {
-        if ( rec->type & REC_TYPE_OPTIONAL )
-            DPRINTF("Ignoring optional record %#x (%s)",
-                    rec->type, rec_type_to_str(rec->type));

You would be best setting rc to 0 here, rather than moving the logic out of process_record().

Quoted 7 lines

There will be another error type in COLO, which indicates a failover, that
needs to be handled in restore(), so I moved the error handling down to avoid duplex code...Otherwise, in process_record, RECORD_NOT_PROCESSED is handled, and in restore another error type returned from process_record is
handled...

Ah ok - I will wait till I get that far through the series.

~Andrew

Quoted 41 lines
Quoted 40 lines

~Andrew

Quoted 23 lines
tools/libxc/xc_sr_restore.c +7 -9
-        else
-        {
-            ERROR("Mandatory record %#x (%s) not handled",
-                  rec->type, rec_type_to_str(rec->type));
-            rc = -1;
-        }
-    }
-
      return rc;
  }
@@ -678,7 +665,20 @@ static int restore(struct xc_sr_context *ctx)
          else
          {
              rc = process_record(ctx, &rec);
-            if ( rc )
+            if ( rc == RECORD_NOT_PROCESSED )
+            {
+                if ( rec.type & REC_TYPE_OPTIONAL )
+                    DPRINTF("Ignoring optional record %#x (%s)",
+                            rec.type, rec_type_to_str(rec.type));
+                else
+                {

tools/libxc/xc_sr_restore.c static int restore(struct xc_sr_context *ctx) · line 684

Quoted 10 lines
tools/libxc/xc_sr_restore.c +7 -0
+                    ERROR("Mandatory record %#x (%s) not handled",
+                          rec.type, rec_type_to_str(rec.type));
+                    rc = -1;
+                    goto err;
+                }
+            }
+            else if ( rc )
                  goto err;
          }
 

.

#5 lore raw

Re: [PATCH v2 COLOPre 01/13] libxc/restore: fix error handle of process_record

In reply to Yang Hongyang
Quoted 2 lines · Yang Hongyang

If the err is RECORD_NOT_PROCESSED, and it is an optional record, restore will still fail. The patch fix this.

Whichever approach you take to fixing this, please say _how_ the change fixes it, it's not at all clear why moving this code should matter.

And if there is an ulterior motive behind the move, please say that too.

Quoted 56 lines
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Andrew Cooper <[email protected]>
---
 tools/libxc/xc_sr_restore.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
tools/libxc/xc_sr_restore.c +14 -14
index 9e27dba..2d2edd3 100644
@@ -560,19 +560,6 @@ static int process_record(struct xc_sr_context *ctx, struct xc_sr_record *rec)
     free(rec->data);
     rec->data = NULL;
 
-    if ( rc == RECORD_NOT_PROCESSED )
-    {
-        if ( rec->type & REC_TYPE_OPTIONAL )
-            DPRINTF("Ignoring optional record %#x (%s)",
-                    rec->type, rec_type_to_str(rec->type));
-        else
-        {
-            ERROR("Mandatory record %#x (%s) not handled",
-                  rec->type, rec_type_to_str(rec->type));
-            rc = -1;
-        }
-    }
-
     return rc;
 }
 
@@ -678,7 +665,20 @@ static int restore(struct xc_sr_context *ctx)
         else
         {
             rc = process_record(ctx, &rec);
-            if ( rc )
+            if ( rc == RECORD_NOT_PROCESSED )
+            {
+                if ( rec.type & REC_TYPE_OPTIONAL )
+                    DPRINTF("Ignoring optional record %#x (%s)",
+                            rec.type, rec_type_to_str(rec.type));
+                else
+                {
+                    ERROR("Mandatory record %#x (%s) not handled",
+                          rec.type, rec_type_to_str(rec.type));
+                    rc = -1;
+                    goto err;
+                }
+            }
+            else if ( rc )
                 goto err;
         }
 
#6 lore raw

Re: [PATCH v2 COLOPre 01/13] libxc/restore: fix error handle of process_record

Quoted 8 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang

If the err is RECORD_NOT_PROCESSED, and it is an optional record, restore will still fail. The patch fix this.

Whichever approach you take to fixing this, please say _how_ the change fixes it, it's not at all clear why moving this code should matter.

And if there is an ulterior motive behind the move, please say that too.

Okay, will describe this in the next version, thank you!

Quoted 61 lines
Quoted 47 lines
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Andrew Cooper <[email protected]>
---
  tools/libxc/xc_sr_restore.c | 28 ++++++++++++++--------------
  1 file changed, 14 insertions(+), 14 deletions(-)
tools/libxc/xc_sr_restore.c +7 -14
index 9e27dba..2d2edd3 100644
@@ -560,19 +560,6 @@ static int process_record(struct xc_sr_context *ctx, struct xc_sr_record *rec)
      free(rec->data);
      rec->data = NULL;
 
-    if ( rc == RECORD_NOT_PROCESSED )
-    {
-        if ( rec->type & REC_TYPE_OPTIONAL )
-            DPRINTF("Ignoring optional record %#x (%s)",
-                    rec->type, rec_type_to_str(rec->type));
-        else
-        {
-            ERROR("Mandatory record %#x (%s) not handled",
-                  rec->type, rec_type_to_str(rec->type));
-            rc = -1;
-        }
-    }
-
      return rc;
  }
 
@@ -678,7 +665,20 @@ static int restore(struct xc_sr_context *ctx)
          else
          {
              rc = process_record(ctx, &rec);
-            if ( rc )
+            if ( rc == RECORD_NOT_PROCESSED )
+            {
+                if ( rec.type & REC_TYPE_OPTIONAL )
+                    DPRINTF("Ignoring optional record %#x (%s)",
+                            rec.type, rec_type_to_str(rec.type));
+                else
+                {

tools/libxc/xc_sr_restore.c static int restore(struct xc_sr_context *ctx) · line 684

Quoted 10 lines
tools/libxc/xc_sr_restore.c +7 -0
+                    ERROR("Mandatory record %#x (%s) not handled",
+                          rec.type, rec_type_to_str(rec.type));
+                    rc = -1;
+                    goto err;
+                }
+            }
+            else if ( rc )
                  goto err;
          }
 

.

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

PATCH v2 2/13 tools/libxc: support to resume uncooperative HVM guests

In reply to Yang Hongyang

From: Wen Congyang <[email protected]>

For PVHVM, the hypercall return code is 0, and it can be resumed in a new domain context.
we suspend PVHVM and resume it is like this:
1. suspend it via evtchn
2. modifty the return code to 1
3. the guest know that the suspend is cancelled, we will use fast path to resume it.

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. We have updated the guest state, so we call it a new domain context.

For HVM, the hypercall is a NOP.

---
 tools/libxc/xc_resume.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
tools/libxc/xc_resume.c +18 -4
index e67bebd..bd82334 100644
@@ -109,6 +109,23 @@ 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;
+
+    /*
+     * If it is PVHVM, the hypercall return code is 0, because this
+     * is not a fast path resume, we do not modify_returncode as in
+     * xc_domain_resume_cooperative.
+     * (resuming it in a new domain context)
+     *
+     * If it is a HVM, the hypercall is a NOP.
+     */
+    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;
@@ -138,10 +155,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
1.9.1
#8 lore raw

Re: [PATCH v2 COLOPre 02/13] tools/libxc: support to resume uncooperative HVM guests

Quoted 10 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

For PVHVM, the hypercall return code is 0, and it can be resumed in a new domain context.
we suspend PVHVM and resume it is like this:
1. suspend it via evtchn
2. modifty the return code to 1
3. the guest know that the suspend is cancelled, we will use fast path to resume it.

Quoted 6 lines

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. We have updated the guest state, so we call it a new domain context.

For HVM, the hypercall is a NOP.

This doesn't match my reading of domain_resume on the Xen side, which is the ultimate effect of this hypercall. It seems to unpause the domain (and all vcpus) regardless of the domain type, including PVHVM vs HVM (which isn't something Xen is generally aware of anyway).

I also can't really follow the stuff about PVHVM vs HVM vs uncooperative guests, and I certainly can't see where the PVHVM vs HVM distinction is made in this patch.

Ian.

Quoted 47 lines
---
 tools/libxc/xc_resume.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
tools/libxc/xc_resume.c +18 -4
index e67bebd..bd82334 100644
@@ -109,6 +109,23 @@ 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;
+
+    /*
+     * If it is PVHVM, the hypercall return code is 0, because this
+     * is not a fast path resume, we do not modify_returncode as in
+     * xc_domain_resume_cooperative.
+     * (resuming it in a new domain context)
+     *
+     * If it is a HVM, the hypercall is a NOP.
+     */
+    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;
@@ -138,10 +155,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 )
     {
#9 lore raw

Re: [PATCH v2 COLOPre 02/13] tools/libxc: support to resume uncooperative HVM guests

Quoted 18 lines · Ian Campbell
Quoted 10 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

For PVHVM, the hypercall return code is 0, and it can be resumed in a new domain context.
we suspend PVHVM and resume it is like this:
1. suspend it via evtchn
2. modifty the return code to 1
3. the guest know that the suspend is cancelled, we will use fast path to resume it.

Quoted 6 lines

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. We have updated the guest state, so we call it a new domain context.

For HVM, the hypercall is a NOP.

Quoted 8 lines

This doesn't match my reading of domain_resume on the Xen side, which is the ultimate effect of this hypercall. It seems to unpause the domain (and all vcpus) regardless of the domain type, including PVHVM vs HVM (which isn't something Xen is generally aware of anyway).

I also can't really follow the stuff about PVHVM vs HVM vs uncooperative guests, and I certainly can't see where the PVHVM vs HVM distinction is made in this patch.

Sorry for my mistake. I read the codes again:

1. suspend
a. PVHVM and PV: we use the same way to suspend the guest(send the suspend
request to the guest)
b. pure HVM: we call xc_domain_shutdown(..., SHUTDOWN_suspend) to suspend
the guest
c. ???: suspending the guest via XenBus control node
I don't know we will goto c in which case.

2. Resume:
a. fast path
In this case, we don't change the guest's state.
PV: modify the return code to 1, and than call the domctl: XEN_DOMCTL_resumedomain
PVHVM: same with PV
HVM: do nothing in modify_returncode, and than call the domctl: XEN_DOMCTL_resumedomain
b. slow
In this case, we have changed the guest's state.
PV: update start info, and reset all secondary CPU states. Than call the
domctl: XEN_DOMCTL_resumedomain
PVHVM and HVM can not be resumed.

For PVHVM, in my test, only call the domctl: XEN_DOMCTL_resumedomain can work. I am not sure if we should update start info and reset all secondary CPU states.

For pure HVM guest, in my test, only call the domctl: XEN_DOMCTL_resumedomain can work.

So we can call libxl__domain_resume(..., 1) if we don't change the guest state, otherwise call libxl__domain_resume(..., 0).

Any suggestion is welcomed.

Thanks
Wen Congyang

Quoted 55 lines

Ian.

Quoted 37 lines
---
 tools/libxc/xc_resume.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
tools/libxc/xc_resume.c +17 -0
index e67bebd..bd82334 100644
@@ -109,6 +109,23 @@ 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;
+
+    /*
+     * If it is PVHVM, the hypercall return code is 0, because this
+     * is not a fast path resume, we do not modify_returncode as in
+     * xc_domain_resume_cooperative.
+     * (resuming it in a new domain context)
+     *
+     * If it is a HVM, the hypercall is a NOP.
+     */
+    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;
@@ -138,10 +155,7 @@ static int xc_domain_resume_any(xc_interface *xch, uint32_t domid)
      */

tools/libxc/xc_resume.c static int xc_domain_resume_any(xc_interface *xch, uint32_t domid) · line 161

Quoted 10 lines
tools/libxc/xc_resume.c +1 -4
 #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 )
     {

.

#10 lore raw

Re: [PATCH v2 COLOPre 02/13] tools/libxc: support to resume uncooperative HVM guests

Quoted 28 lines · Wen Congyang
Quoted 18 lines · Ian Campbell
Quoted 10 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

For PVHVM, the hypercall return code is 0, and it can be resumed in a new domain context.
we suspend PVHVM and resume it is like this:
1. suspend it via evtchn
2. modifty the return code to 1
3. the guest know that the suspend is cancelled, we will use fast path to resume it.

Quoted 6 lines

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. We have updated the guest state, so we call it a new domain context.

For HVM, the hypercall is a NOP.

Quoted 8 lines

This doesn't match my reading of domain_resume on the Xen side, which is the ultimate effect of this hypercall. It seems to unpause the domain (and all vcpus) regardless of the domain type, including PVHVM vs HVM (which isn't something Xen is generally aware of anyway).

I also can't really follow the stuff about PVHVM vs HVM vs uncooperative guests, and I certainly can't see where the PVHVM vs HVM distinction is made in this patch.

Quoted 8 lines

Sorry for my mistake. I read the codes again:

1. suspend
a. PVHVM and PV: we use the same way to suspend the guest(send the suspend
request to the guest)
b. pure HVM: we call xc_domain_shutdown(..., SHUTDOWN_suspend) to suspend
the guest
c. ???: suspending the guest via XenBus control node

AFAIK c is another option under a, it depends on whether the guest supports evtchn or not, if not then the xenstore variant will be used.

Quoted 86 lines

I don't know we will goto c in which case.

2. Resume:
a. fast path
In this case, we don't change the guest's state.
PV: modify the return code to 1, and than call the domctl: XEN_DOMCTL_resumedomain
PVHVM: same with PV
HVM: do nothing in modify_returncode, and than call the domctl: XEN_DOMCTL_resumedomain
b. slow
In this case, we have changed the guest's state.
PV: update start info, and reset all secondary CPU states. Than call the
domctl: XEN_DOMCTL_resumedomain
PVHVM and HVM can not be resumed.

For PVHVM, in my test, only call the domctl: XEN_DOMCTL_resumedomain can work. I am not sure if we should update start info and reset all secondary CPU states.

For pure HVM guest, in my test, only call the domctl: XEN_DOMCTL_resumedomain can work.

So we can call libxl__domain_resume(..., 1) if we don't change the guest state, otherwise call libxl__domain_resume(..., 0).

Any suggestion is welcomed.

Thanks
Wen Congyang

Quoted 55 lines

Ian.

Quoted 37 lines
---
 tools/libxc/xc_resume.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
tools/libxc/xc_resume.c +17 -0
index e67bebd..bd82334 100644
@@ -109,6 +109,23 @@ 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;
+
+    /*
+     * If it is PVHVM, the hypercall return code is 0, because this
+     * is not a fast path resume, we do not modify_returncode as in
+     * xc_domain_resume_cooperative.
+     * (resuming it in a new domain context)
+     *
+     * If it is a HVM, the hypercall is a NOP.
+     */
+    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;
@@ -138,10 +155,7 @@ static int xc_domain_resume_any(xc_interface *xch, uint32_t domid)
      */

tools/libxc/xc_resume.c static int xc_domain_resume_any(xc_interface *xch, uint32_t domid) · line 161

Quoted 10 lines
tools/libxc/xc_resume.c +1 -4
 #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 )
     {

.

#11 lore raw

Re: [PATCH v2 COLOPre 02/13] tools/libxc: support to resume uncooperative HVM guests

Quoted 38 lines · Ian Campbell
Quoted 28 lines · Wen Congyang
Quoted 18 lines · Ian Campbell
Quoted 10 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

For PVHVM, the hypercall return code is 0, and it can be resumed in a new domain context.
we suspend PVHVM and resume it is like this:
1. suspend it via evtchn
2. modifty the return code to 1
3. the guest know that the suspend is cancelled, we will use fast path to resume it.

Quoted 6 lines

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. We have updated the guest state, so we call it a new domain context.

For HVM, the hypercall is a NOP.

Quoted 8 lines

This doesn't match my reading of domain_resume on the Xen side, which is the ultimate effect of this hypercall. It seems to unpause the domain (and all vcpus) regardless of the domain type, including PVHVM vs HVM (which isn't something Xen is generally aware of anyway).

I also can't really follow the stuff about PVHVM vs HVM vs uncooperative guests, and I certainly can't see where the PVHVM vs HVM distinction is made in this patch.

Quoted 8 lines

Sorry for my mistake. I read the codes again:

1. suspend
a. PVHVM and PV: we use the same way to suspend the guest(send the suspend
request to the guest)
b. pure HVM: we call xc_domain_shutdown(..., SHUTDOWN_suspend) to suspend
the guest
c. ???: suspending the guest via XenBus control node

Quoted 2 lines

AFAIK c is another option under a, it depends on whether the guest supports evtchn or not, if not then the xenstore variant will be used.

I remember it now. IIRC, the behavior in the guest are the same. Is it right?

Thanks
Wen Congyang

Quoted 91 lines
Quoted 22 lines

I don't know we will goto c in which case.

2. Resume:
a. fast path
In this case, we don't change the guest's state.
PV: modify the return code to 1, and than call the domctl: XEN_DOMCTL_resumedomain
PVHVM: same with PV
HVM: do nothing in modify_returncode, and than call the domctl: XEN_DOMCTL_resumedomain
b. slow
In this case, we have changed the guest's state.
PV: update start info, and reset all secondary CPU states. Than call the
domctl: XEN_DOMCTL_resumedomain
PVHVM and HVM can not be resumed.

For PVHVM, in my test, only call the domctl: XEN_DOMCTL_resumedomain can work. I am not sure if we should update start info and reset all secondary CPU states.

For pure HVM guest, in my test, only call the domctl: XEN_DOMCTL_resumedomain can work.

Quoted 65 lines

So we can call libxl__domain_resume(..., 1) if we don't change the guest state, otherwise call libxl__domain_resume(..., 0).

Any suggestion is welcomed.

Thanks
Wen Congyang

Quoted 55 lines

Ian.

Quoted 37 lines
---
 tools/libxc/xc_resume.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
tools/libxc/xc_resume.c +17 -0
index e67bebd..bd82334 100644
@@ -109,6 +109,23 @@ 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;
+
+    /*
+     * If it is PVHVM, the hypercall return code is 0, because this
+     * is not a fast path resume, we do not modify_returncode as in
+     * xc_domain_resume_cooperative.
+     * (resuming it in a new domain context)
+     *
+     * If it is a HVM, the hypercall is a NOP.
+     */
+    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;
@@ -138,10 +155,7 @@ static int xc_domain_resume_any(xc_interface *xch, uint32_t domid)
      */

tools/libxc/xc_resume.c static int xc_domain_resume_any(xc_interface *xch, uint32_t domid) · line 161

Quoted 10 lines
tools/libxc/xc_resume.c +1 -4
 #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 )
     {

.

.

#12 lore raw

Re: [PATCH v2 COLOPre 02/13] tools/libxc: support to resume uncooperative HVM guests

Quoted 39 lines · Wen Congyang
Quoted 38 lines · Ian Campbell
Quoted 36 lines · Wen Congyang
Quoted 18 lines · Ian Campbell
Quoted 10 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

For PVHVM, the hypercall return code is 0, and it can be resumed in a new domain context.
we suspend PVHVM and resume it is like this:
1. suspend it via evtchn
2. modifty the return code to 1
3. the guest know that the suspend is cancelled, we will use fast path to resume it.

Quoted 6 lines

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. We have updated the guest state, so we call it a new domain context.

For HVM, the hypercall is a NOP.

Quoted 8 lines

This doesn't match my reading of domain_resume on the Xen side, which is the ultimate effect of this hypercall. It seems to unpause the domain (and all vcpus) regardless of the domain type, including PVHVM vs HVM (which isn't something Xen is generally aware of anyway).

I also can't really follow the stuff about PVHVM vs HVM vs uncooperative guests, and I certainly can't see where the PVHVM vs HVM distinction is made in this patch.

Sorry for my mistake. I read the codes again:

1. suspend
a. PVHVM and PV: we use the same way to suspend the guest(send the suspend
request to the guest)
b. pure HVM: we call xc_domain_shutdown(..., SHUTDOWN_suspend) to suspend
the guest
c. ???: suspending the guest via XenBus control node

Quoted 4 lines
Quoted 2 lines

AFAIK c is another option under a, it depends on whether the guest supports evtchn or not, if not then the xenstore variant will be used.

I remember it now. IIRC, the behavior in the guest are the same. Is it right?

I _think_ so, but I don't know for sure, you'd have to check.

#13 lore raw

PATCH v2 3/13 libxc/restore: zero ioreq page only one time

In reply to Yang Hongyang

ioreq page contains evtchn which will be set when we resume the secondary vm the first time. The hypervisor will check if the evtchn is corrupted, so we cannot zero the ioreq page more than one time.

The ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, so it is OK if we only zero it one time.

---
 tools/libxc/xc_sr_restore_x86_hvm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/libxc/xc_sr_restore_x86_hvm.c +2 -1
index 6f5af0e..06177e0 100644
@@ -78,7 +78,8 @@ static int handle_hvm_params(struct xc_sr_context *ctx,
             break;
         case HVM_PARAM_IOREQ_PFN:
         case HVM_PARAM_BUFIOREQ_PFN:
-            xc_clear_domain_page(xch, ctx->domid, entry->value);
+            if ( !ctx->restore.buffer_all_records )
+                xc_clear_domain_page(xch, ctx->domid, entry->value);
             break;
         }
 
Signature · 1 line
1.9.1
#14 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 11 lines · Yang Hongyang

ioreq page contains evtchn which will be set when we resume the secondary vm the first time. The hypervisor will check if the evtchn is corrupted, so we cannot zero the ioreq page more than one time.

The ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, so it is OK if we only zero it one time.

The issue here is that we are running the restore algorithm over a domain which has already been running in Xen for a while. This is a brand new usecase, as far as I am aware.

Does the qemu process associated with this domain get frozen while the secondary is being reset, or does the process get destroyed and recreated.

I have a gut feeling that it would be safer to clear all of the page other than the event channel, but that depends on exactly what else is going on. We absolutely don't want to do is have an update to this page from the primary with an in-progress IOREQ.

~Andrew

Quoted 18 lines
---
 tools/libxc/xc_sr_restore_x86_hvm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/libxc/xc_sr_restore_x86_hvm.c +2 -1
index 6f5af0e..06177e0 100644
@@ -78,7 +78,8 @@ static int handle_hvm_params(struct xc_sr_context *ctx,
             break;
         case HVM_PARAM_IOREQ_PFN:
         case HVM_PARAM_BUFIOREQ_PFN:
-            xc_clear_domain_page(xch, ctx->domid, entry->value);
+            if ( !ctx->restore.buffer_all_records )
+                xc_clear_domain_page(xch, ctx->domid, entry->value);
             break;
         }
 
#15 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 16 lines · Andrew Cooper
Quoted 11 lines · Yang Hongyang

ioreq page contains evtchn which will be set when we resume the secondary vm the first time. The hypervisor will check if the evtchn is corrupted, so we cannot zero the ioreq page more than one time.

The ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, so it is OK if we only zero it one time.

The issue here is that we are running the restore algorithm over a domain which has already been running in Xen for a while. This is a brand new usecase, as far as I am aware.

Quoted 7 lines

Does the qemu process associated with this domain get frozen while the secondary is being reset, or does the process get destroyed and recreated.

I have a gut feeling that it would be safer to clear all of the page other than the event channel, but that depends on exactly what else is going on. We absolutely don't want to do is have an update to this page from the primary with an in-progress IOREQ.

Or actually worse, an update from the primary with a different event channel in it. There is no requirement or guarantee that the bufioreq event channels are the same on either side.

~Andrew

#16 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

In reply to Andrew Cooper
Quoted 9 lines · Andrew Cooper
Quoted 8 lines · Yang Hongyang

ioreq page contains evtchn which will be set when we resume the secondary vm the first time. The hypervisor will check if the evtchn is corrupted, so we cannot zero the ioreq page more than one time.

The ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, so it is OK if we only zero it one time.

Quoted 7 lines
Quoted 3 lines

The issue here is that we are running the restore algorithm over a domain which has already been running in Xen for a while. This is a brand new usecase, as far as I am aware.

Exactly.

Quoted 3 lines

Does the qemu process associated with this domain get frozen while the secondary is being reset, or does the process get destroyed and recreated.

What do you mean by reset? do you mean secondary is suspended at checkpoint?

Quoted 29 lines

I have a gut feeling that it would be safer to clear all of the page other than the event channel, but that depends on exactly what else is going on. We absolutely don't want to do is have an update to this page from the primary with an in-progress IOREQ.

~Andrew

Quoted 9 lines
---
  tools/libxc/xc_sr_restore_x86_hvm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
tools/libxc/xc_sr_restore_x86_hvm.c +0 -0
index 6f5af0e..06177e0 100644

tools/libxc/xc_sr_restore_x86_hvm.c static int handle_hvm_params(struct xc_sr_context *ctx, · line 85

Quoted 9 lines
tools/libxc/xc_sr_restore_x86_hvm.c +2 -1
@@ -78,7 +78,8 @@ static int handle_hvm_params(struct xc_sr_context *ctx,
              break;
          case HVM_PARAM_IOREQ_PFN:
          case HVM_PARAM_BUFIOREQ_PFN:
-            xc_clear_domain_page(xch, ctx->domid, entry->value);
+            if ( !ctx->restore.buffer_all_records )
+                xc_clear_domain_page(xch, ctx->domid, entry->value);
              break;
          }
 

.

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

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 23 lines · Yang Hongyang
Quoted 9 lines · Andrew Cooper
Quoted 8 lines · Yang Hongyang

ioreq page contains evtchn which will be set when we resume the secondary vm the first time. The hypervisor will check if the evtchn is corrupted, so we cannot zero the ioreq page more than one time.

The ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, so it is OK if we only zero it one time.

Quoted 7 lines
Quoted 3 lines

The issue here is that we are running the restore algorithm over a domain which has already been running in Xen for a while. This is a brand new usecase, as far as I am aware.

Exactly.

Quoted 1 line
Quoted 6 lines
Quoted 3 lines

Does the qemu process associated with this domain get frozen while the secondary is being reset, or does the process get destroyed and recreated.

What do you mean by reset? do you mean secondary is suspended at checkpoint?

Well - at the point that the buffered records are being processed, we are in the process of resetting the state of the secondary to match the primary.

~Andrew

Quoted 33 lines
Quoted 32 lines

I have a gut feeling that it would be safer to clear all of the page other than the event channel, but that depends on exactly what else is going on. We absolutely don't want to do is have an update to this page from the primary with an in-progress IOREQ.

~Andrew

Quoted 11 lines
---
  tools/libxc/xc_sr_restore_x86_hvm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
tools/libxc/xc_sr_restore_x86_hvm.c +0 -0
index 6f5af0e..06177e0 100644

tools/libxc/xc_sr_restore_x86_hvm.c static int handle_hvm_params(struct xc_sr_context · line 85

Quoted 9 lines
tools/libxc/xc_sr_restore_x86_hvm.c +2 -1
@@ -78,7 +78,8 @@ static int handle_hvm_params(struct xc_sr_context
 *ctx,
              break;
          case HVM_PARAM_IOREQ_PFN:
          case HVM_PARAM_BUFIOREQ_PFN:
-            xc_clear_domain_page(xch, ctx->domid, entry->value);
+            if ( !ctx->restore.buffer_all_records )
+                xc_clear_domain_page(xch, ctx->domid, entry->value);
              break;
          }

.

#18 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 28 lines · Andrew Cooper
Quoted 27 lines · Yang Hongyang
Quoted 9 lines · Andrew Cooper
Quoted 8 lines · Yang Hongyang

ioreq page contains evtchn which will be set when we resume the secondary vm the first time. The hypervisor will check if the evtchn is corrupted, so we cannot zero the ioreq page more than one time.

The ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, so it is OK if we only zero it one time.

Quoted 7 lines
Quoted 3 lines

The issue here is that we are running the restore algorithm over a domain which has already been running in Xen for a while. This is a brand new usecase, as far as I am aware.

Exactly.

Quoted 4 lines

Does the qemu process associated with this domain get frozen while the secondary is being reset, or does the process get destroyed and recreated.

Quoted 6 lines
Quoted 2 lines

What do you mean by reset? do you mean secondary is suspended at checkpoint?

Well - at the point that the buffered records are being processed, we are in the process of resetting the state of the secondary to match the primary.

Yes, at this point, the qemu process associated with this domain is frozen. the suspend callback will call libxl__qmp_stop(vm_stop() in qemu) to pause qemu. After we processed all records, qemu will be restored with the received state, that's why we add a libxl__qmp_restore(qemu_load_vmstate() in qemu) api to restore qemu with received state. Currently in libxl, qemu only start with the received state, there's no api to load received state while qemu is running for a while.

Quoted 39 lines

~Andrew

Quoted 24 lines
Quoted 24 lines

I have a gut feeling that it would be safer to clear all of the page other than the event channel, but that depends on exactly what else is going on. We absolutely don't want to do is have an update to this page from the primary with an in-progress IOREQ.

~Andrew

Quoted 15 lines
---
   tools/libxc/xc_sr_restore_x86_hvm.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
tools/libxc/xc_sr_restore_x86_hvm.c +0 -1
index 6f5af0e..06177e0 100644
@@ -78,7 +78,8 @@ static int handle_hvm_params(struct xc_sr_context
 *ctx,
               break;
           case HVM_PARAM_IOREQ_PFN:
           case HVM_PARAM_BUFIOREQ_PFN:
-            xc_clear_domain_page(xch, ctx->domid, entry->value);
Quoted 9 lines
Quoted 8 lines

tools/libxc/xc_sr_restore_x86_hvm.c static int handle_hvm_params(struct xc_sr_context *ctx, · line 84

Quoted 5 lines
tools/libxc/xc_sr_restore_x86_hvm.c +2 -0
+            if ( !ctx->restore.buffer_all_records )
+                xc_clear_domain_page(xch, ctx->domid, entry->value);
               break;
           }

.

.

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

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 38 lines · Yang Hongyang
Quoted 28 lines · Andrew Cooper
Quoted 27 lines · Yang Hongyang
Quoted 9 lines · Andrew Cooper
Quoted 8 lines · Yang Hongyang

ioreq page contains evtchn which will be set when we resume the secondary vm the first time. The hypervisor will check if the evtchn is corrupted, so we cannot zero the ioreq page more than one time.

The ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, so it is OK if we only zero it one time.

Quoted 7 lines
Quoted 3 lines

The issue here is that we are running the restore algorithm over a domain which has already been running in Xen for a while. This is a brand new usecase, as far as I am aware.

Exactly.

Quoted 4 lines

Does the qemu process associated with this domain get frozen while the secondary is being reset, or does the process get destroyed and recreated.

Quoted 6 lines
Quoted 2 lines

What do you mean by reset? do you mean secondary is suspended at checkpoint?

Well - at the point that the buffered records are being processed, we are in the process of resetting the state of the secondary to match the primary.

Quoted 13 lines

Yes, at this point, the qemu process associated with this domain is frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in qemu) to pause
qemu. After we processed all records, qemu will be restored with the received
state, that's why we add a libxl__qmp_restore(qemu_load_vmstate() in qemu)
api to restore qemu with received state. Currently in libxl, qemu only start
with the received state, there's no api to load received state while qemu is
running for a while.

Now I consider this more, it is absolutely wrong to not zero the page here. The event channel in the page is not guaranteed to be the same between the primary and secondary, and we don't want to unexpectedly find a pending/in-flight ioreq.

Either qemu needs to take care of re-initialising the event channels back to appropriate values, or Xen should tolerate the channels disappearing.

~Andrew

#20 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 53 lines · Andrew Cooper
Quoted 38 lines · Yang Hongyang
Quoted 28 lines · Andrew Cooper
Quoted 27 lines · Yang Hongyang
Quoted 9 lines · Andrew Cooper
Quoted 8 lines · Yang Hongyang

ioreq page contains evtchn which will be set when we resume the secondary vm the first time. The hypervisor will check if the evtchn is corrupted, so we cannot zero the ioreq page more than one time.

The ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, so it is OK if we only zero it one time.

Quoted 7 lines
Quoted 3 lines

The issue here is that we are running the restore algorithm over a domain which has already been running in Xen for a while. This is a brand new usecase, as far as I am aware.

Exactly.

Quoted 4 lines

Does the qemu process associated with this domain get frozen while the secondary is being reset, or does the process get destroyed and recreated.

Quoted 6 lines
Quoted 2 lines

What do you mean by reset? do you mean secondary is suspended at checkpoint?

Well - at the point that the buffered records are being processed, we are in the process of resetting the state of the secondary to match the primary.

Quoted 13 lines

Yes, at this point, the qemu process associated with this domain is frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in qemu) to pause
qemu. After we processed all records, qemu will be restored with the received
state, that's why we add a libxl__qmp_restore(qemu_load_vmstate() in qemu)
api to restore qemu with received state. Currently in libxl, qemu only start
with the received state, there's no api to load received state while qemu is
running for a while.

Quoted 3 lines

Now I consider this more, it is absolutely wrong to not zero the page here. The event channel in the page is not guaranteed to be the same between the primary and secondary,

That's why we don't zero it on secondary.

Quoted 2 lines

and we don't want to unexpectedly
find a pending/in-flight ioreq.

ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, there should be no pending/in-flight ioreq at checkpoint.

Quoted 8 lines

Either qemu needs to take care of re-initialising the event channels back to appropriate values, or Xen should tolerate the channels disappearing.

~Andrew
.

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

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 58 lines · Yang Hongyang
Quoted 55 lines · Andrew Cooper
Quoted 53 lines · Yang Hongyang
Quoted 29 lines · Andrew Cooper
Quoted 28 lines · Yang Hongyang
Quoted 9 lines · Andrew Cooper
Quoted 8 lines · Yang Hongyang

ioreq page contains evtchn which will be set when we resume the secondary vm the first time. The hypervisor will check if the evtchn is corrupted, so we cannot zero the ioreq page more than one time.

The ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, so it is OK if we only zero it one time.

Quoted 7 lines
Quoted 3 lines

The issue here is that we are running the restore algorithm over a domain which has already been running in Xen for a while. This is a brand new usecase, as far as I am aware.

Exactly.

Quoted 5 lines

Does the qemu process associated with this domain get frozen while the
secondary is being reset, or does the process get destroyed and recreated.

Quoted 7 lines
Quoted 2 lines

What do you mean by reset? do you mean secondary is suspended at checkpoint?

Well - at the point that the buffered records are being processed, we are in the process of resetting the state of the secondary to match the
primary.

Yes, at this point, the qemu process associated with this domain is frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in qemu) to pause
qemu. After we processed all records, qemu will be restored with the received
state, that's why we add a libxl__qmp_restore(qemu_load_vmstate() in qemu)
api to restore qemu with received state. Currently in libxl, qemu only start
with the received state, there's no api to load received state while qemu is
running for a while.

Quoted 5 lines
Quoted 3 lines

Now I consider this more, it is absolutely wrong to not zero the page here. The event channel in the page is not guaranteed to be the same between the primary and secondary,

That's why we don't zero it on secondary.

I think you missed my point. Apologies for the double negative. It
must, under all circumstances, be zeroed at this point, for safety reasons.

The page in question is subject to logdirty just like any other guest pages, which means that if the guest writes to it naturally (i.e. not a Xen or Qemu write, both of whom have magic mappings which are not subject to logdirty), it will be transmitted in the stream. As the event channel could be different, the lack of zeroing it at this point means that the event channel would be wrong as opposed to simply missing. This is a worse position to be in.

Quoted 6 lines
Quoted 3 lines

and we don't want to unexpectedly
find a pending/in-flight ioreq.

ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, there should be no pending/in-flight ioreq at checkpoint.

In the common case perhaps, but we must consider the exceptional case. The exceptional case here is some corruption which happens to appear as an in-flight ioreq.

Quoted 5 lines
Quoted 5 lines

Either qemu needs to take care of re-initialising the event channels back to appropriate values, or Xen should tolerate the channels disappearing.

I still stand by this statement. I believe it is the only safe way of solving the issue you have discovered.

~Andrew

#22 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Cc Paul Durrant
Quoted 68 lines · Andrew Cooper
Quoted 58 lines · Yang Hongyang
Quoted 55 lines · Andrew Cooper
Quoted 53 lines · Yang Hongyang
Quoted 29 lines · Andrew Cooper
Quoted 28 lines · Yang Hongyang
Quoted 9 lines · Andrew Cooper
Quoted 8 lines · Yang Hongyang

ioreq page contains evtchn which will be set when we resume the secondary vm the first time. The hypervisor will check if the evtchn is corrupted, so we cannot zero the ioreq page more than one time.

The ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, so it is OK if we only zero it one time.

Quoted 7 lines
Quoted 3 lines

The issue here is that we are running the restore algorithm over a domain which has already been running in Xen for a while. This is a brand new usecase, as far as I am aware.

Exactly.

Quoted 5 lines

Does the qemu process associated with this domain get frozen while the
secondary is being reset, or does the process get destroyed and recreated.

Quoted 7 lines
Quoted 2 lines

What do you mean by reset? do you mean secondary is suspended at checkpoint?

Well - at the point that the buffered records are being processed, we are in the process of resetting the state of the secondary to match the
primary.

Yes, at this point, the qemu process associated with this domain is frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in qemu) to pause
qemu. After we processed all records, qemu will be restored with the received
state, that's why we add a libxl__qmp_restore(qemu_load_vmstate() in qemu)
api to restore qemu with received state. Currently in libxl, qemu only start
with the received state, there's no api to load received state while qemu is
running for a while.

Quoted 5 lines
Quoted 3 lines

Now I consider this more, it is absolutely wrong to not zero the page here. The event channel in the page is not guaranteed to be the same between the primary and secondary,

That's why we don't zero it on secondary.

I think you missed my point. Apologies for the double negative. It
must, under all circumstances, be zeroed at this point, for safety reasons.

Quoted 7 lines

The page in question is subject to logdirty just like any other guest pages, which means that if the guest writes to it naturally (i.e. not a Xen or Qemu write, both of whom have magic mappings which are not subject to logdirty), it will be transmitted in the stream. As the event channel could be different, the lack of zeroing it at this point means that the event channel would be wrong as opposed to simply missing. This is a worse position to be in.

The guest should not access this page. I am not sure if the guest can access the ioreq page.

But in the exceptional case, the ioreq page is dirtied, and is copied to the secondary vm. The ioreq page will contain a wrong event channel, the hypervisor will check it: if the event channel is wrong, the guest will be crashed.

Quoted 11 lines
Quoted 7 lines
Quoted 4 lines

and we don't want to unexpectedly
find a pending/in-flight ioreq.

ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, there should be no pending/in-flight ioreq at checkpoint.

In the common case perhaps, but we must consider the exceptional case. The exceptional case here is some corruption which happens to appear as an in-flight ioreq.

If the state is STATE_IOREQ_NONE, it may be hypervisor's bug. If the hypervisor has a bug, anything can happen. I think we should trust the hypervisor.

Quoted 9 lines
Quoted 6 lines
Quoted 6 lines

Either qemu needs to take care of re-initialising the event channels back to appropriate values, or Xen should tolerate the channels disappearing.

I still stand by this statement. I believe it is the only safe way of solving the issue you have discovered.

Add a new qemu monitor command to update ioreq page?

Thanks
Wen Congyang

Quoted 4 lines

~Andrew
.

#23 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 66 lines · Wen Congyang
Cc Paul Durrant
Quoted 56 lines · Andrew Cooper
Quoted 48 lines · Yang Hongyang
Quoted 46 lines · Andrew Cooper
Quoted 45 lines · Yang Hongyang
Quoted 24 lines · Andrew Cooper
Quoted 23 lines · Yang Hongyang
Quoted 9 lines · Andrew Cooper
Quoted 8 lines · Yang Hongyang

ioreq page contains evtchn which will be set when we resume the secondary vm the first time. The hypervisor will check if the evtchn is corrupted, so we cannot zero the ioreq page more than one time.

The ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, so it is OK if we only zero it one time.

Quoted 6 lines
Quoted 3 lines

The issue here is that we are running the restore algorithm over a domain which has already been running in Xen for a while. This is a brand new usecase, as far as I am aware.

Exactly.

Quoted 4 lines

Does the qemu process associated with this domain get frozen while the
secondary is being reset, or does the process get destroyed and recreated.

Quoted 6 lines
Quoted 2 lines

What do you mean by reset? do you mean secondary is suspended at checkpoint?

Well - at the point that the buffered records are being processed, we are in the process of resetting the state of the secondary to match the
primary.

Yes, at this point, the qemu process associated with this domain is frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in qemu) to pause
qemu. After we processed all records, qemu will be restored with the received
state, that's why we add a libxl__qmp_restore(qemu_load_vmstate() in qemu)
api to restore qemu with received state. Currently in libxl, qemu only start
with the received state, there's no api to load received state while qemu is
running for a while.

Quoted 4 lines
Quoted 3 lines

Now I consider this more, it is absolutely wrong to not zero the page here. The event channel in the page is not guaranteed to be the same between the primary and secondary,

That's why we don't zero it on secondary.

I think you missed my point. Apologies for the double negative. It
must, under all circumstances, be zeroed at this point, for safety reasons.

Quoted 7 lines

The page in question is subject to logdirty just like any other guest pages, which means that if the guest writes to it naturally (i.e. not a Xen or Qemu write, both of whom have magic mappings which are not subject to logdirty), it will be transmitted in the stream. As the event channel could be different, the lack of zeroing it at this point means that the event channel would be wrong as opposed to simply missing. This is a worse position to be in.

Quoted 2 lines

The guest should not access this page. I am not sure if the guest can access the ioreq page.

"should not" and "can't" are two very different things. We have had XSAs covering the fact that the guest can write to these pages in the past.

In practice, a guest can't actually query the appropriate hvmparam, but it can rely on the fact that the domain builder is incredibly predictable in this regard.

Quoted 5 lines

But in the exceptional case, the ioreq page is dirtied, and is copied to the secondary vm. The ioreq page will contain a wrong event channel, the hypervisor will check it: if the event channel is wrong, the guest will be crashed.

This is my point. It is completely legitimate for the event channels to be different between the primary and secondary, which means that we should be capable of dealing cleanly with the fallout when the bufioreq page does appear as dirty update.

Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

and we don't want to unexpectedly
find a pending/in-flight ioreq.

ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, there should be no pending/in-flight ioreq at checkpoint.

In the common case perhaps, but we must consider the exceptional case. The exceptional case here is some corruption which happens to appear as an in-flight ioreq.

If the state is STATE_IOREQ_NONE, it may be hypervisor's bug. If the hypervisor has a bug, anything can happen. I think we should trust the hypervisor.

In the worst case, the contents of the pages can be completely arbitrary. Zeroing of the pages is to cover the case where there is junk present, so Xen doesn't crash the guest due to a bad ioreq state.

I think Xen's behaviour is legitimate here. If it observes wonky ioreq state, all bets are off.

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

Either qemu needs to take care of re-initialising the event channels back to appropriate values, or Xen should tolerate the channels disappearing.

I still stand by this statement. I believe it is the only safe way of solving the issue you have discovered.

Add a new qemu monitor command to update ioreq page?

Who/what actually complains about the event channel? I can't see any event channels in the ABI for the pages.

~Andrew

#24 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 126 lines

-----Original Message-----
From: Andrew Cooper [mailto:[email protected]]
Sent: 10 June 2015 11:08
To: Wen Congyang; Yang Hongyang; [email protected]; Paul Durrant
Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 14 lines · Wen Congyang
Cc Paul Durrant
Quoted 11 lines · Andrew Cooper
Quoted 10 lines · Yang Hongyang
Quoted 8 lines · Andrew Cooper
Quoted 7 lines · Yang Hongyang
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Yang Hongyang
Quoted 2 lines · Andrew Cooper
Quoted 1 line · Yang Hongyang

ioreq page contains evtchn which will be set when we resume

the

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

secondary vm the first time. The hypervisor will check if the evtchn is corrupted, so we cannot zero the ioreq page more than one time.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

The ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, so it is OK if we only zero it one time.

The issue here is that we are running the restore algorithm over a domain which has already been running in Xen for a while. This is

a

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line

brand new usecase, as far as I am aware.

Exactly.

Quoted 4 lines

Does the qemu process associated with this domain get frozen while the
secondary is being reset, or does the process get destroyed and recreated.

What do you mean by reset? do you mean secondary is suspended

at

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

checkpoint?

Well - at the point that the buffered records are being processed,

we

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 3 lines

are in the process of resetting the state of the secondary to match the
primary.

Yes, at this point, the qemu process associated with this domain is frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in qemu) to pause
qemu. After we processed all records, qemu will be restored with the received
state, that's why we add a libxl__qmp_restore(qemu_load_vmstate()

in

Quoted 20 lines
Quoted 13 lines
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines

qemu)
api to restore qemu with received state. Currently in libxl, qemu only start
with the received state, there's no api to load received state while qemu is
running for a while.

Now I consider this more, it is absolutely wrong to not zero the page here. The event channel in the page is not guaranteed to be the same between the primary and secondary,

That's why we don't zero it on secondary.

I think you missed my point. Apologies for the double negative. It
must, under all circumstances, be zeroed at this point, for safety reasons.

Quoted 7 lines

The page in question is subject to logdirty just like any other guest pages, which means that if the guest writes to it naturally (i.e. not a Xen or Qemu write, both of whom have magic mappings which are not subject to logdirty), it will be transmitted in the stream. As the event channel could be different, the lack of zeroing it at this point means that the event channel would be wrong as opposed to simply missing. This is a worse position to be in.

Quoted 2 lines

The guest should not access this page. I am not sure if the guest can access the ioreq page.

"should not" and "can't" are two very different things. We have had XSAs covering the fact that the guest can write to these pages in the past.

In practice, a guest can't actually query the appropriate hvmparam, but it can rely on the fact that the domain builder is incredibly predictable in this regard.

Quoted 5 lines

But in the exceptional case, the ioreq page is dirtied, and is copied to the secondary vm. The ioreq page will contain a wrong event channel, the hypervisor will check it: if the event channel is wrong, the guest will be crashed.

This is my point. It is completely legitimate for the event channels to be different between the primary and secondary, which means that we should be capable of dealing cleanly with the fallout when the bufioreq page does appear as dirty update.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

and we don't want to unexpectedly
find a pending/in-flight ioreq.

ioreq->state is always STATE_IOREQ_NONE after the vm is suspended,

there

Quoted 5 lines
Quoted 4 lines
Quoted 1 line

should be no pending/in-flight ioreq at checkpoint.

In the common case perhaps, but we must consider the exceptional case. The exceptional case here is some corruption which happens to appear as an in-flight ioreq.

If the state is STATE_IOREQ_NONE, it may be hypervisor's bug. If the

hypervisor

Quoted 1 line

has a bug, anything can happen. I think we should trust the hypervisor.

In the worst case, the contents of the pages can be completely arbitrary. Zeroing of the pages is to cover the case where there is junk present, so Xen doesn't crash the guest due to a bad ioreq state.

I think Xen's behaviour is legitimate here. If it observes wonky ioreq state, all bets are off.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Either qemu needs to take care of re-initialising the event channels back to appropriate values, or Xen should tolerate the channels disappearing.

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

I still stand by this statement. I believe it is the only safe way of solving the issue you have discovered.

Add a new qemu monitor command to update ioreq page?

Who/what actually complains about the event channel? I can't see any event channels in the ABI for the pages.

QEMU only samples the event channels from the shared ioreq page on startup as it does not expect them to change in its lifetime.

Paul

Quoted 1 line

~Andrew

#25 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

In reply to Wen Congyang
Quoted 118 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 10:06
To: Andrew Cooper; Yang Hongyang; [email protected]; Paul Durrant
Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Cc Paul Durrant
Quoted 32 lines · Andrew Cooper
Quoted 31 lines · Yang Hongyang
Quoted 28 lines · Andrew Cooper
Quoted 27 lines · Yang Hongyang
Quoted 24 lines · Andrew Cooper
Quoted 23 lines · Yang Hongyang
Quoted 9 lines · Andrew Cooper
Quoted 8 lines · Yang Hongyang

ioreq page contains evtchn which will be set when we resume the secondary vm the first time. The hypervisor will check if the evtchn is corrupted, so we cannot zero the ioreq page more than one time.

The ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, so it is OK if we only zero it one time.

Quoted 7 lines
Quoted 3 lines

The issue here is that we are running the restore algorithm over a domain which has already been running in Xen for a while. This is a brand new usecase, as far as I am aware.

Exactly.

Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

Does the qemu process associated with this domain get frozen while the
secondary is being reset, or does the process get destroyed and recreated.

What do you mean by reset? do you mean secondary is suspended

at

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 1 line

checkpoint?

Well - at the point that the buffered records are being processed, we are in the process of resetting the state of the secondary to match the
primary.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Yes, at this point, the qemu process associated with this domain is frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in qemu) to pause
qemu. After we processed all records, qemu will be restored with the received
state, that's why we add a libxl__qmp_restore(qemu_load_vmstate()

in

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

qemu)
api to restore qemu with received state. Currently in libxl, qemu only start
with the received state, there's no api to load received state while qemu is
running for a while.

Quoted 5 lines
Quoted 3 lines

Now I consider this more, it is absolutely wrong to not zero the page here. The event channel in the page is not guaranteed to be the same between the primary and secondary,

That's why we don't zero it on secondary.

I think you missed my point. Apologies for the double negative. It
must, under all circumstances, be zeroed at this point, for safety reasons.

Quoted 7 lines

The page in question is subject to logdirty just like any other guest pages, which means that if the guest writes to it naturally (i.e. not a Xen or Qemu write, both of whom have magic mappings which are not subject to logdirty), it will be transmitted in the stream. As the event channel could be different, the lack of zeroing it at this point means that the event channel would be wrong as opposed to simply missing. This is a worse position to be in.

The guest should not access this page. I am not sure if the guest can access the ioreq page.

But in the exceptional case, the ioreq page is dirtied, and is copied to the secondary vm. The ioreq page will contain a wrong event channel, the hypervisor will check it: if the event channel is wrong, the guest will be crashed.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

and we don't want to unexpectedly
find a pending/in-flight ioreq.

ioreq->state is always STATE_IOREQ_NONE after the vm is suspended,

there

Quoted 5 lines
Quoted 1 line

should be no pending/in-flight ioreq at checkpoint.

In the common case perhaps, but we must consider the exceptional case. The exceptional case here is some corruption which happens to appear as an in-flight ioreq.

If the state is STATE_IOREQ_NONE, it may be hypervisor's bug. If the hypervisor
has a bug, anything can happen. I think we should trust the hypervisor.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

Either qemu needs to take care of re-initialising the event channels back to appropriate values, or Xen should tolerate the channels disappearing.

I still stand by this statement. I believe it is the only safe way of solving the issue you have discovered.

Add a new qemu monitor command to update ioreq page?

If you're attaching to a 'new' VM (i.e one with an updated image) then I suspect you're going to have to destroy and re-create the ioreq server so that the shared page gets re-populated with the correct event channels. Either that or you're going to have to ensure that the page is not part of restored image and sample the new one that Xen should have set up.

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

~Andrew
.

#26 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 122 lines · Paul Durrant
Quoted 122 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 10:06
To: Andrew Cooper; Yang Hongyang; [email protected]; Paul Durrant
Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Cc Paul Durrant
Quoted 32 lines · Andrew Cooper
Quoted 31 lines · Yang Hongyang
Quoted 28 lines · Andrew Cooper
Quoted 27 lines · Yang Hongyang
Quoted 24 lines · Andrew Cooper
Quoted 23 lines · Yang Hongyang
Quoted 9 lines · Andrew Cooper
Quoted 8 lines · Yang Hongyang

ioreq page contains evtchn which will be set when we resume the secondary vm the first time. The hypervisor will check if the evtchn is corrupted, so we cannot zero the ioreq page more than one time.

The ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, so it is OK if we only zero it one time.

Quoted 7 lines
Quoted 3 lines

The issue here is that we are running the restore algorithm over a domain which has already been running in Xen for a while. This is a brand new usecase, as far as I am aware.

Exactly.

Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

Does the qemu process associated with this domain get frozen while the
secondary is being reset, or does the process get destroyed and recreated.

What do you mean by reset? do you mean secondary is suspended

at

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 1 line

checkpoint?

Well - at the point that the buffered records are being processed, we are in the process of resetting the state of the secondary to match the
primary.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Yes, at this point, the qemu process associated with this domain is frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in qemu) to pause
qemu. After we processed all records, qemu will be restored with the received
state, that's why we add a libxl__qmp_restore(qemu_load_vmstate()

in

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

qemu)
api to restore qemu with received state. Currently in libxl, qemu only start
with the received state, there's no api to load received state while qemu is
running for a while.

Quoted 5 lines
Quoted 3 lines

Now I consider this more, it is absolutely wrong to not zero the page here. The event channel in the page is not guaranteed to be the same between the primary and secondary,

That's why we don't zero it on secondary.

I think you missed my point. Apologies for the double negative. It
must, under all circumstances, be zeroed at this point, for safety reasons.

Quoted 7 lines

The page in question is subject to logdirty just like any other guest pages, which means that if the guest writes to it naturally (i.e. not a Xen or Qemu write, both of whom have magic mappings which are not subject to logdirty), it will be transmitted in the stream. As the event channel could be different, the lack of zeroing it at this point means that the event channel would be wrong as opposed to simply missing. This is a worse position to be in.

The guest should not access this page. I am not sure if the guest can access the ioreq page.

But in the exceptional case, the ioreq page is dirtied, and is copied to the secondary vm. The ioreq page will contain a wrong event channel, the hypervisor will check it: if the event channel is wrong, the guest will be crashed.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

and we don't want to unexpectedly
find a pending/in-flight ioreq.

ioreq->state is always STATE_IOREQ_NONE after the vm is suspended,

there

Quoted 5 lines
Quoted 1 line

should be no pending/in-flight ioreq at checkpoint.

In the common case perhaps, but we must consider the exceptional case. The exceptional case here is some corruption which happens to appear as an in-flight ioreq.

If the state is STATE_IOREQ_NONE, it may be hypervisor's bug. If the hypervisor
has a bug, anything can happen. I think we should trust the hypervisor.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

Either qemu needs to take care of re-initialising the event channels back to appropriate values, or Xen should tolerate the channels disappearing.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I still stand by this statement. I believe it is the only safe way of solving the issue you have discovered.

Add a new qemu monitor command to update ioreq page?

If you're attaching to a 'new' VM (i.e one with an updated image) then I suspect you're going to have to destroy and re-create the ioreq server so that the shared page gets re-populated with the correct event channels. Either that or you're going to have to ensure that the page is not part of restored image and sample the new one that Xen should have set up.

I agree with it. I will try to add a new qemu monitor command(or do it when updating qemu's state) to destroy and re-create it.

Thanks
Wen Congyang

Quoted 14 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

~Andrew
.

.

#27 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 153 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 11:55
To: Paul Durrant; Andrew Cooper; Yang Hongyang; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 10:06
To: Andrew Cooper; Yang Hongyang; [email protected]; Paul

Durrant

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 12 lines
Quoted 12 lines

page only one time

Cc Paul Durrant
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Yang Hongyang
Quoted 3 lines · Andrew Cooper
Quoted 2 lines · Yang Hongyang
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Yang Hongyang
Quoted 5 lines · Andrew Cooper
Quoted 2 lines · Yang Hongyang
Quoted 1 line

ioreq page contains evtchn which will be set when we resume

the

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

secondary vm the first time. The hypervisor will check if the evtchn is corrupted, so we cannot zero the ioreq page more than one time.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

The ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, so it is OK if we only zero it one time.

The issue here is that we are running the restore algorithm over

a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

domain which has already been running in Xen for a while. This

is a

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 1 line

brand new usecase, as far as I am aware.

Exactly.

Quoted 5 lines

Does the qemu process associated with this domain get frozen while the
secondary is being reset, or does the process get destroyed and recreated.

What do you mean by reset? do you mean secondary is

suspended

Quoted 4 lines
Quoted 4 lines

at

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

checkpoint?

Well - at the point that the buffered records are being processed,

we

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

are in the process of resetting the state of the secondary to match the
primary.

Yes, at this point, the qemu process associated with this domain is frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in qemu)

to

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

pause
qemu. After we processed all records, qemu will be restored with

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

received
state, that's why we add a

libxl__qmp_restore(qemu_load_vmstate()

Quoted 10 lines
Quoted 10 lines

in

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines

qemu)
api to restore qemu with received state. Currently in libxl, qemu only start
with the received state, there's no api to load received state while qemu is
running for a while.

Now I consider this more, it is absolutely wrong to not zero the page here. The event channel in the page is not guaranteed to be the

same

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

between the primary and secondary,

That's why we don't zero it on secondary.

I think you missed my point. Apologies for the double negative. It
must, under all circumstances, be zeroed at this point, for safety

reasons.

Quoted 19 lines
Quoted 19 lines
Quoted 8 lines

The page in question is subject to logdirty just like any other guest pages, which means that if the guest writes to it naturally (i.e. not a Xen or Qemu write, both of whom have magic mappings which are not subject to logdirty), it will be transmitted in the stream. As the event channel could be different, the lack of zeroing it at this point means that the event channel would be wrong as opposed to simply missing. This is a worse position to be in.

The guest should not access this page. I am not sure if the guest can access the ioreq page.

But in the exceptional case, the ioreq page is dirtied, and is copied to the secondary vm. The ioreq page will contain a wrong event channel, the hypervisor will check it: if the event channel is wrong, the guest will be crashed.

Quoted 2 lines
Quoted 2 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

and we don't want to unexpectedly
find a pending/in-flight ioreq.

ioreq->state is always STATE_IOREQ_NONE after the vm is suspended,

there

Quoted 3 lines
Quoted 1 line

should be no pending/in-flight ioreq at checkpoint.

In the common case perhaps, but we must consider the exceptional

case.

Quoted 1 line
Quoted 1 line
Quoted 1 line

The exceptional case here is some corruption which happens to appear

as

Quoted 13 lines
Quoted 13 lines
Quoted 1 line

an in-flight ioreq.

If the state is STATE_IOREQ_NONE, it may be hypervisor's bug. If the hypervisor
has a bug, anything can happen. I think we should trust the hypervisor.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

Either qemu needs to take care of re-initialising the event channels back to appropriate values, or Xen should tolerate the channels disappearing.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I still stand by this statement. I believe it is the only safe way of solving the issue you have discovered.

Add a new qemu monitor command to update ioreq page?

If you're attaching to a 'new' VM (i.e one with an updated image) then I

Quoted 8 lines

suspect you're going to have to destroy and re-create the ioreq server so that the shared page gets re-populated with the correct event channels. Either that or you're going to have to ensure that the page is not part of restored image and sample the new one that Xen should have set up.

I agree with it. I will try to add a new qemu monitor command(or do it when updating qemu's state) to destroy and re-create it.

The slightly tricky part of that is that you're going to have to cache and replay all the registrations that were done on the old instance, but you need to do that in any case as it's not state that is transferred in the VM save record.

Paul

Quoted 18 lines

Thanks
Wen Congyang

Quoted 14 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

~Andrew
.

.

#28 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 159 lines · Paul Durrant
Quoted 159 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 11:55
To: Paul Durrant; Andrew Cooper; Yang Hongyang; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 10:06
To: Andrew Cooper; Yang Hongyang; [email protected]; Paul

Durrant

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 12 lines
Quoted 12 lines

page only one time

Cc Paul Durrant
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Yang Hongyang
Quoted 3 lines · Andrew Cooper
Quoted 2 lines · Yang Hongyang
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Yang Hongyang
Quoted 5 lines · Andrew Cooper
Quoted 2 lines · Yang Hongyang
Quoted 1 line

ioreq page contains evtchn which will be set when we resume

the

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

secondary vm the first time. The hypervisor will check if the evtchn is corrupted, so we cannot zero the ioreq page more than one time.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

The ioreq->state is always STATE_IOREQ_NONE after the vm is suspended, so it is OK if we only zero it one time.

The issue here is that we are running the restore algorithm over

a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

domain which has already been running in Xen for a while. This

is a

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 1 line

brand new usecase, as far as I am aware.

Exactly.

Quoted 5 lines

Does the qemu process associated with this domain get frozen while the
secondary is being reset, or does the process get destroyed and recreated.

What do you mean by reset? do you mean secondary is

suspended

Quoted 4 lines
Quoted 4 lines

at

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

checkpoint?

Well - at the point that the buffered records are being processed,

we

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

are in the process of resetting the state of the secondary to match the
primary.

Yes, at this point, the qemu process associated with this domain is frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in qemu)

to

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

pause
qemu. After we processed all records, qemu will be restored with

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

received
state, that's why we add a

libxl__qmp_restore(qemu_load_vmstate()

Quoted 10 lines
Quoted 10 lines

in

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines

qemu)
api to restore qemu with received state. Currently in libxl, qemu only start
with the received state, there's no api to load received state while qemu is
running for a while.

Now I consider this more, it is absolutely wrong to not zero the page here. The event channel in the page is not guaranteed to be the

same

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

between the primary and secondary,

That's why we don't zero it on secondary.

I think you missed my point. Apologies for the double negative. It
must, under all circumstances, be zeroed at this point, for safety

reasons.

Quoted 19 lines
Quoted 19 lines
Quoted 8 lines

The page in question is subject to logdirty just like any other guest pages, which means that if the guest writes to it naturally (i.e. not a Xen or Qemu write, both of whom have magic mappings which are not subject to logdirty), it will be transmitted in the stream. As the event channel could be different, the lack of zeroing it at this point means that the event channel would be wrong as opposed to simply missing. This is a worse position to be in.

The guest should not access this page. I am not sure if the guest can access the ioreq page.

But in the exceptional case, the ioreq page is dirtied, and is copied to the secondary vm. The ioreq page will contain a wrong event channel, the hypervisor will check it: if the event channel is wrong, the guest will be crashed.

Quoted 2 lines
Quoted 2 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

and we don't want to unexpectedly
find a pending/in-flight ioreq.

ioreq->state is always STATE_IOREQ_NONE after the vm is suspended,

there

Quoted 3 lines
Quoted 1 line

should be no pending/in-flight ioreq at checkpoint.

In the common case perhaps, but we must consider the exceptional

case.

Quoted 1 line
Quoted 1 line
Quoted 1 line

The exceptional case here is some corruption which happens to appear

as

Quoted 13 lines
Quoted 13 lines
Quoted 1 line

an in-flight ioreq.

If the state is STATE_IOREQ_NONE, it may be hypervisor's bug. If the hypervisor
has a bug, anything can happen. I think we should trust the hypervisor.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

Either qemu needs to take care of re-initialising the event channels back to appropriate values, or Xen should tolerate the channels disappearing.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I still stand by this statement. I believe it is the only safe way of solving the issue you have discovered.

Add a new qemu monitor command to update ioreq page?

If you're attaching to a 'new' VM (i.e one with an updated image) then I

suspect you're going to have to destroy and re-create the ioreq server so that the shared page gets re-populated with the correct event channels. Either that or you're going to have to ensure that the page is not part of restored image and sample the new one that Xen should have set up.

Quoted 4 lines
Quoted 2 lines

I agree with it. I will try to add a new qemu monitor command(or do it when updating qemu's state) to destroy and re-create it.

The slightly tricky part of that is that you're going to have to cache and replay all the registrations that were done on the old instance, but you need to do that in any case as it's not state that is transferred in the VM save record.

Why do we have to cache and replay all the registrations that were done on the old instance? We will set to the guest to a new state, the old state should be dropped.

Thanks
Wen Congyang

Quoted 24 lines

Paul

Quoted 18 lines

Thanks
Wen Congyang

Quoted 14 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

~Andrew
.

.

.

#29 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 191 lines

-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Wen Congyang
Sent: 10 June 2015 12:38
To: Paul Durrant; Andrew Cooper; Yang Hongyang; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 11:55
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 24 lines
Quoted 24 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 10:06
To: Andrew Cooper; Yang Hongyang; [email protected]; Paul

Durrant

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 12 lines
Quoted 12 lines

page only one time

Cc Paul Durrant
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Yang Hongyang
Quoted 3 lines · Andrew Cooper
Quoted 2 lines · Yang Hongyang
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Yang Hongyang
Quoted 5 lines · Andrew Cooper
Quoted 2 lines · Yang Hongyang
Quoted 1 line

ioreq page contains evtchn which will be set when we

resume

Quoted 6 lines
Quoted 6 lines

the

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

secondary vm the first time. The hypervisor will check if the
evtchn is corrupted, so we cannot zero the ioreq page more
than one time.

The ioreq->state is always STATE_IOREQ_NONE after the vm

is

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

suspended, so it is OK if we only zero it one time.

Signed-off-by: Yang Hongyang <[email protected]>
Signed-off-by: Wen congyang <[email protected]>
CC: Andrew Cooper <[email protected]>

The issue here is that we are running the restore algorithm

over

Quoted 2 lines
Quoted 2 lines

a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

domain which has already been running in Xen for a while.

This

Quoted 7 lines
Quoted 7 lines

is a

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

brand new usecase, as far as I am aware.

Exactly.

Quoted 2 lines

Does the qemu process associated with this domain get

frozen

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

while the
secondary is being reset, or does the process get destroyed

and

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

recreated.

What do you mean by reset? do you mean secondary is

suspended

Quoted 4 lines
Quoted 4 lines

at

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

checkpoint?

Well - at the point that the buffered records are being

processed,

Quoted 2 lines
Quoted 2 lines

we

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

are in the process of resetting the state of the secondary to

match

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

the
primary.

Yes, at this point, the qemu process associated with this domain is frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in

qemu)

Quoted 10 lines
Quoted 10 lines

to

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

pause
qemu. After we processed all records, qemu will be restored with

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

received
state, that's why we add a

libxl__qmp_restore(qemu_load_vmstate()

Quoted 3 lines
Quoted 3 lines

in

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

qemu)
api to restore qemu with received state. Currently in libxl, qemu

only

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

start
with the received state, there's no api to load received state while qemu is
running for a while.

Now I consider this more, it is absolutely wrong to not zero the

page

Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

here. The event channel in the page is not guaranteed to be the

same

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

between the primary and secondary,

That's why we don't zero it on secondary.

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I think you missed my point. Apologies for the double negative. It
must, under all circumstances, be zeroed at this point, for safety

reasons.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

The page in question is subject to logdirty just like any other guest pages, which means that if the guest writes to it naturally (i.e. not a Xen or Qemu write, both of whom have magic mappings which are

not

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines

subject to logdirty), it will be transmitted in the stream. As the event channel could be different, the lack of zeroing it at this point means that the event channel would be wrong as opposed to simply missing. This is a worse position to be in.

The guest should not access this page. I am not sure if the guest can access the ioreq page.

But in the exceptional case, the ioreq page is dirtied, and is copied to the secondary vm. The ioreq page will contain a wrong event channel,

the

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

hypervisor will check it: if the event channel is wrong, the guest will be crashed.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

and we don't want to unexpectedly
find a pending/in-flight ioreq.

ioreq->state is always STATE_IOREQ_NONE after the vm is

suspended,

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

there

Quoted 3 lines
Quoted 1 line

should be no pending/in-flight ioreq at checkpoint.

In the common case perhaps, but we must consider the exceptional

case.

Quoted 1 line
Quoted 1 line
Quoted 1 line

The exceptional case here is some corruption which happens to

appear

Quoted 20 lines
Quoted 20 lines

as

Quoted 19 lines
Quoted 18 lines
Quoted 1 line

an in-flight ioreq.

If the state is STATE_IOREQ_NONE, it may be hypervisor's bug. If the hypervisor
has a bug, anything can happen. I think we should trust the hypervisor.

Quoted 9 lines
Quoted 6 lines
Quoted 6 lines

Either qemu needs to take care of re-initialising the event channels back to appropriate values, or Xen should tolerate the channels disappearing.

I still stand by this statement. I believe it is the only safe way of solving the issue you have discovered.

Add a new qemu monitor command to update ioreq page?

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

If you're attaching to a 'new' VM (i.e one with an updated image) then I

suspect you're going to have to destroy and re-create the ioreq server so that the shared page gets re-populated with the correct event channels. Either that or you're going to have to ensure that the page is not part of restored image and sample the new one that Xen should have set up.

I agree with it. I will try to add a new qemu monitor command(or do it

when

Quoted 2 lines
Quoted 1 line

updating qemu's state) to destroy and re-create it.

Quoted 7 lines
Quoted 1 line

The slightly tricky part of that is that you're going to have to cache and

replay all the registrations that were done on the old instance, but you need to do that in any case as it's not state that is transferred in the VM save record.

Why do we have to cache and replay all the registrations that were done on the old instance?

Do you not have device models that you need to continue to function? When the ioreq server is torn down then all MMIO, port IO and PCI config ranges that were mapped to it will disappear.

Paul

Quoted 35 lines

We will set to the guest to a new state, the old state should be dropped.

Thanks
Wen Congyang

Quoted 15 lines

Paul

Quoted 12 lines

Thanks
Wen Congyang

Quoted 8 lines

Paul

Quoted 4 lines

Thanks
Wen Congyang

Quoted 1 line
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

~Andrew
.

.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#30 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 192 lines · Paul Durrant
Quoted 192 lines

-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Wen Congyang
Sent: 10 June 2015 12:38
To: Paul Durrant; Andrew Cooper; Yang Hongyang; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 11:55
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 24 lines
Quoted 24 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 10:06
To: Andrew Cooper; Yang Hongyang; [email protected]; Paul

Durrant

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 12 lines
Quoted 12 lines

page only one time

Cc Paul Durrant
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Yang Hongyang
Quoted 3 lines · Andrew Cooper
Quoted 2 lines · Yang Hongyang
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Yang Hongyang
Quoted 5 lines · Andrew Cooper
Quoted 2 lines · Yang Hongyang

ioreq page contains evtchn which will be set when we

resume

Quoted 6 lines
Quoted 6 lines

the

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

secondary vm the first time. The hypervisor will check if the
evtchn is corrupted, so we cannot zero the ioreq page more
than one time.

The ioreq->state is always STATE_IOREQ_NONE after the vm

is

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

suspended, so it is OK if we only zero it one time.

Signed-off-by: Yang Hongyang <[email protected]>
Signed-off-by: Wen congyang <[email protected]>
CC: Andrew Cooper <[email protected]>

The issue here is that we are running the restore algorithm

over

Quoted 2 lines
Quoted 2 lines

a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

domain which has already been running in Xen for a while.

This

Quoted 7 lines
Quoted 7 lines

is a

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

brand new usecase, as far as I am aware.

Exactly.

Quoted 2 lines

Does the qemu process associated with this domain get

frozen

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

while the
secondary is being reset, or does the process get destroyed

and

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

recreated.

What do you mean by reset? do you mean secondary is

suspended

Quoted 4 lines
Quoted 4 lines

at

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

checkpoint?

Well - at the point that the buffered records are being

processed,

Quoted 2 lines
Quoted 2 lines

we

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

are in the process of resetting the state of the secondary to

match

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

the
primary.

Yes, at this point, the qemu process associated with this domain is frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in

qemu)

Quoted 10 lines
Quoted 10 lines

to

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

pause
qemu. After we processed all records, qemu will be restored with

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

received
state, that's why we add a

libxl__qmp_restore(qemu_load_vmstate()

Quoted 3 lines
Quoted 3 lines

in

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

qemu)
api to restore qemu with received state. Currently in libxl, qemu

only

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

start
with the received state, there's no api to load received state while qemu is
running for a while.

Now I consider this more, it is absolutely wrong to not zero the

page

Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

here. The event channel in the page is not guaranteed to be the

same

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

between the primary and secondary,

That's why we don't zero it on secondary.

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I think you missed my point. Apologies for the double negative. It
must, under all circumstances, be zeroed at this point, for safety

reasons.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

The page in question is subject to logdirty just like any other guest pages, which means that if the guest writes to it naturally (i.e. not a Xen or Qemu write, both of whom have magic mappings which are

not

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines

subject to logdirty), it will be transmitted in the stream. As the event channel could be different, the lack of zeroing it at this point means that the event channel would be wrong as opposed to simply missing. This is a worse position to be in.

The guest should not access this page. I am not sure if the guest can access the ioreq page.

But in the exceptional case, the ioreq page is dirtied, and is copied to the secondary vm. The ioreq page will contain a wrong event channel,

the

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

hypervisor will check it: if the event channel is wrong, the guest will be crashed.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

and we don't want to unexpectedly
find a pending/in-flight ioreq.

ioreq->state is always STATE_IOREQ_NONE after the vm is

suspended,

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

there

Quoted 3 lines
Quoted 1 line

should be no pending/in-flight ioreq at checkpoint.

In the common case perhaps, but we must consider the exceptional

case.

Quoted 1 line
Quoted 1 line
Quoted 1 line

The exceptional case here is some corruption which happens to

appear

Quoted 20 lines
Quoted 20 lines

as

Quoted 19 lines
Quoted 18 lines
Quoted 1 line

an in-flight ioreq.

If the state is STATE_IOREQ_NONE, it may be hypervisor's bug. If the hypervisor
has a bug, anything can happen. I think we should trust the hypervisor.

Quoted 9 lines
Quoted 6 lines
Quoted 6 lines

Either qemu needs to take care of re-initialising the event channels back to appropriate values, or Xen should tolerate the channels disappearing.

I still stand by this statement. I believe it is the only safe way of solving the issue you have discovered.

Add a new qemu monitor command to update ioreq page?

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

If you're attaching to a 'new' VM (i.e one with an updated image) then I

suspect you're going to have to destroy and re-create the ioreq server so that the shared page gets re-populated with the correct event channels. Either that or you're going to have to ensure that the page is not part of restored image and sample the new one that Xen should have set up.

I agree with it. I will try to add a new qemu monitor command(or do it

when

Quoted 3 lines
Quoted 1 line

updating qemu's state) to destroy and re-create it.

The slightly tricky part of that is that you're going to have to cache and

Quoted 8 lines
Quoted 6 lines

replay all the registrations that were done on the old instance, but you need to do that in any case as it's not state that is transferred in the VM save record.

Why do we have to cache and replay all the registrations that were done on the old instance?

Do you not have device models that you need to continue to function? When the ioreq server is torn down then all MMIO, port IO and PCI config ranges that were mapped to it will disappear.

Yes, I don't known which should be done unless I implement and test it.

I have some questions about it:
1. Can guest access the ioreq page? If the page is modified by the guest unexpectedly, what will happen?
2. If the ioreq page is dirtied by the guest, it will be transfered from primary to secondary during checkpoint. The evtchn is invalid, I think the best behavior is that: make the guest crashed, not continue to run.

Thanks
Wen Congyang

Quoted 45 lines

Paul

Quoted 27 lines

We will set to the guest to a new state, the old state should be dropped.

Thanks
Wen Congyang

Quoted 22 lines

Paul

Quoted 18 lines

Thanks
Wen Congyang

Quoted 14 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

~Andrew
.

.

Quoted 8 lines
Quoted 2 lines

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

#31 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 233 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 02:14
To: Paul Durrant; Andrew Cooper; Yang Hongyang; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 5 lines · Paul Durrant
Quoted 5 lines

-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Wen Congyang
Sent: 10 June 2015 12:38
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 15 lines
Quoted 15 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 11:55
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 3 lines
Quoted 3 lines

page only one time

On 06/10/2015 06:40 PM, Paul Durrant wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 10:06
To: Andrew Cooper; Yang Hongyang; [email protected]; Paul

Durrant

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore:

zero

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

ioreq

Quoted 16 lines
Quoted 16 lines

page only one time

Cc Paul Durrant
Quoted 11 lines · Andrew Cooper
Quoted 10 lines · Yang Hongyang
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Yang Hongyang
Quoted 3 lines · Andrew Cooper
Quoted 2 lines · Yang Hongyang
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Andrew Cooper

On 08/06/15 04:43, Yang Hongyang wrote:
ioreq page contains evtchn which will be set when we

resume

Quoted 2 lines
Quoted 2 lines

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

secondary vm the first time. The hypervisor will check if

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

evtchn is corrupted, so we cannot zero the ioreq page

more

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

than one time.

The ioreq->state is always STATE_IOREQ_NONE after the

vm

Quoted 31 lines
Quoted 31 lines

is

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

suspended, so it is OK if we only zero it one time.

Signed-off-by: Yang Hongyang <[email protected]>
Signed-off-by: Wen congyang <[email protected]>
CC: Andrew Cooper <[email protected]>

The issue here is that we are running the restore algorithm

over

Quoted 2 lines
Quoted 2 lines

a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

domain which has already been running in Xen for a while.

This

Quoted 7 lines
Quoted 7 lines

is a

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

brand new usecase, as far as I am aware.

Exactly.

Does the qemu process associated with this domain get

frozen

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

while the
secondary is being reset, or does the process get destroyed

and

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

recreated.

What do you mean by reset? do you mean secondary is

suspended

Quoted 4 lines
Quoted 4 lines

at

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

checkpoint?

Well - at the point that the buffered records are being

Quoted 8 lines
Quoted 8 lines

processed,

Quoted 2 lines
Quoted 2 lines

we

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

are in the process of resetting the state of the secondary to

match

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

the
primary.

Yes, at this point, the qemu process associated with this

domain is

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in

qemu)

Quoted 3 lines
Quoted 3 lines

to

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

pause
qemu. After we processed all records, qemu will be restored

with

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

received
state, that's why we add a

libxl__qmp_restore(qemu_load_vmstate()

Quoted 3 lines
Quoted 3 lines

in

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

qemu)
api to restore qemu with received state. Currently in libxl,

qemu

Quoted 3 lines
Quoted 3 lines

only

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

start
with the received state, there's no api to load received state

while

Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

qemu is
running for a while.

Now I consider this more, it is absolutely wrong to not zero the

page

Quoted 10 lines
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

here. The event channel in the page is not guaranteed to be the

same

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

between the primary and secondary,

That's why we don't zero it on secondary.

I think you missed my point. Apologies for the double negative. It
must, under all circumstances, be zeroed at this point, for safety

reasons.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

The page in question is subject to logdirty just like any other guest pages, which means that if the guest writes to it naturally (i.e. not a Xen or Qemu write, both of whom have magic mappings which are

not

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

subject to logdirty), it will be transmitted in the stream. As the event channel could be different, the lack of zeroing it at this point means that the event channel would be wrong as opposed to

simply

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line

missing. This is a worse position to be in.

The guest should not access this page. I am not sure if the guest can access the ioreq page.

But in the exceptional case, the ioreq page is dirtied, and is copied to the secondary vm. The ioreq page will contain a wrong event

channel,

Quoted 9 lines
Quoted 9 lines

the

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

hypervisor will check it: if the event channel is wrong, the guest will be crashed.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

and we don't want to unexpectedly
find a pending/in-flight ioreq.

Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ioreq->state is always STATE_IOREQ_NONE after the vm is

suspended,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

there

Quoted 3 lines
Quoted 1 line

should be no pending/in-flight ioreq at checkpoint.

In the common case perhaps, but we must consider the

exceptional

Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines

case.

Quoted 1 line
Quoted 1 line
Quoted 1 line

The exceptional case here is some corruption which happens to

appear

Quoted 6 lines
Quoted 6 lines

as

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

an in-flight ioreq.

If the state is STATE_IOREQ_NONE, it may be hypervisor's bug. If the hypervisor
has a bug, anything can happen. I think we should trust the

hypervisor.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Either qemu needs to take care of re-initialising the event

channels

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

back to appropriate values, or Xen should tolerate the channels disappearing.

I still stand by this statement. I believe it is the only safe way of solving the issue you have discovered.

Add a new qemu monitor command to update ioreq page?

If you're attaching to a 'new' VM (i.e one with an updated image) then

I

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

suspect you're going to have to destroy and re-create the ioreq server

so

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

that the shared page gets re-populated with the correct event

channels.

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

Either that or you're going to have to ensure that the page is not part of restored image and sample the new one that Xen should have set up.

I agree with it. I will try to add a new qemu monitor command(or do it

when

Quoted 3 lines
Quoted 1 line

updating qemu's state) to destroy and re-create it.

The slightly tricky part of that is that you're going to have to cache and

replay all the registrations that were done on the old instance, but you

need

Quoted 4 lines
Quoted 4 lines

to do that in any case as it's not state that is transferred in the VM save record.

Why do we have to cache and replay all the registrations that were done

on

Quoted 3 lines
Quoted 1 line

the old instance?

Do you not have device models that you need to continue to function?

When the ioreq server is torn down then all MMIO, port IO and PCI config ranges that were mapped to it will disappear.

Quoted 6 lines

Yes, I don't known which should be done unless I implement and test it.

I have some questions about it:
1. Can guest access the ioreq page? If the page is modified by the guest unexpectedly,
what will happen?

No, the guest cannot modify the pages once a non-default ioreq server is active. The pages are removed from the guest P2M when it is activated, which is one of the reasons for modifying QEMU to not behave as a legacy default server.

Quoted 4 lines

2. If the ioreq page is dirtied by the guest, it will be transfered from primary to secondary during checkpoint. The evtchn is invalid, I think the best
behavior
is that: make the guest crashed, not continue to run.

As I said, the pages are not in the P2M if the server is active so they will not be transferred as part of the VM state. However, this presents a problem; at the far end, the emulator will not be able to hook into the guest. So, when the source domain is paused, the ioreq server needs to be torn down (so that its pages are re-inserted into the P2M and marked dirty for transfer). This is what happens in a normal migration. One extra problem you have is that the source domain is not then killed, it is resumed along with the emulator. Thus, on resume, the emulator needs to create a new ioreq server and re-register all its device models with that new server. I don't know the detail of what you do at the far end, but if you always start a new emulator instance using the QEMU save record then you should be fine (just like with a normal migration).

Paul

Quoted 49 lines

Thanks
Wen Congyang

Quoted 45 lines

Paul

Quoted 27 lines

We will set to the guest to a new state, the old state should be dropped.

Thanks
Wen Congyang

Quoted 22 lines

Paul

Quoted 18 lines

Thanks
Wen Congyang

Quoted 14 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

~Andrew
.

.

Quoted 8 lines
Quoted 2 lines

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

#32 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 242 lines · Paul Durrant
Quoted 233 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 02:14
To: Paul Durrant; Andrew Cooper; Yang Hongyang; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 5 lines · Paul Durrant
Quoted 5 lines

-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Wen Congyang
Sent: 10 June 2015 12:38
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 15 lines
Quoted 15 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 11:55
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 3 lines
Quoted 3 lines

page only one time

On 06/10/2015 06:40 PM, Paul Durrant wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 10:06
To: Andrew Cooper; Yang Hongyang; [email protected]; Paul

Durrant

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore:

zero

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

ioreq

Quoted 16 lines
Quoted 16 lines

page only one time

Cc Paul Durrant
Quoted 11 lines · Andrew Cooper
Quoted 10 lines · Yang Hongyang
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Yang Hongyang
Quoted 3 lines · Andrew Cooper

On 08/06/15 10:58, Yang Hongyang wrote:

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

On 06/08/2015 05:46 PM, Andrew Cooper wrote:
On 08/06/15 04:43, Yang Hongyang wrote:
ioreq page contains evtchn which will be set when we

resume

Quoted 2 lines
Quoted 2 lines

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

secondary vm the first time. The hypervisor will check if

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

evtchn is corrupted, so we cannot zero the ioreq page

more

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

than one time.

The ioreq->state is always STATE_IOREQ_NONE after the

vm

Quoted 31 lines
Quoted 31 lines

is

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

suspended, so it is OK if we only zero it one time.

Signed-off-by: Yang Hongyang <[email protected]>
Signed-off-by: Wen congyang <[email protected]>
CC: Andrew Cooper <[email protected]>

The issue here is that we are running the restore algorithm

over

Quoted 2 lines
Quoted 2 lines

a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

domain which has already been running in Xen for a while.

This

Quoted 7 lines
Quoted 7 lines

is a

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

brand new usecase, as far as I am aware.

Exactly.

Does the qemu process associated with this domain get

frozen

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

while the
secondary is being reset, or does the process get destroyed

and

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

recreated.

What do you mean by reset? do you mean secondary is

suspended

Quoted 4 lines
Quoted 4 lines

at

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

checkpoint?

Well - at the point that the buffered records are being

Quoted 8 lines
Quoted 8 lines

processed,

Quoted 2 lines
Quoted 2 lines

we

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

are in the process of resetting the state of the secondary to

match

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

the
primary.

Yes, at this point, the qemu process associated with this

domain is

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in

qemu)

Quoted 3 lines
Quoted 3 lines

to

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

pause
qemu. After we processed all records, qemu will be restored

with

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

received
state, that's why we add a

libxl__qmp_restore(qemu_load_vmstate()

Quoted 3 lines
Quoted 3 lines

in

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

qemu)
api to restore qemu with received state. Currently in libxl,

qemu

Quoted 3 lines
Quoted 3 lines

only

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

start
with the received state, there's no api to load received state

while

Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

qemu is
running for a while.

Now I consider this more, it is absolutely wrong to not zero the

page

Quoted 10 lines
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

here. The event channel in the page is not guaranteed to be the

same

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

between the primary and secondary,

That's why we don't zero it on secondary.

I think you missed my point. Apologies for the double negative. It
must, under all circumstances, be zeroed at this point, for safety

reasons.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

The page in question is subject to logdirty just like any other guest pages, which means that if the guest writes to it naturally (i.e. not a Xen or Qemu write, both of whom have magic mappings which are

not

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

subject to logdirty), it will be transmitted in the stream. As the event channel could be different, the lack of zeroing it at this point means that the event channel would be wrong as opposed to

simply

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line

missing. This is a worse position to be in.

The guest should not access this page. I am not sure if the guest can access the ioreq page.

But in the exceptional case, the ioreq page is dirtied, and is copied to the secondary vm. The ioreq page will contain a wrong event

channel,

Quoted 9 lines
Quoted 9 lines

the

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

hypervisor will check it: if the event channel is wrong, the guest will be crashed.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

and we don't want to unexpectedly
find a pending/in-flight ioreq.

Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ioreq->state is always STATE_IOREQ_NONE after the vm is

suspended,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

there

Quoted 3 lines
Quoted 1 line

should be no pending/in-flight ioreq at checkpoint.

In the common case perhaps, but we must consider the

exceptional

Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines

case.

Quoted 1 line
Quoted 1 line
Quoted 1 line

The exceptional case here is some corruption which happens to

appear

Quoted 6 lines
Quoted 6 lines

as

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

an in-flight ioreq.

If the state is STATE_IOREQ_NONE, it may be hypervisor's bug. If the hypervisor
has a bug, anything can happen. I think we should trust the

hypervisor.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Either qemu needs to take care of re-initialising the event

channels

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

back to appropriate values, or Xen should tolerate the channels disappearing.

I still stand by this statement. I believe it is the only safe way of solving the issue you have discovered.

Add a new qemu monitor command to update ioreq page?

If you're attaching to a 'new' VM (i.e one with an updated image) then

I

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

suspect you're going to have to destroy and re-create the ioreq server

so

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

that the shared page gets re-populated with the correct event

channels.

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

Either that or you're going to have to ensure that the page is not part of restored image and sample the new one that Xen should have set up.

I agree with it. I will try to add a new qemu monitor command(or do it

when

Quoted 3 lines
Quoted 1 line

updating qemu's state) to destroy and re-create it.

The slightly tricky part of that is that you're going to have to cache and

replay all the registrations that were done on the old instance, but you

need

Quoted 4 lines
Quoted 4 lines

to do that in any case as it's not state that is transferred in the VM save record.

Why do we have to cache and replay all the registrations that were done

on

Quoted 3 lines
Quoted 1 line

the old instance?

Do you not have device models that you need to continue to function?

When the ioreq server is torn down then all MMIO, port IO and PCI config ranges that were mapped to it will disappear.

Quoted 6 lines

Yes, I don't known which should be done unless I implement and test it.

I have some questions about it:
1. Can guest access the ioreq page? If the page is modified by the guest unexpectedly,
what will happen?

No, the guest cannot modify the pages once a non-default ioreq server is active. The pages are removed from the guest P2M when it is activated, which is one of the reasons for modifying QEMU to not behave as a legacy default server.

Quoted 7 lines
Quoted 4 lines

2. If the ioreq page is dirtied by the guest, it will be transfered from primary to secondary during checkpoint. The evtchn is invalid, I think the best
behavior
is that: make the guest crashed, not continue to run.

As I said, the pages are not in the P2M if the server is active so they will not be transferred as part of the VM state. However, this presents a problem; at the far end, the emulator will not be able to hook into the guest. So, when the source domain is paused, the ioreq server needs to be torn down (so that its pages are re-inserted into the P2M and marked dirty for transfer). This is what happens in a normal migration. One extra problem you have is that the source domain is not then killed, it is resumed along with the emulator. Thus, on resume, the emulator needs to create a new ioreq server and re-register all its device models with that new server. I don't know the detail of what you do at the far end, but if you always start a new emulator instance using the QEMU save record then you should be fine (just like with a normal migration).

I don't find the codes where the ioreq server is torn down when the source domain is paused. Which function?

In our implementation, we don't start a new emulator. The codes can work, but some bugs may be not triggered.

Thanks
Wen Congyang

Quoted 55 lines

Paul

Quoted 49 lines

Thanks
Wen Congyang

Quoted 45 lines

Paul

Quoted 27 lines

We will set to the guest to a new state, the old state should be dropped.

Thanks
Wen Congyang

Quoted 22 lines

Paul

Quoted 18 lines

Thanks
Wen Congyang

Quoted 14 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

~Andrew
.

.

Quoted 8 lines
Quoted 2 lines

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

.

#33 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 298 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 09:48
To: Paul Durrant; Andrew Cooper; Yang Hongyang; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 02:14
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 16 lines
Quoted 16 lines

page only one time

Quoted 5 lines · Paul Durrant
Quoted 5 lines

-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Wen Congyang
Sent: 10 June 2015 12:38
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 3 lines
Quoted 3 lines

page only one time

On 06/10/2015 06:58 PM, Paul Durrant wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 11:55
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore:

zero

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

ioreq

Quoted 7 lines
Quoted 7 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 10:06
To: Andrew Cooper; Yang Hongyang; [email protected];

Paul

Quoted 26 lines
Quoted 26 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Durrant

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore:

zero

Quoted 21 lines
Quoted 21 lines
Quoted 13 lines
Quoted 13 lines

ioreq

Quoted 12 lines
Quoted 12 lines

page only one time

Cc Paul Durrant
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Yang Hongyang
Quoted 3 lines · Andrew Cooper
Quoted 2 lines · Yang Hongyang
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Andrew Cooper

On 08/06/15 10:58, Yang Hongyang wrote:

On 06/08/2015 05:46 PM, Andrew Cooper wrote:
On 08/06/15 04:43, Yang Hongyang wrote:
ioreq page contains evtchn which will be set when we

resume

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

secondary vm the first time. The hypervisor will check if

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

evtchn is corrupted, so we cannot zero the ioreq page

more

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

than one time.

The ioreq->state is always STATE_IOREQ_NONE after

the

Quoted 5 lines
Quoted 5 lines

vm

Quoted 4 lines
Quoted 4 lines

is

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

suspended, so it is OK if we only zero it one time.

Signed-off-by: Yang Hongyang

<[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Signed-off-by: Wen congyang

<[email protected]>

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

CC: Andrew Cooper <[email protected]>

The issue here is that we are running the restore

algorithm

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

over

Quoted 2 lines
Quoted 2 lines

a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

domain which has already been running in Xen for a

while.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

This

Quoted 7 lines
Quoted 7 lines

is a

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

brand new usecase, as far as I am aware.

Exactly.

Does the qemu process associated with this domain get

frozen

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

while the
secondary is being reset, or does the process get

destroyed

Quoted 33 lines
Quoted 33 lines
Quoted 9 lines
Quoted 9 lines

and

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

recreated.

What do you mean by reset? do you mean secondary is

suspended

Quoted 4 lines
Quoted 4 lines

at

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

checkpoint?

Well - at the point that the buffered records are being

Quoted 8 lines
Quoted 8 lines

processed,

Quoted 2 lines
Quoted 2 lines

we

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

are in the process of resetting the state of the secondary to

match

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

the
primary.

Yes, at this point, the qemu process associated with this

domain is

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in

qemu)

Quoted 3 lines
Quoted 3 lines

to

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

pause
qemu. After we processed all records, qemu will be restored

with

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

received
state, that's why we add a

libxl__qmp_restore(qemu_load_vmstate()

Quoted 3 lines
Quoted 3 lines

in

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

qemu)
api to restore qemu with received state. Currently in libxl,

qemu

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

only

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

start
with the received state, there's no api to load received state

while

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

qemu is
running for a while.

Now I consider this more, it is absolutely wrong to not zero

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

page

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

here. The event channel in the page is not guaranteed to be

the

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

same

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

between the primary and secondary,

That's why we don't zero it on secondary.

I think you missed my point. Apologies for the double negative.

It

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

must, under all circumstances, be zeroed at this point, for safety

reasons.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The page in question is subject to logdirty just like any other

guest

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

pages, which means that if the guest writes to it naturally (i.e.

not a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Xen or Qemu write, both of whom have magic mappings which

are

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

not

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

subject to logdirty), it will be transmitted in the stream. As the event channel could be different, the lack of zeroing it at this

point

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

means that the event channel would be wrong as opposed to

simply

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

missing. This is a worse position to be in.

The guest should not access this page. I am not sure if the guest

can

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

access the ioreq page.

But in the exceptional case, the ioreq page is dirtied, and is copied

to

Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the secondary vm. The ioreq page will contain a wrong event

channel,

Quoted 2 lines
Quoted 2 lines

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

hypervisor will check it: if the event channel is wrong, the guest

will

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

be crashed.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

and we don't want to unexpectedly
find a pending/in-flight ioreq.

ioreq->state is always STATE_IOREQ_NONE after the vm is

suspended,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

there

Quoted 3 lines
Quoted 1 line

should be no pending/in-flight ioreq at checkpoint.

In the common case perhaps, but we must consider the

Quoted 8 lines
Quoted 8 lines

exceptional

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

case.

Quoted 1 line
Quoted 1 line
Quoted 1 line

The exceptional case here is some corruption which happens to

appear

Quoted 4 lines
Quoted 4 lines

as

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

an in-flight ioreq.

If the state is STATE_IOREQ_NONE, it may be hypervisor's bug. If

the

Quoted 10 lines
Quoted 10 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

hypervisor
has a bug, anything can happen. I think we should trust the

hypervisor.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Either qemu needs to take care of re-initialising the event

channels

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

back to appropriate values, or Xen should tolerate the

channels

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

disappearing.

I still stand by this statement. I believe it is the only safe way of solving the issue you have discovered.

Add a new qemu monitor command to update ioreq page?

If you're attaching to a 'new' VM (i.e one with an updated image)

then

Quoted 2 lines
Quoted 2 lines

I

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

suspect you're going to have to destroy and re-create the ioreq

server

Quoted 4 lines
Quoted 4 lines

so

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

that the shared page gets re-populated with the correct event

channels.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Either that or you're going to have to ensure that the page is not part

of

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

restored image and sample the new one that Xen should have set

up.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I agree with it. I will try to add a new qemu monitor command(or do

it

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

when

Quoted 3 lines
Quoted 1 line

updating qemu's state) to destroy and re-create it.

The slightly tricky part of that is that you're going to have to cache and

replay all the registrations that were done on the old instance, but you

need

Quoted 4 lines
Quoted 4 lines

to do that in any case as it's not state that is transferred in the VM save record.

Why do we have to cache and replay all the registrations that were

done

Quoted 7 lines
Quoted 7 lines

on

Quoted 3 lines
Quoted 1 line

the old instance?

Do you not have device models that you need to continue to function?

When the ioreq server is torn down then all MMIO, port IO and PCI config ranges that were mapped to it will disappear.

Quoted 8 lines
Quoted 6 lines

Yes, I don't known which should be done unless I implement and test it.

I have some questions about it:
1. Can guest access the ioreq page? If the page is modified by the guest unexpectedly,
what will happen?

No, the guest cannot modify the pages once a non-default ioreq server is

active. The pages are removed from the guest P2M when it is activated, which is one of the reasons for modifying QEMU to not behave as a legacy default server.

Quoted 2 lines
Quoted 2 lines

2. If the ioreq page is dirtied by the guest, it will be transfered from

primary

Quoted 5 lines
Quoted 3 lines

to secondary during checkpoint. The evtchn is invalid, I think the best
behavior
is that: make the guest crashed, not continue to run.

As I said, the pages are not in the P2M if the server is active so they will not

be transferred as part of the VM state. However, this presents a problem; at the far end, the emulator will not be able to hook into the guest. So, when the source domain is paused, the ioreq server needs to be torn down (so that its pages are re-inserted into the P2M and marked dirty for transfer). This is what happens in a normal migration. One extra problem you have is that the source domain is not then killed, it is resumed along with the emulator. Thus, on resume, the emulator needs to create a new ioreq server and re-register all its device models with that new server.

Quoted 6 lines
Quoted 1 line

I don't know the detail of what you do at the far end, but if you always start

a new emulator instance using the QEMU save record then you should be fine (just like with a normal migration).

I don't find the codes where the ioreq server is torn down when the source domain is paused. Which function?

Sorry, I overstated that. By 'torn down' I meant disabled. The function that does it is:

static void xen_hvm_change_state_handler(void *opaque, int running,
RunState rstate)

{
    XenIOState *state = opaque;

    if (running) {
        xen_main_loop_prepare(state);
    }

    xen_set_ioreq_server_state(xen_xc, xen_domid,
                               state->ioservid,
                               (rstate == RUN_STATE_RUNNING));
}
Quoted 4 lines

In our implementation, we don't start a new emulator. The codes can work, but some bugs may be not triggered.

How do you reconcile the incoming QEMU save record with the running emulator state?

Paul

Quoted 59 lines

Thanks
Wen Congyang

Quoted 11 lines

Paul

Quoted 8 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line

We will set to the guest to a new state, the old state should be

dropped.

Quoted 44 lines
Quoted 35 lines
Quoted 35 lines
Quoted 34 lines

Thanks
Wen Congyang

Quoted 15 lines

Paul

Quoted 12 lines

Thanks
Wen Congyang

Quoted 8 lines

Paul

Quoted 4 lines

Thanks
Wen Congyang

Quoted 1 line
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

~Andrew
.

.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Quoted 6 lines
Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

.

#34 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 309 lines · Paul Durrant
Quoted 298 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 09:48
To: Paul Durrant; Andrew Cooper; Yang Hongyang; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 02:14
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 16 lines
Quoted 16 lines

page only one time

Quoted 5 lines · Paul Durrant
Quoted 5 lines

-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Wen Congyang
Sent: 10 June 2015 12:38
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 3 lines
Quoted 3 lines

page only one time

On 06/10/2015 06:58 PM, Paul Durrant wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 11:55
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore:

zero

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

ioreq

Quoted 7 lines
Quoted 7 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 10:06
To: Andrew Cooper; Yang Hongyang; [email protected];

Paul

Quoted 26 lines
Quoted 26 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Durrant

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore:

zero

Quoted 21 lines
Quoted 21 lines
Quoted 13 lines
Quoted 13 lines

ioreq

Quoted 12 lines
Quoted 12 lines

page only one time

Cc Paul Durrant
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Yang Hongyang
Quoted 3 lines · Andrew Cooper

On 09/06/2015 01:59, Yang Hongyang wrote:

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

On 06/08/2015 06:15 PM, Andrew Cooper wrote:
On 08/06/15 10:58, Yang Hongyang wrote:

On 06/08/2015 05:46 PM, Andrew Cooper wrote:
On 08/06/15 04:43, Yang Hongyang wrote:
ioreq page contains evtchn which will be set when we

resume

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

secondary vm the first time. The hypervisor will check if

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

evtchn is corrupted, so we cannot zero the ioreq page

more

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

than one time.

The ioreq->state is always STATE_IOREQ_NONE after

the

Quoted 5 lines
Quoted 5 lines

vm

Quoted 4 lines
Quoted 4 lines

is

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

suspended, so it is OK if we only zero it one time.

Signed-off-by: Yang Hongyang

<[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Signed-off-by: Wen congyang

<[email protected]>

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

CC: Andrew Cooper <[email protected]>

The issue here is that we are running the restore

algorithm

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

over

Quoted 2 lines
Quoted 2 lines

a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

domain which has already been running in Xen for a

while.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

This

Quoted 7 lines
Quoted 7 lines

is a

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

brand new usecase, as far as I am aware.

Exactly.

Does the qemu process associated with this domain get

frozen

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

while the
secondary is being reset, or does the process get

destroyed

Quoted 33 lines
Quoted 33 lines
Quoted 9 lines
Quoted 9 lines

and

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

recreated.

What do you mean by reset? do you mean secondary is

suspended

Quoted 4 lines
Quoted 4 lines

at

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

checkpoint?

Well - at the point that the buffered records are being

Quoted 8 lines
Quoted 8 lines

processed,

Quoted 2 lines
Quoted 2 lines

we

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

are in the process of resetting the state of the secondary to

match

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

the
primary.

Yes, at this point, the qemu process associated with this

domain is

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in

qemu)

Quoted 3 lines
Quoted 3 lines

to

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

pause
qemu. After we processed all records, qemu will be restored

with

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

received
state, that's why we add a

libxl__qmp_restore(qemu_load_vmstate()

Quoted 3 lines
Quoted 3 lines

in

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

qemu)
api to restore qemu with received state. Currently in libxl,

qemu

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

only

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

start
with the received state, there's no api to load received state

while

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

qemu is
running for a while.

Now I consider this more, it is absolutely wrong to not zero

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

page

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

here. The event channel in the page is not guaranteed to be

the

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

same

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

between the primary and secondary,

That's why we don't zero it on secondary.

I think you missed my point. Apologies for the double negative.

It

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

must, under all circumstances, be zeroed at this point, for safety

reasons.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The page in question is subject to logdirty just like any other

guest

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

pages, which means that if the guest writes to it naturally (i.e.

not a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Xen or Qemu write, both of whom have magic mappings which

are

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

not

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

subject to logdirty), it will be transmitted in the stream. As the event channel could be different, the lack of zeroing it at this

point

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

means that the event channel would be wrong as opposed to

simply

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

missing. This is a worse position to be in.

The guest should not access this page. I am not sure if the guest

can

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

access the ioreq page.

But in the exceptional case, the ioreq page is dirtied, and is copied

to

Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the secondary vm. The ioreq page will contain a wrong event

channel,

Quoted 2 lines
Quoted 2 lines

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

hypervisor will check it: if the event channel is wrong, the guest

will

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

be crashed.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

and we don't want to unexpectedly
find a pending/in-flight ioreq.

ioreq->state is always STATE_IOREQ_NONE after the vm is

suspended,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

there

Quoted 3 lines
Quoted 1 line

should be no pending/in-flight ioreq at checkpoint.

In the common case perhaps, but we must consider the

Quoted 8 lines
Quoted 8 lines

exceptional

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

case.

Quoted 1 line
Quoted 1 line
Quoted 1 line

The exceptional case here is some corruption which happens to

appear

Quoted 4 lines
Quoted 4 lines

as

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

an in-flight ioreq.

If the state is STATE_IOREQ_NONE, it may be hypervisor's bug. If

the

Quoted 10 lines
Quoted 10 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

hypervisor
has a bug, anything can happen. I think we should trust the

hypervisor.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Either qemu needs to take care of re-initialising the event

channels

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

back to appropriate values, or Xen should tolerate the

channels

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

disappearing.

I still stand by this statement. I believe it is the only safe way of solving the issue you have discovered.

Add a new qemu monitor command to update ioreq page?

If you're attaching to a 'new' VM (i.e one with an updated image)

then

Quoted 2 lines
Quoted 2 lines

I

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

suspect you're going to have to destroy and re-create the ioreq

server

Quoted 4 lines
Quoted 4 lines

so

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

that the shared page gets re-populated with the correct event

channels.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Either that or you're going to have to ensure that the page is not part

of

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

restored image and sample the new one that Xen should have set

up.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I agree with it. I will try to add a new qemu monitor command(or do

it

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

when

Quoted 3 lines
Quoted 1 line

updating qemu's state) to destroy and re-create it.

The slightly tricky part of that is that you're going to have to cache and

replay all the registrations that were done on the old instance, but you

need

Quoted 4 lines
Quoted 4 lines

to do that in any case as it's not state that is transferred in the VM save record.

Why do we have to cache and replay all the registrations that were

done

Quoted 7 lines
Quoted 7 lines

on

Quoted 3 lines
Quoted 1 line

the old instance?

Do you not have device models that you need to continue to function?

When the ioreq server is torn down then all MMIO, port IO and PCI config ranges that were mapped to it will disappear.

Quoted 8 lines
Quoted 6 lines

Yes, I don't known which should be done unless I implement and test it.

I have some questions about it:
1. Can guest access the ioreq page? If the page is modified by the guest unexpectedly,
what will happen?

No, the guest cannot modify the pages once a non-default ioreq server is

active. The pages are removed from the guest P2M when it is activated, which is one of the reasons for modifying QEMU to not behave as a legacy default server.

Quoted 2 lines
Quoted 2 lines

2. If the ioreq page is dirtied by the guest, it will be transfered from

primary

Quoted 5 lines
Quoted 3 lines

to secondary during checkpoint. The evtchn is invalid, I think the best
behavior
is that: make the guest crashed, not continue to run.

As I said, the pages are not in the P2M if the server is active so they will not

be transferred as part of the VM state. However, this presents a problem; at the far end, the emulator will not be able to hook into the guest. So, when the source domain is paused, the ioreq server needs to be torn down (so that its pages are re-inserted into the P2M and marked dirty for transfer). This is what happens in a normal migration. One extra problem you have is that the source domain is not then killed, it is resumed along with the emulator. Thus, on resume, the emulator needs to create a new ioreq server and re-register all its device models with that new server.

Quoted 6 lines
Quoted 1 line

I don't know the detail of what you do at the far end, but if you always start

a new emulator instance using the QEMU save record then you should be fine (just like with a normal migration).

I don't find the codes where the ioreq server is torn down when the source domain is paused. Which function?

Sorry, I overstated that. By 'torn down' I meant disabled. The function that does it is:

static void xen_hvm_change_state_handler(void *opaque, int running,
RunState rstate)

Quoted 12 lines
{
    XenIOState *state = opaque;

    if (running) {
        xen_main_loop_prepare(state);
    }

    xen_set_ioreq_server_state(xen_xc, xen_domid,
                               state->ioservid,
                               (rstate == RUN_STATE_RUNNING));
}

Yes, I see it now.

If the ioreq page is cleared, can xen_main_loop_prepare() put the correct evtchn in the ioreq page? If so, I think COLO can work without this patch.

In the hypervisor, the ioreq page is cleared before re-inserted into the P2M. So the far end always gets the zeroed ioreq page.

IIRC, there is only default ioreq server when I wrote this patch. In that case we don't have xen_main_loop_prepare(). It is OK that COLO cannot work with an older version qemu.

Yang, can you test COLO without this patch? I guess it can work, and we can drop this patch now.

Thanks
Wen Congyang

Quoted 76 lines
Quoted 4 lines

In our implementation, we don't start a new emulator. The codes can work, but some bugs may be not triggered.

How do you reconcile the incoming QEMU save record with the running emulator state?

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line
Quoted 52 lines
Quoted 7 lines
Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line

We will set to the guest to a new state, the old state should be

dropped.

Quoted 44 lines
Quoted 35 lines
Quoted 35 lines
Quoted 34 lines

Thanks
Wen Congyang

Quoted 15 lines

Paul

Quoted 12 lines

Thanks
Wen Congyang

Quoted 8 lines

Paul

Quoted 4 lines

Thanks
Wen Congyang

Quoted 1 line
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

~Andrew
.

.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Quoted 6 lines
Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

#35 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 331 lines · Wen Congyang
Quoted 309 lines · Paul Durrant
Quoted 298 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 09:48
To: Paul Durrant; Andrew Cooper; Yang Hongyang; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 02:14
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 16 lines
Quoted 16 lines

page only one time

Quoted 5 lines · Paul Durrant
Quoted 5 lines

-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Wen Congyang
Sent: 10 June 2015 12:38
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 3 lines
Quoted 3 lines

page only one time

On 06/10/2015 06:58 PM, Paul Durrant wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 11:55
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore:

zero

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

ioreq

Quoted 7 lines
Quoted 7 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 10 June 2015 10:06
To: Andrew Cooper; Yang Hongyang; [email protected];

Paul

Quoted 26 lines
Quoted 26 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Durrant

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; Eddie Dong; [email protected]; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore:

zero

Quoted 21 lines
Quoted 21 lines
Quoted 13 lines
Quoted 13 lines

ioreq

Quoted 12 lines
Quoted 12 lines

page only one time

Cc Paul Durrant
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Yang Hongyang

On 06/09/2015 03:30 PM, Andrew Cooper wrote:
On 09/06/2015 01:59, Yang Hongyang wrote:

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

On 06/08/2015 06:15 PM, Andrew Cooper wrote:
On 08/06/15 10:58, Yang Hongyang wrote:

On 06/08/2015 05:46 PM, Andrew Cooper wrote:
On 08/06/15 04:43, Yang Hongyang wrote:
ioreq page contains evtchn which will be set when we

resume

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

secondary vm the first time. The hypervisor will check if

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

evtchn is corrupted, so we cannot zero the ioreq page

more

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

than one time.

The ioreq->state is always STATE_IOREQ_NONE after

the

Quoted 5 lines
Quoted 5 lines

vm

Quoted 4 lines
Quoted 4 lines

is

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

suspended, so it is OK if we only zero it one time.

Signed-off-by: Yang Hongyang

<[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Signed-off-by: Wen congyang

<[email protected]>

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

CC: Andrew Cooper <[email protected]>

The issue here is that we are running the restore

algorithm

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

over

Quoted 2 lines
Quoted 2 lines

a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

domain which has already been running in Xen for a

while.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

This

Quoted 7 lines
Quoted 7 lines

is a

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

brand new usecase, as far as I am aware.

Exactly.

Does the qemu process associated with this domain get

frozen

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

while the
secondary is being reset, or does the process get

destroyed

Quoted 33 lines
Quoted 33 lines
Quoted 9 lines
Quoted 9 lines

and

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

recreated.

What do you mean by reset? do you mean secondary is

suspended

Quoted 4 lines
Quoted 4 lines

at

Quoted 3 lines
Quoted 3 lines

checkpoint?

Well - at the point that the buffered records are being

Quoted 8 lines
Quoted 8 lines

processed,

Quoted 2 lines
Quoted 2 lines

we

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

are in the process of resetting the state of the secondary to

match

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

the
primary.

Yes, at this point, the qemu process associated with this

domain is

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

frozen.
the suspend callback will call libxl__qmp_stop(vm_stop() in

qemu)

Quoted 3 lines
Quoted 3 lines

to

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

pause
qemu. After we processed all records, qemu will be restored

with

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

received
state, that's why we add a

libxl__qmp_restore(qemu_load_vmstate()

Quoted 3 lines
Quoted 3 lines

in

Quoted 2 lines
Quoted 2 lines

qemu)
api to restore qemu with received state. Currently in libxl,

qemu

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

only

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

start
with the received state, there's no api to load received state

while

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

qemu is
running for a while.

Now I consider this more, it is absolutely wrong to not zero

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

page

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

here. The event channel in the page is not guaranteed to be

the

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

same

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

between the primary and secondary,

That's why we don't zero it on secondary.

I think you missed my point. Apologies for the double negative.

It

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

must, under all circumstances, be zeroed at this point, for safety

reasons.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The page in question is subject to logdirty just like any other

guest

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

pages, which means that if the guest writes to it naturally (i.e.

not a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Xen or Qemu write, both of whom have magic mappings which

are

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

not

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

subject to logdirty), it will be transmitted in the stream. As the event channel could be different, the lack of zeroing it at this

point

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

means that the event channel would be wrong as opposed to

simply

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

missing. This is a worse position to be in.

The guest should not access this page. I am not sure if the guest

can

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

access the ioreq page.

But in the exceptional case, the ioreq page is dirtied, and is copied

to

Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the secondary vm. The ioreq page will contain a wrong event

channel,

Quoted 2 lines
Quoted 2 lines

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

hypervisor will check it: if the event channel is wrong, the guest

will

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

be crashed.

Quoted 6 lines
Quoted 6 lines

and we don't want to unexpectedly
find a pending/in-flight ioreq.

ioreq->state is always STATE_IOREQ_NONE after the vm is

suspended,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

there

Quoted 3 lines
Quoted 1 line

should be no pending/in-flight ioreq at checkpoint.

In the common case perhaps, but we must consider the

Quoted 8 lines
Quoted 8 lines

exceptional

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

case.

Quoted 1 line
Quoted 1 line
Quoted 1 line

The exceptional case here is some corruption which happens to

appear

Quoted 4 lines
Quoted 4 lines

as

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

an in-flight ioreq.

If the state is STATE_IOREQ_NONE, it may be hypervisor's bug. If

the

Quoted 10 lines
Quoted 10 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

hypervisor
has a bug, anything can happen. I think we should trust the

hypervisor.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Either qemu needs to take care of re-initialising the event

channels

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

back to appropriate values, or Xen should tolerate the

channels

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

disappearing.

I still stand by this statement. I believe it is the only safe way of solving the issue you have discovered.

Add a new qemu monitor command to update ioreq page?

If you're attaching to a 'new' VM (i.e one with an updated image)

then

Quoted 2 lines
Quoted 2 lines

I

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

suspect you're going to have to destroy and re-create the ioreq

server

Quoted 4 lines
Quoted 4 lines

so

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

that the shared page gets re-populated with the correct event

channels.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Either that or you're going to have to ensure that the page is not part

of

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

restored image and sample the new one that Xen should have set

up.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I agree with it. I will try to add a new qemu monitor command(or do

it

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

when

Quoted 3 lines
Quoted 1 line

updating qemu's state) to destroy and re-create it.

The slightly tricky part of that is that you're going to have to cache and

replay all the registrations that were done on the old instance, but you

need

Quoted 4 lines
Quoted 4 lines

to do that in any case as it's not state that is transferred in the VM save record.

Why do we have to cache and replay all the registrations that were

done

Quoted 7 lines
Quoted 7 lines

on

Quoted 3 lines
Quoted 1 line

the old instance?

Do you not have device models that you need to continue to function?

When the ioreq server is torn down then all MMIO, port IO and PCI config ranges that were mapped to it will disappear.

Quoted 8 lines
Quoted 6 lines

Yes, I don't known which should be done unless I implement and test it.

I have some questions about it:
1. Can guest access the ioreq page? If the page is modified by the guest unexpectedly,
what will happen?

No, the guest cannot modify the pages once a non-default ioreq server is

active. The pages are removed from the guest P2M when it is activated, which is one of the reasons for modifying QEMU to not behave as a legacy default server.

Quoted 2 lines
Quoted 2 lines

2. If the ioreq page is dirtied by the guest, it will be transfered from

primary

Quoted 5 lines
Quoted 3 lines

to secondary during checkpoint. The evtchn is invalid, I think the best
behavior
is that: make the guest crashed, not continue to run.

As I said, the pages are not in the P2M if the server is active so they will not

be transferred as part of the VM state. However, this presents a problem; at the far end, the emulator will not be able to hook into the guest. So, when the source domain is paused, the ioreq server needs to be torn down (so that its pages are re-inserted into the P2M and marked dirty for transfer). This is what happens in a normal migration. One extra problem you have is that the source domain is not then killed, it is resumed along with the emulator. Thus, on resume, the emulator needs to create a new ioreq server and re-register all its device models with that new server.

Quoted 6 lines
Quoted 1 line

I don't know the detail of what you do at the far end, but if you always start

a new emulator instance using the QEMU save record then you should be fine (just like with a normal migration).

I don't find the codes where the ioreq server is torn down when the source domain is paused. Which function?

Sorry, I overstated that. By 'torn down' I meant disabled. The function that does it is:

static void xen_hvm_change_state_handler(void *opaque, int running,
RunState rstate)

Quoted 12 lines
{
     XenIOState *state = opaque;

     if (running) {
         xen_main_loop_prepare(state);
     }

     xen_set_ioreq_server_state(xen_xc, xen_domid,
                                state->ioservid,
                                (rstate == RUN_STATE_RUNNING));
}

Yes, I see it now.

If the ioreq page is cleared, can xen_main_loop_prepare() put the correct evtchn in the ioreq page? If so, I think COLO can work without this patch.

In the hypervisor, the ioreq page is cleared before re-inserted into the P2M. So the far end always gets the zeroed ioreq page.

Quoted 6 lines

IIRC, there is only default ioreq server when I wrote this patch. In that case we don't have xen_main_loop_prepare(). It is OK that COLO cannot work with an older version qemu.

Yang, can you test COLO without this patch? I guess it can work, and we can drop this patch now.

Ok, this really is a historical patch...

Quoted 83 lines

Thanks
Wen Congyang

Quoted 70 lines
Quoted 4 lines

In our implementation, we don't start a new emulator. The codes can work, but some bugs may be not triggered.

How do you reconcile the incoming QEMU save record with the running emulator state?

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line
Quoted 52 lines
Quoted 7 lines
Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line

We will set to the guest to a new state, the old state should be

dropped.

Quoted 44 lines
Quoted 35 lines
Quoted 35 lines
Quoted 34 lines

Thanks
Wen Congyang

Quoted 15 lines

Paul

Quoted 12 lines

Thanks
Wen Congyang

Quoted 8 lines

Paul

Quoted 4 lines

Thanks
Wen Congyang

Quoted 1 line
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

~Andrew
.

.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Quoted 6 lines
Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

.

Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

.

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

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

On 06/11/2015 08:54 PM, Yang Hongyang wrote:
[...]

Quoted 4 lines
Quoted 1 line

this patch now.

Ok, this really is a historical patch...

Having tested, it is ok to drop this patch now.

Quoted 85 lines
Quoted 84 lines

Thanks
Wen Congyang

Quoted 71 lines
Quoted 4 lines

In our implementation, we don't start a new emulator. The codes can work, but some bugs may be not triggered.

How do you reconcile the incoming QEMU save record with the running emulator state?

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line
Quoted 52 lines
Quoted 7 lines
Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line

We will set to the guest to a new state, the old state should be

dropped.

Quoted 44 lines
Quoted 35 lines
Quoted 35 lines
Quoted 34 lines

Thanks
Wen Congyang

Quoted 15 lines

Paul

Quoted 12 lines

Thanks
Wen Congyang

Quoted 8 lines

Paul

Quoted 4 lines

Thanks
Wen Congyang

Quoted 1 line
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

~Andrew
.

.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Quoted 6 lines
Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

.

Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

.

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

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

In reply to Paul Durrant
Quoted 5 lines · Paul Durrant
Quoted 5 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 09:48
To: Paul Durrant; Andrew Cooper; Yang Hongyang; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected];

[...]

Quoted 7 lines
Quoted 5 lines

In our implementation, we don't start a new emulator. The codes can work, but some bugs may be not triggered.

How do you reconcile the incoming QEMU save record with the running emulator state?

We introduce a qmp command "xen-load-devices-state"(libxl__qmp_restore) which can restore the emulator state. The step of resotre emulator state at a checkpoint is:

1. libxl__qmp_stop -> vm_stop() in qemu
2. libxl__qmp_restore -> load_vmstate() in qemu
3. libxl__qmp_resume -> vm_start() in qemu

Quoted 70 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line
Quoted 52 lines
Quoted 7 lines
Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line

We will set to the guest to a new state, the old state should be

dropped.

Quoted 44 lines
Quoted 35 lines
Quoted 35 lines
Quoted 34 lines

Thanks
Wen Congyang

Quoted 15 lines

Paul

Quoted 12 lines

Thanks
Wen Congyang

Quoted 8 lines

Paul

Quoted 4 lines

Thanks
Wen Congyang

Quoted 1 line
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

~Andrew
.

.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Quoted 6 lines
Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

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

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 29 lines

-----Original Message-----
From: Yang Hongyang [mailto:[email protected]]
Sent: 11 June 2015 13:59
To: Paul Durrant; Wen Congyang; Andrew Cooper; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 09:48
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 1 line
Quoted 1 line
Cc Wei Liu; Ian Campbell; [email protected];

[...]

Quoted 3 lines
Quoted 3 lines

In our implementation, we don't start a new emulator. The codes can

work,

Quoted 4 lines
Quoted 2 lines

but some bugs may be not triggered.

How do you reconcile the incoming QEMU save record with the running

emulator state?

Quoted 9 lines

We introduce a qmp command "xen-load-devices- state"(libxl__qmp_restore) which
can restore the emulator state. The step of resotre emulator state at a checkpoint is:

1. libxl__qmp_stop -> vm_stop() in qemu
2. libxl__qmp_restore -> load_vmstate() in qemu
3. libxl__qmp_resume -> vm_start() in qemu

Ok, that sounds like the ideal time to hook back into Xen by creating a new ioreq server.

Paul

Quoted 74 lines
Quoted 64 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line
Quoted 52 lines
Quoted 7 lines
Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line

We will set to the guest to a new state, the old state should be

dropped.

Quoted 44 lines
Quoted 35 lines
Quoted 35 lines
Quoted 34 lines

Thanks
Wen Congyang

Quoted 15 lines

Paul

Quoted 12 lines

Thanks
Wen Congyang

Quoted 8 lines

Paul

Quoted 4 lines

Thanks
Wen Congyang

Quoted 1 line
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

~Andrew
.

.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Quoted 6 lines
Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

.

Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

--
Thanks,
Yang.

#39 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 34 lines · Paul Durrant
Quoted 34 lines

-----Original Message-----
From: Yang Hongyang [mailto:[email protected]]
Sent: 11 June 2015 13:59
To: Paul Durrant; Wen Congyang; Andrew Cooper; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 09:48
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 1 line
Quoted 1 line
Cc Wei Liu; Ian Campbell; [email protected];

[...]

Quoted 3 lines
Quoted 3 lines

In our implementation, we don't start a new emulator. The codes can

work,

Quoted 4 lines
Quoted 2 lines

but some bugs may be not triggered.

How do you reconcile the incoming QEMU save record with the running

emulator state?

We introduce a qmp command "xen-load-devices- state"(libxl__qmp_restore) which
can restore the emulator state. The step of resotre emulator state at a checkpoint is:

Quoted 6 lines
Quoted 4 lines

1. libxl__qmp_stop -> vm_stop() in qemu
2. libxl__qmp_restore -> load_vmstate() in qemu
3. libxl__qmp_resume -> vm_start() in qemu

Ok, that sounds like the ideal time to hook back into Xen by creating a new ioreq server.

I have some questions about ioreq server:
1. If we use old version xen and newest version qemu, is it OK? Is default ioreq server created when the guest is created. xen_create_ioreq_server() does nothing, and xen_get_ioreq_server_info() will get the default ioreq server information. Is it right?
2. Why we create a default ioreq server when getting the hvm param if there is already a not default ioreq server?
3. In the far end, we will clear the ioreq page, and this ioreq page is used for default ioreq server, is it right?

Thanks
Wen Congyang

Quoted 79 lines

Paul

Quoted 71 lines
Quoted 64 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line
Quoted 52 lines
Quoted 7 lines
Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line

We will set to the guest to a new state, the old state should be

dropped.

Quoted 44 lines
Quoted 35 lines
Quoted 35 lines
Quoted 34 lines

Thanks
Wen Congyang

Quoted 15 lines

Paul

Quoted 12 lines

Thanks
Wen Congyang

Quoted 8 lines

Paul

Quoted 4 lines

Thanks
Wen Congyang

Quoted 1 line
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

~Andrew
.

.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Quoted 6 lines
Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

.

Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

Quoted 3 lines

--
Thanks,
Yang.

.

#40 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 54 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 04:22
To: Paul Durrant; Yang Hongyang; Andrew Cooper; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Yang Hongyang [mailto:[email protected]]
Sent: 11 June 2015 13:59
To: Paul Durrant; Wen Congyang; Andrew Cooper; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 27 lines
Quoted 27 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 09:48
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 1 line
Quoted 1 line
Cc Wei Liu; Ian Campbell; [email protected];

[...]

Quoted 3 lines
Quoted 3 lines

In our implementation, we don't start a new emulator. The codes can

work,

Quoted 4 lines
Quoted 2 lines

but some bugs may be not triggered.

How do you reconcile the incoming QEMU save record with the running

emulator state?

We introduce a qmp command "xen-load-devices- state"(libxl__qmp_restore) which
can restore the emulator state. The step of resotre emulator state at a checkpoint is:

Quoted 6 lines
Quoted 4 lines

1. libxl__qmp_stop -> vm_stop() in qemu
2. libxl__qmp_restore -> load_vmstate() in qemu
3. libxl__qmp_resume -> vm_start() in qemu

Ok, that sounds like the ideal time to hook back into Xen by creating a new

ioreq server.

Quoted 7 lines

I have some questions about ioreq server:
1. If we use old version xen and newest version qemu, is it OK? Is default ioreq server created when the guest is created. xen_create_ioreq_server()
does
nothing, and xen_get_ioreq_server_info() will get the default ioreq server
information.
Is it right?

No. It's not compatible in that direction. A new Xen will work with an old QEMU but not the other way round.

Quoted 3 lines

2. Why we create a default ioreq server when getting the hvm param if there is already a
not default ioreq server?

If something reads the 'legacy' HVM params then that is Xen's trigger to create the default server. Any 'new' emulator should be using the ioreq server hypercalls so the default server will not be needed.

Quoted 3 lines

3. In the far end, we will clear the ioreq page, and this ioreq page is used for default
ioreq server, is it right?

Yes, AFAIK it's only the 'magic' pages that get cleared at the far end - and that includes the default server pages. Other ioreq servers will have their pages cleared on re-insertion to the P2M at the source end when the server is disabled.

Paul

Quoted 83 lines

Thanks
Wen Congyang

Quoted 79 lines

Paul

Quoted 71 lines
Quoted 64 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line
Quoted 52 lines
Quoted 7 lines
Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line

We will set to the guest to a new state, the old state should be

dropped.

Quoted 44 lines
Quoted 35 lines
Quoted 35 lines
Quoted 34 lines

Thanks
Wen Congyang

Quoted 15 lines

Paul

Quoted 12 lines

Thanks
Wen Congyang

Quoted 8 lines

Paul

Quoted 4 lines

Thanks
Wen Congyang

Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

~Andrew
.

.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Quoted 6 lines
Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

.

Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

Quoted 3 lines

--
Thanks,
Yang.

.

#41 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 62 lines · Paul Durrant
Quoted 54 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 04:22
To: Paul Durrant; Yang Hongyang; Andrew Cooper; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Yang Hongyang [mailto:[email protected]]
Sent: 11 June 2015 13:59
To: Paul Durrant; Wen Congyang; Andrew Cooper; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 27 lines
Quoted 27 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 09:48
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

[email protected]

Quoted 1 line
Quoted 1 line
Cc Wei Liu; Ian Campbell; [email protected];

[...]

Quoted 3 lines
Quoted 3 lines

In our implementation, we don't start a new emulator. The codes can

work,

Quoted 4 lines
Quoted 2 lines

but some bugs may be not triggered.

How do you reconcile the incoming QEMU save record with the running

emulator state?

We introduce a qmp command "xen-load-devices- state"(libxl__qmp_restore) which
can restore the emulator state. The step of resotre emulator state at a checkpoint is:

Quoted 6 lines
Quoted 4 lines

1. libxl__qmp_stop -> vm_stop() in qemu
2. libxl__qmp_restore -> load_vmstate() in qemu
3. libxl__qmp_resume -> vm_start() in qemu

Ok, that sounds like the ideal time to hook back into Xen by creating a new

ioreq server.

Quoted 7 lines

I have some questions about ioreq server:
1. If we use old version xen and newest version qemu, is it OK? Is default ioreq server created when the guest is created. xen_create_ioreq_server()
does
nothing, and xen_get_ioreq_server_info() will get the default ioreq server
information.
Is it right?

Quoted 7 lines

No. It's not compatible in that direction. A new Xen will work with an old QEMU but not the other way round.

Quoted 3 lines

2. Why we create a default ioreq server when getting the hvm param if there is already a
not default ioreq server?

If something reads the 'legacy' HVM params then that is Xen's trigger to create the default server. Any 'new' emulator should be using the ioreq server hypercalls so the default server will not be needed.

If there are two ioreq servers: default ioreq server, and a ioreq server created by emulator. The guest can work it correctly in this case? Is there any application(not emulator) that uses the libxenctrl directly?

Thanks
Wen Congyang

Quoted 95 lines
Quoted 4 lines

3. In the far end, we will clear the ioreq page, and this ioreq page is used for default
ioreq server, is it right?

Yes, AFAIK it's only the 'magic' pages that get cleared at the far end - and that includes the default server pages. Other ioreq servers will have their pages cleared on re-insertion to the P2M at the source end when the server is disabled.

Paul

Quoted 83 lines

Thanks
Wen Congyang

Quoted 79 lines

Paul

Quoted 71 lines
Quoted 64 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line
Quoted 52 lines
Quoted 7 lines
Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line

We will set to the guest to a new state, the old state should be

dropped.

Quoted 44 lines
Quoted 35 lines
Quoted 35 lines
Quoted 34 lines

Thanks
Wen Congyang

Quoted 15 lines

Paul

Quoted 12 lines

Thanks
Wen Congyang

Quoted 8 lines

Paul

Thanks
Wen Congyang

Quoted 9 lines
Quoted 6 lines
Quoted 6 lines

~Andrew
.

.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Quoted 6 lines
Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

.

Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

Quoted 3 lines

--
Thanks,
Yang.

.

.

#42 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 87 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 11:26
To: Paul Durrant; Yang Hongyang; Andrew Cooper; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 04:22
To: Paul Durrant; Yang Hongyang; Andrew Cooper; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 21 lines
Quoted 21 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Yang Hongyang [mailto:[email protected]]
Sent: 11 June 2015 13:59
To: Paul Durrant; Wen Congyang; Andrew Cooper; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 9 lines
Quoted 9 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 09:48
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

[email protected]

Quoted 1 line
Quoted 1 line
Cc Wei Liu; Ian Campbell; [email protected];

[...]

Quoted 3 lines
Quoted 3 lines

In our implementation, we don't start a new emulator. The codes

can

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

work,

Quoted 4 lines
Quoted 2 lines

but some bugs may be not triggered.

How do you reconcile the incoming QEMU save record with the

running

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

emulator state?

We introduce a qmp command "xen-load-devices- state"(libxl__qmp_restore) which
can restore the emulator state. The step of resotre emulator state at a checkpoint is:

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

1. libxl__qmp_stop -> vm_stop() in qemu
2. libxl__qmp_restore -> load_vmstate() in qemu
3. libxl__qmp_resume -> vm_start() in qemu

Ok, that sounds like the ideal time to hook back into Xen by creating a

new

Quoted 5 lines
Quoted 5 lines

ioreq server.

I have some questions about ioreq server:
1. If we use old version xen and newest version qemu, is it OK? Is default ioreq server created when the guest is created.

xen_create_ioreq_server()

Quoted 2 lines
Quoted 2 lines

does
nothing, and xen_get_ioreq_server_info() will get the default ioreq

server

Quoted 4 lines
Quoted 2 lines

information.
Is it right?

No. It's not compatible in that direction. A new Xen will work with an old

QEMU but not the other way round.

Quoted 2 lines
Quoted 2 lines

2. Why we create a default ioreq server when getting the hvm param if

there

Quoted 3 lines
Quoted 2 lines

is already a
not default ioreq server?

Quoted 7 lines
Quoted 1 line

If something reads the 'legacy' HVM params then that is Xen's trigger to

create the default server. Any 'new' emulator should be using the ioreq server hypercalls so the default server will not be needed.

If there are two ioreq servers: default ioreq server, and a ioreq server created by emulator. The guest can work it correctly in
this case?

You mean a secondary emulator? Yes, that's why there is the notion of default ioreq server... to allow a secondary emulator to be used even when an old QEMU is in use.

Quoted 3 lines

Is there any application(not emulator) that uses the libxenctrl directly?

What do you mean by application? Toolstacks may use libxenctrl.

Paul

Quoted 102 lines

Thanks
Wen Congyang

Quoted 2 lines
Quoted 2 lines

3. In the far end, we will clear the ioreq page, and this ioreq page is used

for

Quoted 4 lines
Quoted 2 lines

default
ioreq server, is it right?

Yes, AFAIK it's only the 'magic' pages that get cleared at the far end - and

that includes the default server pages. Other ioreq servers will have their pages cleared on re-insertion to the P2M at the source end when the server is disabled.

Quoted 89 lines

Paul

Quoted 83 lines

Thanks
Wen Congyang

Quoted 79 lines

Paul

Quoted 71 lines
Quoted 64 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line
Quoted 52 lines
Quoted 7 lines
Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line

We will set to the guest to a new state, the old state should be

dropped.

Quoted 44 lines
Quoted 35 lines
Quoted 35 lines
Quoted 34 lines

Thanks
Wen Congyang

Quoted 15 lines

Paul

Quoted 12 lines

Thanks
Wen Congyang

Paul

Thanks
Wen Congyang

Quoted 9 lines
Quoted 6 lines

~Andrew
.

.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Quoted 6 lines
Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

.

Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

Quoted 3 lines

--
Thanks,
Yang.

.

.

#43 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 73 lines · Paul Durrant
Quoted 73 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 11:26
To: Paul Durrant; Yang Hongyang; Andrew Cooper; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 04:22
To: Paul Durrant; Yang Hongyang; Andrew Cooper; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 21 lines
Quoted 21 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Yang Hongyang [mailto:[email protected]]
Sent: 11 June 2015 13:59
To: Paul Durrant; Wen Congyang; Andrew Cooper; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 9 lines
Quoted 9 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 09:48
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

[email protected]

Quoted 1 line
Quoted 1 line
Cc Wei Liu; Ian Campbell; [email protected];

[...]

Quoted 3 lines
Quoted 3 lines

In our implementation, we don't start a new emulator. The codes

can

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

work,

Quoted 4 lines
Quoted 2 lines

but some bugs may be not triggered.

How do you reconcile the incoming QEMU save record with the

running

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

emulator state?

We introduce a qmp command "xen-load-devices- state"(libxl__qmp_restore) which
can restore the emulator state. The step of resotre emulator state at a checkpoint is:

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

1. libxl__qmp_stop -> vm_stop() in qemu
2. libxl__qmp_restore -> load_vmstate() in qemu
3. libxl__qmp_resume -> vm_start() in qemu

Ok, that sounds like the ideal time to hook back into Xen by creating a

new

Quoted 5 lines
Quoted 5 lines

ioreq server.

I have some questions about ioreq server:
1. If we use old version xen and newest version qemu, is it OK? Is default ioreq server created when the guest is created.

xen_create_ioreq_server()

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

does
nothing, and xen_get_ioreq_server_info() will get the default ioreq

server

Quoted 4 lines
Quoted 2 lines

information.
Is it right?

No. It's not compatible in that direction. A new Xen will work with an old

QEMU but not the other way round.

If the xen is newest, and qemu is old, how is the default ioreq server created for the emulator? Will the old qemu call xc_get_hvm_param(), and the hypervisor then creates a default ioreq server?
get is a 'readonly' operation, and creating the default ioreq server in it is very strange.

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

2. Why we create a default ioreq server when getting the hvm param if

there

Quoted 4 lines
Quoted 2 lines

is already a
not default ioreq server?

If something reads the 'legacy' HVM params then that is Xen's trigger to

Quoted 8 lines
Quoted 6 lines

create the default server. Any 'new' emulator should be using the ioreq server hypercalls so the default server will not be needed.

If there are two ioreq servers: default ioreq server, and a ioreq server created by emulator. The guest can work it correctly in
this case?

You mean a secondary emulator? Yes, that's why there is the notion of default ioreq server... to allow a secondary emulator to be used even when an old QEMU is in use.

No, only one emulator. Can we run more than one emulator for one hvm guest? How to do it?

Quoted 6 lines
Quoted 4 lines

Is there any application(not emulator) that uses the libxenctrl directly?

What do you mean by application? Toolstacks may use libxenctrl.

For example: libvirt. I know it uses libxl now. Is there any similar application which uses libxenctrl.

Thanks
Wen Congyang

Quoted 108 lines

Paul

Quoted 5 lines

Thanks
Wen Congyang

Quoted 2 lines
Quoted 2 lines

3. In the far end, we will clear the ioreq page, and this ioreq page is used

Quoted 97 lines

for

Quoted 4 lines
Quoted 2 lines

default
ioreq server, is it right?

Yes, AFAIK it's only the 'magic' pages that get cleared at the far end - and

that includes the default server pages. Other ioreq servers will have their pages cleared on re-insertion to the P2M at the source end when the server is disabled.

Quoted 89 lines

Paul

Quoted 83 lines

Thanks
Wen Congyang

Quoted 79 lines

Paul

Quoted 71 lines
Quoted 64 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line
Quoted 52 lines
Quoted 7 lines
Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line

We will set to the guest to a new state, the old state should be

dropped.

Quoted 44 lines
Quoted 35 lines
Quoted 35 lines
Quoted 34 lines

Thanks
Wen Congyang

Quoted 24 lines

Paul

Thanks
Wen Congyang

Paul

Thanks
Wen Congyang

~Andrew
.

.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Quoted 6 lines
Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

.

Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

Quoted 3 lines

--
Thanks,
Yang.

.

.

.

#44 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 96 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 12:10
To: Paul Durrant; Yang Hongyang; Andrew Cooper; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 11:26
To: Paul Durrant; Yang Hongyang; Andrew Cooper; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 14 lines
Quoted 14 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 04:22
To: Paul Durrant; Yang Hongyang; Andrew Cooper; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 2 lines
Quoted 2 lines

page only one time

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · Paul Durrant
Quoted 4 lines
Quoted 4 lines

-----Original Message-----
From: Yang Hongyang [mailto:[email protected]]
Sent: 11 June 2015 13:59
To: Paul Durrant; Wen Congyang; Andrew Cooper; xen-

[email protected]

Quoted 2 lines
Quoted 2 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian

Jackson

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore:

zero

Quoted 21 lines
Quoted 21 lines
Quoted 10 lines
Quoted 10 lines

ioreq

Quoted 9 lines
Quoted 9 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 09:48
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

[email protected]

Quoted 1 line
Quoted 1 line
Cc Wei Liu; Ian Campbell; [email protected];

[...]

Quoted 3 lines
Quoted 3 lines

In our implementation, we don't start a new emulator. The codes

can

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

work,

Quoted 3 lines
Quoted 2 lines

but some bugs may be not triggered.

Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

How do you reconcile the incoming QEMU save record with the

running

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

emulator state?

We introduce a qmp command "xen-load-devices- state"(libxl__qmp_restore) which
can restore the emulator state. The step of resotre emulator state at

a

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

checkpoint is:

1. libxl__qmp_stop -> vm_stop() in qemu
2. libxl__qmp_restore -> load_vmstate() in qemu
3. libxl__qmp_resume -> vm_start() in qemu

Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Ok, that sounds like the ideal time to hook back into Xen by creating a

new

Quoted 4 lines
Quoted 4 lines

ioreq server.

I have some questions about ioreq server:
1. If we use old version xen and newest version qemu, is it OK? Is

default

Quoted 9 lines
Quoted 9 lines
Quoted 1 line
Quoted 1 line

ioreq server created when the guest is created.

xen_create_ioreq_server()

Quoted 2 lines
Quoted 2 lines

does
nothing, and xen_get_ioreq_server_info() will get the default ioreq

server

Quoted 4 lines
Quoted 2 lines

information.
Is it right?

No. It's not compatible in that direction. A new Xen will work with an old

Quoted 9 lines
Quoted 1 line
Quoted 1 line

QEMU but not the other way round.

If the xen is newest, and qemu is old, how is the default ioreq server created for the emulator? Will the old qemu call xc_get_hvm_param(), and the hypervisor
then creates a default ioreq server?
get is a 'readonly' operation, and creating the default ioreq server in it is very strange.

Might be strange, but that's the way it's done.

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 2 lines
Quoted 2 lines

2. Why we create a default ioreq server when getting the hvm param if

there

Quoted 4 lines
Quoted 2 lines

is already a
not default ioreq server?

If something reads the 'legacy' HVM params then that is Xen's trigger to

create the default server. Any 'new' emulator should be using the ioreq server hypercalls so the default server will not be needed.

If there are two ioreq servers: default ioreq server, and a ioreq server created by emulator. The guest can work it correctly in
this case?

Quoted 8 lines
Quoted 1 line

You mean a secondary emulator? Yes, that's why there is the notion of

default ioreq server... to allow a secondary emulator to be used even when an old QEMU is in use.

No, only one emulator. Can we run more than one emulator for one hvm guest? How
to do it?

Yes, more than one emulator can run. There's nothing in libxl to do it, but we do it in XenServer using XAPI.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

Is there any application(not emulator) that uses the libxenctrl directly?

What do you mean by application? Toolstacks may use libxenctrl.

For example: libvirt. I know it uses libxl now. Is there any similar application which uses libxenctrl.

Well, XAPI uses it for one.

Paul

Quoted 116 lines

Thanks
Wen Congyang

Quoted 8 lines

Paul

Quoted 5 lines

Thanks
Wen Congyang

Quoted 2 lines
Quoted 2 lines

3. In the far end, we will clear the ioreq page, and this ioreq page is

used

Quoted 7 lines
Quoted 7 lines

for

Quoted 4 lines
Quoted 2 lines

default
ioreq server, is it right?

Yes, AFAIK it's only the 'magic' pages that get cleared at the far end - and

that includes the default server pages. Other ioreq servers will have their pages cleared on re-insertion to the P2M at the source end when the

server

Quoted 21 lines
Quoted 21 lines

is disabled.

Quoted 20 lines

Paul

Quoted 17 lines

Thanks
Wen Congyang

Quoted 13 lines

Paul

Quoted 10 lines
Quoted 10 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line

We will set to the guest to a new state, the old state should

be

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines

dropped.

Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

Thanks
Wen Congyang

Paul

Thanks
Wen Congyang

Paul

Thanks
Wen Congyang

~Andrew
.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

.

.

_______________________________________________

Quoted 33 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 3 lines

Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

Quoted 2 lines
Quoted 2 lines

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

--
Thanks,
Yang.

.

.

.

#45 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

At 2015/6/12 19:48, Paul Durrant Wrote:

Quoted 106 lines
Quoted 96 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 12:10
To: Paul Durrant; Yang Hongyang; Andrew Cooper; [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 11:26
To: Paul Durrant; Yang Hongyang; Andrew Cooper; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 14 lines
Quoted 14 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 04:22
To: Paul Durrant; Yang Hongyang; Andrew Cooper; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 2 lines
Quoted 2 lines

page only one time

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · Paul Durrant
Quoted 4 lines
Quoted 4 lines

-----Original Message-----
From: Yang Hongyang [mailto:[email protected]]
Sent: 11 June 2015 13:59
To: Paul Durrant; Wen Congyang; Andrew Cooper; xen-

[email protected]

Quoted 2 lines
Quoted 2 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian

Jackson

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore:

zero

Quoted 21 lines
Quoted 21 lines
Quoted 10 lines
Quoted 10 lines

ioreq

Quoted 9 lines
Quoted 9 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 09:48
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

[email protected]

Quoted 1 line
Quoted 1 line
Cc Wei Liu; Ian Campbell; [email protected];

[...]

Quoted 3 lines
Quoted 3 lines

In our implementation, we don't start a new emulator. The codes

can

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

work,

Quoted 3 lines
Quoted 2 lines

but some bugs may be not triggered.

Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

How do you reconcile the incoming QEMU save record with the

running

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

emulator state?

We introduce a qmp command "xen-load-devices- state"(libxl__qmp_restore) which
can restore the emulator state. The step of resotre emulator state at

a

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

checkpoint is:

1. libxl__qmp_stop -> vm_stop() in qemu
2. libxl__qmp_restore -> load_vmstate() in qemu
3. libxl__qmp_resume -> vm_start() in qemu

Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Ok, that sounds like the ideal time to hook back into Xen by creating a

new

Quoted 4 lines
Quoted 4 lines

ioreq server.

I have some questions about ioreq server:
1. If we use old version xen and newest version qemu, is it OK? Is

default

Quoted 9 lines
Quoted 9 lines
Quoted 1 line
Quoted 1 line

ioreq server created when the guest is created.

xen_create_ioreq_server()

Quoted 2 lines
Quoted 2 lines

does
nothing, and xen_get_ioreq_server_info() will get the default ioreq

server

Quoted 4 lines
Quoted 2 lines

information.
Is it right?

No. It's not compatible in that direction. A new Xen will work with an old

Quoted 9 lines
Quoted 1 line
Quoted 1 line

QEMU but not the other way round.

If the xen is newest, and qemu is old, how is the default ioreq server created for the emulator? Will the old qemu call xc_get_hvm_param(), and the hypervisor
then creates a default ioreq server?
get is a 'readonly' operation, and creating the default ioreq server in it is very strange.

Quoted 1 line

Might be strange, but that's the way it's done.

If I only want to get the default ioreq server pfn, and don't want to create the default ioreq server, how can I do it?

Thanks
Wen Congyang

Quoted 163 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 3 lines
Quoted 3 lines

2. Why we create a default ioreq server when getting the hvm param if

there

Quoted 4 lines
Quoted 2 lines

is already a
not default ioreq server?

If something reads the 'legacy' HVM params then that is Xen's trigger to

create the default server. Any 'new' emulator should be using the ioreq server hypercalls so the default server will not be needed.

If there are two ioreq servers: default ioreq server, and a ioreq server created by emulator. The guest can work it correctly in
this case?

Quoted 8 lines
Quoted 1 line

You mean a secondary emulator? Yes, that's why there is the notion of

default ioreq server... to allow a secondary emulator to be used even when an old QEMU is in use.

No, only one emulator. Can we run more than one emulator for one hvm guest? How
to do it?

Yes, more than one emulator can run. There's nothing in libxl to do it, but we do it in XenServer using XAPI.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

Is there any application(not emulator) that uses the libxenctrl directly?

What do you mean by application? Toolstacks may use libxenctrl.

For example: libvirt. I know it uses libxl now. Is there any similar application which uses libxenctrl.

Well, XAPI uses it for one.

Paul

Quoted 77 lines

Thanks
Wen Congyang

Quoted 8 lines

Paul

Quoted 5 lines

Thanks
Wen Congyang

Quoted 2 lines
Quoted 2 lines

3. In the far end, we will clear the ioreq page, and this ioreq page is

used

Quoted 7 lines
Quoted 7 lines

for

Quoted 4 lines
Quoted 2 lines

default
ioreq server, is it right?

Yes, AFAIK it's only the 'magic' pages that get cleared at the far end - and

that includes the default server pages. Other ioreq servers will have their pages cleared on re-insertion to the P2M at the source end when the

server

Quoted 21 lines
Quoted 21 lines

is disabled.

Quoted 20 lines

Paul

Quoted 17 lines

Thanks
Wen Congyang

Quoted 13 lines

Paul

Quoted 10 lines
Quoted 10 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

We will set to the guest to a new state, the old state should

be

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines

dropped.

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines

Thanks
Wen Congyang

Paul

Thanks
Wen Congyang

Paul

Thanks
Wen Congyang

~Andrew
.

.

Quoted 39 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

.

_______________________________________________

Quoted 33 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines

Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

Quoted 2 lines
Quoted 2 lines

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

--
Thanks,
Yang.

.

.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#46 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

Quoted 127 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 16:05
To: Paul Durrant; Wen Congyang; Yang Hongyang; Andrew Cooper; xen- [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

At 2015/6/12 19:48, Paul Durrant Wrote:

Quoted 4 lines
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 12:10
To: Paul Durrant; Yang Hongyang; Andrew Cooper; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 14 lines
Quoted 14 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 11:26
To: Paul Durrant; Yang Hongyang; Andrew Cooper; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 2 lines
Quoted 2 lines

page only one time

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · Paul Durrant
Quoted 4 lines
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 04:22
To: Paul Durrant; Yang Hongyang; Andrew Cooper; xen-

[email protected]

Quoted 2 lines
Quoted 2 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian

Jackson

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore:

zero

Quoted 24 lines
Quoted 24 lines
Quoted 11 lines
Quoted 11 lines

ioreq

Quoted 10 lines
Quoted 10 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Yang Hongyang [mailto:[email protected]]
Sent: 11 June 2015 13:59
To: Paul Durrant; Wen Congyang; Andrew Cooper; xen-

[email protected]

Quoted 2 lines
Quoted 2 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian

Jackson

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore:

zero

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

ioreq

Quoted 9 lines
Quoted 9 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 09:48
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

[email protected]

Quoted 1 line
Quoted 1 line
Cc Wei Liu; Ian Campbell; [email protected];

[...]

Quoted 3 lines
Quoted 3 lines

In our implementation, we don't start a new emulator. The

codes

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

can

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

work,

Quoted 3 lines
Quoted 2 lines

but some bugs may be not triggered.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

How do you reconcile the incoming QEMU save record with the

running

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

emulator state?

We introduce a qmp command "xen-load-devices- state"(libxl__qmp_restore) which
can restore the emulator state. The step of resotre emulator state

at

Quoted 9 lines
Quoted 9 lines

a

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

checkpoint is:

1. libxl__qmp_stop -> vm_stop() in qemu
2. libxl__qmp_restore -> load_vmstate() in qemu
3. libxl__qmp_resume -> vm_start() in qemu

Ok, that sounds like the ideal time to hook back into Xen by

creating a

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

new

Quoted 4 lines
Quoted 4 lines

ioreq server.

I have some questions about ioreq server:
1. If we use old version xen and newest version qemu, is it OK? Is

default

Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

ioreq server created when the guest is created.

xen_create_ioreq_server()

Quoted 2 lines
Quoted 2 lines

does
nothing, and xen_get_ioreq_server_info() will get the default

ioreq

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

server

Quoted 4 lines
Quoted 2 lines

information.
Is it right?

No. It's not compatible in that direction. A new Xen will work with an

old

Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

QEMU but not the other way round.

If the xen is newest, and qemu is old, how is the default ioreq server

created

Quoted 7 lines
Quoted 6 lines

for the emulator? Will the old qemu call xc_get_hvm_param(), and the hypervisor
then creates a default ioreq server?
get is a 'readonly' operation, and creating the default ioreq server in it is very strange.

Quoted 5 lines
Quoted 1 line

Might be strange, but that's the way it's done.

If I only want to get the default ioreq server pfn, and don't want to create the default
ioreq server, how can I do it?

At the moment you can't. If you read the pfns then you will instantiate the server, which I agree is a bit of a problem if you're only doing a domain save.

Paul

Quoted 176 lines

Thanks
Wen Congyang

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

2. Why we create a default ioreq server when getting the hvm

param if

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

there

Quoted 4 lines
Quoted 2 lines

is already a
not default ioreq server?

If something reads the 'legacy' HVM params then that is Xen's trigger

to

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines

create the default server. Any 'new' emulator should be using the ioreq server hypercalls so the default server will not be needed.

If there are two ioreq servers: default ioreq server, and a ioreq server created by emulator. The guest can work it correctly in
this case?

You mean a secondary emulator? Yes, that's why there is the notion of

default ioreq server... to allow a secondary emulator to be used even

when

Quoted 8 lines
Quoted 6 lines

an old QEMU is in use.

No, only one emulator. Can we run more than one emulator for one hvm guest? How
to do it?

Yes, more than one emulator can run. There's nothing in libxl to do it, but

we do it in XenServer using XAPI.

Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

Is there any application(not emulator) that uses the libxenctrl directly?

What do you mean by application? Toolstacks may use libxenctrl.

For example: libvirt. I know it uses libxl now. Is there any similar

application

Quoted 24 lines
Quoted 1 line

which uses libxenctrl.

Well, XAPI uses it for one.

Paul

Quoted 18 lines

Thanks
Wen Congyang

Quoted 8 lines

Paul

Quoted 5 lines

Thanks
Wen Congyang

Quoted 2 lines
Quoted 2 lines

3. In the far end, we will clear the ioreq page, and this ioreq page is

used

Quoted 5 lines
Quoted 5 lines

for

Quoted 4 lines
Quoted 2 lines

default
ioreq server, is it right?

Yes, AFAIK it's only the 'magic' pages that get cleared at the far end -

and

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

that includes the default server pages. Other ioreq servers will have

their

Quoted 23 lines
Quoted 23 lines
Quoted 1 line
Quoted 1 line

pages cleared on re-insertion to the P2M at the source end when the

server

Quoted 21 lines
Quoted 21 lines

is disabled.

Quoted 20 lines

Paul

Quoted 17 lines

Thanks
Wen Congyang

Quoted 13 lines

Paul

Quoted 10 lines
Quoted 10 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Thanks
Wen Congyang

Paul

We will set to the guest to a new state, the old state

should

Quoted 33 lines
Quoted 33 lines

be

Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines

dropped.

Quoted 31 lines
Quoted 31 lines

Thanks
Wen Congyang

Paul

Thanks
Wen Congyang

Paul

Thanks
Wen Congyang

~Andrew
.

.

.

Quoted 6 lines
Quoted 6 lines

_______________________________________________

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________

Quoted 35 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

.

Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

--
Thanks,
Yang.

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

.

.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#47 lore raw

Re: [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

At 2015/6/12 23:31, Paul Durrant Wrote:

Quoted 127 lines
Quoted 127 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 16:05
To: Paul Durrant; Wen Congyang; Yang Hongyang; Andrew Cooper; xen- [email protected]
Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero ioreq page only one time

At 2015/6/12 19:48, Paul Durrant Wrote:

Quoted 4 lines
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 12:10
To: Paul Durrant; Yang Hongyang; Andrew Cooper; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 14 lines
Quoted 14 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 11:26
To: Paul Durrant; Yang Hongyang; Andrew Cooper; xen-

[email protected]

Quoted 3 lines
Quoted 3 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian Jackson
Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore: zero

ioreq

Quoted 2 lines
Quoted 2 lines

page only one time

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · Paul Durrant
Quoted 4 lines
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 12 June 2015 04:22
To: Paul Durrant; Yang Hongyang; Andrew Cooper; xen-

[email protected]

Quoted 2 lines
Quoted 2 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian

Jackson

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore:

zero

Quoted 24 lines
Quoted 24 lines
Quoted 11 lines
Quoted 11 lines

ioreq

Quoted 10 lines
Quoted 10 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Yang Hongyang [mailto:[email protected]]
Sent: 11 June 2015 13:59
To: Paul Durrant; Wen Congyang; Andrew Cooper; xen-

[email protected]

Quoted 2 lines
Quoted 2 lines

Cc: Wei Liu; Ian Campbell; [email protected]; [email protected]; Eddie Dong; [email protected]; Ian

Jackson

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Subject: Re: [Xen-devel] [PATCH v2 COLOPre 03/13] libxc/restore:

zero

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

ioreq

Quoted 9 lines
Quoted 9 lines

page only one time

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Wen Congyang [mailto:[email protected]]
Sent: 11 June 2015 09:48
To: Paul Durrant; Andrew Cooper; Yang Hongyang; xen-

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

[email protected]

Quoted 1 line
Quoted 1 line
Cc Wei Liu; Ian Campbell; [email protected];

[...]

Quoted 3 lines
Quoted 3 lines

In our implementation, we don't start a new emulator. The

codes

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

can

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

work,

Quoted 3 lines
Quoted 2 lines

but some bugs may be not triggered.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

How do you reconcile the incoming QEMU save record with the

running

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

emulator state?

We introduce a qmp command "xen-load-devices- state"(libxl__qmp_restore) which
can restore the emulator state. The step of resotre emulator state

at

Quoted 9 lines
Quoted 9 lines

a

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

checkpoint is:

1. libxl__qmp_stop -> vm_stop() in qemu
2. libxl__qmp_restore -> load_vmstate() in qemu
3. libxl__qmp_resume -> vm_start() in qemu

Ok, that sounds like the ideal time to hook back into Xen by

creating a

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

new

Quoted 4 lines
Quoted 4 lines

ioreq server.

I have some questions about ioreq server:
1. If we use old version xen and newest version qemu, is it OK? Is

default

Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

ioreq server created when the guest is created.

xen_create_ioreq_server()

Quoted 2 lines
Quoted 2 lines

does
nothing, and xen_get_ioreq_server_info() will get the default

ioreq

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

server

Quoted 4 lines
Quoted 2 lines

information.
Is it right?

No. It's not compatible in that direction. A new Xen will work with an

old

Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

QEMU but not the other way round.

If the xen is newest, and qemu is old, how is the default ioreq server

created

Quoted 7 lines
Quoted 6 lines

for the emulator? Will the old qemu call xc_get_hvm_param(), and the hypervisor
then creates a default ioreq server?
get is a 'readonly' operation, and creating the default ioreq server in it is very strange.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Might be strange, but that's the way it's done.

If I only want to get the default ioreq server pfn, and don't want to create the default
ioreq server, how can I do it?

At the moment you can't. If you read the pfns then you will instantiate the server, which I agree is a bit of a problem if you're only doing a domain save.

Yes, but we have to instantiate the server so old version qemu can work. Can we add a new interface to just get the ioreq pfn, buffer ioreq pfn/evtchn? For example HVM_PARAM_DEFAULT_IOREQ_PFN.

Thanks
Wen congyang

Quoted 180 lines

Paul

Quoted 176 lines

Thanks
Wen Congyang

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

2. Why we create a default ioreq server when getting the hvm

param if

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

there

Quoted 4 lines
Quoted 2 lines

is already a
not default ioreq server?

If something reads the 'legacy' HVM params then that is Xen's trigger

to

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines

create the default server. Any 'new' emulator should be using the ioreq server hypercalls so the default server will not be needed.

If there are two ioreq servers: default ioreq server, and a ioreq server created by emulator. The guest can work it correctly in
this case?

You mean a secondary emulator? Yes, that's why there is the notion of

default ioreq server... to allow a secondary emulator to be used even

when

Quoted 8 lines
Quoted 6 lines

an old QEMU is in use.

No, only one emulator. Can we run more than one emulator for one hvm guest? How
to do it?

Yes, more than one emulator can run. There's nothing in libxl to do it, but

we do it in XenServer using XAPI.

Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

Is there any application(not emulator) that uses the libxenctrl directly?

What do you mean by application? Toolstacks may use libxenctrl.

For example: libvirt. I know it uses libxl now. Is there any similar

application

Quoted 24 lines
Quoted 1 line

which uses libxenctrl.

Well, XAPI uses it for one.

Paul

Quoted 18 lines

Thanks
Wen Congyang

Quoted 8 lines

Paul

Quoted 5 lines

Thanks
Wen Congyang

Quoted 2 lines
Quoted 2 lines

3. In the far end, we will clear the ioreq page, and this ioreq page is

used

Quoted 5 lines
Quoted 5 lines

for

Quoted 4 lines
Quoted 2 lines

default
ioreq server, is it right?

Yes, AFAIK it's only the 'magic' pages that get cleared at the far end -

and

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

that includes the default server pages. Other ioreq servers will have

their

Quoted 23 lines
Quoted 23 lines
Quoted 1 line
Quoted 1 line

pages cleared on re-insertion to the P2M at the source end when the

server

Quoted 21 lines
Quoted 21 lines

is disabled.

Quoted 20 lines

Paul

Quoted 17 lines

Thanks
Wen Congyang

Quoted 13 lines

Paul

Quoted 10 lines
Quoted 10 lines

Paul

Quoted 7 lines

Thanks
Wen Congyang

Quoted 4 lines

Paul

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Thanks
Wen Congyang

Paul

We will set to the guest to a new state, the old state

should

Quoted 33 lines
Quoted 33 lines

be

Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines

dropped.

Quoted 31 lines

Thanks
Wen Congyang

Paul

Thanks
Wen Congyang

Paul

Thanks
Wen Congyang

~Andrew
.

.

.

Quoted 6 lines
Quoted 6 lines

_______________________________________________

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________

Quoted 35 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines

Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

.

Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
.

--
Thanks,
Yang.

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

.

.

.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#48 lore raw

PATCH v2 4/13 tools/libxc: export xc_bitops.h

In reply to Yang Hongyang

When we are under COLO, we will send dirty page bitmap info from secondary to primary at every checkpoint. So we need to get/test the dirty page bitmap. We just expose xc_bitops.h for libxl use.

NOTE:
Need to make clean and rerun configure to get it compiled.

---
 tools/libxc/include/xc_bitops.h | 76 +++++++++++++++++++++++++++++++++++++++++
 tools/libxc/xc_bitops.h         | 76 -----------------------------------------
 2 files changed, 76 insertions(+), 76 deletions(-)
 create mode 100644 tools/libxc/include/xc_bitops.h
 delete mode 100644 tools/libxc/xc_bitops.h
tools/libxc/include/xc_bitops.h new file +76 -0
new file mode 100644
index 0000000..cd749f4
@@ -0,0 +1,76 @@
+#ifndef XC_BITOPS_H
+#define XC_BITOPS_H 1
+
+/* bitmap operations for single threaded access */
+
+#include <stdlib.h>
+#include <string.h>
+
+#define BITS_PER_LONG (sizeof(unsigned long) * 8)
+#define ORDER_LONG (sizeof(unsigned long) == 4 ? 5 : 6)
+
+#define BITMAP_ENTRY(_nr,_bmap) ((_bmap))[(_nr)/BITS_PER_LONG]
+#define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG)
+
+/* calculate required space for number of longs needed to hold nr_bits */
+static inline int bitmap_size(int nr_bits)
+{
+    int nr_long, nr_bytes;
+    nr_long = (nr_bits + BITS_PER_LONG - 1) >> ORDER_LONG;
+    nr_bytes = nr_long * sizeof(unsigned long);
+    return nr_bytes;
+}
+
+static inline unsigned long *bitmap_alloc(int nr_bits)
+{
+    return calloc(1, bitmap_size(nr_bits));
+}
+
+static inline void bitmap_set(unsigned long *addr, int nr_bits)
+{
+    memset(addr, 0xff, bitmap_size(nr_bits));
+}
+
+static inline void bitmap_clear(unsigned long *addr, int nr_bits)
+{
+    memset(addr, 0, bitmap_size(nr_bits));
+}
+
+static inline int test_bit(int nr, unsigned long *addr)
+{
+    return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1;
+}
+
+static inline void clear_bit(int nr, unsigned long *addr)
+{
+    BITMAP_ENTRY(nr, addr) &= ~(1UL << BITMAP_SHIFT(nr));
+}
+
+static inline void set_bit(int nr, unsigned long *addr)
+{
+    BITMAP_ENTRY(nr, addr) |= (1UL << BITMAP_SHIFT(nr));
+}
+
+static inline int test_and_clear_bit(int nr, unsigned long *addr)
+{
+    int oldbit = test_bit(nr, addr);
+    clear_bit(nr, addr);
+    return oldbit;
+}
+
+static inline int test_and_set_bit(int nr, unsigned long *addr)
+{
+    int oldbit = test_bit(nr, addr);
+    set_bit(nr, addr);
+    return oldbit;
+}
+
+static inline void bitmap_or(unsigned long *dst, const unsigned long *other,
+                             int nr_bits)
+{
+    int i, nr_longs = (bitmap_size(nr_bits) / sizeof(unsigned long));
+    for ( i = 0; i < nr_longs; ++i )
+        dst[i] |= other[i];
+}
+
+#endif  /* XC_BITOPS_H */
tools/libxc/xc_bitops.h deleted +0 -76

76 lines not on this page · raw message

Signature · 1 line
1.9.1
#49 lore raw

Re: [PATCH v2 COLOPre 04/13] tools/libxc: export xc_bitops.h

Just to note that xc_bitops.h needs cleanup as Andy pointed out in v1... It will done in v3.

Quoted 180 lines · Yang Hongyang

When we are under COLO, we will send dirty page bitmap info from secondary to primary at every checkpoint. So we need to get/test the dirty page bitmap. We just expose xc_bitops.h for libxl use.

NOTE:
Need to make clean and rerun configure to get it compiled.

---
  tools/libxc/include/xc_bitops.h | 76 +++++++++++++++++++++++++++++++++++++++++
  tools/libxc/xc_bitops.h         | 76 -----------------------------------------
  2 files changed, 76 insertions(+), 76 deletions(-)

create mode 100644 tools/libxc/include/xc_bitops.h delete mode 100644 tools/libxc/xc_bitops.h

tools/libxc/include/xc_bitops.h new file +76 -0
new file mode 100644
index 0000000..cd749f4
@@ -0,0 +1,76 @@
+#ifndef XC_BITOPS_H
+#define XC_BITOPS_H 1
+
+/* bitmap operations for single threaded access */
+
+#include <stdlib.h>
+#include <string.h>
+
+#define BITS_PER_LONG (sizeof(unsigned long) * 8)
+#define ORDER_LONG (sizeof(unsigned long) == 4 ? 5 : 6)
+
+#define BITMAP_ENTRY(_nr,_bmap) ((_bmap))[(_nr)/BITS_PER_LONG]
+#define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG)
+
+/* calculate required space for number of longs needed to hold nr_bits */
+static inline int bitmap_size(int nr_bits)
+{
+    int nr_long, nr_bytes;
+    nr_long = (nr_bits + BITS_PER_LONG - 1) >> ORDER_LONG;
+    nr_bytes = nr_long * sizeof(unsigned long);
+    return nr_bytes;
+}
+
+static inline unsigned long *bitmap_alloc(int nr_bits)
+{
+    return calloc(1, bitmap_size(nr_bits));
+}
+
+static inline void bitmap_set(unsigned long *addr, int nr_bits)
+{
+    memset(addr, 0xff, bitmap_size(nr_bits));
+}
+
+static inline void bitmap_clear(unsigned long *addr, int nr_bits)
+{
+    memset(addr, 0, bitmap_size(nr_bits));
+}
+
+static inline int test_bit(int nr, unsigned long *addr)
+{
+    return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1;
+}
+
+static inline void clear_bit(int nr, unsigned long *addr)
+{
+    BITMAP_ENTRY(nr, addr) &= ~(1UL << BITMAP_SHIFT(nr));
+}
+
+static inline void set_bit(int nr, unsigned long *addr)
+{
+    BITMAP_ENTRY(nr, addr) |= (1UL << BITMAP_SHIFT(nr));
+}
+
+static inline int test_and_clear_bit(int nr, unsigned long *addr)
+{
+    int oldbit = test_bit(nr, addr);
+    clear_bit(nr, addr);
+    return oldbit;
+}
+
+static inline int test_and_set_bit(int nr, unsigned long *addr)
+{
+    int oldbit = test_bit(nr, addr);
+    set_bit(nr, addr);
+    return oldbit;
+}
+
+static inline void bitmap_or(unsigned long *dst, const unsigned long *other,
+                             int nr_bits)
+{
+    int i, nr_longs = (bitmap_size(nr_bits) / sizeof(unsigned long));
+    for ( i = 0; i < nr_longs; ++i )
+        dst[i] |= other[i];
+}
+
+#endif  /* XC_BITOPS_H */
tools/libxc/xc_bitops.h deleted +0 -76
deleted file mode 100644
index cd749f4..0000000
@@ -1,76 +0,0 @@
-#ifndef XC_BITOPS_H
-#define XC_BITOPS_H 1
-
-/* bitmap operations for single threaded access */
-
-#include <stdlib.h>
-#include <string.h>
-
-#define BITS_PER_LONG (sizeof(unsigned long) * 8)
-#define ORDER_LONG (sizeof(unsigned long) == 4 ? 5 : 6)
-
-#define BITMAP_ENTRY(_nr,_bmap) ((_bmap))[(_nr)/BITS_PER_LONG]
-#define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG)
-
-/* calculate required space for number of longs needed to hold nr_bits */
-static inline int bitmap_size(int nr_bits)
-{
-    int nr_long, nr_bytes;
-    nr_long = (nr_bits + BITS_PER_LONG - 1) >> ORDER_LONG;
-    nr_bytes = nr_long * sizeof(unsigned long);
-    return nr_bytes;
-}
-
-static inline unsigned long *bitmap_alloc(int nr_bits)
-{
-    return calloc(1, bitmap_size(nr_bits));
-}
-
-static inline void bitmap_set(unsigned long *addr, int nr_bits)
-{
-    memset(addr, 0xff, bitmap_size(nr_bits));
-}
-
-static inline void bitmap_clear(unsigned long *addr, int nr_bits)
-{
-    memset(addr, 0, bitmap_size(nr_bits));
-}
-
-static inline int test_bit(int nr, unsigned long *addr)
-{
-    return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1;
-}
-
-static inline void clear_bit(int nr, unsigned long *addr)
-{
-    BITMAP_ENTRY(nr, addr) &= ~(1UL << BITMAP_SHIFT(nr));
-}
-
-static inline void set_bit(int nr, unsigned long *addr)
-{
-    BITMAP_ENTRY(nr, addr) |= (1UL << BITMAP_SHIFT(nr));
-}
-
-static inline int test_and_clear_bit(int nr, unsigned long *addr)
-{
-    int oldbit = test_bit(nr, addr);
-    clear_bit(nr, addr);
-    return oldbit;
-}
-
-static inline int test_and_set_bit(int nr, unsigned long *addr)
-{
-    int oldbit = test_bit(nr, addr);
-    set_bit(nr, addr);
-    return oldbit;
-}
-
-static inline void bitmap_or(unsigned long *dst, const unsigned long *other,
-                             int nr_bits)
-{
-    int i, nr_longs = (bitmap_size(nr_bits) / sizeof(unsigned long));
-    for ( i = 0; i < nr_longs; ++i )
-        dst[i] |= other[i];
-}
-
-#endif  /* XC_BITOPS_H */
Signature · 2 lines
Thanks,
Yang.
#50 lore raw

Re: [PATCH v2 COLOPre 04/13] tools/libxc: export xc_bitops.h

In reply to Yang Hongyang
Quoted 2 lines · Yang Hongyang

When we are under COLO, we will send dirty page bitmap info from secondary to primary at every checkpoint.

... and this is a _libxl_ operation? Is that the right layer here?

Quoted 178 lines

So we need to get/test
the dirty page bitmap. We just expose xc_bitops.h for libxl use.

NOTE:
Need to make clean and rerun configure to get it compiled.

---
 tools/libxc/include/xc_bitops.h | 76 +++++++++++++++++++++++++++++++++++++++++
 tools/libxc/xc_bitops.h         | 76 -----------------------------------------
 2 files changed, 76 insertions(+), 76 deletions(-)
 create mode 100644 tools/libxc/include/xc_bitops.h
 delete mode 100644 tools/libxc/xc_bitops.h
tools/libxc/include/xc_bitops.h new file +76 -0
new file mode 100644
index 0000000..cd749f4
@@ -0,0 +1,76 @@
+#ifndef XC_BITOPS_H
+#define XC_BITOPS_H 1
+
+/* bitmap operations for single threaded access */
+
+#include <stdlib.h>
+#include <string.h>
+
+#define BITS_PER_LONG (sizeof(unsigned long) * 8)
+#define ORDER_LONG (sizeof(unsigned long) == 4 ? 5 : 6)
+
+#define BITMAP_ENTRY(_nr,_bmap) ((_bmap))[(_nr)/BITS_PER_LONG]
+#define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG)
+
+/* calculate required space for number of longs needed to hold nr_bits */
+static inline int bitmap_size(int nr_bits)
+{
+    int nr_long, nr_bytes;
+    nr_long = (nr_bits + BITS_PER_LONG - 1) >> ORDER_LONG;
+    nr_bytes = nr_long * sizeof(unsigned long);
+    return nr_bytes;
+}
+
+static inline unsigned long *bitmap_alloc(int nr_bits)
+{
+    return calloc(1, bitmap_size(nr_bits));
+}
+
+static inline void bitmap_set(unsigned long *addr, int nr_bits)
+{
+    memset(addr, 0xff, bitmap_size(nr_bits));
+}
+
+static inline void bitmap_clear(unsigned long *addr, int nr_bits)
+{
+    memset(addr, 0, bitmap_size(nr_bits));
+}
+
+static inline int test_bit(int nr, unsigned long *addr)
+{
+    return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1;
+}
+
+static inline void clear_bit(int nr, unsigned long *addr)
+{
+    BITMAP_ENTRY(nr, addr) &= ~(1UL << BITMAP_SHIFT(nr));
+}
+
+static inline void set_bit(int nr, unsigned long *addr)
+{
+    BITMAP_ENTRY(nr, addr) |= (1UL << BITMAP_SHIFT(nr));
+}
+
+static inline int test_and_clear_bit(int nr, unsigned long *addr)
+{
+    int oldbit = test_bit(nr, addr);
+    clear_bit(nr, addr);
+    return oldbit;
+}
+
+static inline int test_and_set_bit(int nr, unsigned long *addr)
+{
+    int oldbit = test_bit(nr, addr);
+    set_bit(nr, addr);
+    return oldbit;
+}
+
+static inline void bitmap_or(unsigned long *dst, const unsigned long *other,
+                             int nr_bits)
+{
+    int i, nr_longs = (bitmap_size(nr_bits) / sizeof(unsigned long));
+    for ( i = 0; i < nr_longs; ++i )
+        dst[i] |= other[i];
+}
+
+#endif  /* XC_BITOPS_H */
tools/libxc/xc_bitops.h deleted +0 -76
deleted file mode 100644
index cd749f4..0000000
@@ -1,76 +0,0 @@
-#ifndef XC_BITOPS_H
-#define XC_BITOPS_H 1
-
-/* bitmap operations for single threaded access */
-
-#include <stdlib.h>
-#include <string.h>
-
-#define BITS_PER_LONG (sizeof(unsigned long) * 8)
-#define ORDER_LONG (sizeof(unsigned long) == 4 ? 5 : 6)
-
-#define BITMAP_ENTRY(_nr,_bmap) ((_bmap))[(_nr)/BITS_PER_LONG]
-#define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG)
-
-/* calculate required space for number of longs needed to hold nr_bits */
-static inline int bitmap_size(int nr_bits)
-{
-    int nr_long, nr_bytes;
-    nr_long = (nr_bits + BITS_PER_LONG - 1) >> ORDER_LONG;
-    nr_bytes = nr_long * sizeof(unsigned long);
-    return nr_bytes;
-}
-
-static inline unsigned long *bitmap_alloc(int nr_bits)
-{
-    return calloc(1, bitmap_size(nr_bits));
-}
-
-static inline void bitmap_set(unsigned long *addr, int nr_bits)
-{
-    memset(addr, 0xff, bitmap_size(nr_bits));
-}
-
-static inline void bitmap_clear(unsigned long *addr, int nr_bits)
-{
-    memset(addr, 0, bitmap_size(nr_bits));
-}
-
-static inline int test_bit(int nr, unsigned long *addr)
-{
-    return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1;
-}
-
-static inline void clear_bit(int nr, unsigned long *addr)
-{
-    BITMAP_ENTRY(nr, addr) &= ~(1UL << BITMAP_SHIFT(nr));
-}
-
-static inline void set_bit(int nr, unsigned long *addr)
-{
-    BITMAP_ENTRY(nr, addr) |= (1UL << BITMAP_SHIFT(nr));
-}
-
-static inline int test_and_clear_bit(int nr, unsigned long *addr)
-{
-    int oldbit = test_bit(nr, addr);
-    clear_bit(nr, addr);
-    return oldbit;
-}
-
-static inline int test_and_set_bit(int nr, unsigned long *addr)
-{
-    int oldbit = test_bit(nr, addr);
-    set_bit(nr, addr);
-    return oldbit;
-}
-
-static inline void bitmap_or(unsigned long *dst, const unsigned long *other,
-                             int nr_bits)
-{
-    int i, nr_longs = (bitmap_size(nr_bits) / sizeof(unsigned long));
-    for ( i = 0; i < nr_longs; ++i )
-        dst[i] |= other[i];
-}
-
-#endif  /* XC_BITOPS_H */
#51 lore raw

Re: [PATCH v2 COLOPre 04/13] tools/libxc: export xc_bitops.h

Quoted 5 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang

When we are under COLO, we will send dirty page bitmap info from secondary to primary at every checkpoint.

... and this is a _libxl_ operation? Is that the right layer here?

For the first question, Yes, this is done in the suspend callback on restore side. We do this in libxl because currently we only added a back channel on libxl side. There're no back channel in libxc.

By considering this more, if we do this in libxc part, the code will be less complex: we can drop the 4th & 9th patch of this series and also get rid of the get_dirty_pfn() callback. instead we will add a patch to add back channel in libxc.

For the second question, I'm not sure, what's Andrew's opinion? which is the right layer to do this operation, libxl or libxc?

Quoted 183 lines
Quoted 169 lines

So we need to get/test
the dirty page bitmap. We just expose xc_bitops.h for libxl use.

NOTE:
Need to make clean and rerun configure to get it compiled.

---
  tools/libxc/include/xc_bitops.h | 76 +++++++++++++++++++++++++++++++++++++++++
  tools/libxc/xc_bitops.h         | 76 -----------------------------------------
  2 files changed, 76 insertions(+), 76 deletions(-)

create mode 100644 tools/libxc/include/xc_bitops.h delete mode 100644 tools/libxc/xc_bitops.h

tools/libxc/include/xc_bitops.h new file +76 -0
new file mode 100644
index 0000000..cd749f4
@@ -0,0 +1,76 @@
+#ifndef XC_BITOPS_H
+#define XC_BITOPS_H 1
+
+/* bitmap operations for single threaded access */
+
+#include <stdlib.h>
+#include <string.h>
+
+#define BITS_PER_LONG (sizeof(unsigned long) * 8)
+#define ORDER_LONG (sizeof(unsigned long) == 4 ? 5 : 6)
+
+#define BITMAP_ENTRY(_nr,_bmap) ((_bmap))[(_nr)/BITS_PER_LONG]
+#define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG)
+
+/* calculate required space for number of longs needed to hold nr_bits */
+static inline int bitmap_size(int nr_bits)
+{
+    int nr_long, nr_bytes;
+    nr_long = (nr_bits + BITS_PER_LONG - 1) >> ORDER_LONG;
+    nr_bytes = nr_long * sizeof(unsigned long);
+    return nr_bytes;
+}
+
+static inline unsigned long *bitmap_alloc(int nr_bits)
+{
+    return calloc(1, bitmap_size(nr_bits));
+}
+
+static inline void bitmap_set(unsigned long *addr, int nr_bits)
+{
+    memset(addr, 0xff, bitmap_size(nr_bits));
+}
+
+static inline void bitmap_clear(unsigned long *addr, int nr_bits)
+{
+    memset(addr, 0, bitmap_size(nr_bits));
+}
+
+static inline int test_bit(int nr, unsigned long *addr)
+{
+    return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1;
+}
+
+static inline void clear_bit(int nr, unsigned long *addr)
+{
+    BITMAP_ENTRY(nr, addr) &= ~(1UL << BITMAP_SHIFT(nr));
+}
+
+static inline void set_bit(int nr, unsigned long *addr)
+{
+    BITMAP_ENTRY(nr, addr) |= (1UL << BITMAP_SHIFT(nr));
+}
+
+static inline int test_and_clear_bit(int nr, unsigned long *addr)
+{
+    int oldbit = test_bit(nr, addr);
+    clear_bit(nr, addr);
+    return oldbit;
+}
+
+static inline int test_and_set_bit(int nr, unsigned long *addr)
+{
+    int oldbit = test_bit(nr, addr);
+    set_bit(nr, addr);
+    return oldbit;
+}
+
+static inline void bitmap_or(unsigned long *dst, const unsigned long *other,
+                             int nr_bits)
+{
+    int i, nr_longs = (bitmap_size(nr_bits) / sizeof(unsigned long));
+    for ( i = 0; i < nr_longs; ++i )
+        dst[i] |= other[i];
+}
+
+#endif  /* XC_BITOPS_H */
tools/libxc/xc_bitops.h deleted +0 -66
deleted file mode 100644
index cd749f4..0000000
@@ -1,76 +0,0 @@
-#ifndef XC_BITOPS_H
-#define XC_BITOPS_H 1
-
-/* bitmap operations for single threaded access */
-
-#include <stdlib.h>
-#include <string.h>
-
-#define BITS_PER_LONG (sizeof(unsigned long) * 8)
-#define ORDER_LONG (sizeof(unsigned long) == 4 ? 5 : 6)
-
-#define BITMAP_ENTRY(_nr,_bmap) ((_bmap))[(_nr)/BITS_PER_LONG]
-#define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG)
-
-/* calculate required space for number of longs needed to hold nr_bits */
-static inline int bitmap_size(int nr_bits)
-{
-    int nr_long, nr_bytes;
-    nr_long = (nr_bits + BITS_PER_LONG - 1) >> ORDER_LONG;
-    nr_bytes = nr_long * sizeof(unsigned long);
-    return nr_bytes;
-}
-
-static inline unsigned long *bitmap_alloc(int nr_bits)
-{
-    return calloc(1, bitmap_size(nr_bits));
-}
-
-static inline void bitmap_set(unsigned long *addr, int nr_bits)
-{
-    memset(addr, 0xff, bitmap_size(nr_bits));
-}
-
-static inline void bitmap_clear(unsigned long *addr, int nr_bits)
-{
-    memset(addr, 0, bitmap_size(nr_bits));
-}
-
-static inline int test_bit(int nr, unsigned long *addr)
-{
-    return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1;
-}
-
-static inline void clear_bit(int nr, unsigned long *addr)
-{
-    BITMAP_ENTRY(nr, addr) &= ~(1UL << BITMAP_SHIFT(nr));
-}
-
-static inline void set_bit(int nr, unsigned long *addr)
-{
-    BITMAP_ENTRY(nr, addr) |= (1UL << BITMAP_SHIFT(nr));
-}
-
-static inline int test_and_clear_bit(int nr, unsigned long *addr)
-{
-    int oldbit = test_bit(nr, addr);
-    clear_bit(nr, addr);
-    return oldbit;
-}
-
-static inline int test_and_set_bit(int nr, unsigned long *addr)
-{
-    int oldbit = test_bit(nr, addr);
-    set_bit(nr, addr);
-    return oldbit;
-}

tools/libxc/xc_bitops.h line 76

Quoted 10 lines
tools/libxc/xc_bitops.h deleted +0 -10
-
-static inline void bitmap_or(unsigned long *dst, const unsigned long *other,
-                             int nr_bits)
-{
-    int i, nr_longs = (bitmap_size(nr_bits) / sizeof(unsigned long));
-    for ( i = 0; i < nr_longs; ++i )
-        dst[i] |= other[i];
-}
-
-#endif  /* XC_BITOPS_H */

.

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

Re: [PATCH v2 COLOPre 04/13] tools/libxc: export xc_bitops.h

Quoted 8 lines · Yang Hongyang
Quoted 5 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang

When we are under COLO, we will send dirty page bitmap info from secondary to primary at every checkpoint.

... and this is a _libxl_ operation? Is that the right layer here?

Quoted 8 lines

For the first question, Yes, this is done in the suspend callback on restore side. We do this in libxl because currently we only added a back channel on libxl side. There're no back channel in libxc.

By considering this more, if we do this in libxc part, the code will be less complex: we can drop the 4th & 9th patch of this series and also get rid of the get_dirty_pfn() callback. instead we will add a patch to add back channel in libxc.

That sounds better to me, but lets see what Andrew thinks.

Quoted 188 lines

For the second question, I'm not sure, what's Andrew's opinion? which is the right layer to do this operation, libxl or libxc?

Quoted 183 lines
Quoted 169 lines

So we need to get/test
the dirty page bitmap. We just expose xc_bitops.h for libxl use.

NOTE:
Need to make clean and rerun configure to get it compiled.

---
  tools/libxc/include/xc_bitops.h | 76 +++++++++++++++++++++++++++++++++++++++++
  tools/libxc/xc_bitops.h         | 76 -----------------------------------------
  2 files changed, 76 insertions(+), 76 deletions(-)

create mode 100644 tools/libxc/include/xc_bitops.h delete mode 100644 tools/libxc/xc_bitops.h

tools/libxc/include/xc_bitops.h new file +76 -0
new file mode 100644
index 0000000..cd749f4
@@ -0,0 +1,76 @@
+#ifndef XC_BITOPS_H
+#define XC_BITOPS_H 1
+
+/* bitmap operations for single threaded access */
+
+#include <stdlib.h>
+#include <string.h>
+
+#define BITS_PER_LONG (sizeof(unsigned long) * 8)
+#define ORDER_LONG (sizeof(unsigned long) == 4 ? 5 : 6)
+
+#define BITMAP_ENTRY(_nr,_bmap) ((_bmap))[(_nr)/BITS_PER_LONG]
+#define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG)
+
+/* calculate required space for number of longs needed to hold nr_bits */
+static inline int bitmap_size(int nr_bits)
+{
+    int nr_long, nr_bytes;
+    nr_long = (nr_bits + BITS_PER_LONG - 1) >> ORDER_LONG;
+    nr_bytes = nr_long * sizeof(unsigned long);
+    return nr_bytes;
+}
+
+static inline unsigned long *bitmap_alloc(int nr_bits)
+{
+    return calloc(1, bitmap_size(nr_bits));
+}
+
+static inline void bitmap_set(unsigned long *addr, int nr_bits)
+{
+    memset(addr, 0xff, bitmap_size(nr_bits));
+}
+
+static inline void bitmap_clear(unsigned long *addr, int nr_bits)
+{
+    memset(addr, 0, bitmap_size(nr_bits));
+}
+
+static inline int test_bit(int nr, unsigned long *addr)
+{
+    return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1;
+}
+
+static inline void clear_bit(int nr, unsigned long *addr)
+{
+    BITMAP_ENTRY(nr, addr) &= ~(1UL << BITMAP_SHIFT(nr));
+}
+
+static inline void set_bit(int nr, unsigned long *addr)
+{
+    BITMAP_ENTRY(nr, addr) |= (1UL << BITMAP_SHIFT(nr));
+}
+
+static inline int test_and_clear_bit(int nr, unsigned long *addr)
+{
+    int oldbit = test_bit(nr, addr);
+    clear_bit(nr, addr);
+    return oldbit;
+}
+
+static inline int test_and_set_bit(int nr, unsigned long *addr)
+{
+    int oldbit = test_bit(nr, addr);
+    set_bit(nr, addr);
+    return oldbit;
+}
+
+static inline void bitmap_or(unsigned long *dst, const unsigned long *other,
+                             int nr_bits)
+{
+    int i, nr_longs = (bitmap_size(nr_bits) / sizeof(unsigned long));
+    for ( i = 0; i < nr_longs; ++i )
+        dst[i] |= other[i];
+}
+
+#endif  /* XC_BITOPS_H */
tools/libxc/xc_bitops.h deleted +0 -66
deleted file mode 100644
index cd749f4..0000000
@@ -1,76 +0,0 @@
-#ifndef XC_BITOPS_H
-#define XC_BITOPS_H 1
-
-/* bitmap operations for single threaded access */
-
-#include <stdlib.h>
-#include <string.h>
-
-#define BITS_PER_LONG (sizeof(unsigned long) * 8)
-#define ORDER_LONG (sizeof(unsigned long) == 4 ? 5 : 6)
-
-#define BITMAP_ENTRY(_nr,_bmap) ((_bmap))[(_nr)/BITS_PER_LONG]
-#define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG)
-
-/* calculate required space for number of longs needed to hold nr_bits */
-static inline int bitmap_size(int nr_bits)
-{
-    int nr_long, nr_bytes;
-    nr_long = (nr_bits + BITS_PER_LONG - 1) >> ORDER_LONG;
-    nr_bytes = nr_long * sizeof(unsigned long);
-    return nr_bytes;
-}
-
-static inline unsigned long *bitmap_alloc(int nr_bits)
-{
-    return calloc(1, bitmap_size(nr_bits));
-}
-
-static inline void bitmap_set(unsigned long *addr, int nr_bits)
-{
-    memset(addr, 0xff, bitmap_size(nr_bits));
-}
-
-static inline void bitmap_clear(unsigned long *addr, int nr_bits)
-{
-    memset(addr, 0, bitmap_size(nr_bits));
-}
-
-static inline int test_bit(int nr, unsigned long *addr)
-{
-    return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1;
-}
-
-static inline void clear_bit(int nr, unsigned long *addr)
-{
-    BITMAP_ENTRY(nr, addr) &= ~(1UL << BITMAP_SHIFT(nr));
-}
-
-static inline void set_bit(int nr, unsigned long *addr)
-{
-    BITMAP_ENTRY(nr, addr) |= (1UL << BITMAP_SHIFT(nr));
-}
-
-static inline int test_and_clear_bit(int nr, unsigned long *addr)
-{
-    int oldbit = test_bit(nr, addr);
-    clear_bit(nr, addr);
-    return oldbit;
-}
-
-static inline int test_and_set_bit(int nr, unsigned long *addr)
-{
-    int oldbit = test_bit(nr, addr);
-    set_bit(nr, addr);
-    return oldbit;
-}

tools/libxc/xc_bitops.h line 76

Quoted 10 lines
tools/libxc/xc_bitops.h deleted +0 -10
-
-static inline void bitmap_or(unsigned long *dst, const unsigned long *other,
-                             int nr_bits)
-{
-    int i, nr_longs = (bitmap_size(nr_bits) / sizeof(unsigned long));
-    for ( i = 0; i < nr_longs; ++i )
-        dst[i] |= other[i];
-}
-
-#endif  /* XC_BITOPS_H */

.

#53 lore raw

Re: [PATCH v2 COLOPre 04/13] tools/libxc: export xc_bitops.h

Quoted 10 lines · Ian Campbell
Quoted 9 lines · Yang Hongyang
Quoted 4 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang

When we are under COLO, we will send dirty page bitmap info from secondary to primary at every checkpoint.

... and this is a _libxl_ operation? Is that the right layer here?

For the first question, Yes, this is done in the suspend callback on restore side. We do this in libxl because currently we only added a back channel on libxl side. There're no back channel in libxc.

Quoted 8 lines
Quoted 4 lines

By considering this more, if we do this in libxc part, the code will be less complex: we can drop the 4th & 9th patch of this series and also get rid of the get_dirty_pfn() callback. instead we will add a patch to add back channel in libxc.

That sounds better to me, but lets see what Andrew thinks.

Quoted 2 lines

For the second question, I'm not sure, what's Andrew's opinion? which is the right layer to do this operation, libxl or libxc?

There are a number of bits of information which would be useful going in "the backchannel".

Some are definitely more appropriate at the libxc level, but others are more appropriate at the libxl.

If you recall from the hackathon, there was an Alibaba usecase where they wanted a positive success/fail from the receiving side that the VM has started up successfully before choosing between cleaning up or continuing the VM on the sending side. This would have to be a libxl level backchannel.

Whatever happens, backchannel wise, it should be a sensibly type/length/chunk'd stream. (I think there is a spec or two floating around somewhere which might be a good start ;p) There should probably be a bit of active negotiation at the start of the backchannel to a) confirm you have the correct backchannel and b) the backchannel is actually functioning.

The data on "the backchannel" is always going to be in reply to an action taking place in the primary channel, but there are complications in that the libxc bit is inherently a blocking model. In terms of coordination, I am leaning towards the view of it being easier and cleaner for each level to maintain its own backchannel communication. The libxc bits can expect to read some records out of the backchannel at each checkpoint and take appropriate actions before starting the next checkpoint.

Thoughts?

~Andrew

#54 lore raw

Re: [PATCH v2 COLOPre 04/13] tools/libxc: export xc_bitops.h

Quoted 23 lines · Andrew Cooper
Quoted 10 lines · Ian Campbell
Quoted 9 lines · Yang Hongyang
Quoted 4 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang

When we are under COLO, we will send dirty page bitmap info from secondary to primary at every checkpoint.

... and this is a _libxl_ operation? Is that the right layer here?

For the first question, Yes, this is done in the suspend callback on restore side. We do this in libxl because currently we only added a back channel on libxl side. There're no back channel in libxc.

Quoted 8 lines
Quoted 4 lines

By considering this more, if we do this in libxc part, the code will be less complex: we can drop the 4th & 9th patch of this series and also get rid of the get_dirty_pfn() callback. instead we will add a patch to add back channel in libxc.

That sounds better to me, but lets see what Andrew thinks.

Quoted 2 lines

For the second question, I'm not sure, what's Andrew's opinion? which is the right layer to do this operation, libxl or libxc?

There are a number of bits of information which would be useful going in "the backchannel".

Quoted 8 lines

Some are definitely more appropriate at the libxc level, but others are more appropriate at the libxl.

If you recall from the hackathon, there was an Alibaba usecase where they wanted a positive success/fail from the receiving side that the VM has started up successfully before choosing between cleaning up or continuing the VM on the sending side. This would have to be a libxl level backchannel.

FWIW this particular case is currently an xl level backchannel, but I think your general point stands.

Quoted 20 lines

Whatever happens, backchannel wise, it should be a sensibly type/length/chunk'd stream. (I think there is a spec or two floating around somewhere which might be a good start ;p) There should probably be a bit of active negotiation at the start of the backchannel to a) confirm you have the correct backchannel and b) the backchannel is actually functioning.

The data on "the backchannel" is always going to be in reply to an action taking place in the primary channel, but there are complications in that the libxc bit is inherently a blocking model. In terms of coordination, I am leaning towards the view of it being easier and cleaner for each level to maintain its own backchannel communication. The libxc bits can expect to read some records out of the backchannel at each checkpoint and take appropriate actions before starting the next checkpoint.

Thoughts?

~Andrew

#55 lore raw

Re: [PATCH v2 COLOPre 04/13] tools/libxc: export xc_bitops.h

Quoted 27 lines · Ian Campbell
Quoted 26 lines · Andrew Cooper
Quoted 10 lines · Ian Campbell
Quoted 9 lines · Yang Hongyang
Quoted 4 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang

When we are under COLO, we will send dirty page bitmap info from secondary to primary at every checkpoint.

... and this is a _libxl_ operation? Is that the right layer here?

For the first question, Yes, this is done in the suspend callback on restore side. We do this in libxl because currently we only added a back channel on libxl side. There're no back channel in libxc.

Quoted 8 lines
Quoted 4 lines

By considering this more, if we do this in libxc part, the code will be less complex: we can drop the 4th & 9th patch of this series and also get rid of the get_dirty_pfn() callback. instead we will add a patch to add back channel in libxc.

That sounds better to me, but lets see what Andrew thinks.

Quoted 2 lines

For the second question, I'm not sure, what's Andrew's opinion? which is the right layer to do this operation, libxl or libxc?

There are a number of bits of information which would be useful going in "the backchannel".

Some are definitely more appropriate at the libxc level, but others are more appropriate at the libxl.

Quoted 8 lines
Quoted 5 lines

If you recall from the hackathon, there was an Alibaba usecase where they wanted a positive success/fail from the receiving side that the VM has started up successfully before choosing between cleaning up or continuing the VM on the sending side. This would have to be a libxl level backchannel.

FWIW this particular case is currently an xl level backchannel, but I think your general point stands.

So are you both agree that we should add a backchannel to libxc, move this operation to libxc layer, what's other tools maintainers's opinion?

Quoted 25 lines
Quoted 17 lines

Whatever happens, backchannel wise, it should be a sensibly type/length/chunk'd stream. (I think there is a spec or two floating around somewhere which might be a good start ;p) There should probably be a bit of active negotiation at the start of the backchannel to a) confirm you have the correct backchannel and b) the backchannel is actually functioning.

The data on "the backchannel" is always going to be in reply to an action taking place in the primary channel, but there are complications in that the libxc bit is inherently a blocking model. In terms of coordination, I am leaning towards the view of it being easier and cleaner for each level to maintain its own backchannel communication. The libxc bits can expect to read some records out of the backchannel at each checkpoint and take appropriate actions before starting the next checkpoint.

Quoted 4 lines

Thoughts?

~Andrew

.

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

PATCH v2 5/13 tools/libxl: introduce a new API libxl__domain_restore() to load qemu state

In reply to Yang Hongyang

Secondary vm is running in colo mode. So we will do the following things again and again:
1. suspend both primay vm and secondary vm
2. sync the state
3. resume both primary vm and secondary vm
We will send qemu's state each time in step2, and slave's qemu should read it each time before resuming secondary vm. Introduce a new API libxl__domain_restore() to do it. This API should be called before resuming secondary vm.

---
 tools/libxl/libxl_dom_save.c | 47 ++++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_internal.h |  4 ++++
 tools/libxl/libxl_qmp.c      | 10 ++++++++++
 3 files changed, 61 insertions(+)
tools/libxl/libxl_dom_save.c +47 -0
index 74a6bae..f9627f8 100644
@@ -663,6 +663,53 @@ int libxl__toolstack_restore(uint32_t domid, const uint8_t *buf,
     return 0;
 }
 
+int libxl__domain_restore(libxl__gc *gc, uint32_t domid)
+{
+    int rc = 0;
+
+    libxl_domain_type type = libxl__domain_type(gc, domid);
+    if (type != LIBXL_DOMAIN_TYPE_HVM) {
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    rc = libxl__domain_restore_device_model(gc, domid);
+    if (rc)
+        LOG(ERROR, "failed to restore device mode for domain %u:%d",
+            domid, rc);
+out:
+    return rc;
+}
+
+int libxl__domain_restore_device_model(libxl__gc *gc, uint32_t domid)
+{
+    char *state_file;
+    int rc;
+
+    switch (libxl__device_model_version_running(gc, domid)) {
+    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
+        /* not supported now */
+        rc = ERROR_INVAL;
+        break;
+    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
+        /*
+         * This function may be called too many times for the same gc,
+         * so we use NOGC, and free the memory before return to avoid
+         * OOM.
+         */
+        state_file = libxl__sprintf(NOGC,
+                                    XC_DEVICE_MODEL_RESTORE_FILE".%d",
+                                    domid);
+        rc = libxl__qmp_restore(gc, domid, state_file);
+        free(state_file);
+        break;
+    default:
+        rc = ERROR_INVAL;
+    }
+
+    return rc;
+}
+
 /*
  * Local variables:
  * mode: C
tools/libxl/libxl_internal.h +4 -0
index 1905195..20364c6 100644
@@ -1022,6 +1022,7 @@ _hidden int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
 
 _hidden int libxl__toolstack_restore(uint32_t domid, const uint8_t *buf,
                                      uint32_t size, void *data);
+_hidden int libxl__domain_restore_device_model(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid);
 
 _hidden const char *libxl__userdata_path(libxl__gc *gc, uint32_t domid,
@@ -1039,6 +1040,7 @@ _hidden int libxl__userdata_store(libxl__gc *gc, uint32_t domid,
                                   const char *userdata_userid,
                                   const uint8_t *data, int datalen);
 
+_hidden int libxl__domain_restore(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__domain_resume(libxl__gc *gc, uint32_t domid,
                                  int suspend_cancel);
 _hidden int libxl__domain_s3_resume(libxl__gc *gc, int domid);
@@ -1651,6 +1653,8 @@ _hidden int libxl__qmp_stop(libxl__gc *gc, int domid);
 _hidden int libxl__qmp_resume(libxl__gc *gc, int domid);
 /* Save current QEMU state into fd. */
 _hidden int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename);
+/* Load current QEMU state from fd. */
+_hidden int libxl__qmp_restore(libxl__gc *gc, int domid, const char *filename);
 /* Set dirty bitmap logging status */
 _hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enable);
 _hidden int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, const libxl_device_disk *disk);
tools/libxl/libxl_qmp.c +10 -0
index 9aa7e2e..a6f1a21 100644
@@ -892,6 +892,16 @@ int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename)
                            NULL, NULL);
 }
 
+int libxl__qmp_restore(libxl__gc *gc, int domid, const char *state_file)
+{
+    libxl__json_object *args = NULL;
+
+    qmp_parameters_add_string(gc, &args, "filename", state_file);
+
+    return qmp_run_command(gc, domid, "xen-load-devices-state", args,
+                           NULL, NULL);
+}
+
 static int qmp_change(libxl__gc *gc, libxl__qmp_handler *qmp,
                       char *device, char *target, char *arg)
 {
Signature · 1 line
1.9.1
#57 lore raw

Re: [PATCH v2 COLOPre 05/13] tools/libxl: introduce a new API libxl__domain_restore() to load qemu state

Quoted 10 lines · Yang Hongyang

Secondary vm is running in colo mode. So we will do the following things again and again:
1. suspend both primay vm and secondary vm
2. sync the state
3. resume both primary vm and secondary vm
We will send qemu's state each time in step2, and slave's qemu should read it each time before resuming secondary vm. Introduce a new API libxl__domain_restore() to do it. This API should be called before resuming secondary vm.

Is this a preexisting qemu interface or one to be added?

Quoted 117 lines
---
 tools/libxl/libxl_dom_save.c | 47 ++++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_internal.h |  4 ++++
 tools/libxl/libxl_qmp.c      | 10 ++++++++++
 3 files changed, 61 insertions(+)
tools/libxl/libxl_dom_save.c +47 -0
index 74a6bae..f9627f8 100644
@@ -663,6 +663,53 @@ int libxl__toolstack_restore(uint32_t domid, const uint8_t *buf,
     return 0;
 }
 
+int libxl__domain_restore(libxl__gc *gc, uint32_t domid)
+{
+    int rc = 0;
+
+    libxl_domain_type type = libxl__domain_type(gc, domid);
+    if (type != LIBXL_DOMAIN_TYPE_HVM) {
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    rc = libxl__domain_restore_device_model(gc, domid);
+    if (rc)
+        LOG(ERROR, "failed to restore device mode for domain %u:%d",
+            domid, rc);
+out:
+    return rc;
+}
+
+int libxl__domain_restore_device_model(libxl__gc *gc, uint32_t domid)
+{
+    char *state_file;
+    int rc;
+
+    switch (libxl__device_model_version_running(gc, domid)) {
+    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
+        /* not supported now */
+        rc = ERROR_INVAL;
+        break;
+    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
+        /*
+         * This function may be called too many times for the same gc,
+         * so we use NOGC, and free the memory before return to avoid
+         * OOM.
+         */
+        state_file = libxl__sprintf(NOGC,
+                                    XC_DEVICE_MODEL_RESTORE_FILE".%d",
+                                    domid);
+        rc = libxl__qmp_restore(gc, domid, state_file);
+        free(state_file);
+        break;
+    default:
+        rc = ERROR_INVAL;
+    }
+
+    return rc;
+}
+
 /*
  * Local variables:
  * mode: C
tools/libxl/libxl_internal.h +4 -0
index 1905195..20364c6 100644
@@ -1022,6 +1022,7 @@ _hidden int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
 
 _hidden int libxl__toolstack_restore(uint32_t domid, const uint8_t *buf,
                                      uint32_t size, void *data);
+_hidden int libxl__domain_restore_device_model(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid);
 
 _hidden const char *libxl__userdata_path(libxl__gc *gc, uint32_t domid,
@@ -1039,6 +1040,7 @@ _hidden int libxl__userdata_store(libxl__gc *gc, uint32_t domid,
                                   const char *userdata_userid,
                                   const uint8_t *data, int datalen);
 
+_hidden int libxl__domain_restore(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__domain_resume(libxl__gc *gc, uint32_t domid,
                                  int suspend_cancel);
 _hidden int libxl__domain_s3_resume(libxl__gc *gc, int domid);
@@ -1651,6 +1653,8 @@ _hidden int libxl__qmp_stop(libxl__gc *gc, int domid);
 _hidden int libxl__qmp_resume(libxl__gc *gc, int domid);
 /* Save current QEMU state into fd. */
 _hidden int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename);
+/* Load current QEMU state from fd. */
+_hidden int libxl__qmp_restore(libxl__gc *gc, int domid, const char *filename);
 /* Set dirty bitmap logging status */
 _hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enable);
 _hidden int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, const libxl_device_disk *disk);
tools/libxl/libxl_qmp.c +10 -0
index 9aa7e2e..a6f1a21 100644
@@ -892,6 +892,16 @@ int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename)
                            NULL, NULL);
 }
 
+int libxl__qmp_restore(libxl__gc *gc, int domid, const char *state_file)
+{
+    libxl__json_object *args = NULL;
+
+    qmp_parameters_add_string(gc, &args, "filename", state_file);
+
+    return qmp_run_command(gc, domid, "xen-load-devices-state", args,
+                           NULL, NULL);
+}
+
 static int qmp_change(libxl__gc *gc, libxl__qmp_handler *qmp,
                       char *device, char *target, char *arg)
 {
#58 lore raw

Re: [PATCH v2 COLOPre 05/13] tools/libxl: introduce a new API libxl__domain_restore() to load qemu state

Quoted 12 lines · Ian Campbell
Quoted 10 lines · Yang Hongyang

Secondary vm is running in colo mode. So we will do the following things again and again:
1. suspend both primay vm and secondary vm
2. sync the state
3. resume both primary vm and secondary vm
We will send qemu's state each time in step2, and slave's qemu should read it each time before resuming secondary vm. Introduce a new API libxl__domain_restore() to do it. This API should be called before resuming secondary vm.

Quoted 1 line

Is this a preexisting qemu interface or one to be added?

We added the qemu interface "xen-load-devices-state", it's not in qemu upstream yet.

Quoted 122 lines
Quoted 108 lines
---
  tools/libxl/libxl_dom_save.c | 47 ++++++++++++++++++++++++++++++++++++++++++++
  tools/libxl/libxl_internal.h |  4 ++++
  tools/libxl/libxl_qmp.c      | 10 ++++++++++
  3 files changed, 61 insertions(+)
tools/libxl/libxl_dom_save.c +47 -0
index 74a6bae..f9627f8 100644
@@ -663,6 +663,53 @@ int libxl__toolstack_restore(uint32_t domid, const uint8_t *buf,
      return 0;
  }
 
+int libxl__domain_restore(libxl__gc *gc, uint32_t domid)
+{
+    int rc = 0;
+
+    libxl_domain_type type = libxl__domain_type(gc, domid);
+    if (type != LIBXL_DOMAIN_TYPE_HVM) {
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    rc = libxl__domain_restore_device_model(gc, domid);
+    if (rc)
+        LOG(ERROR, "failed to restore device mode for domain %u:%d",
+            domid, rc);
+out:
+    return rc;
+}
+
+int libxl__domain_restore_device_model(libxl__gc *gc, uint32_t domid)
+{
+    char *state_file;
+    int rc;
+
+    switch (libxl__device_model_version_running(gc, domid)) {
+    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
+        /* not supported now */
+        rc = ERROR_INVAL;
+        break;
+    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
+        /*
+         * This function may be called too many times for the same gc,
+         * so we use NOGC, and free the memory before return to avoid
+         * OOM.
+         */
+        state_file = libxl__sprintf(NOGC,
+                                    XC_DEVICE_MODEL_RESTORE_FILE".%d",
+                                    domid);
+        rc = libxl__qmp_restore(gc, domid, state_file);
+        free(state_file);
+        break;
+    default:
+        rc = ERROR_INVAL;
+    }
+
+    return rc;
+}
+
  /*
   * Local variables:
   * mode: C
tools/libxl/libxl_internal.h +4 -0
index 1905195..20364c6 100644
@@ -1022,6 +1022,7 @@ _hidden int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
 
  _hidden int libxl__toolstack_restore(uint32_t domid, const uint8_t *buf,
                                       uint32_t size, void *data);
+_hidden int libxl__domain_restore_device_model(libxl__gc *gc, uint32_t domid);
  _hidden int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid);
 
  _hidden const char *libxl__userdata_path(libxl__gc *gc, uint32_t domid,
@@ -1039,6 +1040,7 @@ _hidden int libxl__userdata_store(libxl__gc *gc, uint32_t domid,
                                    const char *userdata_userid,
                                    const uint8_t *data, int datalen);
 
+_hidden int libxl__domain_restore(libxl__gc *gc, uint32_t domid);
  _hidden int libxl__domain_resume(libxl__gc *gc, uint32_t domid,
                                   int suspend_cancel);
  _hidden int libxl__domain_s3_resume(libxl__gc *gc, int domid);
@@ -1651,6 +1653,8 @@ _hidden int libxl__qmp_stop(libxl__gc *gc, int domid);
  _hidden int libxl__qmp_resume(libxl__gc *gc, int domid);
  /* Save current QEMU state into fd. */
  _hidden int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename);
+/* Load current QEMU state from fd. */
+_hidden int libxl__qmp_restore(libxl__gc *gc, int domid, const char *filename);
  /* Set dirty bitmap logging status */
  _hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enable);
  _hidden int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, const libxl_device_disk *disk);
tools/libxl/libxl_qmp.c +3 -0
index 9aa7e2e..a6f1a21 100644
@@ -892,6 +892,16 @@ int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename)
                             NULL, NULL);
  }
 
+int libxl__qmp_restore(libxl__gc *gc, int domid, const char *state_file)
+{
+    libxl__json_object *args = NULL;

tools/libxl/libxl_qmp.c int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename) · line 907

Quoted 10 lines
tools/libxl/libxl_qmp.c +7 -0
+
+    qmp_parameters_add_string(gc, &args, "filename", state_file);
+
+    return qmp_run_command(gc, domid, "xen-load-devices-state", args,
+                           NULL, NULL);
+}
+
  static int qmp_change(libxl__gc *gc, libxl__qmp_handler *qmp,
                        char *device, char *target, char *arg)
  {

.

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

Re: [PATCH v2 COLOPre 05/13] tools/libxl: introduce a new API libxl__domain_restore() to load qemu state

Quoted 14 lines · Yang Hongyang
Quoted 12 lines · Ian Campbell
Quoted 10 lines · Yang Hongyang

Secondary vm is running in colo mode. So we will do the following things again and again:
1. suspend both primay vm and secondary vm
2. sync the state
3. resume both primary vm and secondary vm
We will send qemu's state each time in step2, and slave's qemu should read it each time before resuming secondary vm. Introduce a new API libxl__domain_restore() to do it. This API should be called before resuming secondary vm.

Quoted 4 lines
Quoted 1 line

Is this a preexisting qemu interface or one to be added?

We added the qemu interface "xen-load-devices-state", it's not in qemu upstream yet.

OK, please mention this dependency in the commit text since we will want to be sure the interface is going to be accepted in this form by QEMU upstream before we start using it. Please also CC the QEMU maintainers on this patch in the future (by adding Cc: below the S-o-b if you don't want to spam them the whole series), I've added them here now.

In particular "devices" seems odd to me, perhaps
"xen-load-device-state"?

Quoted 124 lines
Quoted 123 lines
Quoted 109 lines
---
  tools/libxl/libxl_dom_save.c | 47 ++++++++++++++++++++++++++++++++++++++++++++
  tools/libxl/libxl_internal.h |  4 ++++
  tools/libxl/libxl_qmp.c      | 10 ++++++++++
  3 files changed, 61 insertions(+)
tools/libxl/libxl_dom_save.c +47 -0
index 74a6bae..f9627f8 100644
@@ -663,6 +663,53 @@ int libxl__toolstack_restore(uint32_t domid, const uint8_t *buf,
      return 0;
  }
 
+int libxl__domain_restore(libxl__gc *gc, uint32_t domid)
+{
+    int rc = 0;
+
+    libxl_domain_type type = libxl__domain_type(gc, domid);
+    if (type != LIBXL_DOMAIN_TYPE_HVM) {
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    rc = libxl__domain_restore_device_model(gc, domid);
+    if (rc)
+        LOG(ERROR, "failed to restore device mode for domain %u:%d",
+            domid, rc);
+out:
+    return rc;
+}
+
+int libxl__domain_restore_device_model(libxl__gc *gc, uint32_t domid)
+{
+    char *state_file;
+    int rc;
+
+    switch (libxl__device_model_version_running(gc, domid)) {
+    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
+        /* not supported now */
+        rc = ERROR_INVAL;
+        break;
+    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
+        /*
+         * This function may be called too many times for the same gc,
+         * so we use NOGC, and free the memory before return to avoid
+         * OOM.
+         */
+        state_file = libxl__sprintf(NOGC,
+                                    XC_DEVICE_MODEL_RESTORE_FILE".%d",
+                                    domid);
+        rc = libxl__qmp_restore(gc, domid, state_file);
+        free(state_file);
+        break;
+    default:
+        rc = ERROR_INVAL;
+    }
+
+    return rc;
+}
+
  /*
   * Local variables:
   * mode: C
tools/libxl/libxl_internal.h +4 -0
index 1905195..20364c6 100644
@@ -1022,6 +1022,7 @@ _hidden int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
 
  _hidden int libxl__toolstack_restore(uint32_t domid, const uint8_t *buf,
                                       uint32_t size, void *data);
+_hidden int libxl__domain_restore_device_model(libxl__gc *gc, uint32_t domid);
  _hidden int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid);
 
  _hidden const char *libxl__userdata_path(libxl__gc *gc, uint32_t domid,
@@ -1039,6 +1040,7 @@ _hidden int libxl__userdata_store(libxl__gc *gc, uint32_t domid,
                                    const char *userdata_userid,
                                    const uint8_t *data, int datalen);
 
+_hidden int libxl__domain_restore(libxl__gc *gc, uint32_t domid);
  _hidden int libxl__domain_resume(libxl__gc *gc, uint32_t domid,
                                   int suspend_cancel);
  _hidden int libxl__domain_s3_resume(libxl__gc *gc, int domid);
@@ -1651,6 +1653,8 @@ _hidden int libxl__qmp_stop(libxl__gc *gc, int domid);
  _hidden int libxl__qmp_resume(libxl__gc *gc, int domid);
  /* Save current QEMU state into fd. */
  _hidden int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename);
+/* Load current QEMU state from fd. */
+_hidden int libxl__qmp_restore(libxl__gc *gc, int domid, const char *filename);
  /* Set dirty bitmap logging status */
  _hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enable);
  _hidden int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, const libxl_device_disk *disk);
tools/libxl/libxl_qmp.c +3 -0
index 9aa7e2e..a6f1a21 100644
@@ -892,6 +892,16 @@ int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename)
                             NULL, NULL);
  }
 
+int libxl__qmp_restore(libxl__gc *gc, int domid, const char *state_file)
+{
+    libxl__json_object *args = NULL;

tools/libxl/libxl_qmp.c int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename) · line 907

Quoted 10 lines
tools/libxl/libxl_qmp.c +7 -0
+
+    qmp_parameters_add_string(gc, &args, "filename", state_file);
+
+    return qmp_run_command(gc, domid, "xen-load-devices-state", args,
+                           NULL, NULL);
+}
+
  static int qmp_change(libxl__gc *gc, libxl__qmp_handler *qmp,
                        char *device, char *target, char *arg)
  {

.

#60 lore raw

Re: [PATCH v2 COLOPre 05/13] tools/libxl: introduce a new API libxl__domain_restore() to load qemu state

Quoted 20 lines · Ian Campbell
Quoted 14 lines · Yang Hongyang
Quoted 12 lines · Ian Campbell
Quoted 10 lines · Yang Hongyang

Secondary vm is running in colo mode. So we will do the following things again and again:
1. suspend both primay vm and secondary vm
2. sync the state
3. resume both primary vm and secondary vm
We will send qemu's state each time in step2, and slave's qemu should read it each time before resuming secondary vm. Introduce a new API libxl__domain_restore() to do it. This API should be called before resuming secondary vm.

Quoted 4 lines
Quoted 1 line

Is this a preexisting qemu interface or one to be added?

We added the qemu interface "xen-load-devices-state", it's not in qemu upstream yet.

Quoted 8 lines

OK, please mention this dependency in the commit text since we will want to be sure the interface is going to be accepted in this form by QEMU upstream before we start using it. Please also CC the QEMU maintainers on this patch in the future (by adding Cc: below the S-o-b if you don't want to spam them the whole series), I've added them here now.

In particular "devices" seems odd to me, perhaps
"xen-load-device-state"?

This api is an invert operation to "xen-save-devices-stat", we used the name "xen-load-devices-state" in order to follow the existing naming style...

Quoted 129 lines
Quoted 116 lines
Quoted 116 lines
Quoted 116 lines
---
   tools/libxl/libxl_dom_save.c | 47 ++++++++++++++++++++++++++++++++++++++++++++
   tools/libxl/libxl_internal.h |  4 ++++
   tools/libxl/libxl_qmp.c      | 10 ++++++++++
   3 files changed, 61 insertions(+)
tools/libxl/libxl_dom_save.c +47 -0
index 74a6bae..f9627f8 100644
@@ -663,6 +663,53 @@ int libxl__toolstack_restore(uint32_t domid, const uint8_t *buf,
       return 0;
   }
 
+int libxl__domain_restore(libxl__gc *gc, uint32_t domid)
+{
+    int rc = 0;
+
+    libxl_domain_type type = libxl__domain_type(gc, domid);
+    if (type != LIBXL_DOMAIN_TYPE_HVM) {
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    rc = libxl__domain_restore_device_model(gc, domid);
+    if (rc)
+        LOG(ERROR, "failed to restore device mode for domain %u:%d",
+            domid, rc);
+out:
+    return rc;
+}
+
+int libxl__domain_restore_device_model(libxl__gc *gc, uint32_t domid)
+{
+    char *state_file;
+    int rc;
+
+    switch (libxl__device_model_version_running(gc, domid)) {
+    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
+        /* not supported now */
+        rc = ERROR_INVAL;
+        break;
+    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
+        /*
+         * This function may be called too many times for the same gc,
+         * so we use NOGC, and free the memory before return to avoid
+         * OOM.
+         */
+        state_file = libxl__sprintf(NOGC,
+                                    XC_DEVICE_MODEL_RESTORE_FILE".%d",
+                                    domid);
+        rc = libxl__qmp_restore(gc, domid, state_file);
+        free(state_file);
+        break;
+    default:
+        rc = ERROR_INVAL;
+    }
+
+    return rc;
+}
+
   /*
    * Local variables:
    * mode: C
tools/libxl/libxl_internal.h +4 -0
index 1905195..20364c6 100644
@@ -1022,6 +1022,7 @@ _hidden int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
 
   _hidden int libxl__toolstack_restore(uint32_t domid, const uint8_t *buf,
                                        uint32_t size, void *data);
+_hidden int libxl__domain_restore_device_model(libxl__gc *gc, uint32_t domid);
   _hidden int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid);
 
   _hidden const char *libxl__userdata_path(libxl__gc *gc, uint32_t domid,
@@ -1039,6 +1040,7 @@ _hidden int libxl__userdata_store(libxl__gc *gc, uint32_t domid,
                                     const char *userdata_userid,
                                     const uint8_t *data, int datalen);
 
+_hidden int libxl__domain_restore(libxl__gc *gc, uint32_t domid);
   _hidden int libxl__domain_resume(libxl__gc *gc, uint32_t domid,
                                    int suspend_cancel);
   _hidden int libxl__domain_s3_resume(libxl__gc *gc, int domid);
@@ -1651,6 +1653,8 @@ _hidden int libxl__qmp_stop(libxl__gc *gc, int domid);
   _hidden int libxl__qmp_resume(libxl__gc *gc, int domid);
   /* Save current QEMU state into fd. */
   _hidden int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename);
+/* Load current QEMU state from fd. */
+_hidden int libxl__qmp_restore(libxl__gc *gc, int domid, const char *filename);
   /* Set dirty bitmap logging status */
   _hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enable);
   _hidden int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, const libxl_device_disk *disk);
tools/libxl/libxl_qmp.c +9 -0
index 9aa7e2e..a6f1a21 100644
@@ -892,6 +892,16 @@ int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename)
                              NULL, NULL);
   }
 
+int libxl__qmp_restore(libxl__gc *gc, int domid, const char *state_file)
+{
+    libxl__json_object *args = NULL;
+
+    qmp_parameters_add_string(gc, &args, "filename", state_file);
+
+    return qmp_run_command(gc, domid, "xen-load-devices-state", args,
+                           NULL, NULL);
+}
Quoted 9 lines
Quoted 8 lines

tools/libxl/libxl_qmp.c int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename) · line 907

Quoted 4 lines
tools/libxl/libxl_qmp.c +1 -0
+
   static int qmp_change(libxl__gc *gc, libxl__qmp_handler *qmp,
                         char *device, char *target, char *arg)
   {

.

.

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

Re: [PATCH v2 COLOPre 05/13] tools/libxl: introduce a new API libxl__domain_restore() to load qemu state

Quoted 28 lines · Yang Hongyang
Quoted 26 lines · Ian Campbell
Quoted 14 lines · Yang Hongyang
Quoted 12 lines · Ian Campbell
Quoted 10 lines · Yang Hongyang

Secondary vm is running in colo mode. So we will do the following things again and again:
1. suspend both primay vm and secondary vm
2. sync the state
3. resume both primary vm and secondary vm
We will send qemu's state each time in step2, and slave's qemu should read it each time before resuming secondary vm. Introduce a new API libxl__domain_restore() to do it. This API should be called before resuming secondary vm.

Quoted 4 lines
Quoted 1 line

Is this a preexisting qemu interface or one to be added?

We added the qemu interface "xen-load-devices-state", it's not in qemu upstream yet.

OK, please mention this dependency in the commit text since we will want to be sure the interface is going to be accepted in this form by QEMU upstream before we start using it. Please also CC the QEMU maintainers on this patch in the future (by adding Cc: below the S-o-b if you don't want to spam them the whole series), I've added them here now.

Quoted 5 lines
Quoted 2 lines

In particular "devices" seems odd to me, perhaps
"xen-load-device-state"?

This api is an invert operation to "xen-save-devices-stat", we used the name "xen-load-devices-state" in order to follow the existing naming style...

OK, I guess it'll do then, thanks.

#62 lore raw

PATCH v2 6/13 tools/libxl: Introduce a new internal API libxl__domain_unpause()

In reply to Yang Hongyang

From: Wen Congyang <[email protected]>

The guest is paused after libxl_domain_create_restore(). Secondary vm is running in colo mode. So we need to unpause the guest. The current API libxl_domain_unpause() is not an internal API. Introduce a new API to support it. No functional change.

---
 tools/libxl/libxl.c          | 20 ++++++++++++++------
 tools/libxl/libxl_internal.h |  1 +
 2 files changed, 15 insertions(+), 6 deletions(-)
tools/libxl/libxl.c +14 -6
index ba2da92..d5691dc 100644
@@ -933,9 +933,8 @@ out:
     return AO_INPROGRESS;
 }
 
-int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
+int libxl__domain_unpause(libxl__gc *gc, uint32_t domid)
 {
-    GC_INIT(ctx);
     char *path;
     char *state;
     int ret, rc = 0;
@@ -947,7 +946,7 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
     }
 
     if (type == LIBXL_DOMAIN_TYPE_HVM) {
-        uint32_t dm_domid = libxl_get_stubdom_id(ctx, domid);
+        uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid);
 
         path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state");
         state = libxl__xs_read(gc, XBT_NULL, path);
@@ -957,12 +956,21 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
                                          NULL, NULL, NULL);
         }
     }
-    ret = xc_domain_unpause(ctx->xch, domid);
-    if (ret<0) {
-        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unpausing domain %d", domid);
+
+    ret = xc_domain_unpause(CTX->xch, domid);
+    if (ret < 0) {
+        LIBXL__LOG_ERRNO(CTX, LIBXL__LOG_ERROR, "unpausing domain %d", domid);
         rc = ERROR_FAIL;
     }
  out:
+    return rc;
+}
+
+int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
+{
+    GC_INIT(ctx);
+    int rc = libxl__domain_unpause(gc, domid);
+
     GC_FREE;
     return rc;
 }
tools/libxl/libxl_internal.h +1 -0
index 20364c6..366470f 100644
@@ -1044,6 +1044,7 @@ _hidden int libxl__domain_restore(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__domain_resume(libxl__gc *gc, uint32_t domid,
                                  int suspend_cancel);
 _hidden int libxl__domain_s3_resume(libxl__gc *gc, int domid);
+_hidden int libxl__domain_unpause(libxl__gc *gc, uint32_t domid);
 
 /* returns 0 or 1, or a libxl error code */
 _hidden int libxl__domain_pvcontrol_available(libxl__gc *gc, uint32_t domid);
Signature · 1 line
1.9.1
#63 lore raw

Re: [PATCH v2 COLOPre 06/13] tools/libxl: Introduce a new internal API libxl__domain_unpause()

Quoted 7 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

The guest is paused after libxl_domain_create_restore(). Secondary vm is running in colo mode. So we need to unpause the guest. The current API libxl_domain_unpause() is not an internal API. Introduce a new API to support it. No functional change.

In general there is nothing wrong with using a public function internally. Is there some special consideration here?

Quoted 69 lines
---
 tools/libxl/libxl.c          | 20 ++++++++++++++------
 tools/libxl/libxl_internal.h |  1 +
 2 files changed, 15 insertions(+), 6 deletions(-)
tools/libxl/libxl.c +14 -6
index ba2da92..d5691dc 100644
@@ -933,9 +933,8 @@ out:
     return AO_INPROGRESS;
 }
 
-int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
+int libxl__domain_unpause(libxl__gc *gc, uint32_t domid)
 {
-    GC_INIT(ctx);
     char *path;
     char *state;
     int ret, rc = 0;
@@ -947,7 +946,7 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
     }
 
     if (type == LIBXL_DOMAIN_TYPE_HVM) {
-        uint32_t dm_domid = libxl_get_stubdom_id(ctx, domid);
+        uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid);
 
         path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state");
         state = libxl__xs_read(gc, XBT_NULL, path);
@@ -957,12 +956,21 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
                                          NULL, NULL, NULL);
         }
     }
-    ret = xc_domain_unpause(ctx->xch, domid);
-    if (ret<0) {
-        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unpausing domain %d", domid);
+
+    ret = xc_domain_unpause(CTX->xch, domid);
+    if (ret < 0) {
+        LIBXL__LOG_ERRNO(CTX, LIBXL__LOG_ERROR, "unpausing domain %d", domid);
         rc = ERROR_FAIL;
     }
  out:
+    return rc;
+}
+
+int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
+{
+    GC_INIT(ctx);
+    int rc = libxl__domain_unpause(gc, domid);
+
     GC_FREE;
     return rc;
 }
tools/libxl/libxl_internal.h +1 -0
index 20364c6..366470f 100644
@@ -1044,6 +1044,7 @@ _hidden int libxl__domain_restore(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__domain_resume(libxl__gc *gc, uint32_t domid,
                                  int suspend_cancel);
 _hidden int libxl__domain_s3_resume(libxl__gc *gc, int domid);
+_hidden int libxl__domain_unpause(libxl__gc *gc, uint32_t domid);
 
 /* returns 0 or 1, or a libxl error code */
 _hidden int libxl__domain_pvcontrol_available(libxl__gc *gc, uint32_t domid);
#64 lore raw

Re: [PATCH v2 COLOPre 06/13] tools/libxl: Introduce a new internal API libxl__domain_unpause()

Quoted 11 lines · Ian Campbell
Quoted 7 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

The guest is paused after libxl_domain_create_restore(). Secondary vm is running in colo mode. So we need to unpause the guest. The current API libxl_domain_unpause() is not an internal API. Introduce a new API to support it. No functional change.

In general there is nothing wrong with using a public function internally. Is there some special consideration here?

It's just that we thought it's better to use internal functions for internal purpose.
Most the public functions take ctx as the first param, the internal functions take gc/egc as the first param(although we can get ctx from gcs and call public functions when needed).
If it doesn't matter, we can drop this patch.

Quoted 74 lines
Quoted 63 lines
---
  tools/libxl/libxl.c          | 20 ++++++++++++++------
  tools/libxl/libxl_internal.h |  1 +
  2 files changed, 15 insertions(+), 6 deletions(-)
tools/libxl/libxl.c +14 -6
index ba2da92..d5691dc 100644
@@ -933,9 +933,8 @@ out:
      return AO_INPROGRESS;
  }
 
-int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
+int libxl__domain_unpause(libxl__gc *gc, uint32_t domid)
  {
-    GC_INIT(ctx);
      char *path;
      char *state;
      int ret, rc = 0;
@@ -947,7 +946,7 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
      }
 
      if (type == LIBXL_DOMAIN_TYPE_HVM) {
-        uint32_t dm_domid = libxl_get_stubdom_id(ctx, domid);
+        uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid);
 
          path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state");
          state = libxl__xs_read(gc, XBT_NULL, path);
@@ -957,12 +956,21 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
                                           NULL, NULL, NULL);
          }
      }
-    ret = xc_domain_unpause(ctx->xch, domid);
-    if (ret<0) {
-        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unpausing domain %d", domid);
+
+    ret = xc_domain_unpause(CTX->xch, domid);
+    if (ret < 0) {
+        LIBXL__LOG_ERRNO(CTX, LIBXL__LOG_ERROR, "unpausing domain %d", domid);
          rc = ERROR_FAIL;
      }
   out:
+    return rc;
+}
+
+int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
+{
+    GC_INIT(ctx);
+    int rc = libxl__domain_unpause(gc, domid);
+
      GC_FREE;
      return rc;
  }
tools/libxl/libxl_internal.h +0 -0
index 20364c6..366470f 100644

tools/libxl/libxl_internal.h _hidden int libxl__domain_restore(libxl__gc *gc, uint32_t domid); · line 1050

Quoted 7 lines
tools/libxl/libxl_internal.h +1 -0
@@ -1044,6 +1044,7 @@ _hidden int libxl__domain_restore(libxl__gc *gc, uint32_t domid);
  _hidden int libxl__domain_resume(libxl__gc *gc, uint32_t domid,
                                   int suspend_cancel);
  _hidden int libxl__domain_s3_resume(libxl__gc *gc, int domid);
+_hidden int libxl__domain_unpause(libxl__gc *gc, uint32_t domid);
 
  /* returns 0 or 1, or a libxl error code */
  _hidden int libxl__domain_pvcontrol_available(libxl__gc *gc, uint32_t domid);

.

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

Re: [PATCH v2 COLOPre 06/13] tools/libxl: Introduce a new internal API libxl__domain_unpause()

Quoted 14 lines · Yang Hongyang
Quoted 11 lines · Ian Campbell
Quoted 7 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

The guest is paused after libxl_domain_create_restore(). Secondary vm is running in colo mode. So we need to unpause the guest. The current API libxl_domain_unpause() is not an internal API. Introduce a new API to support it. No functional change.

In general there is nothing wrong with using a public function internally. Is there some special consideration here?

Quoted 6 lines

It's just that we thought it's better to use internal functions for internal purpose.
Most the public functions take ctx as the first param, the internal functions take gc/egc as the first param(although we can get ctx from gcs and call public functions when needed).
If it doesn't matter, we can drop this patch.

It doesn't matter so you can, yes.

Quoted 76 lines
Quoted 75 lines
Quoted 64 lines
---
  tools/libxl/libxl.c          | 20 ++++++++++++++------
  tools/libxl/libxl_internal.h |  1 +
  2 files changed, 15 insertions(+), 6 deletions(-)
tools/libxl/libxl.c +14 -6
index ba2da92..d5691dc 100644
@@ -933,9 +933,8 @@ out:
      return AO_INPROGRESS;
  }
 
-int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
+int libxl__domain_unpause(libxl__gc *gc, uint32_t domid)
  {
-    GC_INIT(ctx);
      char *path;
      char *state;
      int ret, rc = 0;
@@ -947,7 +946,7 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
      }
 
      if (type == LIBXL_DOMAIN_TYPE_HVM) {
-        uint32_t dm_domid = libxl_get_stubdom_id(ctx, domid);
+        uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid);
 
          path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state");
          state = libxl__xs_read(gc, XBT_NULL, path);
@@ -957,12 +956,21 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
                                           NULL, NULL, NULL);
          }
      }
-    ret = xc_domain_unpause(ctx->xch, domid);
-    if (ret<0) {
-        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unpausing domain %d", domid);
+
+    ret = xc_domain_unpause(CTX->xch, domid);
+    if (ret < 0) {
+        LIBXL__LOG_ERRNO(CTX, LIBXL__LOG_ERROR, "unpausing domain %d", domid);
          rc = ERROR_FAIL;
      }
   out:
+    return rc;
+}
+
+int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
+{
+    GC_INIT(ctx);
+    int rc = libxl__domain_unpause(gc, domid);
+
      GC_FREE;
      return rc;
  }
tools/libxl/libxl_internal.h +0 -0
index 20364c6..366470f 100644

tools/libxl/libxl_internal.h _hidden int libxl__domain_restore(libxl__gc *gc, uint32_t domid); · line 1050

Quoted 7 lines
tools/libxl/libxl_internal.h +1 -0
@@ -1044,6 +1044,7 @@ _hidden int libxl__domain_restore(libxl__gc *gc, uint32_t domid);
  _hidden int libxl__domain_resume(libxl__gc *gc, uint32_t domid,
                                   int suspend_cancel);
  _hidden int libxl__domain_s3_resume(libxl__gc *gc, int domid);
+_hidden int libxl__domain_unpause(libxl__gc *gc, uint32_t domid);
 
  /* returns 0 or 1, or a libxl error code */
  _hidden int libxl__domain_pvcontrol_available(libxl__gc *gc, uint32_t domid);

.

#66 lore raw

Re: [PATCH v2 COLOPre 06/13] tools/libxl: Introduce a new internal API libxl__domain_unpause()

Quoted 15 lines · Ian Campbell
Quoted 14 lines · Yang Hongyang
Quoted 11 lines · Ian Campbell
Quoted 7 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

The guest is paused after libxl_domain_create_restore(). Secondary vm is running in colo mode. So we need to unpause the guest. The current API libxl_domain_unpause() is not an internal API. Introduce a new API to support it. No functional change.

In general there is nothing wrong with using a public function internally. Is there some special consideration here?

Quoted 8 lines
Quoted 6 lines

It's just that we thought it's better to use internal functions for internal purpose.
Most the public functions take ctx as the first param, the internal functions take gc/egc as the first param(although we can get ctx from gcs and call public functions when needed).
If it doesn't matter, we can drop this patch.

It doesn't matter so you can, yes.

If the public API creates a new AO, it is safe to call it directly?

Thanks
Wen Congyang

Quoted 81 lines
Quoted 70 lines
Quoted 70 lines
Quoted 70 lines
---
  tools/libxl/libxl.c          | 20 ++++++++++++++------
  tools/libxl/libxl_internal.h |  1 +
  2 files changed, 15 insertions(+), 6 deletions(-)
tools/libxl/libxl.c +14 -6
index ba2da92..d5691dc 100644
@@ -933,9 +933,8 @@ out:
      return AO_INPROGRESS;
  }
 
-int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
+int libxl__domain_unpause(libxl__gc *gc, uint32_t domid)
  {
-    GC_INIT(ctx);
      char *path;
      char *state;
      int ret, rc = 0;
@@ -947,7 +946,7 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
      }
 
      if (type == LIBXL_DOMAIN_TYPE_HVM) {
-        uint32_t dm_domid = libxl_get_stubdom_id(ctx, domid);
+        uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid);
 
          path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state");
          state = libxl__xs_read(gc, XBT_NULL, path);
@@ -957,12 +956,21 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
                                           NULL, NULL, NULL);
          }
      }
-    ret = xc_domain_unpause(ctx->xch, domid);
-    if (ret<0) {
-        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unpausing domain %d", domid);
+
+    ret = xc_domain_unpause(CTX->xch, domid);
+    if (ret < 0) {
+        LIBXL__LOG_ERRNO(CTX, LIBXL__LOG_ERROR, "unpausing domain %d", domid);
          rc = ERROR_FAIL;
      }
   out:
+    return rc;
+}
+
+int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
+{
+    GC_INIT(ctx);
+    int rc = libxl__domain_unpause(gc, domid);
+
      GC_FREE;
      return rc;
  }
tools/libxl/libxl_internal.h +1 -0
index 20364c6..366470f 100644
@@ -1044,6 +1044,7 @@ _hidden int libxl__domain_restore(libxl__gc *gc, uint32_t domid);
  _hidden int libxl__domain_resume(libxl__gc *gc, uint32_t domid,
                                   int suspend_cancel);
  _hidden int libxl__domain_s3_resume(libxl__gc *gc, int domid);
+_hidden int libxl__domain_unpause(libxl__gc *gc, uint32_t domid);
 
Quoted 7 lines
Quoted 6 lines

tools/libxl/libxl_internal.h _hidden int libxl__domain_restore(libxl__gc *gc, uint32_t domid); · line 1050

Quoted 2 lines
tools/libxl/libxl_internal.h +0 -0
  /* returns 0 or 1, or a libxl error code */
  _hidden int libxl__domain_pvcontrol_available(libxl__gc *gc, uint32_t domid);

.

.

#67 lore raw

Re: [PATCH v2 COLOPre 06/13] tools/libxl: Introduce a new internal API libxl__domain_unpause()

Quoted 23 lines · Wen Congyang
Quoted 22 lines · Ian Campbell
Quoted 20 lines · Yang Hongyang
Quoted 11 lines · Ian Campbell
Quoted 7 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

The guest is paused after libxl_domain_create_restore(). Secondary vm is running in colo mode. So we need to unpause the guest. The current API libxl_domain_unpause() is not an internal API. Introduce a new API to support it. No functional change.

In general there is nothing wrong with using a public function internally. Is there some special consideration here?

It's just that we thought it's better to use internal functions for internal purpose.
Most the public functions take ctx as the first param, the internal functions take gc/egc as the first param(although we can get ctx from gcs and call public functions when needed).
If it doesn't matter, we can drop this patch.

Quoted 3 lines
Quoted 1 line

It doesn't matter so you can, yes.

If the public API creates a new AO, it is safe to call it directly?

A public function which takes an ao_how is, I believe, an exception to this rule and should be annotated with LIBXL_EXTERNAL_CALLERS_ONLY to prevent accidents.

I don't think libxl_domain_unpause is such a function though.

Ian.

#68 lore raw

Re: [PATCH v2 COLOPre 06/13] tools/libxl: Introduce a new internal API libxl__domain_unpause()

Quoted 26 lines · Ian Campbell
Quoted 25 lines · Wen Congyang
Quoted 23 lines · Ian Campbell
Quoted 14 lines · Yang Hongyang
Quoted 11 lines · Ian Campbell
Quoted 7 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

The guest is paused after libxl_domain_create_restore(). Secondary vm is running in colo mode. So we need to unpause the guest. The current API libxl_domain_unpause() is not an internal API. Introduce a new API to support it. No functional change.

In general there is nothing wrong with using a public function internally. Is there some special consideration here?

Quoted 6 lines

It's just that we thought it's better to use internal functions for internal purpose.
Most the public functions take ctx as the first param, the internal functions take gc/egc as the first param(although we can get ctx from gcs and call public functions when needed).
If it doesn't matter, we can drop this patch.

It doesn't matter so you can, yes.

Quoted 7 lines
Quoted 1 line

If the public API creates a new AO, it is safe to call it directly?

A public function which takes an ao_how is, I believe, an exception to this rule and should be annotated with LIBXL_EXTERNAL_CALLERS_ONLY to prevent accidents.

I don't think libxl_domain_unpause is such a function though.

OK, we will drop this patch.

Thanks
Wen Congyang

Quoted 6 lines

Ian.

.

#69 lore raw

Re: [PATCH v2 COLOPre 06/13] tools/libxl: Introduce a new internal API libxl__domain_unpause()

In reply to Ian Campbell

Ian Campbell writes ("Re: [Xen-devel] [PATCH v2 COLOPre 06/13] tools/libxl: Introduce a new internal API libxl__domain_unpause()"):

Quoted 6 lines · Wen Congyang
Quoted 1 line

If the public API creates a new AO, it is safe to call it directly?

A public function which takes an ao_how is, I believe, an exception to this rule and should be annotated with LIBXL_EXTERNAL_CALLERS_ONLY to prevent accidents.

Yes.

Quoted 1 line

I don't think libxl_domain_unpause is such a function though.

Indeed.

Ian.

#70 lore raw

PATCH v2 7/13 tools/libxl: Update libxl__domain_unpause() to support qemu-xen

In reply to Yang Hongyang

Currently, libxl__domain_unpause() only supports qemu-xen-traditional. Update it to support qemu-xen.

---
 tools/libxl/libxl.c | 42 +++++++++++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 9 deletions(-)
tools/libxl/libxl.c +33 -9
index d5691dc..5c843c2 100644
@@ -933,10 +933,37 @@ out:
     return AO_INPROGRESS;
 }
 
-int libxl__domain_unpause(libxl__gc *gc, uint32_t domid)
+static int libxl__domain_unpause_device_model(libxl__gc *gc, uint32_t domid)
 {
     char *path;
     char *state;
+
+    switch (libxl__device_model_version_running(gc, domid)) {
+    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
+        uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid);
+
+        path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state");
+        state = libxl__xs_read(gc, XBT_NULL, path);
+        if (state != NULL && !strcmp(state, "paused")) {
+            libxl__qemu_traditional_cmd(gc, domid, "continue");
+            libxl__wait_for_device_model_deprecated(gc, domid, "running",
+                                                    NULL, NULL, NULL);
+        }
+        break;
+    }
+    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
+        if (libxl__qmp_resume(gc, domid))
+            return ERROR_FAIL;
+        break;
+    default:
+        return ERROR_INVAL;
+    }
+
+    return 0;
+}
+
+int libxl__domain_unpause(libxl__gc *gc, uint32_t domid)
+{
     int ret, rc = 0;
 
     libxl_domain_type type = libxl__domain_type(gc, domid);
@@ -946,14 +973,11 @@ int libxl__domain_unpause(libxl__gc *gc, uint32_t domid)
     }
 
     if (type == LIBXL_DOMAIN_TYPE_HVM) {
-        uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid);
-
-        path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state");
-        state = libxl__xs_read(gc, XBT_NULL, path);
-        if (state != NULL && !strcmp(state, "paused")) {
-            libxl__qemu_traditional_cmd(gc, domid, "continue");
-            libxl__wait_for_device_model_deprecated(gc, domid, "running",
-                                         NULL, NULL, NULL);
+        rc = libxl__domain_unpause_device_model(gc, domid);
+        if (rc < 0) {
+            LOG(ERROR, "failed to unpause device model for domain %u:%d",
+                domid, rc);
+            goto out;
         }
     }
 
Signature · 1 line
1.9.1
#71 lore raw

Re: [PATCH v2 COLOPre 07/13] tools/libxl: Update libxl__domain_unpause() to support qemu-xen

Quoted 5 lines · Yang Hongyang

Currently, libxl__domain_unpause() only supports qemu-xen-traditional. Update it to support qemu-xen.

This looks very similar to an existing function called libxl__domain_resume_device_model. Maybe you don't need to invent a new function.

Quoted 15 lines
---
 tools/libxl/libxl.c | 42 +++++++++++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 9 deletions(-)
tools/libxl/libxl.c +1 -1
index d5691dc..5c843c2 100644
@@ -933,10 +933,37 @@ out:
     return AO_INPROGRESS;
 }
 
-int libxl__domain_unpause(libxl__gc *gc, uint32_t domid)
+static int libxl__domain_unpause_device_model(libxl__gc *gc, uint32_t domid)
 {

tools/libxl/libxl.c out: · line 947

Quoted 10 lines
tools/libxl/libxl.c +8 -0
     char *path;
     char *state;
+
+    switch (libxl__device_model_version_running(gc, domid)) {
+    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
+        uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid);
+
+        path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state");
+        state = libxl__xs_read(gc, XBT_NULL, path);
+        if (state != NULL && !strcmp(state, "paused")) {

The only difference between your function and libxl__domain_unpause_device_model is the check for "state" node. I think you can just add the check to libxl__domain_resume_device_model and use that function.

Wei.

#72 lore raw

Re: [PATCH v2 COLOPre 07/13] tools/libxl: Update libxl__domain_unpause() to support qemu-xen

Quoted 33 lines · Wei Liu
Quoted 5 lines · Yang Hongyang

Currently, libxl__domain_unpause() only supports qemu-xen-traditional. Update it to support qemu-xen.

This looks very similar to an existing function called libxl__domain_resume_device_model. Maybe you don't need to invent a new function.

Quoted 22 lines
---
  tools/libxl/libxl.c | 42 +++++++++++++++++++++++++++++++++---------
  1 file changed, 33 insertions(+), 9 deletions(-)
tools/libxl/libxl.c +6 -1
index d5691dc..5c843c2 100644
@@ -933,10 +933,37 @@ out:
      return AO_INPROGRESS;
  }
 
-int libxl__domain_unpause(libxl__gc *gc, uint32_t domid)
+static int libxl__domain_unpause_device_model(libxl__gc *gc, uint32_t domid)
  {
      char *path;
      char *state;
+
+    switch (libxl__device_model_version_running(gc, domid)) {
+    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
+        uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid);
+
Quoted 8 lines

tools/libxl/libxl.c out: · line 947

Quoted 3 lines
tools/libxl/libxl.c +3 -0
+        path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state");
+        state = libxl__xs_read(gc, XBT_NULL, path);
+        if (state != NULL && !strcmp(state, "paused")) {

The only difference between your function and libxl__domain_unpause_device_model is the check for "state" node. I think you can just add the check to libxl__domain_resume_device_model and use that function.

I'm not sure if we change the existing function's behavior will affect the existing callers, if there's no problem to do so, I will do as what you said in the next version.

Quoted 4 lines

Wei.
.

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

Re: [PATCH v2 COLOPre 07/13] tools/libxl: Update libxl__domain_unpause() to support qemu-xen

Quoted 45 lines · Yang Hongyang
Quoted 33 lines · Wei Liu
Quoted 5 lines · Yang Hongyang

Currently, libxl__domain_unpause() only supports qemu-xen-traditional. Update it to support qemu-xen.

This looks very similar to an existing function called libxl__domain_resume_device_model. Maybe you don't need to invent a new function.

Quoted 22 lines
---
 tools/libxl/libxl.c | 42 +++++++++++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 9 deletions(-)
tools/libxl/libxl.c +6 -1
index d5691dc..5c843c2 100644
@@ -933,10 +933,37 @@ out:
     return AO_INPROGRESS;
 }
 
-int libxl__domain_unpause(libxl__gc *gc, uint32_t domid)
+static int libxl__domain_unpause_device_model(libxl__gc *gc, uint32_t domid)
 {
     char *path;
     char *state;
+
+    switch (libxl__device_model_version_running(gc, domid)) {
+    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
+        uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid);
+
Quoted 8 lines

tools/libxl/libxl.c out: · line 947

Quoted 3 lines
tools/libxl/libxl.c +3 -0
+        path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state");
+        state = libxl__xs_read(gc, XBT_NULL, path);
+        if (state != NULL && !strcmp(state, "paused")) {

The only difference between your function and libxl__domain_unpause_device_model is the check for "state" node. I think you can just add the check to libxl__domain_resume_device_model and use that function.

Quoted 4 lines

I'm not sure if we change the existing function's behavior will affect the existing callers, if there's no problem to do so, I will do as what you said in the next version.

Qemu-dm currently has several states. libxl__domain_resume_device_model doesn't check the state and writes unconditionally. I think checking before writing would be an improvement.

Wei.

Quoted 8 lines
Quoted 4 lines

Wei.
.

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

Re: [PATCH v2 COLOPre 07/13] tools/libxl: Update libxl__domain_unpause() to support qemu-xen

Quoted 46 lines · Wei Liu
Quoted 45 lines · Yang Hongyang
Quoted 41 lines · Wei Liu
Quoted 5 lines · Yang Hongyang

Currently, libxl__domain_unpause() only supports qemu-xen-traditional. Update it to support qemu-xen.

This looks very similar to an existing function called libxl__domain_resume_device_model. Maybe you don't need to invent a new function.

Quoted 15 lines
---
  tools/libxl/libxl.c | 42 +++++++++++++++++++++++++++++++++---------
  1 file changed, 33 insertions(+), 9 deletions(-)
tools/libxl/libxl.c +1 -1
index d5691dc..5c843c2 100644
@@ -933,10 +933,37 @@ out:
      return AO_INPROGRESS;
  }
 
-int libxl__domain_unpause(libxl__gc *gc, uint32_t domid)
+static int libxl__domain_unpause_device_model(libxl__gc *gc, uint32_t domid)
  {

tools/libxl/libxl.c out: · line 947

Quoted 10 lines
tools/libxl/libxl.c +8 -0
      char *path;
      char *state;
+
+    switch (libxl__device_model_version_running(gc, domid)) {
+    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
+        uint32_t dm_domid = libxl_get_stubdom_id(CTX, domid);
+
+        path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state");
+        state = libxl__xs_read(gc, XBT_NULL, path);
+        if (state != NULL && !strcmp(state, "paused")) {

The only difference between your function and libxl__domain_unpause_device_model is the check for "state" node. I think you can just add the check to libxl__domain_resume_device_model and use that function.

Quoted 8 lines
Quoted 4 lines

I'm not sure if we change the existing function's behavior will affect the existing callers, if there's no problem to do so, I will do as what you said in the next version.

Qemu-dm currently has several states. libxl__domain_resume_device_model doesn't check the state and writes unconditionally. I think checking before writing would be an improvement.

fixed, thank you!

Quoted 13 lines

Wei.

Quoted 8 lines
Quoted 4 lines

Wei.
.

--
Thanks,
Yang.

.

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

PATCH v2 8/13 tools/libxl: introduce libxl__domain_common_switch_qemu_logdirty()

In reply to Yang Hongyang

Secondary vm is running in colo mode, we need to send secondary vm's dirty page information to master at checkpoint, so we have to enable qemu logdirty on secondary.

libxl__domain_suspend_common_switch_qemu_logdirty() is to enable qemu logdirty. But it uses domain_save_state, and calls libxl__xc_domain_saverestore_async_callback_done() before exits. This can not be used for secondary vm.

Update libxl__domain_suspend_common_switch_qemu_logdirty() to introduce a new API libxl__domain_common_switch_qemu_logdirty(). This API only uses libxl__logdirty_switch, and calls lds->callback before exits.

---
 tools/libxl/libxl_dom_save.c | 78 ++++++++++++++++++++++++++------------------
 tools/libxl/libxl_internal.h |  8 +++++
 2 files changed, 54 insertions(+), 32 deletions(-)
tools/libxl/libxl_dom_save.c +46 -32
index f9627f8..c15e9f1 100644
@@ -44,7 +44,7 @@ static void switch_logdirty_timeout(libxl__egc *egc, libxl__ev_time *ev,
 static void switch_logdirty_xswatch(libxl__egc *egc, libxl__ev_xswatch*,
                             const char *watch_path, const char *event_path);
 static void switch_logdirty_done(libxl__egc *egc,
-                                 libxl__domain_save_state *dss, int ok);
+                                 libxl__logdirty_switch *lds, int ok);
 
 static void logdirty_init(libxl__logdirty_switch *lds)
 {
@@ -54,13 +54,10 @@ static void logdirty_init(libxl__logdirty_switch *lds)
 }
 
 static void domain_suspend_switch_qemu_xen_traditional_logdirty
-                               (int domid, unsigned enable,
-                                libxl__save_helper_state *shs)
+                               (libxl__egc *egc, int domid, unsigned enable,
+                                libxl__logdirty_switch *lds)
 {
-    libxl__egc *egc = shs->egc;
-    libxl__domain_save_state *dss = CONTAINER_OF(shs, *dss, shs);
-    libxl__logdirty_switch *lds = &dss->logdirty;
-    STATE_AO_GC(dss->ao);
+    STATE_AO_GC(lds->ao);
     int rc;
     xs_transaction_t t = 0;
     const char *got;
@@ -122,64 +119,81 @@ static void domain_suspend_switch_qemu_xen_traditional_logdirty
  out:
     LOG(ERROR,"logdirty switch failed (rc=%d), aborting suspend",rc);
     libxl__xs_transaction_abort(gc, &t);
-    switch_logdirty_done(egc,dss,-1);
+    switch_logdirty_done(egc,lds,-1);
 }
 
 static void domain_suspend_switch_qemu_xen_logdirty
-                               (int domid, unsigned enable,
-                                libxl__save_helper_state *shs)
+                               (libxl__egc *egc, int domid, unsigned enable,
+                                libxl__logdirty_switch *lds)
 {
-    libxl__egc *egc = shs->egc;
-    libxl__domain_save_state *dss = CONTAINER_OF(shs, *dss, shs);
-    STATE_AO_GC(dss->ao);
+    STATE_AO_GC(lds->ao);
     int rc;
 
     rc = libxl__qmp_set_global_dirty_log(gc, domid, enable);
     if (!rc) {
-        libxl__xc_domain_saverestore_async_callback_done(egc, shs, 0);
+        lds->callback(egc, lds, 0);
     } else {
         LOG(ERROR,"logdirty switch failed (rc=%d), aborting suspend",rc);
-        libxl__xc_domain_saverestore_async_callback_done(egc, shs, -1);
+        lds->callback(egc, lds, -1);
     }
 }
 
+static void libxl__domain_suspend_switch_qemu_logdirty_done
+                        (libxl__egc *egc, libxl__logdirty_switch *lds, int rc)
+{
+    libxl__domain_save_state *dss = CONTAINER_OF(lds, *dss, logdirty);
+
+    libxl__xc_domain_saverestore_async_callback_done(egc, &dss->shs, rc);
+}
+
 void libxl__domain_suspend_common_switch_qemu_logdirty
                                (int domid, unsigned enable, void *user)
 {
     libxl__save_helper_state *shs = user;
     libxl__egc *egc = shs->egc;
     libxl__domain_save_state *dss = CONTAINER_OF(shs, *dss, shs);
-    STATE_AO_GC(dss->ao);
+
+    /* convenience aliases */
+    libxl__logdirty_switch *const lds = &dss->logdirty;
+
+    lds->callback = libxl__domain_suspend_switch_qemu_logdirty_done;
+    libxl__domain_common_switch_qemu_logdirty(egc, domid, enable, lds);
+}
+
+void libxl__domain_common_switch_qemu_logdirty(libxl__egc *egc,
+                                               int domid, unsigned enable,
+                                               libxl__logdirty_switch *lds)
+{
+    STATE_AO_GC(lds->ao);
 
     switch (libxl__device_model_version_running(gc, domid)) {
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
-        domain_suspend_switch_qemu_xen_traditional_logdirty(domid, enable, shs);
+        domain_suspend_switch_qemu_xen_traditional_logdirty(egc, domid, enable,
+                                                            lds);
         break;
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
-        domain_suspend_switch_qemu_xen_logdirty(domid, enable, shs);
+        domain_suspend_switch_qemu_xen_logdirty(egc, domid, enable, lds);
         break;
     default:
         LOG(ERROR,"logdirty switch failed"
             ", no valid device model version found, aborting suspend");
-        libxl__xc_domain_saverestore_async_callback_done(egc, shs, -1);
+        lds->callback(egc, lds, -1);
     }
 }
 static void switch_logdirty_timeout(libxl__egc *egc, libxl__ev_time *ev,
                                     const struct timeval *requested_abs)
 {
-    libxl__domain_save_state *dss = CONTAINER_OF(ev, *dss, logdirty.timeout);
-    STATE_AO_GC(dss->ao);
+    libxl__logdirty_switch *lds = CONTAINER_OF(ev, *lds, timeout);
+    STATE_AO_GC(lds->ao);
     LOG(ERROR,"logdirty switch: wait for device model timed out");
-    switch_logdirty_done(egc,dss,-1);
+    switch_logdirty_done(egc,lds,-1);
 }
 
 static void switch_logdirty_xswatch(libxl__egc *egc, libxl__ev_xswatch *watch,
                             const char *watch_path, const char *event_path)
 {
-    libxl__domain_save_state *dss =
-        CONTAINER_OF(watch, *dss, logdirty.watch);
-    libxl__logdirty_switch *lds = &dss->logdirty;
-    STATE_AO_GC(dss->ao);
+    libxl__logdirty_switch *lds = CONTAINER_OF(watch, *lds, watch);
+    STATE_AO_GC(lds->ao);
     const char *got;
     xs_transaction_t t = 0;
     int rc;
@@ -223,24 +237,23 @@ static void switch_logdirty_xswatch(libxl__egc *egc, libxl__ev_xswatch *watch,
     libxl__xs_transaction_abort(gc, &t);
 
     if (!rc) {
-        switch_logdirty_done(egc,dss,0);
+        switch_logdirty_done(egc,lds,0);
     } else if (rc < 0) {
         LOG(ERROR,"logdirty switch: failed (rc=%d)",rc);
-        switch_logdirty_done(egc,dss,-1);
+        switch_logdirty_done(egc,lds,-1);
     }
 }
 
 static void switch_logdirty_done(libxl__egc *egc,
-                                 libxl__domain_save_state *dss,
+                                 libxl__logdirty_switch *lds,
                                  int broke)
 {
-    STATE_AO_GC(dss->ao);
-    libxl__logdirty_switch *lds = &dss->logdirty;
+    STATE_AO_GC(lds->ao);
 
     libxl__ev_xswatch_deregister(gc, &lds->watch);
     libxl__ev_time_deregister(gc, &lds->timeout);
 
-    libxl__xc_domain_saverestore_async_callback_done(egc, &dss->shs, broke);
+    lds->callback(egc, lds, broke);
 }
 
 /*----- callbacks, called by xc_domain_save -----*/
@@ -357,6 +370,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss)
     libxl__domain_suspend_state *dsps = &dss->dsps;
 
     logdirty_init(&dss->logdirty);
+    dss->logdirty.ao = ao;
     libxl__xswait_init(&dsps->pvcontrol);
     libxl__ev_evtchn_init(&dsps->guest_evtchn);
     libxl__ev_xswatch_init(&dsps->guest_watch);
tools/libxl/libxl_internal.h +8 -0
index 366470f..0b62107 100644
@@ -2837,6 +2837,11 @@ typedef void libxl__save_device_model_cb(libxl__egc*,
                                          libxl__domain_save_state*, int rc);
 
 typedef struct libxl__logdirty_switch {
+    /* set by caller of libxl__domain_common_switch_qemu_logdirty */
+    libxl__ao *ao;
+    void (*callback)(libxl__egc *egc, struct libxl__logdirty_switch *lds,
+                     int rc);
+
     const char *cmd;
     const char *cmd_path;
     const char *ret_path;
@@ -3179,6 +3184,9 @@ void libxl__xc_domain_saverestore_async_callback_done(libxl__egc *egc,
 
 _hidden void libxl__domain_suspend_common_switch_qemu_logdirty
                                (int domid, unsigned int enable, void *data);
+_hidden void libxl__domain_common_switch_qemu_logdirty(libxl__egc *egc,
+                                               int domid, unsigned enable,
+                                               libxl__logdirty_switch *lds);
 _hidden int libxl__toolstack_save(uint32_t domid, uint8_t **buf,
         uint32_t *len, void *data);
 
Signature · 1 line
1.9.1
Acked-by on v2 8/13
#76 lore raw

Re: [PATCH v2 COLOPre 08/13] tools/libxl: introduce libxl__domain_common_switch_qemu_logdirty()

Quoted 9 lines · Yang Hongyang

Secondary vm is running in colo mode, we need to send secondary vm's dirty page information to master at checkpoint, so we have to enable qemu logdirty on secondary.

libxl__domain_suspend_common_switch_qemu_logdirty() is to enable qemu logdirty. But it uses domain_save_state, and calls libxl__xc_domain_saverestore_async_callback_done() before exits. This can not be used for secondary vm.

Quoted 7 lines

Update libxl__domain_suspend_common_switch_qemu_logdirty() to introduce a new API libxl__domain_common_switch_qemu_logdirty(). This API only uses libxl__logdirty_switch, and calls lds->callback before exits.

#77 lore raw

PATCH v2 9/13 tools/libxl: Update libxl_save_msgs_gen.pl to support return data from xl to xc

In reply to Yang Hongyang

From: Wen Congyang <[email protected]>

Currently, all callbacks return an integer value or void. We cannot return some data to xc via callback. Update libxl_save_msgs_gen.pl to support this case.

---
 tools/libxl/libxl_internal.h       |  3 ++
 tools/libxl/libxl_save_callout.c   | 31 ++++++++++++++++++
 tools/libxl/libxl_save_helper.c    | 17 ++++++++++
 tools/libxl/libxl_save_msgs_gen.pl | 65 ++++++++++++++++++++++++++++++++++----
 4 files changed, 109 insertions(+), 7 deletions(-)
tools/libxl/libxl_internal.h +3 -0
index 0b62107..fbbae93 100644
@@ -3180,6 +3180,9 @@ _hidden void libxl__xc_domain_save_done(libxl__egc*, void *dss_void,
  * When they are ready to indicate completion, they call this. */
 void libxl__xc_domain_saverestore_async_callback_done(libxl__egc *egc,
                            libxl__save_helper_state *shs, int return_value);
+void libxl__xc_domain_saverestore_async_callback_done_with_data(libxl__egc *egc,
+                           libxl__save_helper_state *shs,
+                           const void *data, uint64_t size);
 
 
 _hidden void libxl__domain_suspend_common_switch_qemu_logdirty
tools/libxl/libxl_save_callout.c +31 -0
index cd342b9..5c691eb 100644
@@ -145,6 +145,15 @@ void libxl__xc_domain_saverestore_async_callback_done(libxl__egc *egc,
     shs->egc = 0;
 }
 
+void libxl__xc_domain_saverestore_async_callback_done_with_data(libxl__egc *egc,
+                           libxl__save_helper_state *shs,
+                           const void *data, uint64_t size)
+{
+    shs->egc = egc;
+    libxl__srm_callout_sendreply_data(data, size, shs);
+    shs->egc = 0;
+}
+
 /*----- helper execution -----*/
 
 static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
@@ -370,6 +379,28 @@ void libxl__srm_callout_sendreply(int r, void *user)
         helper_failed(egc, shs, ERROR_FAIL);
 }
 
+void libxl__srm_callout_sendreply_data(const void *data, uint64_t size, void *user)
+{
+    libxl__save_helper_state *shs = user;
+    libxl__egc *egc = shs->egc;
+    STATE_AO_GC(shs->ao);
+    int errnoval;
+
+    errnoval = libxl_write_exactly(CTX, libxl__carefd_fd(shs->pipes[0]),
+                                   &size, sizeof(size), shs->stdin_what,
+                                   "callback return data length");
+    if (errnoval)
+        goto out;
+
+    errnoval = libxl_write_exactly(CTX, libxl__carefd_fd(shs->pipes[0]),
+                                   data, size, shs->stdin_what,
+                                   "callback return data");
+
+out:
+    if (errnoval)
+        helper_failed(egc, shs, ERROR_FAIL);
+}
+
 void libxl__srm_callout_callback_log(uint32_t level, uint32_t errnoval,
                   const char *context, const char *formatted, void *user)
 {
tools/libxl/libxl_save_helper.c +17 -0
index 74826a1..44c5807 100644
@@ -155,6 +155,23 @@ int helper_getreply(void *user)
     return v;
 }
 
+uint8_t *helper_getreply_data(void *user)
+{
+    uint64_t size;
+    int r = read_exactly(0, &size, sizeof(size));
+    uint8_t *data;
+
+    if (r <= 0)
+        exit(-2);
+
+    data = helper_allocbuf(size, user);
+    r = read_exactly(0, data, size);
+    if (r <= 0)
+        exit(-2);
+
+    return data;
+}
+
 /*----- other callbacks -----*/
 
 static int toolstack_save_fd;
tools/libxl/libxl_save_msgs_gen.pl +58 -7

135 lines not on this page · raw message

Signature · 1 line
1.9.1
#78 lore raw

Re: [PATCH v2 COLOPre 09/13] tools/libxl: Update libxl_save_msgs_gen.pl to support return data from xl to xc

Quoted 5 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

Currently, all callbacks return an integer value or void. We cannot return some data to xc via callback. Update libxl_save_msgs_gen.pl to support this case.

(Odd two space indent from somewhere)

Can you be more specific about what kind of data you need to pass back here? Is it an opaque "void *" blob or is it potentially more structured? That is useful to know in case there might be a better way to achieve the goal.

Ian.

#79 lore raw

Re: [PATCH v2 COLOPre 09/13] tools/libxl: Update libxl_save_msgs_gen.pl to support return data from xl to xc

Quoted 7 lines · Ian Campbell
Quoted 5 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

Currently, all callbacks return an integer value or void. We cannot return some data to xc via callback. Update libxl_save_msgs_gen.pl to support this case.

Quoted 6 lines

(Odd two space indent from somewhere)

Can you be more specific about what kind of data you need to pass back here? Is it an opaque "void *" blob or is it potentially more structured? That is useful to know in case there might be a better way to achieve the goal.

The secondary vm's dirty bitmap.

Thanks
Wen Congyang

Quoted 5 lines

Ian.

.

#80 lore raw

Re: [PATCH v2 COLOPre 09/13] tools/libxl: Update libxl_save_msgs_gen.pl to support return data from xl to xc

Wen Congyang writes ("Re: [Xen-devel] [PATCH v2 COLOPre 09/13] tools/libxl: Update libxl_save_msgs_gen.pl to support return data from xl to xc"):

Quoted 7 lines · Ian Campbell
Quoted 4 lines

Can you be more specific about what kind of data you need to pass back here? Is it an opaque "void *" blob or is it potentially more structured? That is useful to know in case there might be a better way to achieve the goal.

The secondary vm's dirty bitmap.

This is going to be quite large, potentially. Is assembling it in memory in one go really the right approach ?

Also, I'm not sure why this information needs to be plumbed through to libxl ? Maybe it would be better to offer libxc a backchannel, directly.

Ian.

#81 lore raw

Re: [PATCH v2 COLOPre 09/13] tools/libxl: Update libxl_save_msgs_gen.pl to support return data from xl to xc

In reply to Ian Campbell

Ian Campbell writes ("Re: [Xen-devel] [PATCH v2 COLOPre 09/13] tools/libxl: Update libxl_save_msgs_gen.pl to support return data from xl to xc"):

Quoted 6 lines · Yang Hongyang
Quoted 5 lines

From: Wen Congyang <[email protected]>

Currently, all callbacks return an integer value or void. We cannot return some data to xc via callback. Update libxl_save_msgs_gen.pl to support this case.

For some reason I have only v2 of this in my INBOX. Should I start trying to complain to corporate IT again ?

Ian.

#82 lore raw

Re: [PATCH v2 COLOPre 09/13] tools/libxl: Update libxl_save_msgs_gen.pl to support return data from xl to xc

In reply to Yang Hongyang

Yang Hongyang writes ("[Xen-devel] [PATCH v2 COLOPre 09/13] tools/libxl: Update libxl_save_msgs_gen.pl to support return data from xl to xc"):

Quoted 5 lines

From: Wen Congyang <[email protected]>

Currently, all callbacks return an integer value or void. We cannot return some data to xc via callback. Update libxl_save_msgs_gen.pl to support this case.

Thanks for this. I would have some comments on the details, but first I want to properly understand your use case. So while I'm the author and maintainer of this save helper, I won't review this in detail just yet. I'm following the thread about what this is for...

Thanks,
Ian.

#83 lore raw

Re: [PATCH v2 COLOPre 09/13] tools/libxl: Update libxl_save_msgs_gen.pl to support return data from xl to xc

Hi Ian,

Quoted 11 lines · Ian Jackson

Yang Hongyang writes ("[Xen-devel] [PATCH v2 COLOPre 09/13] tools/libxl: Update libxl_save_msgs_gen.pl to support return data from xl to xc"):

Quoted 5 lines

From: Wen Congyang <[email protected]>

Currently, all callbacks return an integer value or void. We cannot return some data to xc via callback. Update libxl_save_msgs_gen.pl to support this case.

Thanks for this. I would have some comments on the details, but first I want to properly understand your use case. So while I'm the author and maintainer of this save helper, I won't review this in detail just yet. I'm following the thread about what this is for...

We need to send secondary's dirty page pfn back to primary. Primary will then send pages that are both dirtied on primary/secondary to secondary. in this way the secondary's memory will be consistent with primary.

As we disscussed in [PATCH v2 COLOPre 04/13] tools/libxc: export xc_bitops.h If we move this operation to libxc layer, this patch could be dropped.

Quoted 5 lines

Thanks,
Ian.
.

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

PATCH v2 10/13 tools/libxl: Add back channel to allow migration target send data back

In reply to Yang Hongyang

From: Wen Congyang <[email protected]>

In colo mode, slave needs to send data to master, but the io_fd only can be written in master, and only can be read in slave. Save recv_fd in domain_suspend_state, and send_fd in domain_create_state.

---
 tools/libxl/libxl.c          |  2 +-
 tools/libxl/libxl_create.c   | 14 ++++++++++----
 tools/libxl/libxl_internal.h |  2 ++
 tools/libxl/libxl_types.idl  |  7 +++++++
 tools/libxl/xl_cmdimpl.c     |  7 +++++++
 5 files changed, 27 insertions(+), 5 deletions(-)
tools/libxl/libxl.c +1 -1
index 5c843c2..36b97fe 100644
@@ -832,7 +832,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
     dss->callback = remus_failover_cb;
     dss->domid = domid;
     dss->fd = send_fd;
-    /* TODO do something with recv_fd */
+    dss->recv_fd = recv_fd;
     dss->type = type;
     dss->live = 1;
     dss->debug = 0;
tools/libxl/libxl_create.c +10 -4
index 86384d2..bd8149c 100644
@@ -1577,8 +1577,8 @@ static void domain_create_cb(libxl__egc *egc,
                              int rc, uint32_t domid);
 
 static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config,
-                            uint32_t *domid,
-                            int restore_fd, int checkpointed_stream,
+                            uint32_t *domid, int restore_fd,
+                            int send_fd, int checkpointed_stream,
                             const libxl_asyncop_how *ao_how,
                             const libxl_asyncprogress_how *aop_console_how)
 {
@@ -1591,6 +1591,7 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config,
     libxl_domain_config_init(&cdcs->dcs.guest_config_saved);
     libxl_domain_config_copy(ctx, &cdcs->dcs.guest_config_saved, d_config);
     cdcs->dcs.restore_fd = restore_fd;
+    cdcs->dcs.send_fd = send_fd;
     cdcs->dcs.callback = domain_create_cb;
     cdcs->dcs.checkpointed_stream = checkpointed_stream;
     libxl__ao_progress_gethow(&cdcs->dcs.aop_console_how, aop_console_how);
@@ -1619,7 +1620,7 @@ int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,
                             const libxl_asyncop_how *ao_how,
                             const libxl_asyncprogress_how *aop_console_how)
 {
-    return do_domain_create(ctx, d_config, domid, -1, 0,
+    return do_domain_create(ctx, d_config, domid, -1, -1, 0,
                             ao_how, aop_console_how);
 }
 
@@ -1629,7 +1630,12 @@ int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config,
                                 const libxl_asyncop_how *ao_how,
                                 const libxl_asyncprogress_how *aop_console_how)
 {
-    return do_domain_create(ctx, d_config, domid, restore_fd,
+    int send_fd = -1;
+
+    if (params->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_COLO)
+        send_fd = params->send_fd;
+
+    return do_domain_create(ctx, d_config, domid, restore_fd, send_fd,
                             params->checkpointed_stream, ao_how, aop_console_how);
 }
 
tools/libxl/libxl_internal.h +2 -0
index fbbae93..6d214b5 100644
@@ -2874,6 +2874,7 @@ struct libxl__domain_save_state {
 
     uint32_t domid;
     int fd;
+    int recv_fd;
     libxl_domain_type type;
     int live;
     int debug;
@@ -3143,6 +3144,7 @@ struct libxl__domain_create_state {
     libxl_domain_config *guest_config;
     libxl_domain_config guest_config_saved; /* vanilla config */
     int restore_fd;
+    int send_fd;
     libxl__domain_create_cb *callback;
     libxl_asyncprogress_how aop_console_how;
     /* private to domain_create */
tools/libxl/libxl_types.idl +7 -0
index 23f27d4..8a3d7ba 100644
@@ -198,6 +198,12 @@ libxl_viridian_enlightenment = Enumeration("viridian_enlightenment", [
     (3, "reference_tsc"),
     ])
 
+libxl_checkpointed_stream = Enumeration("checkpointed_stream", [
+    (0, "NONE"),
+    (1, "REMUS"),
+    (2, "COLO"),
+    ], init_val = 0)
+
 #
 # Complex libxl types
 #
@@ -346,6 +352,7 @@ libxl_domain_create_info = Struct("domain_create_info",[
 
 libxl_domain_restore_params = Struct("domain_restore_params", [
     ("checkpointed_stream", integer),
+    ("send_fd", integer),
     ])
 
 libxl_domain_sched_params = Struct("domain_sched_params",[
tools/libxl/xl_cmdimpl.c +7 -0
index c858068..adfadd1 100644
@@ -154,6 +154,7 @@ struct domain_create {
     const char *extra_config; /* extra config string */
     const char *restore_file;
     int migrate_fd; /* -1 means none */
+    int send_fd; /* -1 means none */
     char **migration_domname_r; /* from malloc */
 };
 
@@ -2533,6 +2534,7 @@ static uint32_t create_domain(struct domain_create *dom_info)
     void *config_data = 0;
     int config_len = 0;
     int restore_fd = -1;
+    int send_fd = -1;
     const libxl_asyncprogress_how *autoconnect_console_how;
     struct save_file_header hdr;
 
@@ -2549,6 +2551,7 @@ static uint32_t create_domain(struct domain_create *dom_info)
         if (migrate_fd >= 0) {
             restore_source = "<incoming migration stream>";
             restore_fd = migrate_fd;
+            send_fd = dom_info->send_fd;
         } else {
             restore_source = restore_file;
             restore_fd = open(restore_file, O_RDONLY);
@@ -2723,6 +2726,7 @@ start:
         libxl_domain_restore_params_init(&params);
 
         params.checkpointed_stream = dom_info->checkpointed_stream;
+        params.send_fd = send_fd;
         ret = libxl_domain_create_restore(ctx, &d_config,
                                           &domid, restore_fd,
                                           &params,
@@ -4266,6 +4270,7 @@ static void migrate_receive(int debug, int daemonize, int monitor,
     dom_info.monitor = monitor;
     dom_info.paused = 1;
     dom_info.migrate_fd = recv_fd;
+    dom_info.send_fd = send_fd;
     dom_info.migration_domname_r = &migration_domname;
     dom_info.checkpointed_stream = remus;
 
@@ -4436,6 +4441,7 @@ int main_restore(int argc, char **argv)
     dom_info.config_file = config_file;
     dom_info.restore_file = checkpoint_file;
     dom_info.migrate_fd = -1;
+    dom_info.send_fd = -1;
     dom_info.vnc = vnc;
     dom_info.vncautopass = vncautopass;
     dom_info.console_autoconnect = console_autoconnect;
@@ -4886,6 +4892,7 @@ int main_create(int argc, char **argv)
     dom_info.config_file = filename;
     dom_info.extra_config = extra_config;
     dom_info.migrate_fd = -1;
+    dom_info.send_fd = -1;
     dom_info.vnc = vnc;
     dom_info.vncautopass = vncautopass;
     dom_info.console_autoconnect = console_autoconnect;
Signature · 1 line
1.9.1
#85 lore raw

Re: [PATCH v2 COLOPre 10/13] tools/libxl: Add back channel to allow migration target send data back

Quoted 7 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

In colo mode, slave needs to send data to master, but the io_fd only can be written in master, and only can be read in slave. Save recv_fd in domain_suspend_state, and send_fd in domain_create_state.

You failed to mention in commit message new structures are introduced in IDL.

Quoted 8 lines
---
 tools/libxl/libxl.c          |  2 +-
 tools/libxl/libxl_create.c   | 14 ++++++++++----
 tools/libxl/libxl_internal.h |  2 ++
 tools/libxl/libxl_types.idl  |  7 +++++++
 tools/libxl/xl_cmdimpl.c     |  7 +++++++

You also need to add LIBXL_HAVE in libxl.h.

Quoted 86 lines
 5 files changed, 27 insertions(+), 5 deletions(-)
tools/libxl/libxl.c +1 -1
index 5c843c2..36b97fe 100644
@@ -832,7 +832,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
     dss->callback = remus_failover_cb;
     dss->domid = domid;
     dss->fd = send_fd;
-    /* TODO do something with recv_fd */
+    dss->recv_fd = recv_fd;
     dss->type = type;
     dss->live = 1;
     dss->debug = 0;
tools/libxl/libxl_create.c +10 -4
index 86384d2..bd8149c 100644
@@ -1577,8 +1577,8 @@ static void domain_create_cb(libxl__egc *egc,
                              int rc, uint32_t domid);
 
 static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config,
-                            uint32_t *domid,
-                            int restore_fd, int checkpointed_stream,
+                            uint32_t *domid, int restore_fd,
+                            int send_fd, int checkpointed_stream,
                             const libxl_asyncop_how *ao_how,
                             const libxl_asyncprogress_how *aop_console_how)
 {
@@ -1591,6 +1591,7 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config,
     libxl_domain_config_init(&cdcs->dcs.guest_config_saved);
     libxl_domain_config_copy(ctx, &cdcs->dcs.guest_config_saved, d_config);
     cdcs->dcs.restore_fd = restore_fd;
+    cdcs->dcs.send_fd = send_fd;
     cdcs->dcs.callback = domain_create_cb;
     cdcs->dcs.checkpointed_stream = checkpointed_stream;
     libxl__ao_progress_gethow(&cdcs->dcs.aop_console_how, aop_console_how);
@@ -1619,7 +1620,7 @@ int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,
                             const libxl_asyncop_how *ao_how,
                             const libxl_asyncprogress_how *aop_console_how)
 {
-    return do_domain_create(ctx, d_config, domid, -1, 0,
+    return do_domain_create(ctx, d_config, domid, -1, -1, 0,
                             ao_how, aop_console_how);
 }
 
@@ -1629,7 +1630,12 @@ int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config,
                                 const libxl_asyncop_how *ao_how,
                                 const libxl_asyncprogress_how *aop_console_how)
 {
-    return do_domain_create(ctx, d_config, domid, restore_fd,
+    int send_fd = -1;
+
+    if (params->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_COLO)
+        send_fd = params->send_fd;
+
+    return do_domain_create(ctx, d_config, domid, restore_fd, send_fd,
                             params->checkpointed_stream, ao_how, aop_console_how);
 }
 
tools/libxl/libxl_internal.h +2 -0
index fbbae93..6d214b5 100644
@@ -2874,6 +2874,7 @@ struct libxl__domain_save_state {
 
     uint32_t domid;
     int fd;
+    int recv_fd;
     libxl_domain_type type;
     int live;
     int debug;
@@ -3143,6 +3144,7 @@ struct libxl__domain_create_state {
     libxl_domain_config *guest_config;
     libxl_domain_config guest_config_saved; /* vanilla config */
     int restore_fd;
+    int send_fd;
     libxl__domain_create_cb *callback;
     libxl_asyncprogress_how aop_console_how;
     /* private to domain_create */
tools/libxl/libxl_types.idl +0 -0
index 23f27d4..8a3d7ba 100644

tools/libxl/libxl_types.idl libxl_viridian_enlightenment = Enumeration("viridian_enlightenment", [ · line 205

Quoted 8 lines
tools/libxl/libxl_types.idl +5 -0
@@ -198,6 +198,12 @@ libxl_viridian_enlightenment = Enumeration("viridian_enlightenment", [
     (3, "reference_tsc"),
     ])
 
+libxl_checkpointed_stream = Enumeration("checkpointed_stream", [
+    (0, "NONE"),
+    (1, "REMUS"),
+    (2, "COLO"),
+    ], init_val = 0)

The default init_val is 0 so you don't need to write it down.

tools/libxl/libxl_types.idl libxl_domain_create_info = Struct("domain_create_info",[ · line 355

Quoted 9 lines
tools/libxl/libxl_types.idl +2 -0
+
 #
 # Complex libxl types
 #
@@ -346,6 +352,7 @@ libxl_domain_create_info = Struct("domain_create_info",[
 
 libxl_domain_restore_params = Struct("domain_restore_params", [
     ("checkpointed_stream", integer),
+    ("send_fd", integer),

I'm not entirely sure if we want to bury an extra argument here.

After looking at code I think you're trying to work around API limitation. I think we are safe to extend the API -- we've already done that before. See libxl.h around line 990.

Ian and Ian, what do you think?

tools/libxl/xl_cmdimpl.c

Quoted 7 lines
tools/libxl/libxl_types.idl +0 -0
     ])
 
 libxl_domain_sched_params = Struct("domain_sched_params",[
tools/libxl/xl_cmdimpl.c +0 -0
index c858068..adfadd1 100644

I would also suggest you rename the last argument of migrate_receive in this file from "remus" to "checkpointed_stream_type" since the semantics of that parameter has changed.

Wei.

#86 lore raw

Re: [PATCH v2 COLOPre 10/13] tools/libxl: Add back channel to allow migration target send data back

Wei Liu writes ("Re: [Xen-devel] [PATCH v2 COLOPre 10/13] tools/libxl: Add back channel to allow migration target send data back"):

Quoted 7 lines · Yang Hongyang
Quoted 6 lines

From: Wen Congyang <[email protected]>

In colo mode, slave needs to send data to master, but the io_fd only can be written in master, and only can be read in slave. Save recv_fd in domain_suspend_state, and send_fd in domain_create_state.

...

Quoted 11 lines
Quoted 3 lines

libxl_domain_restore_params = Struct("domain_restore_params", [
("checkpointed_stream", integer),
+ ("send_fd", integer),

I'm not entirely sure if we want to bury an extra argument here.

After looking at code I think you're trying to work around API limitation. I think we are safe to extend the API -- we've already done that before. See libxl.h around line 990.

Ian and Ian, what do you think?

I agree with you, Wei. I don't think an fd should be in libxl_domain_restore_params at all.

We need to understand what the API semantics are. Are are going to introduce a new libxl API entrypoint ? We already have libxl_domain_remus_start.

Ian.

#87 lore raw

Re: [PATCH v2 COLOPre 10/13] tools/libxl: Add back channel to allow migration target send data back

Quoted 15 lines · Ian Jackson

Wei Liu writes ("Re: [Xen-devel] [PATCH v2 COLOPre 10/13] tools/libxl: Add back channel to allow migration target send data back"):

Quoted 7 lines · Yang Hongyang
Quoted 6 lines

From: Wen Congyang <[email protected]>

In colo mode, slave needs to send data to master, but the io_fd only can be written in master, and only can be read in slave. Save recv_fd in domain_suspend_state, and send_fd in domain_create_state.

...

Quoted 6 lines
Quoted 3 lines

libxl_domain_restore_params = Struct("domain_restore_params", [
("checkpointed_stream", integer),
+ ("send_fd", integer),

I'm not entirely sure if we want to bury an extra argument here.

Quoted 8 lines
Quoted 5 lines

After looking at code I think you're trying to work around API limitation. I think we are safe to extend the API -- we've already done that before. See libxl.h around line 990.

Ian and Ian, what do you think?

I agree with you, Wei. I don't think an fd should be in libxl_domain_restore_params at all.

Then I'll just extend the params of libxl_domain_create_restore().

Quoted 4 lines

We need to understand what the API semantics are. Are are going to introduce a new libxl API entrypoint ? We already have libxl_domain_remus_start.

We use libxl_domain_remus_start for COLO. COLO is an option of "xl remus".

Quoted 4 lines

Ian.
.

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

Re: [PATCH v2 COLOPre 10/13] tools/libxl: Add back channel to allow migration target send data back

Quoted 21 lines · Yang Hongyang
Quoted 19 lines · Ian Jackson

Wei Liu writes ("Re: [Xen-devel] [PATCH v2 COLOPre 10/13] tools/libxl: Add back channel to allow migration target send data back"):

Quoted 7 lines · Yang Hongyang
Quoted 6 lines

From: Wen Congyang <[email protected]>

In colo mode, slave needs to send data to master, but the io_fd only can be written in master, and only can be read in slave. Save recv_fd in domain_suspend_state, and send_fd in domain_create_state.

...

Quoted 10 lines
Quoted 3 lines

libxl_domain_restore_params = Struct("domain_restore_params", [
("checkpointed_stream", integer),
+ ("send_fd", integer),

I'm not entirely sure if we want to bury an extra argument here.

After looking at code I think you're trying to work around API limitation. I think we are safe to extend the API -- we've already done that before. See libxl.h around line 990.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Ian and Ian, what do you think?

I agree with you, Wei. I don't think an fd should be in libxl_domain_restore_params at all.

Then I'll just extend the params of libxl_domain_create_restore().

One question first: is it really to be expected that send_fd and recv_fd will be different, as opposed to the bidirectional data going over the same socket?

Quoted 13 lines
Quoted 5 lines

We need to understand what the API semantics are. Are are going to introduce a new libxl API entrypoint ? We already have libxl_domain_remus_start.

We use libxl_domain_remus_start for COLO. COLO is an option of "xl remus".

Quoted 4 lines

Ian.
.

#89 lore raw

Re: [PATCH v2 COLOPre 10/13] tools/libxl: Add back channel to allow migration target send data back

Ian Campbell writes ("Re: [Xen-devel] [PATCH v2 COLOPre 10/13] tools/libxl: Add back channel to allow migration target send data back"):

Quoted 6 lines · Yang Hongyang
Quoted 1 line

Then I'll just extend the params of libxl_domain_create_restore().

One question first: is it really to be expected that send_fd and recv_fd will be different, as opposed to the bidirectional data going over the same socket?

If this is supposed to be able to work over a pipe, and ssh, then yes.

Even if you give ssh copies of the same socketpair fd on 0 and 1, sshd's child gets ends of two different pipes on 0 and 1.

Ian.

#90 lore raw

Re: [PATCH v2 COLOPre 10/13] tools/libxl: Add back channel to allow migration target send data back

In reply to Wei Liu
Quoted 112 lines · Wei Liu
Quoted 7 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

In colo mode, slave needs to send data to master, but the io_fd only can be written in master, and only can be read in slave. Save recv_fd in domain_suspend_state, and send_fd in domain_create_state.

You failed to mention in commit message new structures are introduced in IDL.

Quoted 8 lines
---
  tools/libxl/libxl.c          |  2 +-
  tools/libxl/libxl_create.c   | 14 ++++++++++----
  tools/libxl/libxl_internal.h |  2 ++
  tools/libxl/libxl_types.idl  |  7 +++++++
  tools/libxl/xl_cmdimpl.c     |  7 +++++++

You also need to add LIBXL_HAVE in libxl.h.

Quoted 89 lines
  5 files changed, 27 insertions(+), 5 deletions(-)
tools/libxl/libxl.c +1 -1
index 5c843c2..36b97fe 100644
@@ -832,7 +832,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
      dss->callback = remus_failover_cb;
      dss->domid = domid;
      dss->fd = send_fd;
-    /* TODO do something with recv_fd */
+    dss->recv_fd = recv_fd;
      dss->type = type;
      dss->live = 1;
      dss->debug = 0;
tools/libxl/libxl_create.c +10 -4
index 86384d2..bd8149c 100644
@@ -1577,8 +1577,8 @@ static void domain_create_cb(libxl__egc *egc,
                               int rc, uint32_t domid);
 
  static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config,
-                            uint32_t *domid,
-                            int restore_fd, int checkpointed_stream,
+                            uint32_t *domid, int restore_fd,
+                            int send_fd, int checkpointed_stream,
                              const libxl_asyncop_how *ao_how,
                              const libxl_asyncprogress_how *aop_console_how)
  {
@@ -1591,6 +1591,7 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config,
      libxl_domain_config_init(&cdcs->dcs.guest_config_saved);
      libxl_domain_config_copy(ctx, &cdcs->dcs.guest_config_saved, d_config);
      cdcs->dcs.restore_fd = restore_fd;
+    cdcs->dcs.send_fd = send_fd;
      cdcs->dcs.callback = domain_create_cb;
      cdcs->dcs.checkpointed_stream = checkpointed_stream;
      libxl__ao_progress_gethow(&cdcs->dcs.aop_console_how, aop_console_how);
@@ -1619,7 +1620,7 @@ int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,
                              const libxl_asyncop_how *ao_how,
                              const libxl_asyncprogress_how *aop_console_how)
  {
-    return do_domain_create(ctx, d_config, domid, -1, 0,
+    return do_domain_create(ctx, d_config, domid, -1, -1, 0,
                              ao_how, aop_console_how);
  }
 
@@ -1629,7 +1630,12 @@ int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config,
                                  const libxl_asyncop_how *ao_how,
                                  const libxl_asyncprogress_how *aop_console_how)
  {
-    return do_domain_create(ctx, d_config, domid, restore_fd,
+    int send_fd = -1;
+
+    if (params->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_COLO)
+        send_fd = params->send_fd;
+
+    return do_domain_create(ctx, d_config, domid, restore_fd, send_fd,
                              params->checkpointed_stream, ao_how, aop_console_how);
  }
 
tools/libxl/libxl_internal.h +2 -0
index fbbae93..6d214b5 100644
@@ -2874,6 +2874,7 @@ struct libxl__domain_save_state {
 
      uint32_t domid;
      int fd;
+    int recv_fd;
      libxl_domain_type type;
      int live;
      int debug;
@@ -3143,6 +3144,7 @@ struct libxl__domain_create_state {
      libxl_domain_config *guest_config;
      libxl_domain_config guest_config_saved; /* vanilla config */
      int restore_fd;
+    int send_fd;
      libxl__domain_create_cb *callback;
      libxl_asyncprogress_how aop_console_how;
      /* private to domain_create */
tools/libxl/libxl_types.idl +0 -0
index 23f27d4..8a3d7ba 100644
@@ -198,6 +198,12 @@ libxl_viridian_enlightenment = Enumeration("viridian_enlightenment", [
      (3, "reference_tsc"),
      ])
 
Quoted 7 lines

tools/libxl/libxl_types.idl libxl_viridian_enlightenment = Enumeration("viridian_enlightenment", [ · line 205

Quoted 5 lines
tools/libxl/libxl_types.idl +5 -0
+libxl_checkpointed_stream = Enumeration("checkpointed_stream", [
+    (0, "NONE"),
+    (1, "REMUS"),
+    (2, "COLO"),
+    ], init_val = 0)

The default init_val is 0 so you don't need to write it down.

Okay.

Quoted 21 lines

tools/libxl/libxl_types.idl libxl_domain_create_info = Struct("domain_create_info",[ · line 355

Quoted 10 lines
tools/libxl/libxl_types.idl +2 -0
+
  #
  # Complex libxl types
  #
@@ -346,6 +352,7 @@ libxl_domain_create_info = Struct("domain_create_info",[
 
  libxl_domain_restore_params = Struct("domain_restore_params", [
      ("checkpointed_stream", integer),
+    ("send_fd", integer),

I'm not entirely sure if we want to bury an extra argument here.

After looking at code I think you're trying to work around API limitation. I think we are safe to extend the API -- we've already done that before. See libxl.h around line 990.

Ian and Ian, what do you think?

Quoted 2 lines
tools/libxl/libxl_types.idl +0 -0
      ])
 
Quoted 9 lines

tools/libxl/xl_cmdimpl.c

Quoted 5 lines
tools/libxl/libxl_types.idl +0 -0
  libxl_domain_sched_params = Struct("domain_sched_params",[
tools/libxl/xl_cmdimpl.c +0 -0
index c858068..adfadd1 100644

I would also suggest you rename the last argument of migrate_receive in this file from "remus" to "checkpointed_stream_type" since the semantics of that parameter has changed.

I've renamed it to "checkpointed".

Quoted 4 lines

Wei.
.

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

PATCH v2 11/13 tools/libxl: rename remus device to checkpoint device

In reply to Yang Hongyang

This 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

---
 tools/libxl/Makefile                  |   2 +-
 tools/libxl/libxl_checkpoint_device.c | 327 ++++++++++++++++++++++++++++++++++
 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_device.c      | 327 ----------------------------------
 tools/libxl/libxl_remus_disk_drbd.c   |  52 +++---
 tools/libxl/libxl_types.idl           |   4 +-
 9 files changed, 509 insertions(+), 509 deletions(-)
 create mode 100644 tools/libxl/libxl_checkpoint_device.c
 delete mode 100644 tools/libxl/libxl_remus_device.c
tools/libxl/Makefile +1 -1
index df51b22..cd63dac 100644
@@ -56,7 +56,7 @@ else
 LIBXL_OBJS-y += libxl_nonetbuffer.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_checkpoint_device.c new file +327 -0

327 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

301 lines not on this page · raw message

tools/libxl/libxl_nonetbuffer.c +5 -5
index 3c659c2..4b68152 100644
@@ -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

193 lines not on this page · raw message

tools/libxl/libxl_remus_device.c deleted +0 -327

327 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
index 8a3d7ba..375c546 100644
@@ -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"),
     ], value_namespace = "")
Signature · 1 line
1.9.1
#92 lore raw

Re: [PATCH v2 COLOPre 11/13] tools/libxl: rename remus device to checkpoint device

On Mon, Jun 08, 2015 at 11:43:15AM +0800, Yang Hongyang wrote:
[...]

Quoted 13 lines
---
 tools/libxl/Makefile                  |   2 +-
 tools/libxl/libxl_checkpoint_device.c | 327 ++++++++++++++++++++++++++++++++++
 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_device.c      | 327 ----------------------------------
 tools/libxl/libxl_remus_disk_drbd.c   |  52 +++---
 tools/libxl/libxl_types.idl           |   4 +-

This only thing I need to complain is the change to IDL.

Quoted 8 lines

.kind = LIBXL__DEVICE_KIND_VBD,
.setup = drbd_setup,
.teardown = drbd_teardown,

tools/libxl/libxl_types.idl +0 -0
index 8a3d7ba..375c546 100644

tools/libxl/libxl_types.idl libxl_error = Enumeration("error", [ · line 65

Quoted 7 lines
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"),

You should add two new error numbers.

Wei.

Quoted 11 lines
tools/libxl/libxl_types.idl +0 -0
     (-20, "VNUMA_CONFIG_INVALID"),
     (-21, "DOMAIN_NOTFOUND"),
     ], value_namespace = "")
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#93 lore raw

Re: [PATCH v2 COLOPre 11/13] tools/libxl: rename remus device to checkpoint device

Quoted 27 lines · Wei Liu

On Mon, Jun 08, 2015 at 11:43:15AM +0800, Yang Hongyang wrote:
[...]

Quoted 13 lines
---
 tools/libxl/Makefile                  |   2 +-
 tools/libxl/libxl_checkpoint_device.c | 327 ++++++++++++++++++++++++++++++++++
 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_device.c      | 327 ----------------------------------
 tools/libxl/libxl_remus_disk_drbd.c   |  52 +++---
 tools/libxl/libxl_types.idl           |   4 +-

This only thing I need to complain is the change to IDL.

Quoted 9 lines

.kind = LIBXL__DEVICE_KIND_VBD,
.setup = drbd_setup,
.teardown = drbd_teardown,

tools/libxl/libxl_types.idl +0 -0
index 8a3d7ba..375c546 100644
@@ -61,8 +61,8 @@ libxl_error = Enumeration("error", [
     (-15, "LOCK_FAIL"),
Quoted 9 lines

tools/libxl/libxl_types.idl libxl_error = Enumeration("error", [ · line 65

Quoted 6 lines
tools/libxl/libxl_types.idl +2 -2
     (-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"),

You should add two new error numbers.

And in that case you might also need to go through all places to make sure the correct error numbers are return. I.e. old remus code path still returns REMUS error code and new CHECKPOINT code path returns new error code.

I merely speak from API backward compatibility point of view. If you think what I suggest doesn't make sense, please let me know.

Wei.

Quoted 13 lines

Wei.

Quoted 11 lines
tools/libxl/libxl_types.idl +0 -0
     (-20, "VNUMA_CONFIG_INVALID"),
     (-21, "DOMAIN_NOTFOUND"),
     ], value_namespace = "")
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#94 lore raw

Re: [PATCH v2 COLOPre 11/13] tools/libxl: rename remus device to checkpoint device

Wei Liu writes ("Re: [Xen-devel] [PATCH v2 COLOPre 11/13] tools/libxl: rename remus device to checkpoint device"):

Quoted 10 lines · Wei Liu
Quoted 8 lines · Yang Hongyang

tools/libxl/libxl_types.idl libxl_error = Enumeration("error", [ · line 65

Quoted 4 lines
tools/libxl/libxl_types.idl +2 -2
-    (-18, "REMUS_DEVOPS_DOES_NOT_MATCH"),
-    (-19, "REMUS_DEVICE_NOT_SUPPORTED"),
+    (-18, "CHECKPOINT_DEVOPS_DOES_NOT_MATCH"),
+    (-19, "CHECKPOINT_DEVICE_NOT_SUPPORTED"),

You should add two new error numbers.

Quoted 7 lines

And in that case you might also need to go through all places to make sure the correct error numbers are return. I.e. old remus code path still returns REMUS error code and new CHECKPOINT code path returns new error code.

I merely speak from API backward compatibility point of view. If you think what I suggest doesn't make sense, please let me know.

To me this line of reasons prompts me to ask: what would be wrong with leaving the word REMUS in the error names, and simply updating the descriptions ?

After all AFIACT the circumstances are very similar. I don't think it makes sense to require libxl to do something like
rc = were_we_doing_colo_not_remus ? CHECKPOINT_BLAH : REMUS_BLAH;

Please to contradict me if I have misunderstood...

Ian.

#95 lore raw

Re: [PATCH v2 COLOPre 11/13] tools/libxl: rename remus device to checkpoint device

Quoted 23 lines · Ian Jackson

Wei Liu writes ("Re: [Xen-devel] [PATCH v2 COLOPre 11/13] tools/libxl: rename remus device to checkpoint device"):

Quoted 10 lines · Wei Liu
Quoted 8 lines · Yang Hongyang

tools/libxl/libxl_types.idl libxl_error = Enumeration("error", [ · line 65

Quoted 4 lines
tools/libxl/libxl_types.idl +2 -2
-    (-18, "REMUS_DEVOPS_DOES_NOT_MATCH"),
-    (-19, "REMUS_DEVICE_NOT_SUPPORTED"),
+    (-18, "CHECKPOINT_DEVOPS_DOES_NOT_MATCH"),
+    (-19, "CHECKPOINT_DEVICE_NOT_SUPPORTED"),

You should add two new error numbers.

Quoted 7 lines

And in that case you might also need to go through all places to make sure the correct error numbers are return. I.e. old remus code path still returns REMUS error code and new CHECKPOINT code path returns new error code.

I merely speak from API backward compatibility point of view. If you think what I suggest doesn't make sense, please let me know.

To me this line of reasons prompts me to ask: what would be wrong with leaving the word REMUS in the error names, and simply updating the descriptions ?

Quoted 5 lines

After all AFIACT the circumstances are very similar. I don't think it makes sense to require libxl to do something like

    rc = were_we_doing_colo_not_remus ? CHECKPOINT_BLAH : REMUS_BLAH;

Please to contradict me if I have misunderstood...

COLO and REMUS both are checkpoint device. We use checkpoint device layer as a more abstract layer for both COLO and REMUS, come to the error code, these can be used by both COLO and REMUS. So we don't distinguish if we are doing COLO or REMUS, uses are aware of what they're executing(colo or remus).

Quoted 4 lines

Ian.
.

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

Re: [PATCH v2 COLOPre 11/13] tools/libxl: rename remus device to checkpoint device

Quoted 30 lines · Yang Hongyang
Quoted 27 lines · Ian Jackson

Wei Liu writes ("Re: [Xen-devel] [PATCH v2 COLOPre 11/13] tools/libxl: rename remus device to checkpoint device"):

Quoted 10 lines · Wei Liu
Quoted 8 lines · Yang Hongyang

tools/libxl/libxl_types.idl libxl_error = Enumeration("error", [ · line 65

Quoted 4 lines
tools/libxl/libxl_types.idl +2 -2
-    (-18, "REMUS_DEVOPS_DOES_NOT_MATCH"),
-    (-19, "REMUS_DEVICE_NOT_SUPPORTED"),
+    (-18, "CHECKPOINT_DEVOPS_DOES_NOT_MATCH"),
+    (-19, "CHECKPOINT_DEVICE_NOT_SUPPORTED"),

You should add two new error numbers.

Quoted 7 lines

And in that case you might also need to go through all places to make sure the correct error numbers are return. I.e. old remus code path still returns REMUS error code and new CHECKPOINT code path returns new error code.

I merely speak from API backward compatibility point of view. If you think what I suggest doesn't make sense, please let me know.

To me this line of reasons prompts me to ask: what would be wrong with leaving the word REMUS in the error names, and simply updating the descriptions ?

After all AFIACT the circumstances are very similar. I don't think it makes sense to require libxl to do something like
rc = were_we_doing_colo_not_remus ? CHECKPOINT_BLAH : REMUS_BLAH;

Quoted 8 lines
Quoted 1 line

Please to contradict me if I have misunderstood...

COLO and REMUS both are checkpoint device. We use checkpoint device layer as a more abstract layer for both COLO and REMUS, come to the error code, these can be used by both COLO and REMUS. So we don't distinguish if we are doing COLO or REMUS, uses are aware of what they're executing(colo or remus).

Right. So continue using REMUS_ error code is fine.

Wei.

#97 lore raw

Re: [PATCH v2 COLOPre 11/13] tools/libxl: rename remus device to checkpoint device

Quoted 33 lines · Wei Liu
Quoted 32 lines · Yang Hongyang
Quoted 28 lines · Ian Jackson

Wei Liu writes ("Re: [Xen-devel] [PATCH v2 COLOPre 11/13] tools/libxl: rename remus device to checkpoint device"):

Quoted 10 lines · Wei Liu
Quoted 8 lines · Yang Hongyang

tools/libxl/libxl_types.idl libxl_error = Enumeration("error", [ · line 65

Quoted 4 lines
tools/libxl/libxl_types.idl +2 -2
-    (-18, "REMUS_DEVOPS_DOES_NOT_MATCH"),
-    (-19, "REMUS_DEVICE_NOT_SUPPORTED"),
+    (-18, "CHECKPOINT_DEVOPS_DOES_NOT_MATCH"),
+    (-19, "CHECKPOINT_DEVICE_NOT_SUPPORTED"),

You should add two new error numbers.

Quoted 7 lines

And in that case you might also need to go through all places to make sure the correct error numbers are return. I.e. old remus code path still returns REMUS error code and new CHECKPOINT code path returns new error code.

I merely speak from API backward compatibility point of view. If you think what I suggest doesn't make sense, please let me know.

To me this line of reasons prompts me to ask: what would be wrong with leaving the word REMUS in the error names, and simply updating the descriptions ?

After all AFIACT the circumstances are very similar. I don't think it makes sense to require libxl to do something like
rc = were_we_doing_colo_not_remus ? CHECKPOINT_BLAH : REMUS_BLAH;

Please to contradict me if I have misunderstood...

Quoted 8 lines
Quoted 6 lines

COLO and REMUS both are checkpoint device. We use checkpoint device layer as a more abstract layer for both COLO and REMUS, come to the error code, these can be used by both COLO and REMUS. So we don't distinguish if we are doing COLO or REMUS, uses are aware of what they're executing(colo or remus).

Right. So continue using REMUS_ error code is fine.

Seems like it would also be OK to switch the name and then in libxl,h

#ifdef LIB_API_VERSION < 0xWHENEVER
#define REMUS_BLAH CHECKPOINT_BLAH
#define ...
#endif

_If_ we think the new names make more sense going fwd...

#98 lore raw

Re: [PATCH v2 COLOPre 11/13] tools/libxl: rename remus device to checkpoint device

Quoted 43 lines · Ian Campbell
Quoted 33 lines · Wei Liu
Quoted 32 lines · Yang Hongyang
Quoted 28 lines · Ian Jackson

Wei Liu writes ("Re: [Xen-devel] [PATCH v2 COLOPre 11/13] tools/libxl: rename remus device to checkpoint device"):

Quoted 10 lines · Wei Liu
Quoted 8 lines · Yang Hongyang

Review

Quoted 4 lines
(quoted diff) +2 -2
-    (-18, "REMUS_DEVOPS_DOES_NOT_MATCH"),
-    (-19, "REMUS_DEVICE_NOT_SUPPORTED"),
+    (-18, "CHECKPOINT_DEVOPS_DOES_NOT_MATCH"),
+    (-19, "CHECKPOINT_DEVICE_NOT_SUPPORTED"),

You should add two new error numbers.

Quoted 7 lines

And in that case you might also need to go through all places to make sure the correct error numbers are return. I.e. old remus code path still returns REMUS error code and new CHECKPOINT code path returns new error code.

I merely speak from API backward compatibility point of view. If you think what I suggest doesn't make sense, please let me know.

To me this line of reasons prompts me to ask: what would be wrong with leaving the word REMUS in the error names, and simply updating the descriptions ?

After all AFIACT the circumstances are very similar. I don't think it makes sense to require libxl to do something like

    rc = were_we_doing_colo_not_remus ? CHECKPOINT_BLAH : REMUS_BLAH;

Please to contradict me if I have misunderstood...

Quoted 8 lines
Quoted 6 lines

COLO and REMUS both are checkpoint device. We use checkpoint device layer as a more abstract layer for both COLO and REMUS, come to the error code, these can be used by both COLO and REMUS. So we don't distinguish if we are doing COLO or REMUS, uses are aware of what they're executing(colo or remus).

Right. So continue using REMUS_ error code is fine.

Quoted 8 lines

Seems like it would also be OK to switch the name and then in libxl,h

#ifdef LIB_API_VERSION < 0xWHENEVER
#define REMUS_BLAH CHECKPOINT_BLAH
#define ...
#endif

_If_ we think the new names make more sense going fwd...

Well, I think the new names are better, I also think it is safe to just rename them, I don't find any other users using these error codes except Remus/COLO, it is only used by Remus/COLO internally.

Quoted 4 lines

.

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

Re: [PATCH v2 COLOPre 11/13] tools/libxl: rename remus device to checkpoint device

Quoted 53 lines · Yang Hongyang
Quoted 50 lines · Ian Campbell
Quoted 33 lines · Wei Liu
Quoted 32 lines · Yang Hongyang
Quoted 28 lines · Ian Jackson

Wei Liu writes ("Re: [Xen-devel] [PATCH v2 COLOPre 11/13] tools/libxl: rename remus device to checkpoint device"):

Quoted 10 lines · Wei Liu
Quoted 8 lines · Yang Hongyang

Review

Quoted 4 lines
(quoted diff) +2 -2
-    (-18, "REMUS_DEVOPS_DOES_NOT_MATCH"),
-    (-19, "REMUS_DEVICE_NOT_SUPPORTED"),
+    (-18, "CHECKPOINT_DEVOPS_DOES_NOT_MATCH"),
+    (-19, "CHECKPOINT_DEVICE_NOT_SUPPORTED"),

You should add two new error numbers.

Quoted 7 lines

And in that case you might also need to go through all places to make sure the correct error numbers are return. I.e. old remus code path still returns REMUS error code and new CHECKPOINT code path returns new error code.

I merely speak from API backward compatibility point of view. If you think what I suggest doesn't make sense, please let me know.

To me this line of reasons prompts me to ask: what would be wrong with leaving the word REMUS in the error names, and simply updating the descriptions ?

After all AFIACT the circumstances are very similar. I don't think it makes sense to require libxl to do something like
rc = were_we_doing_colo_not_remus ? CHECKPOINT_BLAH : REMUS_BLAH;

Please to contradict me if I have misunderstood...

Quoted 8 lines
Quoted 6 lines

COLO and REMUS both are checkpoint device. We use checkpoint device layer as a more abstract layer for both COLO and REMUS, come to the error code, these can be used by both COLO and REMUS. So we don't distinguish if we are doing COLO or REMUS, uses are aware of what they're executing(colo or remus).

Right. So continue using REMUS_ error code is fine.

Seems like it would also be OK to switch the name and then in libxl,h

#ifdef LIB_API_VERSION < 0xWHENEVER
#define REMUS_BLAH CHECKPOINT_BLAH
#define ...
#endif

Quoted 6 lines
Quoted 1 line

_If_ we think the new names make more sense going fwd...

Well, I think the new names are better, I also think it is safe to just rename them, I don't find any other users using these error codes except Remus/COLO, it is only used by Remus/COLO internally.

The main point is, this is external visible interface. Some user might have also developed their solution based on remus. In their code they check for REMUS_$FOO error code.

I agree renaming to CHECKPOINT even for the sake of matching API names is good. I think Ian's suggestion should be the simplest way of moving forward.

Wei.

Quoted 8 lines
Quoted 4 lines

.

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

Re: [PATCH v2 COLOPre 11/13] tools/libxl: rename remus device to checkpoint device

Quoted 61 lines · Wei Liu
Quoted 53 lines · Yang Hongyang
Quoted 50 lines · Ian Campbell
Quoted 33 lines · Wei Liu
Quoted 32 lines · Yang Hongyang
Quoted 28 lines · Ian Jackson

Wei Liu writes ("Re: [Xen-devel] [PATCH v2 COLOPre 11/13] tools/libxl: rename remus device to checkpoint device"):

Quoted 10 lines · Wei Liu
Quoted 8 lines · Yang Hongyang

Review

Quoted 4 lines
(quoted diff) +2 -2
-    (-18, "REMUS_DEVOPS_DOES_NOT_MATCH"),
-    (-19, "REMUS_DEVICE_NOT_SUPPORTED"),
+    (-18, "CHECKPOINT_DEVOPS_DOES_NOT_MATCH"),
+    (-19, "CHECKPOINT_DEVICE_NOT_SUPPORTED"),

You should add two new error numbers.

Quoted 7 lines

And in that case you might also need to go through all places to make sure the correct error numbers are return. I.e. old remus code path still returns REMUS error code and new CHECKPOINT code path returns new error code.

I merely speak from API backward compatibility point of view. If you think what I suggest doesn't make sense, please let me know.

To me this line of reasons prompts me to ask: what would be wrong with leaving the word REMUS in the error names, and simply updating the descriptions ?

After all AFIACT the circumstances are very similar. I don't think it makes sense to require libxl to do something like

    rc = were_we_doing_colo_not_remus ? CHECKPOINT_BLAH : REMUS_BLAH;

Please to contradict me if I have misunderstood...

Quoted 8 lines
Quoted 6 lines

COLO and REMUS both are checkpoint device. We use checkpoint device layer as a more abstract layer for both COLO and REMUS, come to the error code, these can be used by both COLO and REMUS. So we don't distinguish if we are doing COLO or REMUS, uses are aware of what they're executing(colo or remus).

Right. So continue using REMUS_ error code is fine.

Seems like it would also be OK to switch the name and then in libxl,h

#ifdef LIB_API_VERSION < 0xWHENEVER
#define REMUS_BLAH CHECKPOINT_BLAH
#define ...
#endif

Quoted 6 lines
Quoted 1 line

_If_ we think the new names make more sense going fwd...

Well, I think the new names are better, I also think it is safe to just rename them, I don't find any other users using these error codes except Remus/COLO, it is only used by Remus/COLO internally.

Quoted 7 lines

The main point is, this is external visible interface. Some user might have also developed their solution based on remus. In their code they check for REMUS_$FOO error code.

I agree renaming to CHECKPOINT even for the sake of matching API names is good. I think Ian's suggestion should be the simplest way of moving forward.

Ok, will add an extra patch to deal with this back compatibility issue in the next version.

Quoted 13 lines

Wei.

Quoted 8 lines
Quoted 4 lines

.

--
Thanks,
Yang.

.

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

PATCH v2 12/13 tools/libxl: adjust the indentation

In reply to Yang Hongyang

This is just tidying up after the previous 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
index 109cd23..226f159 100644
@@ -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
index 5399601..3a1360b 100644
@@ -2673,7 +2673,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
@@ -2734,7 +2735,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
@@ -2742,7 +2744,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;
@@ -2755,7 +2757,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).
      */
@@ -2817,13 +2820,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);
 
 /*----- Domain suspend (save) state structure -----*/
Signature · 1 line
1.9.1
#103 lore raw

PATCH v2 13/13 tools/libxl: don't touch remus in checkpoint_device

In reply to Yang Hongyang

Checkpoint 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:
1. remus_ops: we use remus ops directly in checkpoint device. Store it in checkpoint device state.
2. concrete layer's private member: add a new structure remus state, and move them to remus state.
3. init/cleanup device subkind: we call (init|cleanup)_subkind_nic and (init|cleanup)_subkind_drbd_disk directly in checkpoint device. Call them before calling libxl__checkpoint_devices_setup() or after calling libxl__checkpoint_devices_teardown().

---
 tools/libxl/libxl.c                   |  2 +-
 tools/libxl/libxl_checkpoint_device.c | 52 ++-------------------
 tools/libxl/libxl_dom_save.c          |  3 +-
 tools/libxl/libxl_internal.h          | 40 ++++++++++------
 tools/libxl/libxl_netbuffer.c         | 51 +++++++++++---------
 tools/libxl/libxl_remus.c             | 88 ++++++++++++++++++++++++++++-------
 tools/libxl/libxl_remus_disk_drbd.c   |  8 ++--
 7 files changed, 135 insertions(+), 109 deletions(-)
tools/libxl/libxl.c +1 -1
index 36b97fe..10d3d82 100644
@@ -841,7 +841,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_checkpoint_device.c +3 -49

85 lines not on this page · raw message

tools/libxl/libxl_dom_save.c +1 -2
index c15e9f1..cb3d8db 100644
@@ -402,7 +402,6 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss)
     dsps->dm_savefile = libxl__device_model_savefile(gc, domid);
 
     if (r_info != NULL) {
-        dss->interval = r_info->interval;
         dss->xcflags |= XCFLAGS_CHECKPOINTED;
         if (libxl_defbool_val(r_info->compression))
             dss->xcflags |= XCFLAGS_CHECKPOINT_COMPRESS;
@@ -601,7 +600,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);
 }
 
 /*==================== Domain restore ====================*/
tools/libxl/libxl_internal.h +25 -15
index 3a1360b..0ebb104 100644
@@ -2750,6 +2750,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 -----*/
 
@@ -2770,16 +2772,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;
 };
 
 /*
@@ -2827,6 +2819,26 @@ _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 */
+
+    /* abstract layer */
+    libxl__checkpoint_devices_state cds;
+
+    /*----- 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);
 
 /*----- Domain suspend (save) state structure -----*/
@@ -2886,9 +2898,7 @@ struct libxl__domain_save_state {
     libxl__domain_suspend_state dsps;
     int hvm;
     int xcflags;
-    libxl__checkpoint_devices_state cds;
-    libxl__ev_time checkpoint_timeout; /* used for Remus checkpoint */
-    int interval; /* checkpoint interval (for Remus) */
+    libxl__remus_state rs;
     libxl__save_helper_state shs;
     libxl__logdirty_switch logdirty;
     /* private for libxl__domain_save_device_model */
@@ -3231,9 +3241,9 @@ _hidden void libxl__remus_domain_resume_callback(void *data);
 _hidden void libxl__remus_domain_checkpoint_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);
 
 /*
tools/libxl/libxl_netbuffer.c +29 -22

148 lines not on this page · raw message

tools/libxl/libxl_remus.c +71 -17

199 lines not on this page · raw message

tools/libxl/libxl_remus_disk_drbd.c +5 -3
index 50b897d..a8d8949 100644
@@ -28,10 +28,11 @@ typedef struct libxl__remus_drbd_disk {
 
 int init_subkind_drbd_disk(libxl__checkpoint_devices_state *cds)
 {
+    libxl__remus_state *rs = CONTAINER_OF(cds, *rs, cds);
     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 = CONTAINER_OF(dev->cds, *rs, cds);
     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
1.9.1
#104 lore raw

Re: [PATCH v2 COLOPre 13/13] tools/libxl: don't touch remus in checkpoint_device

Quoted 13 lines · Yang Hongyang

Checkpoint 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:
1. remus_ops: we use remus ops directly in checkpoint device. Store it in checkpoint device state.
2. concrete layer's private member: add a new structure remus state, and move them to remus state.
3. init/cleanup device subkind: we call (init|cleanup)_subkind_nic and (init|cleanup)_subkind_drbd_disk directly in checkpoint device. Call them before calling libxl__checkpoint_devices_setup() or after calling libxl__checkpoint_devices_teardown().

Quoted 1 line

From the look of it this patch is mostly refactoring and doesn't involve

functional changes, right? If so please state that in commit message.

I suppose this needs review from remus maintainer.

Wei.

#105 lore raw

Re: [PATCH v2 COLOPre 13/13] tools/libxl: don't touch remus in checkpoint_device

Quoted 14 lines · Wei Liu
Quoted 12 lines · Yang Hongyang

Checkpoint 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:
1. remus_ops: we use remus ops directly in checkpoint device. Store it in checkpoint device state.
2. concrete layer's private member: add a new structure remus state, and move them to remus state.
3. init/cleanup device subkind: we call (init|cleanup)_subkind_nic and (init|cleanup)_subkind_drbd_disk directly in checkpoint device. Call them before calling libxl__checkpoint_devices_setup() or after calling libxl__checkpoint_devices_teardown().

Quoted 2 lines
Quoted 1 line

From the look of it this patch is mostly refactoring and doesn't involve

functional changes, right? If so please state that in commit message.

Yes, it is refactoring and no functional changes, will mention it in next version.

Quoted 6 lines

I suppose this needs review from remus maintainer.

Wei.
.

Signature · 2 lines
Thanks,
Yang.