Skip to contentSkip to conversation

Prerequisite patches for COLO

PATCH In review Yang Hongyang 6 participants 101 messages Jul 15, 2015 – Jan 4, 2016

lore
Share & tools
lore
#0 lore raw

v4 cover Prerequisite patches for COLO

This patchset is Prerequisite for COLO feature. Refer to:
http://wiki.xen.org/wiki/COLO_-_Coarse_Grain_Lock_Stepping

This patchse is based on Andrew Cooper's Libxl migration v4.1:
http://xenbits.xen.org/gitweb/?p=people/andrewcoop/xen.git;a=shortlog;h=refs/heads/libxl-migv2-v4.1

In this version, I moved some of the COLO specific patches down to the COLO main series, so most patches of this series are refactoring and can be applied first.

I've done some simple test. Both Remus and normal migration work after apply this patchset. The patch to fix Remus on migration v2 will be sent later as a seperate patch.

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

v3->v4:
- Rebased to the latest migration v2 branch
- Addressed comments from last round

v2->v3:
- Merge '[PATCH v2 0/6] Misc cleanups for libxl' into this patchset for easy review
- Addressed review comments
- Add back channel to libxc
- Introduce should_checkpoint callback
- Introduce DIRTY_BITMAP record on libxc side
- Introduce COLO_CONTEXT record on libxl side
- Ported to Libxl migration v2

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

Wen Congyang (2):
tools/libxc: support to resume uncooperative HVM guests tools/libxl: Add back channel to allow migration target send data back

Yang Hongyang (23):
tools/libxl: rename libxl__domain_suspend to libxl__domain_save
A tools/libxl: move domain suspend code into libxl_dom_suspend.c A tools/libxl: move domain resume code into libxl_dom_suspend.c
tools/libxl: rename remus checkpoint callbacks libxl/remus: introduce libxl__remus_setup
libxl/remus: introduce libxl__remus_teardown
libxl/remus: init checkpoint_callback in Remus checkpoint callback tools/libxl: move remus code into libxl_remus.c
A tools/libxl: move save/restore code into libxl_dom_save.c
libxl/save: Refactor libxl__domain_suspend_state tools/libxl: introduce enum type libxl_checkpointed_stream migration/save: pass checkpointed_stream from libxl to libxc tools/libxl: introduce libxl__domain_restore_device_model to load qemu
state
tools/libxl: check QEMU state before resume dm tools/libxl: Update libxl_domain_unpause() to support qemu-xen
A tools/libxl: introduce libxl__domain_common_switch_qemu_logdirty() A tools/libxl: export logdirty_init
tools/libx{l,c}: add back channel to libxc
tools/libxl: rename remus device to checkpoint device
A tools/libxl: adjust the indentation
tools/libxl: store remus_ops in checkpoint device state tools/libxl: move remus state into a seperate structure tools/libxl: seperate device init/cleanup from checkpoint device layer

 tools/libxc/include/xenguest.h        |   13 +-
 tools/libxc/xc_domain_restore.c       |    4 +-
 tools/libxc/xc_domain_save.c          |    6 +-
 tools/libxc/xc_nomigrate.c            |    3 +-
 tools/libxc/xc_resume.c               |   22 +-
 tools/libxc/xc_sr_common.h            |    2 +-
 tools/libxc/xc_sr_restore.c           |    2 +-
 tools/libxc/xc_sr_save.c              |    5 +-
 tools/libxl/Makefile                  |    5 +-
 tools/libxl/libxl.c                   |  119 +---
 tools/libxl/libxl.h                   |   30 +-
 tools/libxl/libxl_checkpoint_device.c |  282 ++++++++
 tools/libxl/libxl_create.c            |   33 +-
 tools/libxl/libxl_dom.c               | 1243 ---------------------------------
 tools/libxl/libxl_dom_save.c          |  721 +++++++++++++++++++
 tools/libxl/libxl_dom_suspend.c       |  503 +++++++++++++
 tools/libxl/libxl_internal.h          |  246 ++++---
 tools/libxl/libxl_netbuffer.c         |  117 ++--
 tools/libxl/libxl_nonetbuffer.c       |   10 +-
 tools/libxl/libxl_qmp.c               |   10 +
 tools/libxl/libxl_remus.c             |  395 +++++++++++
 tools/libxl/libxl_remus_device.c      |  327 ---------
 tools/libxl/libxl_remus_disk_drbd.c   |   56 +-
 tools/libxl/libxl_save_callout.c      |   43 +-
 tools/libxl/libxl_save_helper.c       |    9 +-
 tools/libxl/libxl_stream_write.c      |   14 +-
 tools/libxl/libxl_types.idl           |   10 +-
 tools/libxl/xl_cmdimpl.c              |   21 +-
 tools/ocaml/libs/xl/xenlight_stubs.c  |    2 +-
 29 files changed, 2321 insertions(+), 1932 deletions(-)
 create mode 100644 tools/libxl/libxl_checkpoint_device.c
 create mode 100644 tools/libxl/libxl_dom_save.c
 create mode 100644 tools/libxl/libxl_dom_suspend.c
 create mode 100644 tools/libxl/libxl_remus.c
 delete mode 100644 tools/libxl/libxl_remus_device.c
Signature · 1 line
1.9.1
#1 lore raw

PATCH v4 1/25 tools/libxl: rename libxl__domain_suspend to libxl__domain_save

The suspend/save terminology used by libxc is more consistent. "suspend" refers to quiescing the VM, so pausing qemu, making a remote_shutdown(SHUTDOWN_suspend) hypercall etc. "save" refers to the actions involved in actually shuffling the state of the VM, so xc_domain_save() etc.

libxl currently uses "suspend" to encapsulate both. The patch Rename libxl__domain_suspend() to libxl__domain_save() since it actually refers to shuffling the state of the VM.

This results in some strangeness in that some functions called *save* are now passed a struct called *suspend*, this is temporary and is all fixed up later by the refactoring of the suspend_state.

Some comments, commit messages:

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxl/libxl.c          |  4 ++--
 tools/libxl/libxl_dom.c      | 16 ++++++++--------
 tools/libxl/libxl_internal.h | 13 ++++++++++---
 3 files changed, 20 insertions(+), 13 deletions(-)
tools/libxl/libxl.c +2 -2
index 38aff8d..fa42c1c 100644
@@ -914,7 +914,7 @@ static void libxl__remus_setup_done(libxl__egc *egc,
     STATE_AO_GC(dss->ao);
 
     if (!rc) {
-        libxl__domain_suspend(egc, dss);
+        libxl__domain_save(egc, dss);
         return;
     }
 
@@ -981,7 +981,7 @@ int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd, int flags,
     dss->live = flags & LIBXL_SUSPEND_LIVE;
     dss->debug = flags & LIBXL_SUSPEND_DEBUG;
 
-    libxl__domain_suspend(egc, dss);
+    libxl__domain_save(egc, dss);
     return AO_INPROGRESS;
 
  out_err:
tools/libxl/libxl_dom.c +8 -8
index 81adb3d..3bbec99 100644
@@ -1155,8 +1155,8 @@ out:
 
 static void stream_done(libxl__egc *egc,
                         libxl__stream_write_state *sws, int rc);
-static void domain_suspend_done(libxl__egc *egc,
-                        libxl__domain_suspend_state *dss, int rc);
+static void domain_save_done(libxl__egc *egc,
+                             libxl__domain_suspend_state *dss, int rc);
 static void domain_suspend_callback_common_done(libxl__egc *egc,
                                 libxl__domain_suspend_state *dss, int rc);
 
@@ -2036,9 +2036,9 @@ static void remus_next_checkpoint(libxl__egc *egc, libxl__ev_time *ev,
     libxl__xc_domain_saverestore_async_callback_done(egc, &dss->sws.shs, !rc);
 }
 
-/*----- main code for suspending, in order of execution -----*/
+/*----- main code for saving, in order of execution -----*/
 
-void libxl__domain_suspend(libxl__egc *egc, libxl__domain_suspend_state *dss)
+void libxl__domain_save(libxl__egc *egc, libxl__domain_suspend_state *dss)
 {
     STATE_AO_GC(dss->ao);
     int port;
@@ -2125,13 +2125,13 @@ void libxl__domain_suspend(libxl__egc *egc, libxl__domain_suspend_state *dss)
     return;
 
  out:
-    domain_suspend_done(egc, dss, rc);
+    domain_save_done(egc, dss, rc);
 }
 
 static void stream_done(libxl__egc *egc,
                         libxl__stream_write_state *sws, int rc)
 {
-    domain_suspend_done(egc, sws->dss, rc);
+    domain_save_done(egc, sws->dss, rc);
 }
 
 static void save_device_model_datacopier_done(libxl__egc *egc,
@@ -2229,8 +2229,8 @@ static void remus_teardown_done(libxl__egc *egc,
                                        libxl__remus_devices_state *rds,
                                        int rc);
 
-static void domain_suspend_done(libxl__egc *egc,
-                        libxl__domain_suspend_state *dss, int rc)
+static void domain_save_done(libxl__egc *egc,
+                             libxl__domain_suspend_state *dss, int rc)
 {
     STATE_AO_GC(dss->ao);
 
tools/libxl/libxl_internal.h +10 -3
index d9deaad..7599f15 100644
@@ -2946,6 +2946,13 @@ static inline bool libxl__conversion_helper_inuse
 
 
 /*----- Domain suspend (save) state structure -----*/
+/*
+ * "suspend" refers to quiescing the VM, so pausing qemu, making a
+ * remote_shutdown(SHUTDOWN_suspend) hypercall etc.
+ *
+ * "save" refers to the actions involved in actually shuffling the
+ * state of the VM, so xc_domain_save() etc.
+ */
 
 typedef struct libxl__domain_suspend_state libxl__domain_suspend_state;
 
@@ -3010,7 +3017,7 @@ typedef struct libxl__logdirty_switch {
 } libxl__logdirty_switch;
 
 struct libxl__domain_suspend_state {
-    /* set by caller of libxl__domain_suspend */
+    /* set by caller of libxl__domain_save */
     libxl__ao *ao;
     libxl__domain_suspend_cb *callback;
 
@@ -3375,8 +3382,8 @@ struct libxl__domain_create_state {
 /*----- Domain suspend (save) functions -----*/
 
 /* calls dss->callback when done */
-_hidden void libxl__domain_suspend(libxl__egc *egc,
-                                   libxl__domain_suspend_state *dss);
+_hidden void libxl__domain_save(libxl__egc *egc,
+                                libxl__domain_suspend_state *dss);
 
 
 /* calls libxl__xc_domain_suspend_done when done */
Signature · 1 line
1.9.1
Acked-by on v4 1/25
#2 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 01/25] tools/libxl: rename libxl__domain_suspend to libxl__domain_save

Quoted 10 lines · Yang Hongyang

The suspend/save terminology used by libxc is more consistent. "suspend" refers to quiescing the VM, so pausing qemu, making a remote_shutdown(SHUTDOWN_suspend) hypercall etc. "save" refers to the actions involved in actually shuffling the state of the VM, so xc_domain_save() etc.

libxl currently uses "suspend" to encapsulate both. The patch Rename libxl__domain_suspend() to libxl__domain_save() since it actually refers to shuffling the state of the VM.

Quoted 7 lines

This results in some strangeness in that some functions called *save* are now passed a struct called *suspend*, this is temporary and is all fixed up later by the refactoring of the suspend_state.

Some comments, commit messages:

#3 lore raw

PATCH v4 2/25 tools/libxl: move domain suspend code into libxl_dom_suspend.c

In reply to Yang Hongyang

Move domain suspend code into a separate file libxl_dom_suspend.c. Add an API libxl__domain_suspend() which wraps the static function domain_suspend_callback_common() for internal use. Export the existing API libxl__domain_suspend_callback() used by libxc to suspend the guest during migration.

Note that the newly added file libxl_dom_suspend.c is used for suspend/resume code.

---
 tools/libxl/Makefile            |   3 +-
 tools/libxl/libxl_dom.c         | 342 +-----------------------------------
 tools/libxl/libxl_dom_suspend.c | 380 ++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_internal.h    |   6 +
 4 files changed, 389 insertions(+), 342 deletions(-)
 create mode 100644 tools/libxl/libxl_dom_suspend.c
tools/libxl/Makefile +2 -1
index 0150ec7..4a5957e 100644
@@ -102,7 +102,8 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
 			libxl_json.o libxl_aoutils.o libxl_numa.o libxl_vnuma.o \
 			libxl_stream_read.o libxl_stream_write.o \
 			libxl_save_callout.o _libxl_save_msgs_callout.o \
-			libxl_qmp.o libxl_event.o libxl_fork.o $(LIBXL_OBJS-y)
+			libxl_qmp.o libxl_event.o libxl_fork.o \
+			libxl_dom_suspend.o $(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
 
tools/libxl/libxl_dom.c +1 -341

372 lines not on this page · raw message

tools/libxl/libxl_dom_suspend.c new file +380 -0

380 lines not on this page · raw message

tools/libxl/libxl_internal.h +6 -0
index 7599f15..3a2ef00 100644
@@ -3439,6 +3439,12 @@ _hidden void libxl__domain_save_device_model(libxl__egc *egc,
 
 _hidden const char *libxl__device_model_savefile(libxl__gc *gc, uint32_t domid);
 
+/* calls dss->callback_common_done when done */
+_hidden void libxl__domain_suspend(libxl__egc *egc,
+                                   libxl__domain_suspend_state *dss);
+/* used by libxc to suspend the guest during migration */
+_hidden void libxl__domain_suspend_callback(void *data);
+
 
 /*
  * Convenience macros.
Signature · 1 line
1.9.1
#4 lore raw

PATCH v4 3/25 tools/libxl: move domain resume code into libxl_dom_suspend.c

In reply to Yang Hongyang

move domain resume code into libxl_dom_suspend.c.
pure code move.

libxl__domain_resume_device_model() will be used later by COLO, so we are not making this func static.

---
 tools/libxl/libxl.c             | 33 -------------------------
 tools/libxl/libxl_dom.c         | 20 ---------------
 tools/libxl/libxl_dom_suspend.c | 55 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 53 deletions(-)
tools/libxl/libxl.c +0 -33
index fa42c1c..69a6937 100644
@@ -513,39 +513,6 @@ int libxl_domain_rename(libxl_ctx *ctx, uint32_t domid,
     return rc;
 }
 
-int libxl__domain_resume(libxl__gc *gc, uint32_t domid, int suspend_cancel)
-{
-    int rc = 0;
-
-    if (xc_domain_resume(CTX->xch, domid, suspend_cancel)) {
-        LOGE(ERROR, "xc_domain_resume failed for domain %u", domid);
-        rc = ERROR_FAIL;
-        goto out;
-    }
-
-    libxl_domain_type type = libxl__domain_type(gc, domid);
-    if (type == LIBXL_DOMAIN_TYPE_INVALID) {
-        rc = ERROR_FAIL;
-        goto out;
-    }
-
-    if (type == LIBXL_DOMAIN_TYPE_HVM) {
-        rc = libxl__domain_resume_device_model(gc, domid);
-        if (rc) {
-            LOG(ERROR, "failed to resume device model for domain %u:%d",
-                domid, rc);
-            goto out;
-        }
-    }
-
-    if (!xs_resume_domain(CTX->xsh, domid)) {
-        LOGE(ERROR, "xs_resume_domain failed for domain %u", domid);
-        rc = ERROR_FAIL;
-    }
-out:
-    return rc;
-}
-
 int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid, int suspend_cancel,
                         const libxl_asyncop_how *ao_how)
 {
tools/libxl/libxl_dom.c +0 -20
index e21e110..0788309 100644
@@ -1384,26 +1384,6 @@ static void switch_logdirty_done(libxl__egc *egc,
 
 /*----- callbacks, called by xc_domain_save -----*/
 
-int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid)
-{
-
-    switch (libxl__device_model_version_running(gc, domid)) {
-    case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
-        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;
-}
-
 static inline char *physmap_path(libxl__gc *gc, uint32_t dm_domid,
                                  uint32_t domid,
                                  char *phys_offset, char *node)
tools/libxl/libxl_dom_suspend.c +55 -0

61 lines not on this page · raw message

Signature · 1 line
1.9.1
#5 lore raw

PATCH v4 4/25 tools/libxl: rename remus checkpoint callbacks

In reply to Yang Hongyang

There are 2 remus checkpoint callbacks(save/restore), currently, they both called libxl__remus_domain_checkpoint_callback in diffrent file, so it is ok. But in the following patch, we will move all of the remus callback code into a seperate file, the name should be diffrent. So rename them to:
libxl__remus_domain_{save/restore}_checkpoint_callback

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxl/libxl_create.c | 4 ++--
 tools/libxl/libxl_dom.c    | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
tools/libxl/libxl_create.c +2 -2
index 5b4d333..a32e3df 100644
@@ -677,7 +677,7 @@ static int store_libxl_entry(libxl__gc *gc, uint32_t domid,
 static void remus_checkpoint_stream_done(
     libxl__egc *egc, libxl__stream_read_state *srs, int rc);
 
-static void libxl__remus_domain_checkpoint_callback(void *data)
+static void libxl__remus_domain_restore_checkpoint_callback(void *data)
 {
     libxl__save_helper_state *shs = data;
     libxl__domain_create_state *dcs = shs->caller_state;
@@ -989,7 +989,7 @@ static void domcreate_bootloader_done(libxl__egc *egc,
     }
 
     /* Restore */
-    callbacks->checkpoint = libxl__remus_domain_checkpoint_callback;
+    callbacks->checkpoint = libxl__remus_domain_restore_checkpoint_callback;
 
     rc = libxl__build_pre(gc, domid, d_config, state);
     if (rc)
tools/libxl/libxl_dom.c +2 -2
index 0788309..9c61fa7 100644
@@ -1586,7 +1586,7 @@ static void remus_next_checkpoint(libxl__egc *egc, libxl__ev_time *ev,
                                   const struct timeval *requested_abs,
                                   int rc);
 
-static void libxl__remus_domain_checkpoint_callback(void *data)
+static void libxl__remus_domain_save_checkpoint_callback(void *data)
 {
     libxl__save_helper_state *shs = data;
     libxl__domain_suspend_state *dss = shs->caller_state;
@@ -1749,7 +1749,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_suspend_state *dss)
     if (r_info != NULL) {
         callbacks->suspend = libxl__remus_domain_suspend_callback;
         callbacks->postcopy = libxl__remus_domain_resume_callback;
-        callbacks->checkpoint = libxl__remus_domain_checkpoint_callback;
+        callbacks->checkpoint = libxl__remus_domain_save_checkpoint_callback;
         dss->sws.checkpoint_callback = remus_checkpoint_stream_written;
     } else
         callbacks->suspend = libxl__domain_suspend_callback;
Signature · 1 line
1.9.1
Acked-by on v4 4/25
#6 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 04/25] tools/libxl: rename remus checkpoint callbacks

Quoted 4 lines · Yang Hongyang

There are 2 remus checkpoint callbacks(save/restore), currently, they both called libxl__remus_domain_checkpoint_callback in diffrent file, so it is ok. But in the following patch, we will move all of the remus callback code into a seperate file, the name should be diffrent.

"separate" and "different" (twice).

Quoted 4 lines

So rename them to:
libxl__remus_domain_{save/restore}_checkpoint_callback

Quoted 51 lines
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxl/libxl_create.c | 4 ++--
 tools/libxl/libxl_dom.c    | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
tools/libxl/libxl_create.c +2 -2
index 5b4d333..a32e3df 100644
@@ -677,7 +677,7 @@ static int store_libxl_entry(libxl__gc *gc, uint32_t domid,
 static void remus_checkpoint_stream_done(
     libxl__egc *egc, libxl__stream_read_state *srs, int rc);
 
-static void libxl__remus_domain_checkpoint_callback(void *data)
+static void libxl__remus_domain_restore_checkpoint_callback(void *data)
 {
     libxl__save_helper_state *shs = data;
     libxl__domain_create_state *dcs = shs->caller_state;
@@ -989,7 +989,7 @@ static void domcreate_bootloader_done(libxl__egc *egc,
     }
 
     /* Restore */
-    callbacks->checkpoint = libxl__remus_domain_checkpoint_callback;
+    callbacks->checkpoint = libxl__remus_domain_restore_checkpoint_callback;
 
     rc = libxl__build_pre(gc, domid, d_config, state);
     if (rc)
tools/libxl/libxl_dom.c +2 -2
index 0788309..9c61fa7 100644
@@ -1586,7 +1586,7 @@ static void remus_next_checkpoint(libxl__egc *egc, libxl__ev_time *ev,
                                   const struct timeval *requested_abs,
                                   int rc);
 
-static void libxl__remus_domain_checkpoint_callback(void *data)
+static void libxl__remus_domain_save_checkpoint_callback(void *data)
 {
     libxl__save_helper_state *shs = data;
     libxl__domain_suspend_state *dss = shs->caller_state;
@@ -1749,7 +1749,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_suspend_state *dss)
     if (r_info != NULL) {
         callbacks->suspend = libxl__remus_domain_suspend_callback;
         callbacks->postcopy = libxl__remus_domain_resume_callback;
-        callbacks->checkpoint = libxl__remus_domain_checkpoint_callback;
+        callbacks->checkpoint = libxl__remus_domain_save_checkpoint_callback;
         dss->sws.checkpoint_callback = remus_checkpoint_stream_written;
     } else
         callbacks->suspend = libxl__domain_suspend_callback;
#7 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 04/25] tools/libxl: rename remus checkpoint callbacks

Quoted 7 lines · Ian Campbell
Quoted 4 lines · Yang Hongyang

There are 2 remus checkpoint callbacks(save/restore), currently, they both called libxl__remus_domain_checkpoint_callback in diffrent file, so it is ok. But in the following patch, we will move all of the remus callback code into a seperate file, the name should be diffrent.

"separate" and "different" (twice).

OK, thanks!

Quoted 63 lines
Quoted 5 lines

So rename them to:
libxl__remus_domain_{save/restore}_checkpoint_callback

Quoted 43 lines
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
  tools/libxl/libxl_create.c | 4 ++--
  tools/libxl/libxl_dom.c    | 4 ++--
  2 files changed, 4 insertions(+), 4 deletions(-)
tools/libxl/libxl_create.c +2 -2
index 5b4d333..a32e3df 100644
@@ -677,7 +677,7 @@ static int store_libxl_entry(libxl__gc *gc, uint32_t domid,
  static void remus_checkpoint_stream_done(
      libxl__egc *egc, libxl__stream_read_state *srs, int rc);
 
-static void libxl__remus_domain_checkpoint_callback(void *data)
+static void libxl__remus_domain_restore_checkpoint_callback(void *data)
  {
      libxl__save_helper_state *shs = data;
      libxl__domain_create_state *dcs = shs->caller_state;
@@ -989,7 +989,7 @@ static void domcreate_bootloader_done(libxl__egc *egc,
      }
 
      /* Restore */
-    callbacks->checkpoint = libxl__remus_domain_checkpoint_callback;
+    callbacks->checkpoint = libxl__remus_domain_restore_checkpoint_callback;
 
      rc = libxl__build_pre(gc, domid, d_config, state);
      if (rc)
tools/libxl/libxl_dom.c +1 -1
index 0788309..9c61fa7 100644
@@ -1586,7 +1586,7 @@ static void remus_next_checkpoint(libxl__egc *egc, libxl__ev_time *ev,
                                    const struct timeval *requested_abs,
                                    int rc);
 
-static void libxl__remus_domain_checkpoint_callback(void *data)
+static void libxl__remus_domain_save_checkpoint_callback(void *data)
  {
      libxl__save_helper_state *shs = data;
      libxl__domain_suspend_state *dss = shs->caller_state;

tools/libxl/libxl_dom.c void libxl__domain_save(libxl__egc *egc, libxl__domain_suspend_state *dss) · line 1755

Quoted 8 lines
tools/libxl/libxl_dom.c +1 -1
@@ -1749,7 +1749,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_suspend_state *dss)
      if (r_info != NULL) {
          callbacks->suspend = libxl__remus_domain_suspend_callback;
          callbacks->postcopy = libxl__remus_domain_resume_callback;
-        callbacks->checkpoint = libxl__remus_domain_checkpoint_callback;
+        callbacks->checkpoint = libxl__remus_domain_save_checkpoint_callback;
          dss->sws.checkpoint_callback = remus_checkpoint_stream_written;
      } else
          callbacks->suspend = libxl__domain_suspend_callback;

.

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

PATCH v4 5/25 libxl/remus: introduce libxl__remus_setup

In reply to Yang Hongyang

Refactoring Remus setup by introducing libxl__remus_setup API. All Remus setup work are done in this function.

Also remove the libxl__ prefix for static functions.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxl/libxl.c | 46 ++++++++++++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 16 deletions(-)
tools/libxl/libxl.c +30 -16
index 69a6937..acb5639 100644
@@ -795,10 +795,12 @@ out:
     return ptr;
 }
 
-static void libxl__remus_setup_done(libxl__egc *egc,
-                                    libxl__remus_devices_state *rds, int rc);
-static void libxl__remus_setup_failed(libxl__egc *egc,
-                                      libxl__remus_devices_state *rds, int rc);
+static void libxl__remus_setup(libxl__egc *egc,
+                               libxl__domain_suspend_state *dss);
+static void remus_setup_done(libxl__egc *egc,
+                             libxl__remus_devices_state *rds, int rc);
+static void remus_setup_failed(libxl__egc *egc,
+                               libxl__remus_devices_state *rds, int rc);
 static void remus_failover_cb(libxl__egc *egc,
                               libxl__domain_suspend_state *dss, int rc);
 
@@ -847,13 +849,26 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
 
     assert(info);
 
+    /* Point of no return */
+    libxl__remus_setup(egc, dss);
+    return AO_INPROGRESS;
+
+ out:
+    return AO_CREATE_FAIL(rc);
+}
+
+static void libxl__remus_setup(libxl__egc *egc,
+                               libxl__domain_suspend_state *dss)
+{
     /* Convenience aliases */
     libxl__remus_devices_state *const rds = &dss->rds;
+    const libxl_domain_remus_info *const info = dss->remus;
+
+    STATE_AO_GC(dss->ao);
 
     if (libxl_defbool_val(info->netbuf)) {
         if (!libxl__netbuffer_enabled(gc)) {
             LOG(ERROR, "Remus: No support for network buffering");
-            rc = ERROR_FAIL;
             goto out;
         }
         rds->device_kind_flags |= (1 << LIBXL__DEVICE_KIND_VIF);
@@ -863,19 +878,18 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
         rds->device_kind_flags |= (1 << LIBXL__DEVICE_KIND_VBD);
 
     rds->ao = ao;
-    rds->domid = domid;
-    rds->callback = libxl__remus_setup_done;
+    rds->domid = dss->domid;
+    rds->callback = remus_setup_done;
 
-    /* Point of no return */
     libxl__remus_devices_setup(egc, rds);
-    return AO_INPROGRESS;
+    return;
 
- out:
-    return AO_CREATE_FAIL(rc);
+out:
+    dss->callback(egc, dss, ERROR_FAIL);
 }
 
-static void libxl__remus_setup_done(libxl__egc *egc,
-                                    libxl__remus_devices_state *rds, int rc)
+static void remus_setup_done(libxl__egc *egc,
+                             libxl__remus_devices_state *rds, int rc)
 {
     libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds);
     STATE_AO_GC(dss->ao);
@@ -887,12 +901,12 @@ static void libxl__remus_setup_done(libxl__egc *egc,
 
     LOG(ERROR, "Remus: failed to setup device for guest with domid %u, rc %d",
         dss->domid, rc);
-    rds->callback = libxl__remus_setup_failed;
+    rds->callback = remus_setup_failed;
     libxl__remus_devices_teardown(egc, rds);
 }
 
-static void libxl__remus_setup_failed(libxl__egc *egc,
-                                      libxl__remus_devices_state *rds, int rc)
+static void remus_setup_failed(libxl__egc *egc,
+                               libxl__remus_devices_state *rds, int rc)
 {
     libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds);
     STATE_AO_GC(dss->ao);
Signature · 1 line
1.9.1
#9 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 05/25] libxl/remus: introduce libxl__remus_setup

Quoted 4 lines · Yang Hongyang

Refactoring Remus setup by introducing libxl__remus_setup API. All Remus setup work are done in this function.

Also remove the libxl__ prefix for static functions.

There is a subtle behavioural change here, which is that if anything which is now done in _setup fails then the result is a call to dss->callback( ..,..,ERROR_FAIL) rather than _start returning AO_CREATE_FAIL(ERROR_FAIL).

I think this is probably a reasonable and correct change, but I think it is worth mentioning in the commit log.

That said, I also wonder if the actual check for netbuffer_enabled (the only such failure in practice) ought to be moved up such that it stays in _start along with the other similar checks, i.e. _start would do:

    if (libxl_defbool_val(info->netbuf) && !libxl__netbuffer_enabled(gc)) {
            LOG(ERROR, "Remus: No support for network buffering");
            rc = ERROR_FAIL;
            goto out;
        }

while _setup would do:

    if (libxl_defbool_val(info->netbuf)) {
        // MAYBE : assert(libxl__netbuffer_enabled(gc))
        rds->device_kind_flags |= (1 << LIBXL__DEVICE_KIND_VIF);
    }

Ian.

#10 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 05/25] libxl/remus: introduce libxl__remus_setup

Quoted 6 lines · Ian Campbell
Quoted 4 lines · Yang Hongyang

Refactoring Remus setup by introducing libxl__remus_setup API. All Remus setup work are done in this function.

Also remove the libxl__ prefix for static functions.

Quoted 7 lines

There is a subtle behavioural change here, which is that if anything which is now done in _setup fails then the result is a call to dss->callback( ..,..,ERROR_FAIL) rather than _start returning AO_CREATE_FAIL(ERROR_FAIL).

I think this is probably a reasonable and correct change, but I think it is worth mentioning in the commit log.

Yes, will update the commit log.

Quoted 10 lines

That said, I also wonder if the actual check for netbuffer_enabled (the only such failure in practice) ought to be moved up such that it stays in _start along with the other similar checks, i.e. _start would do:

     if (libxl_defbool_val(info->netbuf) && !libxl__netbuffer_enabled(gc)) {
             LOG(ERROR, "Remus: No support for network buffering");
             rc = ERROR_FAIL;
             goto out;
         }

This check is for Remus only, we want to reuse _start for COLO, so anything related to Remus only should sit in libxl_remus.c.

Quoted 12 lines

while _setup would do:

     if (libxl_defbool_val(info->netbuf)) {
         // MAYBE : assert(libxl__netbuffer_enabled(gc))
         rds->device_kind_flags |= (1 << LIBXL__DEVICE_KIND_VIF);
     }

Ian.

.

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

Re: [PATCH v4 --for 4.6 COLOPre 05/25] libxl/remus: introduce libxl__remus_setup

Quoted 23 lines · Yang Hongyang
Quoted 6 lines · Ian Campbell
Quoted 4 lines · Yang Hongyang

Refactoring Remus setup by introducing libxl__remus_setup API. All Remus setup work are done in this function.

Also remove the libxl__ prefix for static functions.

Quoted 7 lines

There is a subtle behavioural change here, which is that if anything which is now done in _setup fails then the result is a call to dss->callback( ..,..,ERROR_FAIL) rather than _start returning AO_CREATE_FAIL(ERROR_FAIL).

I think this is probably a reasonable and correct change, but I think it is worth mentioning in the commit log.

Yes, will update the commit log.

Quoted 5 lines

That said, I also wonder if the actual check for netbuffer_enabled (the only such failure in practice) ought to be moved up such that it stays in _start along with the other similar checks, i.e. _start would do:

Quoted 8 lines
Quoted 5 lines
     if (libxl_defbool_val(info->netbuf) && !libxl__netbuffer_enabled(gc)) {
             LOG(ERROR, "Remus: No support for network buffering");
             rc = ERROR_FAIL;
             goto out;
         }

This check is for Remus only, we want to reuse _start for COLO, so anything related to Remus only should sit in libxl_remus.c.

Makes sense, thanks.

#12 lore raw

PATCH v4 6/25 libxl/remus: introduce libxl__remus_teardown

In reply to Yang Hongyang

introduce libxl__remus_teardown to teardown Remus devices.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxl/libxl_dom.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tools/libxl/libxl_dom.c +12 -0
index 9c61fa7..77a917c 100644
@@ -1865,6 +1865,9 @@ static void save_device_model_datacopier_done(libxl__egc *egc,
     dss->save_dm_callback(egc, dss, our_rc);
 }
 
+static void libxl__remus_teardown(libxl__egc *egc,
+                                  libxl__domain_suspend_state *dss,
+                                  int rc);
 static void remus_teardown_done(libxl__egc *egc,
                                        libxl__remus_devices_state *rds,
                                        int rc);
@@ -1894,6 +1897,15 @@ 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);
+}
+
+static void libxl__remus_teardown(libxl__egc *egc,
+                                  libxl__domain_suspend_state *dss,
+                                  int rc)
+{
+    EGC_GC;
+
     LOG(WARN, "Remus: Domain suspend terminated with rc %d,"
         " teardown Remus devices...", rc);
     dss->rds.callback = remus_teardown_done;
Signature · 1 line
1.9.1
Acked-by on v4 6/25
#13 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 06/25] libxl/remus: introduce libxl__remus_teardown

Quoted 3 lines · Yang Hongyang

introduce libxl__remus_teardown to teardown Remus devices.

If you need to respin then you might consider inverting the if remus check in domain_suspend_done and calling this new function if true, e.g.

    if (dss->remus) {
	libxl__remus_teardown(...)
	return;
    }

    dss->callback(egc, dss, rc);

I think the control flow would feel more natural then.

#14 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 06/25] libxl/remus: introduce libxl__remus_teardown

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

introduce libxl__remus_teardown to teardown Remus devices.

If you need to respin then you might consider inverting the if remus check in domain_suspend_done and calling this new function if true, e.g.

Quoted 8 lines
     if (dss->remus) {
	libxl__remus_teardown(...)
	return;
     }

     dss->callback(egc, dss, rc);

I think the control flow would feel more natural then.

will do, thanks!

Quoted 4 lines

.

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

PATCH v4 7/25 libxl/remus: init checkpoint_callback in Remus checkpoint callback

In reply to Yang Hongyang

init stream {read/write} state checkpoint_callback in Remus checkpoint callback.

CC Andrew Cooper <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxl/libxl_create.c | 2 +-
 tools/libxl/libxl_dom.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/libxl/libxl_create.c +1 -1
index a32e3df..94fe98f 100644
@@ -684,6 +684,7 @@ static void libxl__remus_domain_restore_checkpoint_callback(void *data)
     libxl__egc *egc = shs->egc;
     STATE_AO_GC(dcs->ao);
 
+    dcs->srs.checkpoint_callback = remus_checkpoint_stream_done;
     libxl__stream_read_start_checkpoint(egc, &dcs->srs);
 }
 
@@ -1000,7 +1001,6 @@ static void domcreate_bootloader_done(libxl__egc *egc,
     dcs->srs.fd = restore_fd;
     dcs->srs.legacy = (dcs->restore_params.stream_version == 1);
     dcs->srs.completion_callback = domcreate_stream_done;
-    dcs->srs.checkpoint_callback = remus_checkpoint_stream_done;
 
     libxl__stream_read_start(egc, &dcs->srs);
     return;
tools/libxl/libxl_dom.c +1 -1
index 77a917c..1740bed 100644
@@ -1593,6 +1593,7 @@ static void libxl__remus_domain_save_checkpoint_callback(void *data)
     libxl__egc *egc = shs->egc;
     STATE_AO_GC(dss->ao);
 
+    dss->sws.checkpoint_callback = remus_checkpoint_stream_written;
     libxl__stream_write_start_checkpoint(egc, &dss->sws);
 }
 
@@ -1750,7 +1751,6 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_suspend_state *dss)
         callbacks->suspend = libxl__remus_domain_suspend_callback;
         callbacks->postcopy = libxl__remus_domain_resume_callback;
         callbacks->checkpoint = libxl__remus_domain_save_checkpoint_callback;
-        dss->sws.checkpoint_callback = remus_checkpoint_stream_written;
     } else
         callbacks->suspend = libxl__domain_suspend_callback;
 
Signature · 1 line
1.9.1
#16 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 07/25] libxl/remus: init checkpoint_callback in Remus checkpoint callback

Quoted 2 lines · Yang Hongyang

init stream {read/write} state checkpoint_callback in Remus checkpoint callback.

Why? Is this earlier or later than previously? Seems later?

Quoted 51 lines
CC Andrew Cooper <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxl/libxl_create.c | 2 +-
 tools/libxl/libxl_dom.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/libxl/libxl_create.c +1 -1
index a32e3df..94fe98f 100644
@@ -684,6 +684,7 @@ static void libxl__remus_domain_restore_checkpoint_callback(void *data)
     libxl__egc *egc = shs->egc;
     STATE_AO_GC(dcs->ao);
 
+    dcs->srs.checkpoint_callback = remus_checkpoint_stream_done;
     libxl__stream_read_start_checkpoint(egc, &dcs->srs);
 }
 
@@ -1000,7 +1001,6 @@ static void domcreate_bootloader_done(libxl__egc *egc,
     dcs->srs.fd = restore_fd;
     dcs->srs.legacy = (dcs->restore_params.stream_version == 1);
     dcs->srs.completion_callback = domcreate_stream_done;
-    dcs->srs.checkpoint_callback = remus_checkpoint_stream_done;
 
     libxl__stream_read_start(egc, &dcs->srs);
     return;
tools/libxl/libxl_dom.c +1 -1
index 77a917c..1740bed 100644
@@ -1593,6 +1593,7 @@ static void libxl__remus_domain_save_checkpoint_callback(void *data)
     libxl__egc *egc = shs->egc;
     STATE_AO_GC(dss->ao);
 
+    dss->sws.checkpoint_callback = remus_checkpoint_stream_written;
     libxl__stream_write_start_checkpoint(egc, &dss->sws);
 }
 
@@ -1750,7 +1751,6 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_suspend_state *dss)
         callbacks->suspend = libxl__remus_domain_suspend_callback;
         callbacks->postcopy = libxl__remus_domain_resume_callback;
         callbacks->checkpoint = libxl__remus_domain_save_checkpoint_callback;
-        dss->sws.checkpoint_callback = remus_checkpoint_stream_written;
     } else
         callbacks->suspend = libxl__domain_suspend_callback;
 
#17 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 07/25] libxl/remus: init checkpoint_callback in Remus checkpoint callback

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

init stream {read/write} state checkpoint_callback in Remus checkpoint callback.

Why? Is this earlier or later than previously? Seems later?

There's no functional change, it's just refactoring so that we can move all remus code into one file.

Quoted 56 lines
Quoted 45 lines
CC Andrew Cooper <[email protected]>
CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
  tools/libxl/libxl_create.c | 2 +-
  tools/libxl/libxl_dom.c    | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
tools/libxl/libxl_create.c +1 -1
index a32e3df..94fe98f 100644
@@ -684,6 +684,7 @@ static void libxl__remus_domain_restore_checkpoint_callback(void *data)
      libxl__egc *egc = shs->egc;
      STATE_AO_GC(dcs->ao);
 
+    dcs->srs.checkpoint_callback = remus_checkpoint_stream_done;
      libxl__stream_read_start_checkpoint(egc, &dcs->srs);
  }
 
@@ -1000,7 +1001,6 @@ static void domcreate_bootloader_done(libxl__egc *egc,
      dcs->srs.fd = restore_fd;
      dcs->srs.legacy = (dcs->restore_params.stream_version == 1);
      dcs->srs.completion_callback = domcreate_stream_done;
-    dcs->srs.checkpoint_callback = remus_checkpoint_stream_done;
 
      libxl__stream_read_start(egc, &dcs->srs);
      return;
tools/libxl/libxl_dom.c +1 -0
index 77a917c..1740bed 100644
@@ -1593,6 +1593,7 @@ static void libxl__remus_domain_save_checkpoint_callback(void *data)
      libxl__egc *egc = shs->egc;
      STATE_AO_GC(dss->ao);
 
+    dss->sws.checkpoint_callback = remus_checkpoint_stream_written;
      libxl__stream_write_start_checkpoint(egc, &dss->sws);
  }
 

tools/libxl/libxl_dom.c void libxl__domain_save(libxl__egc *egc, libxl__domain_suspend_state *dss) · line 1756

Quoted 7 lines
tools/libxl/libxl_dom.c +0 -1
@@ -1750,7 +1751,6 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_suspend_state *dss)
          callbacks->suspend = libxl__remus_domain_suspend_callback;
          callbacks->postcopy = libxl__remus_domain_resume_callback;
          callbacks->checkpoint = libxl__remus_domain_save_checkpoint_callback;
-        dss->sws.checkpoint_callback = remus_checkpoint_stream_written;
      } else
          callbacks->suspend = libxl__domain_suspend_callback;
 

.

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

Re: [PATCH v4 --for 4.6 COLOPre 07/25] libxl/remus: init checkpoint_callback in Remus checkpoint callback

Quoted 10 lines · Yang Hongyang
Quoted 5 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang

init stream {read/write} state checkpoint_callback in Remus checkpoint callback.

Why? Is this earlier or later than previously? Seems later?

There's no functional change, it's just refactoring so that we can move all remus code into one file.

That answers the why, thanks.

But, it would be a no functional change if the initialisation was moving from e.g. the very start of a function to the caller of that function right before the call or from the end of a function to the caller right after the call.

But AFAICT this movement is a bit more than that, e.g. the init of dcs->srs.checkpoint_callback has moved from near the end of domcreate_bootloader_done to libxl__remus_domain_restore_checkpoint_callback before a call to libxl__stream_read_start_checkpoint, which doesn't have the property I describe above, at least not in an obvious way.

So there is either a span of time where the callback is no longer initialised when it was before, or it is initialised for a larger span that it was before (with the former having the larger potential for issues).

It's also not entirely clear that the new location of the initialisation is traversed on all the same paths as before, or if it happens on fewer paths that those are exactly the ones which matter.

Lastly it seems odd to split out the initialisation of only one member of dcs->srs and dcs->sws into a different location to all the others, especially putting it into the checkpoint callback (which is called repeatedly).

Perhaps what is really needed here is a new function to initialise a dcs->srs for remus, and another for dcs->sws to be called exactly where the init happens today?

#19 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 07/25] libxl/remus: init checkpoint_callback in Remus checkpoint callback

Quoted 35 lines · Ian Campbell
Quoted 10 lines · Yang Hongyang
Quoted 5 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang

init stream {read/write} state checkpoint_callback in Remus checkpoint callback.

Why? Is this earlier or later than previously? Seems later?

There's no functional change, it's just refactoring so that we can move all remus code into one file.

That answers the why, thanks.

But, it would be a no functional change if the initialisation was moving from e.g. the very start of a function to the caller of that function right before the call or from the end of a function to the caller right after the call.

But AFAICT this movement is a bit more than that, e.g. the init of dcs->srs.checkpoint_callback has moved from near the end of domcreate_bootloader_done to libxl__remus_domain_restore_checkpoint_callback before a call to libxl__stream_read_start_checkpoint, which doesn't have the property I describe above, at least not in an obvious way.

So there is either a span of time where the callback is no longer initialised when it was before, or it is initialised for a larger span that it was before (with the former having the larger potential for issues).

It's also not entirely clear that the new location of the initialisation is traversed on all the same paths as before, or if it happens on fewer paths that those are exactly the ones which matter.

Quoted 8 lines

Lastly it seems odd to split out the initialisation of only one member of dcs->srs and dcs->sws into a different location to all the others, especially putting it into the checkpoint callback (which is called repeatedly).

Perhaps what is really needed here is a new function to initialise a dcs->srs for remus, and another for dcs->sws to be called exactly where the init happens today?

The checkpoint_callback() only used by remus, you can see from the initialisation line:
dss->sws.checkpoint_callback = remus_checkpoint_stream_written; dcs->srs.checkpoint_callback = remus_checkpoint_stream_done;

These two functions remus_checkpoint_stream_written & remus_checkpoint_stream_done only called when libxc call chaeckpoint() callback, so there should be no problem with the move. Given the fact it's only used by Remus, init it in previous place is not a good idea IMO.

Quoted 4 lines

.

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

Re: [PATCH v4 --for 4.6 COLOPre 07/25] libxl/remus: init checkpoint_callback in Remus checkpoint callback

Quoted 51 lines · Yang Hongyang
Quoted 35 lines · Ian Campbell
Quoted 10 lines · Yang Hongyang
Quoted 5 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang

init stream {read/write} state checkpoint_callback in Remus checkpoint callback.

Why? Is this earlier or later than previously? Seems later?

There's no functional change, it's just refactoring so that we can move all remus code into one file.

That answers the why, thanks.

But, it would be a no functional change if the initialisation was moving from e.g. the very start of a function to the caller of that function right before the call or from the end of a function to the caller right after the call.

But AFAICT this movement is a bit more than that, e.g. the init of dcs->srs.checkpoint_callback has moved from near the end of domcreate_bootloader_done to libxl__remus_domain_restore_checkpoint_callback before a call to libxl__stream_read_start_checkpoint, which doesn't have the property I describe above, at least not in an obvious way.

So there is either a span of time where the callback is no longer initialised when it was before, or it is initialised for a larger span that it was before (with the former having the larger potential for issues).

It's also not entirely clear that the new location of the initialisation is traversed on all the same paths as before, or if it happens on fewer paths that those are exactly the ones which matter.

Quoted 8 lines

Lastly it seems odd to split out the initialisation of only one member of dcs->srs and dcs->sws into a different location to all the others, especially putting it into the checkpoint callback (which is called repeatedly).

Perhaps what is really needed here is a new function to initialise a dcs->srs for remus, and another for dcs->sws to be called exactly where the init happens today?

The checkpoint_callback() only used by remus, you can see from the initialisation line:
dss->sws.checkpoint_callback = remus_checkpoint_stream_written; dcs->srs.checkpoint_callback = remus_checkpoint_stream_done;

Quoted 5 lines

These two functions remus_checkpoint_stream_written & remus_checkpoint_stream_done only called when libxc call chaeckpoint() callback, so there should be no problem with the move. Given the fact it's only used by Remus, init it in previous place is not a good idea IMO.

I suggested a pair of Remus specific functions to init an sws or srs stream for Remus, called in the same place, which is not the same thing as just leaving it there, nor of initialising this state from the callback itself. You can call that init function on the same condition as I suppose you will eventually apply to:

    callbacks->checkpoint = libxl__remus_domain_checkpoint_callback;

Or perhaps have the remus (and other checkpoint types if necessary) setup code fill in two callbacks in a higher level struct which are called at the appropriate points to init dss->{sws,srs}?

Ian.

#21 lore raw

PATCH v4 8/25 tools/libxl: move remus code into libxl_remus.c

In reply to Yang Hongyang

After previous refactoring, we are now able to move all remus code into a separate file libxl_remus.c.

Export following functions for internal use:
- Remus callbacks
* libxl__remus_domain_suspend_callback
* libxl__remus_domain_resume_callback
* libxl__remus_domain_save_checkpoint_callback
* libxl__remus_domain_restore_checkpoint_callback
- setup/teardown Remus:
* libxl__remus_setup
* libxl__remus_teardown

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxl/Makefile         |   2 +-
 tools/libxl/libxl.c          |  67 ---------
 tools/libxl/libxl_create.c   |  22 ---
 tools/libxl/libxl_dom.c      | 223 ----------------------------
 tools/libxl/libxl_internal.h |  12 ++
 tools/libxl/libxl_remus.c    | 339 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 352 insertions(+), 313 deletions(-)
 create mode 100644 tools/libxl/libxl_remus.c
tools/libxl/Makefile +1 -1
index 4a5957e..b10f4e7 100644
@@ -62,7 +62,7 @@ else
 LIBXL_OBJS-y += libxl_no_convert_callout.o
 endif
 
-LIBXL_OBJS-y += libxl_remus_device.o libxl_remus_disk_drbd.o
+LIBXL_OBJS-y += libxl_remus.o libxl_remus_device.o libxl_remus_disk_drbd.o
 
 LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o
 LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
tools/libxl/libxl.c +0 -67

79 lines not on this page · raw message

tools/libxl/libxl_create.c +0 -22
index 94fe98f..cbd7693 100644
@@ -672,28 +672,6 @@ static int store_libxl_entry(libxl__gc *gc, uint32_t domid,
         libxl_device_model_version_to_string(b_info->device_model_version));
 }
 
-/*----- remus asynchronous checkpoint callback -----*/
-
-static void remus_checkpoint_stream_done(
-    libxl__egc *egc, libxl__stream_read_state *srs, int rc);
-
-static void libxl__remus_domain_restore_checkpoint_callback(void *data)
-{
-    libxl__save_helper_state *shs = data;
-    libxl__domain_create_state *dcs = shs->caller_state;
-    libxl__egc *egc = shs->egc;
-    STATE_AO_GC(dcs->ao);
-
-    dcs->srs.checkpoint_callback = remus_checkpoint_stream_done;
-    libxl__stream_read_start_checkpoint(egc, &dcs->srs);
-}
-
-static void remus_checkpoint_stream_done(
-    libxl__egc *egc, libxl__stream_read_state *stream, int rc)
-{
-    libxl__xc_domain_saverestore_async_callback_done(egc, &stream->shs, rc);
-}
-
 /*----- main domain creation -----*/
 
 /* We have a linear control flow; only one event callback is
tools/libxl/libxl_dom.c +0 -223

241 lines not on this page · raw message

tools/libxl/libxl_internal.h +12 -0
index 3a2ef00..7ce3eca 100644
@@ -3445,6 +3445,18 @@ _hidden void libxl__domain_suspend(libxl__egc *egc,
 /* used by libxc to suspend the guest during migration */
 _hidden void libxl__domain_suspend_callback(void *data);
 
+/* Remus callbacks for save */
+_hidden void libxl__remus_domain_suspend_callback(void *data);
+_hidden void libxl__remus_domain_resume_callback(void *data);
+_hidden void libxl__remus_domain_save_checkpoint_callback(void *data);
+/* Remus callbacks for restore */
+_hidden void libxl__remus_domain_restore_checkpoint_callback(void *data);
+/* Remus setup and teardown*/
+_hidden void libxl__remus_setup(libxl__egc *egc,
+                                libxl__domain_suspend_state *dss);
+_hidden void libxl__remus_teardown(libxl__egc *egc,
+                                   libxl__domain_suspend_state *dss,
+                                   int rc);
 
 /*
  * Convenience macros.
tools/libxl/libxl_remus.c new file +339 -0

339 lines not on this page · raw message

Signature · 1 line
1.9.1
Acked-by on v4 8/25
#22 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 08/25] tools/libxl: move remus code into libxl_remus.c

Quoted 13 lines · Yang Hongyang

After previous refactoring, we are now able to move all remus code into a separate file libxl_remus.c.

Export following functions for internal use:
- Remus callbacks
* libxl__remus_domain_suspend_callback
* libxl__remus_domain_resume_callback
* libxl__remus_domain_save_checkpoint_callback
* libxl__remus_domain_restore_checkpoint_callback
- setup/teardown Remus:
* libxl__remus_setup
* libxl__remus_teardown

Quoted 1 line

On the understanding this is code motion apart from some loss of static and associated tweaks:

Quoted 1 line
CC Ian Campbell <[email protected]>
#23 lore raw

PATCH v4 9/25 tools/libxl: move save/restore code into libxl_dom_save.c

In reply to Yang Hongyang

This is purely code motion.

---
 tools/libxl/Makefile         |   2 +-
 tools/libxl/libxl_dom.c      | 672 -----------------------------------------
 tools/libxl/libxl_dom_save.c | 700 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 701 insertions(+), 673 deletions(-)
 create mode 100644 tools/libxl/libxl_dom_save.c
tools/libxl/Makefile +1 -1
index b10f4e7..2e4c944 100644
@@ -103,7 +103,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
 			libxl_stream_read.o libxl_stream_write.o \
 			libxl_save_callout.o _libxl_save_msgs_callout.o \
 			libxl_qmp.o libxl_event.o libxl_fork.o \
-			libxl_dom_suspend.o $(LIBXL_OBJS-y)
+			libxl_dom_suspend.o libxl_dom_save.o $(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
 
tools/libxl/libxl_dom.c +0 -672

678 lines not on this page · raw message

tools/libxl/libxl_dom_save.c new file +700 -0

700 lines not on this page · raw message

Signature · 1 line
1.9.1
#24 lore raw

PATCH v4 10/25 libxl/save: Refactor libxl__domain_suspend_state

In reply to Yang Hongyang

Currently struct libxl__domain_suspend_state contains 2 type of states, one is save state, another is suspend state. This patch separates those two out.
The motivation of this is that COLO will need to do suspend/resume continuously, we need a more common suspend state.

After this change, dss stands for libxl__domain_save_state, dsps stands for libxl__domain_suspend_state.

Also introduce libxl__domain_suspend_init to initialise the libxl__domain_suspend_state.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Andrew Cooper <[email protected]>
---
 tools/libxl/libxl.c              |  10 +-
 tools/libxl/libxl_dom_save.c     |  69 +++++--------
 tools/libxl/libxl_dom_suspend.c  | 217 +++++++++++++++++++++++++--------------
 tools/libxl/libxl_internal.h     |  60 +++++++----
 tools/libxl/libxl_netbuffer.c    |   2 +-
 tools/libxl/libxl_remus.c        |  37 ++++---
 tools/libxl/libxl_save_callout.c |   2 +-
 tools/libxl/libxl_stream_write.c |  14 +--
 8 files changed, 234 insertions(+), 177 deletions(-)
tools/libxl/libxl.c +5 -5
index f1237d8..05688cd 100644
@@ -796,7 +796,7 @@ out:
 }
 
 static void remus_failover_cb(libxl__egc *egc,
-                              libxl__domain_suspend_state *dss, int rc);
+                              libxl__domain_save_state *dss, int rc);
 
 /* TODO: Explicit Checkpoint acknowledgements via recv_fd. */
 int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
@@ -804,7 +804,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
                              const libxl_asyncop_how *ao_how)
 {
     AO_CREATE(ctx, domid, ao_how);
-    libxl__domain_suspend_state *dss;
+    libxl__domain_save_state *dss;
     int rc;
 
     libxl_domain_type type = libxl__domain_type(gc, domid);
@@ -852,7 +852,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
 }
 
 static void remus_failover_cb(libxl__egc *egc,
-                              libxl__domain_suspend_state *dss, int rc)
+                              libxl__domain_save_state *dss, int rc)
 {
     STATE_AO_GC(dss->ao);
     /*
@@ -864,7 +864,7 @@ static void remus_failover_cb(libxl__egc *egc,
 }
 
 static void domain_suspend_cb(libxl__egc *egc,
-                              libxl__domain_suspend_state *dss, int rc)
+                              libxl__domain_save_state *dss, int rc)
 {
     STATE_AO_GC(dss->ao);
     libxl__ao_complete(egc,ao,rc);
@@ -883,7 +883,7 @@ int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd, int flags,
         goto out_err;
     }
 
-    libxl__domain_suspend_state *dss;
+    libxl__domain_save_state *dss;
     GCNEW(dss);
 
     dss->ao = ao;
tools/libxl/libxl_dom_save.c +24 -45

188 lines not on this page · raw message

tools/libxl/libxl_dom_suspend.c +138 -79

411 lines not on this page · raw message

tools/libxl/libxl_internal.h +38 -22

124 lines not on this page · raw message

tools/libxl/libxl_netbuffer.c +1 -1
index 107e867..c245a4e 100644
@@ -41,7 +41,7 @@ int libxl__netbuffer_enabled(libxl__gc *gc)
 int init_subkind_nic(libxl__remus_devices_state *rds)
 {
     int rc, ret;
-    libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds);
+    libxl__domain_save_state *dss = CONTAINER_OF(rds, *dss, rds);
 
     STATE_AO_GC(rds->ao);
 
tools/libxl/libxl_remus.c +20 -17
index b7fa022..e64792b 100644
@@ -26,7 +26,7 @@ static void remus_setup_failed(libxl__egc *egc,
                                libxl__remus_devices_state *rds, int rc);
 
 void libxl__remus_setup(libxl__egc *egc,
-                        libxl__domain_suspend_state *dss)
+                        libxl__domain_save_state *dss)
 {
     /* Convenience aliases */
     libxl__remus_devices_state *const rds = &dss->rds;
@@ -59,7 +59,7 @@ out:
 static void remus_setup_done(libxl__egc *egc,
                              libxl__remus_devices_state *rds, int rc)
 {
-    libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds);
+    libxl__domain_save_state *dss = CONTAINER_OF(rds, *dss, rds);
     STATE_AO_GC(dss->ao);
 
     if (!rc) {
@@ -76,7 +76,7 @@ static void remus_setup_done(libxl__egc *egc,
 static void remus_setup_failed(libxl__egc *egc,
                                libxl__remus_devices_state *rds, int rc)
 {
-    libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds);
+    libxl__domain_save_state *dss = CONTAINER_OF(rds, *dss, rds);
     STATE_AO_GC(dss->ao);
 
     if (rc)
@@ -90,7 +90,7 @@ static void remus_teardown_done(libxl__egc *egc,
                                 libxl__remus_devices_state *rds,
                                 int rc);
 void libxl__remus_teardown(libxl__egc *egc,
-                           libxl__domain_suspend_state *dss,
+                           libxl__domain_save_state *dss,
                            int rc)
 {
     EGC_GC;
@@ -105,7 +105,7 @@ static void remus_teardown_done(libxl__egc *egc,
                                 libxl__remus_devices_state *rds,
                                 int rc)
 {
-    libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds);
+    libxl__domain_save_state *dss = CONTAINER_OF(rds, *dss, rds);
     STATE_AO_GC(dss->ao);
 
     if (rc)
@@ -118,7 +118,7 @@ static void remus_teardown_done(libxl__egc *egc,
 /*---------------------- remus callbacks (save) -----------------------*/
 
 static void remus_domain_suspend_callback_common_done(libxl__egc *egc,
-                                libxl__domain_suspend_state *dss, int ok);
+                                libxl__domain_suspend_state *dsps, int ok);
 static void remus_devices_postsuspend_cb(libxl__egc *egc,
                                          libxl__remus_devices_state *rds,
                                          int rc);
@@ -130,15 +130,18 @@ void libxl__remus_domain_suspend_callback(void *data)
 {
     libxl__save_helper_state *shs = data;
     libxl__egc *egc = shs->egc;
-    libxl__domain_suspend_state *dss = shs->caller_state;
+    libxl__domain_save_state *dss = shs->caller_state;
+    libxl__domain_suspend_state *dsps = &dss->dsps;
 
-    dss->callback_common_done = remus_domain_suspend_callback_common_done;
-    libxl__domain_suspend(egc, dss);
+    dsps->callback_common_done = remus_domain_suspend_callback_common_done;
+    libxl__domain_suspend(egc, dsps);
 }
 
 static void remus_domain_suspend_callback_common_done(libxl__egc *egc,
-                                libxl__domain_suspend_state *dss, int rc)
+                                libxl__domain_suspend_state *dsps, int rc)
 {
+    libxl__domain_save_state *dss = CONTAINER_OF(dsps, *dss, dsps);
+
     if (rc)
         goto out;
 
@@ -156,7 +159,7 @@ static void remus_devices_postsuspend_cb(libxl__egc *egc,
                                          libxl__remus_devices_state *rds,
                                          int rc)
 {
-    libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds);
+    libxl__domain_save_state *dss = CONTAINER_OF(rds, *dss, rds);
 
     if (rc)
         goto out;
@@ -173,7 +176,7 @@ void libxl__remus_domain_resume_callback(void *data)
 {
     libxl__save_helper_state *shs = data;
     libxl__egc *egc = shs->egc;
-    libxl__domain_suspend_state *dss = shs->caller_state;
+    libxl__domain_save_state *dss = shs->caller_state;
     STATE_AO_GC(dss->ao);
 
     libxl__remus_devices_state *const rds = &dss->rds;
@@ -185,7 +188,7 @@ static void remus_devices_preresume_cb(libxl__egc *egc,
                                        libxl__remus_devices_state *rds,
                                        int rc)
 {
-    libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds);
+    libxl__domain_save_state *dss = CONTAINER_OF(rds, *dss, rds);
     STATE_AO_GC(dss->ao);
 
     if (rc)
@@ -218,7 +221,7 @@ static void remus_next_checkpoint(libxl__egc *egc, libxl__ev_time *ev,
 void libxl__remus_domain_save_checkpoint_callback(void *data)
 {
     libxl__save_helper_state *shs = data;
-    libxl__domain_suspend_state *dss = shs->caller_state;
+    libxl__domain_save_state *dss = shs->caller_state;
     libxl__egc *egc = shs->egc;
     STATE_AO_GC(dss->ao);
 
@@ -229,7 +232,7 @@ void libxl__remus_domain_save_checkpoint_callback(void *data)
 static void remus_checkpoint_stream_written(
     libxl__egc *egc, libxl__stream_write_state *sws, int rc)
 {
-    libxl__domain_suspend_state *dss = CONTAINER_OF(sws, *dss, sws);
+    libxl__domain_save_state *dss = CONTAINER_OF(sws, *dss, sws);
 
     /* Convenience aliases */
     libxl__remus_devices_state *const rds = &dss->rds;
@@ -254,7 +257,7 @@ static void remus_devices_commit_cb(libxl__egc *egc,
                                     libxl__remus_devices_state *rds,
                                     int rc)
 {
-    libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds);
+    libxl__domain_save_state *dss = CONTAINER_OF(rds, *dss, rds);
 
     STATE_AO_GC(dss->ao);
 
@@ -289,7 +292,7 @@ static void remus_next_checkpoint(libxl__egc *egc, libxl__ev_time *ev,
                                   const struct timeval *requested_abs,
                                   int rc)
 {
-    libxl__domain_suspend_state *dss =
+    libxl__domain_save_state *dss =
                             CONTAINER_OF(ev, *dss, checkpoint_timeout);
 
     STATE_AO_GC(dss->ao);
tools/libxl/libxl_save_callout.c +1 -1
index f2ce868..eecb356 100644
@@ -76,7 +76,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs,
                argnums, ARRAY_SIZE(argnums));
 }
 
-void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_suspend_state *dss,
+void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_save_state *dss,
                            libxl__save_helper_state *shs)
 {
     STATE_AO_GC(dss->ao);
tools/libxl/libxl_stream_write.c +7 -7
index 944a87b..16f667a 100644
@@ -252,7 +252,7 @@ static void libxc_header_done(libxl__egc *egc,
 void libxl__xc_domain_save_done(libxl__egc *egc, void *dss_void,
                                 int rc, int retval, int errnoval)
 {
-    libxl__domain_suspend_state *dss = dss_void;
+    libxl__domain_save_state *dss = dss_void;
     libxl__stream_write_state *stream = &dss->sws;
     STATE_AO_GC(dss->ao);
 
@@ -261,10 +261,10 @@ void libxl__xc_domain_save_done(libxl__egc *egc, void *dss_void,
 
     if (retval) {
         LOGEV(ERROR, errnoval, "saving domain: %s",
-              dss->guest_responded ?
+              dss->dsps.guest_responded ?
               "domain responded to suspend request" :
               "domain did not respond to suspend request");
-        if (!dss->guest_responded)
+        if (!dss->dsps.guest_responded)
             rc = ERROR_GUEST_TIMEDOUT;
         else if (dss->rc)
             rc = dss->rc;
@@ -282,7 +282,7 @@ void libxl__xc_domain_save_done(libxl__egc *egc, void *dss_void,
 static void write_toolstack_record(libxl__egc *egc,
                                    libxl__stream_write_state *stream)
 {
-    libxl__domain_suspend_state *dss = stream->dss;
+    libxl__domain_save_state *dss = stream->dss;
     STATE_AO_GC(stream->ao);
     struct libxl__sr_rec_hdr rec;
     int rc;
@@ -314,7 +314,7 @@ static void write_toolstack_record(libxl__egc *egc,
 static void toolstack_record_done(libxl__egc *egc,
                                   libxl__stream_write_state *stream)
 {
-    libxl__domain_suspend_state *dss = stream->dss;
+    libxl__domain_save_state *dss = stream->dss;
 
     if (dss->type == LIBXL_DOMAIN_TYPE_HVM)
         write_emulator_record(egc, stream);
@@ -329,7 +329,7 @@ static void toolstack_record_done(libxl__egc *egc,
 static void write_emulator_record(libxl__egc *egc,
                                   libxl__stream_write_state *stream)
 {
-    libxl__domain_suspend_state *dss = stream->dss;
+    libxl__domain_save_state *dss = stream->dss;
     libxl__datacopier_state *dc = &stream->emu_dc;
     STATE_AO_GC(stream->ao);
     struct libxl__sr_rec_hdr *rec = &stream->emu_rec_hdr;
@@ -340,7 +340,7 @@ static void write_emulator_record(libxl__egc *egc,
     assert(dss->type == LIBXL_DOMAIN_TYPE_HVM);
 
     /* Convenience aliases */
-    const char *const filename = dss->dm_savefile;
+    const char *const filename = dss->dsps.dm_savefile;
     const uint32_t domid = dss->domid;
 
     libxl__carefd_begin();
Signature · 1 line
1.9.1
Acked-by on v4 10/25
#25 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 10/25] libxl/save: Refactor libxl__domain_suspend_state

Quoted 6 lines · Yang Hongyang

Currently struct libxl__domain_suspend_state contains 2 type of states, one is save state, another is suspend state. This patch separates those two out.
The motivation of this is that COLO will need to do suspend/resume continuously, we need a more common suspend state.

Quoted 7 lines

After this change, dss stands for libxl__domain_save_state, dsps stands for libxl__domain_suspend_state.

Also introduce libxl__domain_suspend_init to initialise the libxl__domain_suspend_state.

#26 lore raw

PATCH v4 11/25 tools/libxc: support to resume uncooperative HVM guests

In reply to Yang Hongyang

From: Wen Congyang <[email protected]>

1. suspend
a. PVHVM and PV: we use the same way to suspend the guest (send the suspend
request to the guest). If the guest doesn't support evtchn, the xenstore variant will be used, suspending the guest via XenBus control node.
b. pure HVM: we call xc_domain_shutdown(..., SHUTDOWN_suspend) to suspend
the guest

2. Resume:
a. fast path
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
Used when the guest's state have been changed.
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).

Under COLO, we will update the guest's state(modify memory, cpu's registers, device status...). In this case, we cannot use the fast path to resume it. Keep the return code 0, and use a slow path to resume the guest. While resuming HVM using slow path is not supported currently, this patch is to make the resume call do not fail.

---
 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
#27 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 11/25] tools/libxc: support to resume uncooperative HVM guests

Quoted 30 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

1. suspend
a. PVHVM and PV: we use the same way to suspend the guest (send the suspend
request to the guest). If the guest doesn't support evtchn, the xenstore variant will be used, suspending the guest via XenBus control node.
b. pure HVM: we call xc_domain_shutdown(..., SHUTDOWN_suspend) to suspend
the guest

2. Resume:
a. fast path
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
Used when the guest's state have been changed.
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 8 lines

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

Under COLO, we will update the guest's state(modify memory, cpu's registers, device status...). In this case, we cannot use the fast path to resume it. Keep the return code 0, and use a slow path to resume the guest. While resuming HVM using slow path is not supported currently, this patch is to make the resume call do not fail.

I'm afraid that the addition of this paragraph has not really addressed my comment on v3:

I'm afraid I think the commit message for this patch (and the associated doc comments) need revisiting almost from scratch, to clearly explain what this patch is doing and why and what the constraints on the new functionality will be.

At the moment it mostly talks in a confusing way about the old behaviour and adds very specific assumptions to the new function which are not made clear.

It also appears that this has not been addressed:

Hrm, so it sounds here like the correctness of this new functionality requires the caller to have not messed with the domain's state? What sort of changes are to the guest state are we talking about here?

Isn't that a new requirement for this call? If so then it should be documented somewhere, specifically what sorts of changes are and are not allowed and the types of guests which are affected.

The two usages of "in my test" in the commit message also do not inspire confidence that this change is understood to be correct, vs. happening to be something which works for you.

Ian.

Quoted 46 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 )
     {
#28 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 11/25] tools/libxc: support to resume uncooperative HVM guests

Quoted 52 lines · Ian Campbell
Quoted 30 lines · Yang Hongyang

From: Wen Congyang <[email protected]>

1. suspend
a. PVHVM and PV: we use the same way to suspend the guest (send the suspend
request to the guest). If the guest doesn't support evtchn, the xenstore variant will be used, suspending the guest via XenBus control node.
b. pure HVM: we call xc_domain_shutdown(..., SHUTDOWN_suspend) to suspend
the guest

2. Resume:
a. fast path
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
Used when the guest's state have been changed.
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 8 lines

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

Under COLO, we will update the guest's state(modify memory, cpu's registers, device status...). In this case, we cannot use the fast path to resume it. Keep the return code 0, and use a slow path to resume the guest. While resuming HVM using slow path is not supported currently, this patch is to make the resume call do not fail.

I'm afraid that the addition of this paragraph has not really addressed my comment on v3:

I'm afraid I think the commit message for this patch (and the associated doc comments) need revisiting almost from scratch, to clearly explain what this patch is doing and why and what the constraints on the new functionality will be.

At the moment it mostly talks in a confusing way about the old behaviour and adds very specific assumptions to the new function which are not made clear.

Quoted 5 lines

It also appears that this has not been addressed:

Hrm, so it sounds here like the correctness of this new functionality requires the caller to have not messed with the domain's state? What sort of changes are to the guest state are we talking about here?

This is used for secondary, at a checkpoint, we do:
1. suspend the guest
2. sync the guest state with primary <== here the guest state has been changed
3. resume the guest
The guest state is changed by step 2, then we will resume the guest, since the guest state has been changed, we cannot use the fast path to resume it. For slow path, resume HVM is not supported currently, this patch is to add the support.

While the XEN_DOMCTL_resumedomain hyper call for HVM is an NOP, it happens to me that we could do this in a different way. We can modify libxl__domain_resume, if the domain is HVM, we skip the xc_domain_resume call, what do you think?

Quoted 61 lines

Isn't that a new requirement for this call? If so then it should be documented somewhere, specifically what sorts of changes are and are not allowed and the types of guests which are affected.

The two usages of "in my test" in the commit message also do not inspire confidence that this change is understood to be correct, vs. happening to be something which works for you.

Ian.

Quoted 36 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 )
      {

.

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

Re: [PATCH v4 --for 4.6 COLOPre 11/25] tools/libxc: support to resume uncooperative HVM guests

Yang Hongyang writes ("Re: [Xen-devel] [PATCH v4 --for 4.6 COLOPre 11/25] tools/libxc: support to resume uncooperative HVM guests"):
...

Quoted 1 line

This is used for secondary, at a checkpoint, we do:

Thanks for this explanation, which helps somewhat.

However, Ian Campbell asked for changes to the commit message to better explain what is going. I don't think what you have sent here is intended as a new commit message. So you aren't addressing his concern in the way that he is expecting.

Ian wrote, in response to v3:

I'm afraid I think the commit message for this patch (and the associated doc comments) need revisiting almost from scratch, to clearly explain what this patch is doing and why and what the constraints on the new functionality will be.

At the moment it mostly talks in a confusing way about the old behaviour and adds very specific assumptions to the new function which are not made clear.

To `revisit the commit message almost from scratch' means to completely rewrite the commit message.

In v4 this patch had an additional paragraph in the commit message, but the commit message was otherwise substantially the same. So in response to v4 Ian C said:

I'm afraid that the addition of [an extra] paragraph has not really addressed my comment on v3:

and then he requoted the text above.

Your response seems again to miss the main point of Ian's comment.

If you are unable to rewrite the commit message right now because you don't understand what is missing or wrong, then we can discuss that more. We may even be able to help write it.

However, it is not appropriate to simply ignore Ian Campbell's very clearly stated request for a complete overhaul of the commit message.

While it is a good spirit of helpfulness to provide additional explanation in an email, that is not the same thing.

Moving forward, what we need is a commit message which explains, in Ian Campbell's words:

what this patch is doing

That is, what the change in behaviour is. This includes clearly distinguishing old behaviour, before the patch, from new behaviour, after the patch. I appreciate that there may be language problems which are making this more difficult - I think your native language may not use tenses the way English does. So we can help you with the language, but we need the old and new behaviours to be clearly marked in your message.

why

You have already gone some way to answering this but the information needs to be folded into the commit message.

what the constraints on the new functionality will be.

It appears that you are supporting slow path resume for all HVM guests. Is that true ? Are there any cases left unhandled ?

I suggest that the best thing for you to do next is either to reply to me with ideally (a) a draft of a new commit message for the patch, or if (as I suspect) you don't feel confident to do that, (a) questions to help you understand what we are looking for, or (c) a request for help with drafting.

Quoted 4 lines

While the XEN_DOMCTL_resumedomain hyper call for HVM is an NOP, it happens to me that we could do this in a different way. We can modify libxl__domain_resume, if the domain is HVM, we skip the xc_domain_resume call, what do you think?

Until we understand the answers to the questions above, it will be difficult for us to give a sensible opinion.

Thanks,
Ian.

#30 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 11/25] tools/libxc: support to resume uncooperative HVM guests

Quoted 38 lines · Ian Jackson

Yang Hongyang writes ("Re: [Xen-devel] [PATCH v4 --for 4.6 COLOPre 11/25] tools/libxc: support to resume uncooperative HVM guests"):
...

Quoted 1 line

This is used for secondary, at a checkpoint, we do:

Thanks for this explanation, which helps somewhat.

However, Ian Campbell asked for changes to the commit message to better explain what is going. I don't think what you have sent here is intended as a new commit message. So you aren't addressing his concern in the way that he is expecting.

Ian wrote, in response to v3:

I'm afraid I think the commit message for this patch (and the associated doc comments) need revisiting almost from scratch, to clearly explain what this patch is doing and why and what the constraints on the new functionality will be.

At the moment it mostly talks in a confusing way about the old behaviour and adds very specific assumptions to the new function which are not made clear.

To `revisit the commit message almost from scratch' means to completely rewrite the commit message.

In v4 this patch had an additional paragraph in the commit message, but the commit message was otherwise substantially the same. So in response to v4 Ian C said:

I'm afraid that the addition of [an extra] paragraph has not really addressed my comment on v3:

and then he requoted the text above.

Your response seems again to miss the main point of Ian's comment.

Quoted 6 lines

If you are unable to rewrite the commit message right now because you don't understand what is missing or wrong, then we can discuss that more. We may even be able to help write it.

However, it is not appropriate to simply ignore Ian Campbell's very clearly stated request for a complete overhaul of the commit message.

I'm sorry, I didn't mean to it.

Quoted 10 lines

While it is a good spirit of helpfulness to provide additional explanation in an email, that is not the same thing.

Moving forward, what we need is a commit message which explains, in Ian Campbell's words:

what this patch is doing

Quoted 7 lines

That is, what the change in behaviour is. This includes clearly distinguishing old behaviour, before the patch, from new behaviour, after the patch. I appreciate that there may be language problems which are making this more difficult - I think your native language may not use tenses the way English does. So we can help you with the language, but we need the old and new behaviours to be clearly marked in your message.

I thought this is being addressed in the commit message, sorry again for my poor English and not make it clear, I would appreciate your help.

Quoted 10 lines

why

You have already gone some way to answering this but the information needs to be folded into the commit message.

what the constraints on the new functionality will be.

It appears that you are supporting slow path resume for all HVM guests. Is that true ? Are there any cases left unhandled ?

For the first question, yes. For second, Sorry that I don't catch your question, did you mean in some cases resuming HVM through slow path will be unhandled?

Quoted 7 lines

I suggest that the best thing for you to do next is either to reply to me with ideally (a) a draft of a new commit message for the patch, or if (as I suspect) you don't feel confident to do that, (a) questions to help you understand what we are looking for, or (c) a request for help with drafting.

c, I would appreciate your help with drafting, thank you.

Quoted 15 lines
Quoted 6 lines

While the XEN_DOMCTL_resumedomain hyper call for HVM is an NOP, it happens to me that we could do this in a different way. We can modify libxl__domain_resume, if the domain is HVM, we skip the xc_domain_resume call, what do you think?

Until we understand the answers to the questions above, it will be difficult for us to give a sensible opinion.

Thanks,
Ian.
.

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

Re: [PATCH v4 --for 4.6 COLOPre 11/25] tools/libxc: support to resume uncooperative HVM guests

Yang Hongyang writes ("Re: [Xen-devel] [PATCH v4 --for 4.6 COLOPre 11/25] tools/libxc: support to resume uncooperative HVM guests"):

Quoted 11 lines · Ian Jackson
Quoted 9 lines

what this patch is doing

That is, what the change in behaviour is. This includes clearly distinguishing old behaviour, before the patch, from new behaviour, after the patch. I appreciate that there may be language problems which are making this more difficult - I think your native language may not use tenses the way English does. So we can help you with the language, but we need the old and new behaviours to be clearly marked in your message.

Quoted 3 lines

I thought this is being addressed in the commit message, sorry again for my poor English and not make it clear, I would appreciate your help.

Right. Thanks. I hope we can work on this together. I appreciate that working in a non-native language is difficult.

OK, at the moment I find the existing proposed commit message unclear about before-and-after. I'm not sure I can write it correctly. Can I make a suggestion ? How about you send me a copy of it with the different parts explicitly marked BEFORE: and AFTER: ?

Quoted 8 lines
Quoted 4 lines

what the constraints on the new functionality will be.

It appears that you are supporting slow path resume for all HVM guests. Is that true ? Are there any cases left unhandled ?

For the first question, yes. For second, Sorry that I don't catch your question, did you mean in some cases resuming HVM through slow path will be unhandled?

What I mean is: I think that this patch has this overall effect:

BEFORE: HVM resume for slow path does not work

AFTER: HVM resume for slow path does work

But I have questions. I don't know in what way it "does not work". What happens instead ?

And, another question: is it true that

AFTER: HVM resume for slow path does work in all cases

or

AFTER: HVM resume for slow path works in some cases (specify!)
but in other cases it (does something else - what?)

Does that make sense of my question ?

Thanks,
Ian.

#32 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 11/25] tools/libxc: support to resume uncooperative HVM guests

Quoted 33 lines · Ian Jackson

Yang Hongyang writes ("Re: [Xen-devel] [PATCH v4 --for 4.6 COLOPre 11/25] tools/libxc: support to resume uncooperative HVM guests"):

Quoted 11 lines · Ian Jackson
Quoted 9 lines

what this patch is doing

That is, what the change in behaviour is. This includes clearly distinguishing old behaviour, before the patch, from new behaviour, after the patch. I appreciate that there may be language problems which are making this more difficult - I think your native language may not use tenses the way English does. So we can help you with the language, but we need the old and new behaviours to be clearly marked in your message.

Quoted 3 lines

I thought this is being addressed in the commit message, sorry again for my poor English and not make it clear, I would appreciate your help.

Right. Thanks. I hope we can work on this together. I appreciate that working in a non-native language is difficult.

OK, at the moment I find the existing proposed commit message unclear about before-and-after. I'm not sure I can write it correctly. Can I make a suggestion ? How about you send me a copy of it with the different parts explicitly marked BEFORE: and AFTER: ?

Quoted 8 lines
Quoted 4 lines

what the constraints on the new functionality will be.

It appears that you are supporting slow path resume for all HVM guests. Is that true ? Are there any cases left unhandled ?

For the first question, yes. For second, Sorry that I don't catch your question, did you mean in some cases resuming HVM through slow path will be unhandled?

Quoted 8 lines

What I mean is: I think that this patch has this overall effect:

BEFORE: HVM resume for slow path does not work

AFTER: HVM resume for slow path does work

But I have questions. I don't know in what way it "does not work". What happens instead ?

Sorry for the late reply.
BEFORE: HVM resume for slow path does not work. You will get the following error message:
"Cannot resume uncooperative HVM guests"

Fast resume: the guest status is not changed, so there is no need to disconnect and reconnect the backend and frontend pv driver.

Slow path resume: the guest status is changed, so we must disconnect and reconnect the backend and frontend pv driver. When we reconnect the backend and frontend, it will take too many time, because xenstore is very slow. That is why it is a slow path.

In which case the slow path doesn't work? If the guest status is changed, but it is also corrupted. I don't know what will happen in this case. I think resuming PV guest in such state doesn't work(the behavior is undefined.)

Quoted 11 lines

And, another question: is it true that

AFTER: HVM resume for slow path does work in all cases

or

AFTER: HVM resume for slow path works in some cases (specify!)
but in other cases it (does something else - what?)

Does that make sense of my question ?

In my test, it works. I know I cannot say it does work in all cases. How to know if it does work in all cases?
List all cases, and do a test for all cases.
But I think it is hard to list all cases...

How to resume domU if its state(memory, device state, cpu's register...) is changed? Note that, the domU can be resumed.(All states are copied from another guest with the same config).
Before this patch, we only support pv guest, and do the following thing:
1. rewrite store_mfn and console_mfn
2. reset all secondary CPU states
3. resume domain(do_domctl(xch, ...), cmd is XEN_DOMCTL_resumedomain)

Thanks
Wen Congyang

Quoted 6 lines

Thanks,
Ian.
.

#33 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 11/25] tools/libxc: support to resume uncooperative HVM guests

Wen Congyang writes ("Re: [Xen-devel] [PATCH v4 --for 4.6 COLOPre 11/25] tools/libxc: support to resume uncooperative HVM guests"):

Quoted 8 lines

Sorry for the late reply.
BEFORE: HVM resume for slow path does not work. You will get the following error message:
"Cannot resume uncooperative HVM guests"

Fast resume: the guest status is not changed, so there is no need to disconnect and reconnect the backend and frontend pv driver.

Quoted 7 lines

Slow path resume: the guest status is changed, so we must disconnect and reconnect the backend and frontend pv driver. When we reconnect the backend and frontend, it will take too many time, because xenstore is very slow. That is why it is a slow path.

In which case the slow path doesn't work? If the guest status is changed, but it is also corrupted. I don't know what will happen in this case. I think resuming PV guest in such state doesn't work(the behavior is undefined.)

Right. Thanks, this is nice and clear. Indeed, the guest will be corrupted and if we're lucky (!) it will crash.

Quoted 6 lines

[discussion of AFTER]

In my test, it works. I know I cannot say it does work in all cases. How to know if it does work in all cases?
List all cases, and do a test for all cases.
But I think it is hard to list all cases...

I certainly don't expect you to list them all and test them. I'm just trying to understand what you are saying in the commit message.

So I think you could say something like:

AFTER: I think it should work in XYZ cases. I have tested PQR (only), but the others are probably good because [explanation].

Or perhaps:

There may still be problems with situation ABC because of problem FOO. I have not tested this. But situation ABC is already broken and this patch makes it no worse.

Thanks,
Ian.

#34 lore raw

PATCH v4 12/25 tools/libxl: introduce enum type libxl_checkpointed_stream

In reply to Yang Hongyang

introduce enum type libxl_checkpointed_stream in IDL. rename the last argument of migrate_receive from "remus" to "checkpointed" since the semantics of this parameter has changed.

NOTE:
libxl_domain_restore_params isn't changed here, checkpointed_stream is still an int.
It has to change eventually and other callers will have to be updated to cope (and there should be LIBXL_HAVE_...).

---
 tools/libxl/libxl_types.idl |  5 +++++
 tools/libxl/xl_cmdimpl.c    | 13 +++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)
tools/libxl/libxl_types.idl +5 -0
index bc0c4ef..94c230e 100644
@@ -207,6 +207,11 @@ libxl_hdtype = Enumeration("hdtype", [
     (2, "AHCI"),
     ], init_val = "LIBXL_HDTYPE_IDE")
 
+libxl_checkpointed_stream = Enumeration("checkpointed_stream", [
+    (0, "NONE"),
+    (1, "REMUS"),
+    ])
+
 #
 # Complex libxl types
 #
tools/libxl/xl_cmdimpl.c +7 -6
index 13e154d..aa641fd 100644
@@ -4282,7 +4282,7 @@ static void migrate_domain(uint32_t domid, const char *rune, int debug,
 }
 
 static void migrate_receive(int debug, int daemonize, int monitor,
-                            int send_fd, int recv_fd, int remus)
+                            int send_fd, int recv_fd, int checkpointed)
 {
     uint32_t domid;
     int rc, rc2;
@@ -4307,7 +4307,7 @@ static void migrate_receive(int debug, int daemonize, int monitor,
     dom_info.paused = 1;
     dom_info.migrate_fd = recv_fd;
     dom_info.migration_domname_r = &migration_domname;
-    dom_info.checkpointed_stream = remus;
+    dom_info.checkpointed_stream = checkpointed;
 
     rc = create_domain(&dom_info);
     if (rc < 0) {
@@ -4318,7 +4318,7 @@ static void migrate_receive(int debug, int daemonize, int monitor,
 
     domid = rc;
 
-    if (remus) {
+    if (checkpointed) {
         /* If we are here, it means that the sender (primary) has crashed.
          * TODO: Split-Brain Check.
          */
@@ -4489,7 +4489,8 @@ int main_restore(int argc, char **argv)
 
 int main_migrate_receive(int argc, char **argv)
 {
-    int debug = 0, daemonize = 1, monitor = 1, remus = 0;
+    int debug = 0, daemonize = 1, monitor = 1;
+    int checkpointed = LIBXL_CHECKPOINTED_STREAM_NONE;
     int opt;
 
     SWITCH_FOREACH_OPT(opt, "Fedr", NULL, "migrate-receive", 0) {
@@ -4504,7 +4505,7 @@ int main_migrate_receive(int argc, char **argv)
         debug = 1;
         break;
     case 'r':
-        remus = 1;
+        checkpointed = LIBXL_CHECKPOINTED_STREAM_REMUS;
         break;
     }
 
@@ -4514,7 +4515,7 @@ int main_migrate_receive(int argc, char **argv)
     }
     migrate_receive(debug, daemonize, monitor,
                     STDOUT_FILENO, STDIN_FILENO,
-                    remus);
+                    checkpointed);
 
     return 0;
 }
Signature · 1 line
1.9.1
#35 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 12/25] tools/libxl: introduce enum type libxl_checkpointed_stream

Quoted 10 lines · Yang Hongyang

introduce enum type libxl_checkpointed_stream in IDL. rename the last argument of migrate_receive from "remus" to "checkpointed" since the semantics of this parameter has changed.

NOTE:
libxl_domain_restore_params isn't changed here, checkpointed_stream is still an int.
It has to change eventually and other callers will have to be updated to cope (and there should be LIBXL_HAVE_...).

Will this be fixed up later in this series? If so please say so.

tools/libxl/xl_cmdimpl.c static void migrate_domain(uint32_t domid, const char *rune, int debug, · line 4285

Quoted 6 lines
tools/libxl/xl_cmdimpl.c +1 -1
@@ -4282,7 +4282,7 @@ static void migrate_domain(uint32_t domid, const char *rune, int debug,
 }
 
 static void migrate_receive(int debug, int daemonize, int monitor,
-                            int send_fd, int recv_fd, int remus)
+                            int send_fd, int recv_fd, int checkpointed)

I think you can start using the new enum type in xl straight away even if dom_info.checkpointed_stream remains an int. So that means here.

tools/libxl/xl_cmdimpl.c int main_restore(int argc, char **argv) · line 4493

Quoted 7 lines
tools/libxl/xl_cmdimpl.c +2 -1
@@ -4489,7 +4489,8 @@ int main_restore(int argc, char **argv)
 
 int main_migrate_receive(int argc, char **argv)
 {
-    int debug = 0, daemonize = 1, monitor = 1, remus = 0;
+    int debug = 0, daemonize = 1, monitor = 1;
+    int checkpointed = LIBXL_CHECKPOINTED_STREAM_NONE;

and here.

tools/libxl/xl_cmdimpl.c static void migrate_receive(int debug, int daemonize, int monitor, · line 4324

Quoted 9 lines
tools/libxl/xl_cmdimpl.c +1 -1
@@ -4318,7 +4318,7 @@ static void migrate_receive(int debug, int daemonize, int monitor,
 
     domid = rc;
 
-    if (remus) {
+    if (checkpointed) {
         /* If we are here, it means that the sender (primary) has crashed.
          * TODO: Split-Brain Check.
          */

Is it the case that we expect all check pointing solutions will use the same failover code here? If yes then this should be "if (checkpointed ! = ...NONE)".

If we think they might differ (even if remus and colo happen to be the same) then I think a switch where the NONE case does nothing would be more structurally appropriate.

Ian.

#36 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 12/25] tools/libxl: introduce enum type libxl_checkpointed_stream

Quoted 6 lines · Ian Campbell
Quoted 5 lines · Yang Hongyang

introduce enum type libxl_checkpointed_stream in IDL. rename the last argument of migrate_receive from "remus" to "checkpointed" since the semantics of this parameter has changed.

Quoted 7 lines
Quoted 5 lines

NOTE:
libxl_domain_restore_params isn't changed here, checkpointed_stream is still an int.
It has to change eventually and other callers will have to be updated to cope (and there should be LIBXL_HAVE_...).

Will this be fixed up later in this series? If so please say so.

It's not fixed in this series, I plan to fix this later, but seems there will be another round for this series, I can fix this in the next version. My main concern is that this change is an api change, it will affect the existing callers.

Quoted 43 lines

tools/libxl/xl_cmdimpl.c static void migrate_domain(uint32_t domid, const char *rune, int debug, · line 4285

Quoted 7 lines
tools/libxl/xl_cmdimpl.c +1 -1
@@ -4282,7 +4282,7 @@ static void migrate_domain(uint32_t domid, const char *rune, int debug,
  }
 
  static void migrate_receive(int debug, int daemonize, int monitor,
-                            int send_fd, int recv_fd, int remus)
+                            int send_fd, int recv_fd, int checkpointed)

I think you can start using the new enum type in xl straight away even if dom_info.checkpointed_stream remains an int. So that means here.

tools/libxl/xl_cmdimpl.c int main_restore(int argc, char **argv) · line 4493

Quoted 7 lines
tools/libxl/xl_cmdimpl.c +2 -1
@@ -4489,7 +4489,8 @@ int main_restore(int argc, char **argv)
 
  int main_migrate_receive(int argc, char **argv)
  {
-    int debug = 0, daemonize = 1, monitor = 1, remus = 0;
+    int debug = 0, daemonize = 1, monitor = 1;
+    int checkpointed = LIBXL_CHECKPOINTED_STREAM_NONE;

and here.

tools/libxl/xl_cmdimpl.c static void migrate_receive(int debug, int daemonize, int monitor, · line 4324

Quoted 9 lines
tools/libxl/xl_cmdimpl.c +1 -1
@@ -4318,7 +4318,7 @@ static void migrate_receive(int debug, int daemonize, int monitor,
 
      domid = rc;
 
-    if (remus) {
+    if (checkpointed) {
          /* If we are here, it means that the sender (primary) has crashed.
           * TODO: Split-Brain Check.
           */

Is it the case that we expect all check pointing solutions will use the same failover code here? If yes then this should be "if (checkpointed ! = ...NONE)".

If we think they might differ (even if remus and colo happen to be the same) then I think a switch where the NONE case does nothing would be more structurally appropriate.

Ian.

.

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

Re: [PATCH v4 --for 4.6 COLOPre 12/25] tools/libxl: introduce enum type libxl_checkpointed_stream

Quoted 14 lines · Yang Hongyang
Quoted 12 lines · Ian Campbell
Quoted 10 lines · Yang Hongyang

introduce enum type libxl_checkpointed_stream in IDL. rename the last argument of migrate_receive from "remus" to "checkpointed" since the semantics of this parameter has changed.

NOTE:
libxl_domain_restore_params isn't changed here, checkpointed_stream is still an int.
It has to change eventually and other callers will have to be updated to cope (and there should be LIBXL_HAVE_...).

Quoted 6 lines
Quoted 1 line

Will this be fixed up later in this series? If so please say so.

It's not fixed in this series, I plan to fix this later, but seems there will be another round for this series, I can fix this in the next version. My main concern is that this change is an api change, it will affect the existing callers.

It is already an API change, whether or not is reflected in the type of checkpointed_stream in the API struct you've already changed the semantics of that field and so a LIBLX_HAVE is already needed, it makes no sense to not also change the type to be correct while you are making these changes even if the interchangeability of ints and enums seems on the face of it to make it possible to avoid doing so.

Ian.

#38 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 12/25] tools/libxl: introduce enum type libxl_checkpointed_stream

Quoted 22 lines · Ian Campbell
Quoted 14 lines · Yang Hongyang
Quoted 12 lines · Ian Campbell
Quoted 10 lines · Yang Hongyang

introduce enum type libxl_checkpointed_stream in IDL. rename the last argument of migrate_receive from "remus" to "checkpointed" since the semantics of this parameter has changed.

NOTE:
libxl_domain_restore_params isn't changed here, checkpointed_stream is still an int.
It has to change eventually and other callers will have to be updated to cope (and there should be LIBXL_HAVE_...).

Quoted 6 lines
Quoted 1 line

Will this be fixed up later in this series? If so please say so.

It's not fixed in this series, I plan to fix this later, but seems there will be another round for this series, I can fix this in the next version. My main concern is that this change is an api change, it will affect the existing callers.

Quoted 6 lines

It is already an API change, whether or not is reflected in the type of checkpointed_stream in the API struct you've already changed the semantics of that field and so a LIBLX_HAVE is already needed, it makes no sense to not also change the type to be correct while you are making these changes even if the interchangeability of ints and enums seems on the face of it to make it possible to avoid doing so.

Fair enough, will fix, thank you!

Quoted 5 lines

Ian.

.

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

PATCH v4 13/25 migration/save: pass checkpointed_stream from libxl to libxc

In reply to Yang Hongyang

Pass checkpointed_stream from libxl to libxc.
It won't affact legacy migration because legacy migration won't use this param.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Andrew Cooper <[email protected]>
---
 tools/libxc/include/xenguest.h   |  9 ++++++---
 tools/libxc/xc_domain_save.c     |  6 ++++--
 tools/libxc/xc_nomigrate.c       |  3 ++-
 tools/libxc/xc_sr_common.h       |  2 +-
 tools/libxc/xc_sr_save.c         |  5 +++--
 tools/libxl/libxl.c              |  2 ++
 tools/libxl/libxl_dom_save.c     | 11 ++++++++---
 tools/libxl/libxl_internal.h     |  1 +
 tools/libxl/libxl_save_callout.c |  2 +-
 tools/libxl/libxl_save_helper.c  |  3 ++-
 10 files changed, 30 insertions(+), 14 deletions(-)
tools/libxc/include/xenguest.h +6 -3
index e95af54..6e24b6c 100644
@@ -30,7 +30,6 @@
 #define XCFLAGS_HVM       (1 << 2)
 #define XCFLAGS_STDVGA    (1 << 3)
 #define XCFLAGS_CHECKPOINT_COMPRESS    (1 << 4)
-#define XCFLAGS_CHECKPOINTED    (1 << 5)
 
 #define X86_64_B_SIZE   64 
 #define X86_32_B_SIZE   32
@@ -85,16 +84,20 @@ struct save_callbacks {
  * @parm xch a handle to an open hypervisor interface
  * @parm fd the file descriptor to save a domain to
  * @parm dom the id of the domain
+ * @parm checkpointed_stream non-zero if the far end of the stream is using
+ *       checkpointing
  * @return 0 on success, -1 on failure
  */
 int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters,
                    uint32_t max_factor, uint32_t flags /* XCFLAGS_xxx */,
-                   struct save_callbacks* callbacks, int hvm);
+                   struct save_callbacks* callbacks, int hvm,
+                   int checkpointed_stream);
 
 /* Domain Save v2 */
 int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters,
                     uint32_t max_factor, uint32_t flags,
-                    struct save_callbacks* callbacks, int hvm);
+                    struct save_callbacks* callbacks, int hvm,
+                    int checkpointed_stream);
 
 /* callbacks provided by xc_domain_restore */
 struct restore_callbacks {
tools/libxc/xc_domain_save.c +4 -2
index 3222473..0da3cca 100644
@@ -802,7 +802,8 @@ static int save_tsc_info(xc_interface *xch, uint32_t dom, int io_fd)
 
 int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters,
                    uint32_t max_factor, uint32_t flags,
-                   struct save_callbacks* callbacks, int hvm)
+                   struct save_callbacks* callbacks, int hvm,
+                   int checkpointed_stream)
 {
     xc_dominfo_t info;
     DECLARE_DOMCTL;
@@ -897,7 +898,8 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter
     if ( getenv("XG_MIGRATION_V2") )
     {
         return xc_domain_save2(xch, io_fd, dom, max_iters,
-                               max_factor, flags, callbacks, hvm);
+                               max_factor, flags, callbacks, hvm,
+                               checkpointed_stream);
     }
 
     DPRINTF("%s: starting save of domid %u", __func__, dom);
tools/libxc/xc_nomigrate.c +2 -1
index 76978a0..374d5bf 100644
@@ -23,7 +23,8 @@
 
 int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters,
                    uint32_t max_factor, uint32_t flags,
-                   struct save_callbacks* callbacks, int hvm)
+                   struct save_callbacks* callbacks, int hvm,
+                   int checkpointed_stream)
 {
     errno = ENOSYS;
     return -1;
tools/libxc/xc_sr_common.h +1 -1
index 64f6082..28755ac 100644
@@ -178,7 +178,7 @@ struct xc_sr_context
             bool live;
 
             /* Plain VM, or checkpoints over time. */
-            bool checkpointed;
+            int checkpointed;
 
             /* Further debugging information in the stream. */
             bool debug;
tools/libxc/xc_sr_save.c +3 -2
index d63b783..6102b66 100644
@@ -820,7 +820,8 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)
 
 int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom,
                     uint32_t max_iters, uint32_t max_factor, uint32_t flags,
-                    struct save_callbacks* callbacks, int hvm)
+                    struct save_callbacks* callbacks, int hvm,
+                    int checkpointed_stream)
 {
     xen_pfn_t nr_pfns;
     struct xc_sr_context ctx =
@@ -833,7 +834,7 @@ int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom,
     ctx.save.callbacks = callbacks;
     ctx.save.live  = !!(flags & XCFLAGS_LIVE);
     ctx.save.debug = !!(flags & XCFLAGS_DEBUG);
-    ctx.save.checkpointed = !!(flags & XCFLAGS_CHECKPOINTED);
+    ctx.save.checkpointed = checkpointed_stream;
 
     /*
      * TODO: Find some time to better tweak the live migration algorithm.
tools/libxl/libxl.c +2 -0
index 05688cd..5b2d045 100644
@@ -840,6 +840,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
     dss->live = 1;
     dss->debug = 0;
     dss->remus = info;
+    dss->checkpointed_stream = LIBXL_CHECKPOINTED_STREAM_REMUS;
 
     assert(info);
 
@@ -894,6 +895,7 @@ int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd, int flags,
     dss->type = type;
     dss->live = flags & LIBXL_SUSPEND_LIVE;
     dss->debug = flags & LIBXL_SUSPEND_DEBUG;
+    dss->checkpointed_stream = LIBXL_CHECKPOINTED_STREAM_NONE;
 
     libxl__domain_save(egc, dss);
     return AO_INPROGRESS;
tools/libxl/libxl_dom_save.c +8 -3
index 6348cae..f89f5d4 100644
@@ -389,6 +389,12 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss)
         &dss->sws.shs.callbacks.save.a;
     libxl__domain_suspend_state *dsps = &dss->dsps;
 
+    if (dss->checkpointed_stream && !r_info) {
+        LOG(ERROR, "Migration stream is checkpointed, but there's no "
+                   "checkpoint info!");
+        goto out;
+    }
+
     dss->rc = 0;
     logdirty_init(&dss->logdirty);
     dsps->ao = ao;
@@ -412,15 +418,14 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss)
           | (debug ? XCFLAGS_DEBUG : 0)
           | (dss->hvm ? XCFLAGS_HVM : 0);
 
-    if (r_info != NULL) {
+    if (dss->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_REMUS) {
         dss->interval = r_info->interval;
-        dss->xcflags |= XCFLAGS_CHECKPOINTED;
         if (libxl_defbool_val(r_info->compression))
             dss->xcflags |= XCFLAGS_CHECKPOINT_COMPRESS;
     }
 
     memset(callbacks, 0, sizeof(*callbacks));
-    if (r_info != NULL) {
+    if (dss->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_REMUS) {
         callbacks->suspend = libxl__remus_domain_suspend_callback;
         callbacks->postcopy = libxl__remus_domain_resume_callback;
         callbacks->checkpoint = libxl__remus_domain_save_checkpoint_callback;
tools/libxl/libxl_internal.h +1 -0
index c53a148..0eb5f41 100644
@@ -3050,6 +3050,7 @@ struct libxl__domain_save_state {
     libxl_domain_type type;
     int live;
     int debug;
+    int checkpointed_stream;
     const libxl_domain_remus_info *remus;
     /* private */
     int rc;
tools/libxl/libxl_save_callout.c +1 -1
index eecb356..f393abc 100644
@@ -86,7 +86,7 @@ void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_save_state *dss,
 
     const unsigned long argnums[] = {
         dss->domid, 0, 0, dss->xcflags, dss->hvm,
-        cbflags,
+        cbflags, dss->checkpointed_stream,
     };
 
     shs->ao = ao;
tools/libxl/libxl_save_helper.c +2 -1
index 1622bb7..4c9d34c 100644
@@ -250,6 +250,7 @@ int main(int argc, char **argv)
         uint32_t flags =           strtoul(NEXTARG,0,10);
         int hvm =                  atoi(NEXTARG);
         unsigned cbflags =         strtoul(NEXTARG,0,10);
+        int checkpointed_stream =  strtoul(NEXTARG,0,10);
         assert(!*++argv);
 
         helper_setcallbacks_save(&helper_save_callbacks, cbflags);
@@ -258,7 +259,7 @@ int main(int argc, char **argv)
         setup_signals(save_signal_handler);
 
         r = xc_domain_save2(xch, io_fd, dom, max_iters, max_factor, flags,
-                           &helper_save_callbacks, hvm);
+                           &helper_save_callbacks, hvm, checkpointed_stream);
         complete(r);
 
     } else if (!strcmp(mode,"--restore-domain")) {
Signature · 1 line
1.9.1
#40 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 13/25] migration/save: pass checkpointed_stream from libxl to libxc

Quoted 35 lines · Yang Hongyang

Pass checkpointed_stream from libxl to libxc.
It won't affact legacy migration because legacy migration won't use this param.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Andrew Cooper <[email protected]>
---
 tools/libxc/include/xenguest.h   |  9 ++++++---
 tools/libxc/xc_domain_save.c     |  6 ++++--
 tools/libxc/xc_nomigrate.c       |  3 ++-
 tools/libxc/xc_sr_common.h       |  2 +-
 tools/libxc/xc_sr_save.c         |  5 +++--
 tools/libxl/libxl.c              |  2 ++
 tools/libxl/libxl_dom_save.c     | 11 ++++++++---
 tools/libxl/libxl_internal.h     |  1 +
 tools/libxl/libxl_save_callout.c |  2 +-
 tools/libxl/libxl_save_helper.c  |  3 ++-
 10 files changed, 30 insertions(+), 14 deletions(-)
tools/libxc/include/xenguest.h +0 -1
index e95af54..6e24b6c 100644
@@ -30,7 +30,6 @@
 #define XCFLAGS_HVM       (1 << 2)
 #define XCFLAGS_STDVGA    (1 << 3)
 #define XCFLAGS_CHECKPOINT_COMPRESS    (1 << 4)
-#define XCFLAGS_CHECKPOINTED    (1 << 5)
 
 #define X86_64_B_SIZE   64 
 #define X86_32_B_SIZE   32

tools/libxc/include/xenguest.h struct save_callbacks { · line 88

Quoted 5 lines
tools/libxc/include/xenguest.h +2 -0
@@ -85,16 +84,20 @@ struct save_callbacks {
  * @parm xch a handle to an open hypervisor interface
  * @parm fd the file descriptor to save a domain to
  * @parm dom the id of the domain
+ * @parm checkpointed_stream non-zero if the far end of the stream is using
+ *       checkpointing

Do (or will) specific non-zero values have any meaning to the libxc layer? i.e. does it have any knowledge of COLO vs. Remus as the libxl enum added in the last patch does?

If (as I hope) the answer is no then this should be a boolean and the libxl code which propagates the enum into this field ought to use some appropriate condition (!= ..._NONE most likely).

Ian.

#41 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 13/25] migration/save: pass checkpointed_stream from libxl to libxc

Quoted 33 lines · Ian Campbell
Quoted 32 lines · Yang Hongyang

Pass checkpointed_stream from libxl to libxc.
It won't affact legacy migration because legacy migration won't use this param.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Andrew Cooper <[email protected]>
---
  tools/libxc/include/xenguest.h   |  9 ++++++---
  tools/libxc/xc_domain_save.c     |  6 ++++--
  tools/libxc/xc_nomigrate.c       |  3 ++-
  tools/libxc/xc_sr_common.h       |  2 +-
  tools/libxc/xc_sr_save.c         |  5 +++--
  tools/libxl/libxl.c              |  2 ++
  tools/libxl/libxl_dom_save.c     | 11 ++++++++---
  tools/libxl/libxl_internal.h     |  1 +
  tools/libxl/libxl_save_callout.c |  2 +-
  tools/libxl/libxl_save_helper.c  |  3 ++-
  10 files changed, 30 insertions(+), 14 deletions(-)
tools/libxc/include/xenguest.h +0 -1
index e95af54..6e24b6c 100644
@@ -30,7 +30,6 @@
  #define XCFLAGS_HVM       (1 << 2)
  #define XCFLAGS_STDVGA    (1 << 3)
  #define XCFLAGS_CHECKPOINT_COMPRESS    (1 << 4)
-#define XCFLAGS_CHECKPOINTED    (1 << 5)
 
Quoted 12 lines

tools/libxc/include/xenguest.h struct save_callbacks { · line 88

Quoted 8 lines
tools/libxc/include/xenguest.h +2 -0
  #define X86_64_B_SIZE   64
  #define X86_32_B_SIZE   32
@@ -85,16 +84,20 @@ struct save_callbacks {
   * @parm xch a handle to an open hypervisor interface
   * @parm fd the file descriptor to save a domain to
   * @parm dom the id of the domain
+ * @parm checkpointed_stream non-zero if the far end of the stream is using
+ *       checkpointing

Do (or will) specific non-zero values have any meaning to the libxc layer? i.e. does it have any knowledge of COLO vs. Remus as the libxl enum added in the last patch does?

Yes, libxc side should be aware of the type of checkpointed_stream (Remus or COLO).

I think it is better to document the non-zero values here?
for example:
* @parm checkpointed_stream non-zero if the far end of the stream is using
* checkpointing
* 0 no checkpointed stream
* 1 Remus
* 2 COLO

Quoted 9 lines

If (as I hope) the answer is no then this should be a boolean and the libxl code which propagates the enum into this field ought to use some appropriate condition (!= ..._NONE most likely).

Ian.

.

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

Re: [PATCH v4 --for 4.6 COLOPre 13/25] migration/save: pass checkpointed_stream from libxl to libxc

Quoted 48 lines · Yang Hongyang
Quoted 33 lines · Ian Campbell
Quoted 32 lines · Yang Hongyang

Pass checkpointed_stream from libxl to libxc.
It won't affact legacy migration because legacy migration won't use this param.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Andrew Cooper <[email protected]>
---
  tools/libxc/include/xenguest.h   |  9 ++++++---
  tools/libxc/xc_domain_save.c     |  6 ++++--
  tools/libxc/xc_nomigrate.c       |  3 ++-
  tools/libxc/xc_sr_common.h       |  2 +-
  tools/libxc/xc_sr_save.c         |  5 +++--
  tools/libxl/libxl.c              |  2 ++
  tools/libxl/libxl_dom_save.c     | 11 ++++++++---
  tools/libxl/libxl_internal.h     |  1 +
  tools/libxl/libxl_save_callout.c |  2 +-
  tools/libxl/libxl_save_helper.c  |  3 ++-
  10 files changed, 30 insertions(+), 14 deletions(-)
tools/libxc/include/xenguest.h +0 -1
index e95af54..6e24b6c 100644
@@ -30,7 +30,6 @@
  #define XCFLAGS_HVM       (1 << 2)
  #define XCFLAGS_STDVGA    (1 << 3)
  #define XCFLAGS_CHECKPOINT_COMPRESS    (1 << 4)
-#define XCFLAGS_CHECKPOINTED    (1 << 5)
 
Quoted 12 lines

tools/libxc/include/xenguest.h struct save_callbacks { · line 88

Quoted 8 lines
tools/libxc/include/xenguest.h +2 -0
  #define X86_64_B_SIZE   64
  #define X86_32_B_SIZE   32
@@ -85,16 +84,20 @@ struct save_callbacks {
   * @parm xch a handle to an open hypervisor interface
   * @parm fd the file descriptor to save a domain to
   * @parm dom the id of the domain
+ * @parm checkpointed_stream non-zero if the far end of the stream is using
+ *       checkpointing

Do (or will) specific non-zero values have any meaning to the libxc layer? i.e. does it have any knowledge of COLO vs. Remus as the libxl enum added in the last patch does?

Quoted 2 lines

Yes, libxc side should be aware of the type of checkpointed_stream (Remus or COLO).

In which case I'm afraid something somewhere needs to explicitly convert from the LIBXL_ namespace to the libxc one (which would be better made explicit with their own names not open coded numbers). See the handling of libxl_tsc_mode or libxl_trigger for an example.

Alternatively you could add a comment to libxl_types.idl like libxl_timer_mode and libxl_shutdown_reason have indicating that these values must remain consistent with some underlying interface. I don't much like that but it is tolerable I suppose.

Quoted 8 lines

I think it is better to document the non-zero values here?
for example:
* @parm checkpointed_stream non-zero if the far end of the stream is using
* checkpointing
* 0 no checkpointed stream
* 1 Remus
* 2 COLO

I'd prefer named constants in the XC_ namespace.

Ian.

#43 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 13/25] migration/save: pass checkpointed_stream from libxl to libxc

In reply to Yang Hongyang
Quoted 52 lines · Yang Hongyang
Quoted 33 lines · Ian Campbell
Quoted 32 lines · Yang Hongyang

Pass checkpointed_stream from libxl to libxc.
It won't affact legacy migration because legacy migration won't use this param.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Andrew Cooper <[email protected]>
---
 tools/libxc/include/xenguest.h   |  9 ++++++---
 tools/libxc/xc_domain_save.c     |  6 ++++--
 tools/libxc/xc_nomigrate.c       |  3 ++-
 tools/libxc/xc_sr_common.h       |  2 +-
 tools/libxc/xc_sr_save.c         |  5 +++--
 tools/libxl/libxl.c              |  2 ++
 tools/libxl/libxl_dom_save.c     | 11 ++++++++---
 tools/libxl/libxl_internal.h     |  1 +
 tools/libxl/libxl_save_callout.c |  2 +-
 tools/libxl/libxl_save_helper.c  |  3 ++-
 10 files changed, 30 insertions(+), 14 deletions(-)
tools/libxc/include/xenguest.h +0 -1
index e95af54..6e24b6c 100644
@@ -30,7 +30,6 @@
 #define XCFLAGS_HVM       (1 << 2)
 #define XCFLAGS_STDVGA    (1 << 3)
 #define XCFLAGS_CHECKPOINT_COMPRESS    (1 << 4)
-#define XCFLAGS_CHECKPOINTED    (1 << 5)
 
Quoted 12 lines

tools/libxc/include/xenguest.h struct save_callbacks { · line 88

Quoted 8 lines
tools/libxc/include/xenguest.h +2 -0
 #define X86_64_B_SIZE   64
 #define X86_32_B_SIZE   32
@@ -85,16 +84,20 @@ struct save_callbacks {
  * @parm xch a handle to an open hypervisor interface
  * @parm fd the file descriptor to save a domain to
  * @parm dom the id of the domain
+ * @parm checkpointed_stream non-zero if the far end of the stream is using
+ *       checkpointing

Do (or will) specific non-zero values have any meaning to the libxc layer? i.e. does it have any knowledge of COLO vs. Remus as the libxl enum added in the last patch does?

Yes, libxc side should be aware of the type of checkpointed_stream (Remus or COLO).

Quoted 8 lines

I think it is better to document the non-zero values here?
for example:
* @parm checkpointed_stream non-zero if the far end of the stream is using
* checkpointing
* 0 no checkpointed stream
* 1 Remus
* 2 COLO

These should be proper #defines instead of being buried in comments -- so that you can use them in code.

Wei.

#44 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 13/25] migration/save: pass checkpointed_stream from libxl to libxc

Quoted 62 lines · Wei Liu
Quoted 52 lines · Yang Hongyang
Quoted 33 lines · Ian Campbell
Quoted 32 lines · Yang Hongyang

Pass checkpointed_stream from libxl to libxc.
It won't affact legacy migration because legacy migration won't use this param.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Andrew Cooper <[email protected]>
---
  tools/libxc/include/xenguest.h   |  9 ++++++---
  tools/libxc/xc_domain_save.c     |  6 ++++--
  tools/libxc/xc_nomigrate.c       |  3 ++-
  tools/libxc/xc_sr_common.h       |  2 +-
  tools/libxc/xc_sr_save.c         |  5 +++--
  tools/libxl/libxl.c              |  2 ++
  tools/libxl/libxl_dom_save.c     | 11 ++++++++---
  tools/libxl/libxl_internal.h     |  1 +
  tools/libxl/libxl_save_callout.c |  2 +-
  tools/libxl/libxl_save_helper.c  |  3 ++-
  10 files changed, 30 insertions(+), 14 deletions(-)
tools/libxc/include/xenguest.h +0 -1
index e95af54..6e24b6c 100644
@@ -30,7 +30,6 @@
  #define XCFLAGS_HVM       (1 << 2)
  #define XCFLAGS_STDVGA    (1 << 3)
  #define XCFLAGS_CHECKPOINT_COMPRESS    (1 << 4)
-#define XCFLAGS_CHECKPOINTED    (1 << 5)
 
Quoted 12 lines

tools/libxc/include/xenguest.h struct save_callbacks { · line 88

Quoted 8 lines
tools/libxc/include/xenguest.h +2 -0
  #define X86_64_B_SIZE   64
  #define X86_32_B_SIZE   32
@@ -85,16 +84,20 @@ struct save_callbacks {
   * @parm xch a handle to an open hypervisor interface
   * @parm fd the file descriptor to save a domain to
   * @parm dom the id of the domain
+ * @parm checkpointed_stream non-zero if the far end of the stream is using
+ *       checkpointing

Do (or will) specific non-zero values have any meaning to the libxc layer? i.e. does it have any knowledge of COLO vs. Remus as the libxl enum added in the last patch does?

Yes, libxc side should be aware of the type of checkpointed_stream (Remus or COLO).

Quoted 8 lines

I think it is better to document the non-zero values here?
for example:
* @parm checkpointed_stream non-zero if the far end of the stream is using
* checkpointing
* 0 no checkpointed stream
* 1 Remus
* 2 COLO

Quoted 2 lines

These should be proper #defines instead of being buried in comments -- so that you can use them in code.

Those defines are introduced later in the colo series, I will move them here and follow Ian C's suggestion using XC_ prefix, or I can move this patch down to colo series.

Quoted 4 lines

Wei.
.

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

Re: [PATCH v4 --for 4.6 COLOPre 13/25] migration/save: pass checkpointed_stream from libxl to libxc

On Fri, Jul 17, 2015 at 12:21:11AM +0800, Yang Hongyang wrote:
[...]

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 3 lines

Do (or will) specific non-zero values have any meaning to the libxc layer? i.e. does it have any knowledge of COLO vs. Remus as the libxl enum added in the last patch does?

Yes, libxc side should be aware of the type of checkpointed_stream (Remus or COLO).

I think it is better to document the non-zero values here?
for example:
* @parm checkpointed_stream non-zero if the far end of the stream is using
* checkpointing
* 0 no checkpointed stream
* 1 Remus
* 2 COLO

Quoted 7 lines
Quoted 2 lines

These should be proper #defines instead of being buried in comments -- so that you can use them in code.

Those defines are introduced later in the colo series, I will move them here and follow Ian C's suggestion using XC_ prefix, or I can move this patch down to colo series.

Either works for me.

Wei.

#46 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 13/25] migration/save: pass checkpointed_stream from libxl to libxc

In reply to Yang Hongyang
Quoted 10 lines · Yang Hongyang

Pass checkpointed_stream from libxl to libxc.
It won't affact legacy migration because legacy migration won't use this param.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Andrew Cooper <[email protected]>

---

[...]

Quoted 2 lines

+ if (dss->checkpointed_stream && !r_info) {

Please explicitly check for _NONE type instead of relying it of being 0. Arguably the actual value is not going to change in the future but it's better to be explicit.

Wei.

Quoted 8 lines
tools/libxl/libxl_dom_save.c +5 -0
+        LOG(ERROR, "Migration stream is checkpointed, but there's no "
+                   "checkpoint info!");
+        goto out;
+    }
+
     dss->rc = 0;
     logdirty_init(&dss->logdirty);
     dsps->ao = ao;
#47 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 13/25] migration/save: pass checkpointed_stream from libxl to libxc

Quoted 11 lines · Wei Liu
Quoted 10 lines · Yang Hongyang

Pass checkpointed_stream from libxl to libxc.
It won't affact legacy migration because legacy migration won't use this param.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Andrew Cooper <[email protected]>

---

Quoted 7 lines

[...]

Quoted 2 lines

+ if (dss->checkpointed_stream && !r_info) {

Please explicitly check for _NONE type instead of relying it of being 0. Arguably the actual value is not going to change in the future but it's better to be explicit.

I think you mean check xxx != _NONE here, right? will fix.

Quoted 13 lines

Wei.

tools/libxl/libxl_dom_save.c void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) · line 400

Quoted 8 lines
tools/libxl/libxl_dom_save.c +5 -0
+        LOG(ERROR, "Migration stream is checkpointed, but there's no "
+                   "checkpoint info!");
+        goto out;
+    }
+
      dss->rc = 0;
      logdirty_init(&dss->logdirty);
      dsps->ao = ao;

.

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

Re: [PATCH v4 --for 4.6 COLOPre 13/25] migration/save: pass checkpointed_stream from libxl to libxc

Quoted 16 lines · Yang Hongyang
Quoted 13 lines · Wei Liu
Quoted 10 lines · Yang Hongyang

Pass checkpointed_stream from libxl to libxc.
It won't affact legacy migration because legacy migration won't use this param.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Andrew Cooper <[email protected]>

---

[...]

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

+ if (dss->checkpointed_stream && !r_info) {

Please explicitly check for _NONE type instead of relying it of being 0. Arguably the actual value is not going to change in the future but it's better to be explicit.

I think you mean check xxx != _NONE here, right? will fix.

Yes, that's what I meant.

Wei.

#49 lore raw

PATCH v4 14/25 tools/libxl: introduce libxl__domain_restore_device_model to load qemu state

In reply to Yang Hongyang

In normal migration, the qemu state was passed to qemu as a parameter. With COLO, Secondary vm is running. So we will do the following steps at every checkpoint:
1. suspend both primay vm and secondary vm
2. sync the state
3. resume both primary vm and secondary vm
Primary will send qemu's state in step2, and
Secondary's qemu should read it and restore the state before it is resumed. We can not pass the state to qemu as a parameter because Secondary QEMU already started at this point, so we introduce libxl__domain_restore_device_model() to do it.
This API should be called before resuming secondary vm.

---
 tools/libxl/libxl_dom_save.c | 29 +++++++++++++++++++++++++++++
 tools/libxl/libxl_internal.h |  3 +++
 tools/libxl/libxl_qmp.c      | 10 ++++++++++
 3 files changed, 42 insertions(+)
tools/libxl/libxl_dom_save.c +29 -0
index f89f5d4..0926b71 100644
@@ -675,6 +675,35 @@ out:
     return ret;
 }
 
+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 +3 -0
index 0eb5f41..fb777c1 100644
@@ -1074,6 +1074,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,
@@ -1702,6 +1703,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 6484f5e..080cb9f 100644
@@ -904,6 +904,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
#50 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 14/25] tools/libxl: introduce libxl__domain_restore_device_model to load qemu state

Quoted 4 lines · Yang Hongyang

In normal migration, the qemu state was passed to qemu as a parameter. With COLO, Secondary vm is running. So we will do the following steps at every checkpoint:
1. suspend both primay vm and secondary vm

"primary"

Quoted 32 lines

2. sync the state
3. resume both primary vm and secondary vm
Primary will send qemu's state in step2, and
Secondary's qemu should read it and restore the state before it is resumed. We can not pass the state to qemu as a parameter because Secondary QEMU already started at this point, so we introduce libxl__domain_restore_device_model() to do it.
This API should be called before resuming secondary vm.

---
 tools/libxl/libxl_dom_save.c | 29 +++++++++++++++++++++++++++++
 tools/libxl/libxl_internal.h |  3 +++
 tools/libxl/libxl_qmp.c      | 10 ++++++++++
 3 files changed, 42 insertions(+)
tools/libxl/libxl_dom_save.c +6 -0
index f89f5d4..0926b71 100644
@@ -675,6 +675,35 @@ out:
     return ret;
 }
 
+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)) {

tools/libxl/libxl_dom_save.c out: · line 693

Quoted 10 lines
tools/libxl/libxl_dom_save.c +10 -0
+    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.
+         */

It occurs to me that domid shouldn't change for the duration of a COLO run, right?

Thus I think the path can be allocated once at start of day and not per iteration, and can be stored in suspend_state (or similar) and passed in here. Hence no complexity like a nested ao is needed.

Quoted 58 lines
tools/libxl/libxl_dom_save.c +13 -0
+        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 +3 -0
index 0eb5f41..fb777c1 100644
@@ -1074,6 +1074,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,
@@ -1702,6 +1703,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 6484f5e..080cb9f 100644
@@ -904,6 +904,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)
 {
#51 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 14/25] tools/libxl: introduce libxl__domain_restore_device_model to load qemu state

Quoted 45 lines · Ian Campbell
Quoted 4 lines · Yang Hongyang

In normal migration, the qemu state was passed to qemu as a parameter. With COLO, Secondary vm is running. So we will do the following steps at every checkpoint:
1. suspend both primay vm and secondary vm

"primary"

Quoted 37 lines

2. sync the state
3. resume both primary vm and secondary vm
Primary will send qemu's state in step2, and
Secondary's qemu should read it and restore the state before it is resumed. We can not pass the state to qemu as a parameter because Secondary QEMU already started at this point, so we introduce libxl__domain_restore_device_model() to do it.
This API should be called before resuming secondary vm.

---
  tools/libxl/libxl_dom_save.c | 29 +++++++++++++++++++++++++++++
  tools/libxl/libxl_internal.h |  3 +++
  tools/libxl/libxl_qmp.c      | 10 ++++++++++
  3 files changed, 42 insertions(+)
tools/libxl/libxl_dom_save.c +11 -0
index f89f5d4..0926b71 100644
@@ -675,6 +675,35 @@ out:
      return ret;
  }
 
+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:
Quoted 8 lines

tools/libxl/libxl_dom_save.c out: · line 693

Quoted 5 lines
tools/libxl/libxl_dom_save.c +5 -0
+        /*
+         * 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.
+         */

It occurs to me that domid shouldn't change for the duration of a COLO run, right?

right!

Quoted 4 lines

Thus I think the path can be allocated once at start of day and not per iteration, and can be stored in suspend_state (or similar) and passed in here. Hence no complexity like a nested ao is needed.

Good idea, thank you!

Quoted 63 lines
Quoted 49 lines
tools/libxl/libxl_dom_save.c +13 -0
+        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 +3 -0
index 0eb5f41..fb777c1 100644
@@ -1074,6 +1074,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,
@@ -1702,6 +1703,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 6484f5e..080cb9f 100644
@@ -904,6 +904,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 919

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.
#52 lore raw

PATCH v4 15/25 tools/libxl: check QEMU state before resume dm

In reply to Yang Hongyang

check QEMU state before resume dm on QEMU_XEN_TRADITIONAL.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxl/libxl_dom_suspend.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
tools/libxl/libxl_dom_suspend.c +11 -2
index 6f04c26..686a49b 100644
@@ -434,11 +434,20 @@ static void domain_suspend_callback_common_done(libxl__egc *egc,
 
 int libxl__domain_resume_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: {
-        libxl__qemu_traditional_cmd(gc, domid, "continue");
-        libxl__wait_for_device_model_deprecated(gc, domid, "running", NULL, NULL, NULL);
+        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:
Signature · 1 line
1.9.1
#53 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 15/25] tools/libxl: check QEMU state before resume dm

Quoted 15 lines · Yang Hongyang

check QEMU state before resume dm on QEMU_XEN_TRADITIONAL.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxl/libxl_dom_suspend.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
tools/libxl/libxl_dom_suspend.c +0 -0
index 6f04c26..686a49b 100644

tools/libxl/libxl_dom_suspend.c static void domain_suspend_callback_common_done(libxl__egc *egc, · line 438

Quoted 5 lines
tools/libxl/libxl_dom_suspend.c +2 -0
@@ -434,11 +434,20 @@ static void domain_suspend_callback_common_done(libxl__egc *egc,
 
 int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid)
 {
+    char *path;
+    char *state;

Can both be const.

Could also be on one line, but that is is a matter of taste so up to you.

tools/libxl/libxl_dom_suspend.c static void domain_suspend_callback_common_done(libxl__egc *egc, · line 447

Quoted 10 lines
tools/libxl/libxl_dom_suspend.c +6 -2
     switch (libxl__device_model_version_running(gc, domid)) {
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
-        libxl__qemu_traditional_cmd(gc, domid, "continue");
-        libxl__wait_for_device_model_deprecated(gc, domid, "running", NULL, NULL, NULL);
+        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");

Please can you explain the apparent discrepancy between the use of dm_domid and domid here?

Quoted 6 lines
tools/libxl/libxl_dom_suspend.c +3 -0
+            libxl__wait_for_device_model_deprecated(gc, domid, "running",
+                                                    NULL, NULL, NULL);
+        }
         break;
     }
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
#54 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 15/25] tools/libxl: check QEMU state before resume dm

Quoted 11 lines · Ian Campbell

tools/libxl/libxl_dom_suspend.c static void domain_suspend_callback_common_done(libxl__egc *egc, · line 447

Quoted 10 lines
     switch (libxl__device_model_version_running(gc, domid)) {
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
tools/libxl/libxl_dom_suspend.c +6 -2
-        libxl__qemu_traditional_cmd(gc, domid, "continue");
-        libxl__wait_for_device_model_deprecated(gc, domid, "running", NULL, NULL, NULL);
+        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");
Quoted 2 lines

Please can you explain the apparent discrepancy between the use of dm_domid and domid here?

I see from the next patch that this pattern came from the existing libxl_domain_unpause, which hopes to use this helper in the future.

Looking at git annotate:

83cc69fa        (Ian Jackson    2012-06-28 18:43:28 +0100       1045)    if (type == LIBXL_DOMAIN_TYPE_HVM) {
1fc3aeb3        (   Wei Liu     2015-04-09 19:49:25 +0100       1046)        uint32_t dm_domid = libxl_get_stubdom_id(ctx, domid);
1fc3aeb3        (   Wei Liu     2015-04-09 19:49:25 +0100       1047)
1fc3aeb3        (   Wei Liu     2015-04-09 19:49:25 +0100       1048)        path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state");
bdf07e8e        (Ian Jackson    2011-12-12 17:48:42 +0000       1049)        state = libxl__xs_read(gc, XBT_NULL, path);
d1c7c3ef        (Keir Fraser    2009-11-30 10:53:39 +0000       1050)        if (state != NULL && !strcmp(state, "paused")) {
0cb90b31        (Shriram Rajagopalan    2012-02-09 18:07:48 +0000       1051)            libxl__qemu_traditional_cmd(gc, domid, "continue");
47cb2273        (Ian Jackson    2013-10-14 17:26:01 +0100       1052)            libxl__wait_for_device_model_deprecated(gc, domid, "running",
3b6eaa3e        (Ian Campbell   2011-05-24 15:57:24 +0100       1053)                                         NULL, NULL, NULL);
d1c7c3ef        (Keir Fraser    2009-11-30 10:53:39 +0000       1054)        }

It seems this came from Wei in 1fc3aeb3aa26 "libxl: use new QEMU xenstore protocol". I suspect it was a mistake. Wei?

Ian.

#55 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 15/25] tools/libxl: check QEMU state before resume dm

Quoted 30 lines · Ian Campbell
Quoted 11 lines · Ian Campbell

tools/libxl/libxl_dom_suspend.c static void domain_suspend_callback_common_done(libxl__egc *egc, · line 447

Quoted 10 lines
     switch (libxl__device_model_version_running(gc, domid)) {
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
tools/libxl/libxl_dom_suspend.c +6 -2
-        libxl__qemu_traditional_cmd(gc, domid, "continue");
-        libxl__wait_for_device_model_deprecated(gc, domid, "running", NULL, NULL, NULL);
+        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");
Quoted 2 lines

Please can you explain the apparent discrepancy between the use of dm_domid and domid here?

I see from the next patch that this pattern came from the existing libxl_domain_unpause, which hopes to use this helper in the future.

Looking at git annotate:

83cc69fa        (Ian Jackson    2012-06-28 18:43:28 +0100       1045)    if (type == LIBXL_DOMAIN_TYPE_HVM) {
1fc3aeb3        (   Wei Liu     2015-04-09 19:49:25 +0100       1046)        uint32_t dm_domid = libxl_get_stubdom_id(ctx, domid);
1fc3aeb3        (   Wei Liu     2015-04-09 19:49:25 +0100       1047)
1fc3aeb3        (   Wei Liu     2015-04-09 19:49:25 +0100       1048)        path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state");
bdf07e8e        (Ian Jackson    2011-12-12 17:48:42 +0000       1049)        state = libxl__xs_read(gc, XBT_NULL, path);
d1c7c3ef        (Keir Fraser    2009-11-30 10:53:39 +0000       1050)        if (state != NULL && !strcmp(state, "paused")) {
0cb90b31        (Shriram Rajagopalan    2012-02-09 18:07:48 +0000       1051)            libxl__qemu_traditional_cmd(gc, domid, "continue");
47cb2273        (Ian Jackson    2013-10-14 17:26:01 +0100       1052)            libxl__wait_for_device_model_deprecated(gc, domid, "running",
3b6eaa3e        (Ian Campbell   2011-05-24 15:57:24 +0100       1053)                                         NULL, NULL, NULL);
d1c7c3ef        (Keir Fraser    2009-11-30 10:53:39 +0000       1054)        }
Quoted 3 lines

It seems this came from Wei in 1fc3aeb3aa26 "libxl: use new QEMU xenstore protocol". I suspect it was a mistake. Wei?

No, it's not.

libxl__qemu_traditional_cmd accepts domid and then it calls libxl_get_stubdom_id to extract dm_domid.

Wei.

Quoted 1 line

Ian.

#56 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 15/25] tools/libxl: check QEMU state before resume dm

Quoted 31 lines · Wei Liu
Quoted 30 lines · Ian Campbell
Quoted 11 lines · Ian Campbell

tools/libxl/libxl_dom_suspend.c static void domain_suspend_callback_common_done(libxl__egc *egc, · line 447

Quoted 10 lines
     switch (libxl__device_model_version_running(gc, domid)) {
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
tools/libxl/libxl_dom_suspend.c +6 -2
-        libxl__qemu_traditional_cmd(gc, domid, "continue");
-        libxl__wait_for_device_model_deprecated(gc, domid, "running", NULL, NULL, NULL);
+        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");
Quoted 2 lines

Please can you explain the apparent discrepancy between the use of dm_domid and domid here?

I see from the next patch that this pattern came from the existing libxl_domain_unpause, which hopes to use this helper in the future.

Looking at git annotate:

83cc69fa        (Ian Jackson    2012-06-28 18:43:28 +0100       1045)    if (type == LIBXL_DOMAIN_TYPE_HVM) {
1fc3aeb3        (   Wei Liu     2015-04-09 19:49:25 +0100       1046)        uint32_t dm_domid = libxl_get_stubdom_id(ctx, domid);
1fc3aeb3        (   Wei Liu     2015-04-09 19:49:25 +0100       1047)
1fc3aeb3        (   Wei Liu     2015-04-09 19:49:25 +0100       1048)        path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state");
bdf07e8e        (Ian Jackson    2011-12-12 17:48:42 +0000       1049)        state = libxl__xs_read(gc, XBT_NULL, path);
d1c7c3ef        (Keir Fraser    2009-11-30 10:53:39 +0000       1050)        if (state != NULL && !strcmp(state, "paused")) {
0cb90b31        (Shriram Rajagopalan    2012-02-09 18:07:48 +0000       1051)            libxl__qemu_traditional_cmd(gc, domid, "continue");
47cb2273        (Ian Jackson    2013-10-14 17:26:01 +0100       1052)            libxl__wait_for_device_model_deprecated(gc, domid, "running",
3b6eaa3e        (Ian Campbell   2011-05-24 15:57:24 +0100       1053)                                         NULL, NULL, NULL);
d1c7c3ef        (Keir Fraser    2009-11-30 10:53:39 +0000       1054)        }
Quoted 8 lines
Quoted 3 lines

It seems this came from Wei in 1fc3aeb3aa26 "libxl: use new QEMU xenstore protocol". I suspect it was a mistake. Wei?

No, it's not.

libxl__qemu_traditional_cmd accepts domid and then it calls libxl_get_stubdom_id to extract dm_domid.

How... exciting.

Some sort of helper to get the DM state would help to hide this sort of wrinkle.

Anyway, I shall go see if this means I can ack the COLO patches which moved this code.

Ian.

Acked-by
#57 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 15/25] tools/libxl: check QEMU state before resume dm

In reply to Ian Campbell
Quoted 38 lines · Ian Campbell
Quoted 15 lines · Yang Hongyang

check QEMU state before resume dm on QEMU_XEN_TRADITIONAL.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxl/libxl_dom_suspend.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
tools/libxl/libxl_dom_suspend.c +0 -0
index 6f04c26..686a49b 100644

tools/libxl/libxl_dom_suspend.c static void domain_suspend_callback_common_done(libxl__egc *egc, · line 438

Quoted 5 lines
tools/libxl/libxl_dom_suspend.c +2 -0
@@ -434,11 +434,20 @@ static void domain_suspend_callback_common_done(libxl__egc *egc,
 
 int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid)
 {
+    char *path;
+    char *state;

Can both be const.

Could also be on one line, but that is is a matter of taste so up to you.

tools/libxl/libxl_dom_suspend.c static void domain_suspend_callback_common_done(libxl__egc *egc, · line 447

Quoted 10 lines
tools/libxl/libxl_dom_suspend.c +6 -2
     switch (libxl__device_model_version_running(gc, domid)) {
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
-        libxl__qemu_traditional_cmd(gc, domid, "continue");
-        libxl__wait_for_device_model_deprecated(gc, domid, "running", NULL, NULL, NULL);
+        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");
Quoted 2 lines

Please can you explain the apparent discrepancy between the use of dm_domid and domid here?

Wei explained this, so with at least the const-ness issue mentioned above fixed:

Acked-by on v4 15/25
#58 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 15/25] tools/libxl: check QEMU state before resume dm

In reply to Yang Hongyang
Quoted 6 lines · Yang Hongyang

check QEMU state before resume dm on QEMU_XEN_TRADITIONAL.

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

I think it was me who suggested this and this patch looks correct.

Quoted 39 lines
---
 tools/libxl/libxl_dom_suspend.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
tools/libxl/libxl_dom_suspend.c +11 -2
index 6f04c26..686a49b 100644
@@ -434,11 +434,20 @@ static void domain_suspend_callback_common_done(libxl__egc *egc,
 
 int libxl__domain_resume_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: {
-        libxl__qemu_traditional_cmd(gc, domid, "continue");
-        libxl__wait_for_device_model_deprecated(gc, domid, "running", NULL, NULL, NULL);
+        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:
Signature · 7 lines
1.9.1


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

Re: [PATCH v4 --for 4.6 COLOPre 15/25] tools/libxl: check QEMU state before resume dm

Quoted 11 lines · Wei Liu
Quoted 6 lines · Yang Hongyang

check QEMU state before resume dm on QEMU_XEN_TRADITIONAL.

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

I think it was me who suggested this and this patch looks correct.

Thanks!

Quoted 42 lines
Quoted 36 lines
---
  tools/libxl/libxl_dom_suspend.c | 13 +++++++++++--
  1 file changed, 11 insertions(+), 2 deletions(-)
tools/libxl/libxl_dom_suspend.c +11 -3
index 6f04c26..686a49b 100644
@@ -434,11 +434,20 @@ static void domain_suspend_callback_common_done(libxl__egc *egc,
 
  int libxl__domain_resume_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: {
-        libxl__qemu_traditional_cmd(gc, domid, "continue");
-        libxl__wait_for_device_model_deprecated(gc, domid, "running", NULL, NULL, NULL);
+        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:
--

1.9.1

Quoted 4 lines

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

.

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

PATCH v4 16/25 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. We use libxl__domain_resume_device_model to unpause guest dm.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxl/libxl.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
tools/libxl/libxl.c +5 -10
index 5b2d045..799aead 100644
@@ -941,8 +941,6 @@ out:
 int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
 {
     GC_INIT(ctx);
-    char *path;
-    char *state;
     int ret, rc = 0;
 
     libxl_domain_type type = libxl__domain_type(gc, domid);
@@ -952,14 +950,11 @@ 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);
-
-        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_resume_device_model(gc, domid);
+        if (rc < 0) {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "failed to unpause device model "
+                       "for domain %u:%d", domid, rc);
+            goto out;
         }
     }
     ret = xc_domain_unpause(ctx->xch, domid);
Signature · 1 line
1.9.1
#61 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 16/25] tools/libxl: Update libxl_domain_unpause() to support qemu-xen

Quoted 31 lines · Yang Hongyang

Currently, libxl__domain_unpause() only supports qemu-xen-traditional. Update it to support qemu-xen. We use libxl__domain_resume_device_model to unpause guest dm.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxl/libxl.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
tools/libxl/libxl.c +0 -4
index 5b2d045..799aead 100644
@@ -941,8 +941,6 @@ out:
 int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
 {
     GC_INIT(ctx);
-    char *path;
-    char *state;
     int ret, rc = 0;
 
     libxl_domain_type type = libxl__domain_type(gc, domid);
@@ -952,14 +950,11 @@ 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);
-

tools/libxl/libxl.c int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid) · line 956

Quoted 10 lines
tools/libxl/libxl.c +4 -6
-        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_resume_device_model(gc, domid);
+        if (rc < 0) {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "failed to unpause device model "
+                       "for domain %u:%d", domid, rc);

Please use the preferred form of LOG(ERROR, "failed to..."), which should also hopefully allow you to avoid splitting the line in the middle of a string constant which is discouraged.

If you can't use LOG() then please:
LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
"failed to unpause device model for domain %u:%d",
domid, rc);

Not splitting string constants means you can grep for an error message.

Ian.

#62 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 16/25] tools/libxl: Update libxl_domain_unpause() to support qemu-xen

Quoted 47 lines · Ian Campbell
Quoted 31 lines · Yang Hongyang

Currently, libxl__domain_unpause() only supports qemu-xen-traditional. Update it to support qemu-xen. We use libxl__domain_resume_device_model to unpause guest dm.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
  tools/libxl/libxl.c | 15 +++++----------
  1 file changed, 5 insertions(+), 10 deletions(-)
tools/libxl/libxl.c +0 -4
index 5b2d045..799aead 100644
@@ -941,8 +941,6 @@ out:
  int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
  {
      GC_INIT(ctx);
-    char *path;
-    char *state;
      int ret, rc = 0;
 
      libxl_domain_type type = libxl__domain_type(gc, domid);
@@ -952,14 +950,11 @@ 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);
-

tools/libxl/libxl.c int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid) · line 956

Quoted 10 lines
tools/libxl/libxl.c +4 -6
-        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_resume_device_model(gc, domid);
+        if (rc < 0) {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "failed to unpause device model "
+                       "for domain %u:%d", domid, rc);

Please use the preferred form of LOG(ERROR, "failed to..."), which should also hopefully allow you to avoid splitting the line in the middle of a string constant which is discouraged.

Quoted 6 lines

If you can't use LOG() then please:
LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
"failed to unpause device model for domain %u:%d",
domid, rc);

Not splitting string constants means you can grep for an error message.

Sorry, the commit message is wrong, it's libxl_domain_unpause, not libxl__domain_unpause, LOG() can't be used, so I will update commit message and use your later suggestion, thank you!

Quoted 5 lines

Ian.

.

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

Re: [PATCH v4 --for 4.6 COLOPre 16/25] tools/libxl: Update libxl_domain_unpause() to support qemu-xen

Quoted 54 lines · Yang Hongyang
Quoted 52 lines · Ian Campbell
Quoted 31 lines · Yang Hongyang

Currently, libxl__domain_unpause() only supports qemu-xen-traditional. Update it to support qemu-xen. We use libxl__domain_resume_device_model to unpause guest dm.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
  tools/libxl/libxl.c | 15 +++++----------
  1 file changed, 5 insertions(+), 10 deletions(-)
tools/libxl/libxl.c +0 -4
index 5b2d045..799aead 100644
@@ -941,8 +941,6 @@ out:
  int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
  {
      GC_INIT(ctx);
-    char *path;
-    char *state;
      int ret, rc = 0;
 
      libxl_domain_type type = libxl__domain_type(gc, domid);
@@ -952,14 +950,11 @@ 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);
-

tools/libxl/libxl.c int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid) · line 956

Quoted 10 lines
tools/libxl/libxl.c +4 -6
-        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_resume_device_model(gc, domid);
+        if (rc < 0) {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "failed to unpause device model "
+                       "for domain %u:%d", domid, rc);

Please use the preferred form of LOG(ERROR, "failed to..."), which should also hopefully allow you to avoid splitting the line in the middle of a string constant which is discouraged.

If you can't use LOG() then please:
LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
"failed to unpause device model for domain %u:%d",
domid, rc);

Quoted 5 lines
Quoted 1 line

Not splitting string constants means you can grep for an error message.

Sorry, the commit message is wrong, it's libxl_domain_unpause, not libxl__domain_unpause, LOG() can't be used, so I will update commit message and use your later suggestion, thank you!

Why can't LOG() be used? libxl_domain_unpause has a GC_INIT(ctx), so you should have a gc in scope, which is all you need.

Ian.

#64 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 16/25] tools/libxl: Update libxl_domain_unpause() to support qemu-xen

Quoted 55 lines · Ian Campbell
Quoted 54 lines · Yang Hongyang
Quoted 52 lines · Ian Campbell
Quoted 31 lines · Yang Hongyang

Currently, libxl__domain_unpause() only supports qemu-xen-traditional. Update it to support qemu-xen. We use libxl__domain_resume_device_model to unpause guest dm.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
   tools/libxl/libxl.c | 15 +++++----------
   1 file changed, 5 insertions(+), 10 deletions(-)
tools/libxl/libxl.c +0 -4
index 5b2d045..799aead 100644
@@ -941,8 +941,6 @@ out:
   int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
   {
       GC_INIT(ctx);
-    char *path;
-    char *state;
       int ret, rc = 0;
 
       libxl_domain_type type = libxl__domain_type(gc, domid);
@@ -952,14 +950,11 @@ 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);
-

tools/libxl/libxl.c int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid) · line 956

Quoted 10 lines
tools/libxl/libxl.c +4 -6
-        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_resume_device_model(gc, domid);
+        if (rc < 0) {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "failed to unpause device model "
+                       "for domain %u:%d", domid, rc);

Please use the preferred form of LOG(ERROR, "failed to..."), which should also hopefully allow you to avoid splitting the line in the middle of a string constant which is discouraged.

If you can't use LOG() then please:
LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
"failed to unpause device model for domain %u:%d",
domid, rc);

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Not splitting string constants means you can grep for an error message.

Sorry, the commit message is wrong, it's libxl_domain_unpause, not libxl__domain_unpause, LOG() can't be used, so I will update commit message and use your later suggestion, thank you!

Why can't LOG() be used? libxl_domain_unpause has a GC_INIT(ctx), so you should have a gc in scope, which is all you need.

Sorry, my memory is wrong, fixed now.

Quoted 5 lines

Ian.

.

Signature · 2 lines
Thanks,
Yang.
Acked-by on v4 16/25
#65 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 16/25] tools/libxl: Update libxl_domain_unpause() to support qemu-xen

In reply to Yang Hongyang
Quoted 8 lines · Yang Hongyang

Currently, libxl__domain_unpause() only supports qemu-xen-traditional. Update it to support qemu-xen. We use libxl__domain_resume_device_model to unpause guest dm.

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

I think I suggested this, too.

With Ian's comment addressed:

Quoted 45 lines
---
 tools/libxl/libxl.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
tools/libxl/libxl.c +5 -10
index 5b2d045..799aead 100644
@@ -941,8 +941,6 @@ out:
 int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
 {
     GC_INIT(ctx);
-    char *path;
-    char *state;
     int ret, rc = 0;
 
     libxl_domain_type type = libxl__domain_type(gc, domid);
@@ -952,14 +950,11 @@ 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);
-
-        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_resume_device_model(gc, domid);
+        if (rc < 0) {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "failed to unpause device model "
+                       "for domain %u:%d", domid, rc);
+            goto out;
         }
     }
     ret = xc_domain_unpause(ctx->xch, domid);
Signature · 7 lines
1.9.1


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

PATCH v4 17/25 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 | 93 ++++++++++++++++++++++++--------------------
 tools/libxl/libxl_internal.h |  8 ++++
 2 files changed, 59 insertions(+), 42 deletions(-)
tools/libxl/libxl_dom_save.c +51 -42
index 0926b71..ba7fc42 100644
@@ -59,7 +59,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 rc);
+                                 libxl__logdirty_switch *lds, int rc);
 
 static void logdirty_init(libxl__logdirty_switch *lds)
 {
@@ -69,13 +69,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 = shs->caller_state;
-    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;
@@ -137,26 +134,34 @@ static void domain_suspend_switch_qemu_xen_traditional_logdirty
  out:
     LOG(ERROR,"logdirty switch failed (rc=%d), abandoning suspend",rc);
     libxl__xs_transaction_abort(gc, &t);
-    switch_logdirty_done(egc,dss,rc);
+    switch_logdirty_done(egc,lds,rc);
 }
 
 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 = shs->caller_state;
-    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);
-    } else {
+    if (rc)
         LOG(ERROR,"logdirty switch failed (rc=%d), abandoning suspend",rc);
+
+    lds->callback(egc, lds, rc);
+}
+
+static void 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);
+
+    if (rc) {
         dss->rc = rc;
-        libxl__xc_domain_saverestore_async_callback_done(egc, shs, -1);
-    }
+        libxl__xc_domain_saverestore_async_callback_done(egc,
+                                                         &dss->sws.shs, -1);
+    } else
+        libxl__xc_domain_saverestore_async_callback_done(egc, &dss->sws.shs, 0);
 }
 
 void libxl__domain_suspend_common_switch_qemu_logdirty
@@ -165,39 +170,49 @@ void libxl__domain_suspend_common_switch_qemu_logdirty
     libxl__save_helper_state *shs = user;
     libxl__egc *egc = shs->egc;
     libxl__domain_save_state *dss = shs->caller_state;
-    STATE_AO_GC(dss->ao);
+
+    /* convenience aliases */
+    libxl__logdirty_switch *const lds = &dss->logdirty;
+
+    lds->callback = 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, abandoning suspend");
-        dss->rc = ERROR_FAIL;
-        libxl__xc_domain_saverestore_async_callback_done(egc, shs, -1);
+        lds->callback(egc, lds, ERROR_FAIL);
     }
 }
 static void switch_logdirty_timeout(libxl__egc *egc, libxl__ev_time *ev,
                                     const struct timeval *requested_abs,
                                     int rc)
 {
-    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,ERROR_FAIL);
+    switch_logdirty_done(egc,lds,ERROR_FAIL);
 }
 
 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;
@@ -243,28 +258,20 @@ static void switch_logdirty_xswatch(libxl__egc *egc, libxl__ev_xswatch *watch,
     if (rc <= 0) {
         if (rc < 0)
             LOG(ERROR,"logdirty switch: failed (rc=%d)",rc);
-        switch_logdirty_done(egc,dss,rc);
+        switch_logdirty_done(egc,lds,rc);
     }
 }
 
 static void switch_logdirty_done(libxl__egc *egc,
-                                 libxl__domain_save_state *dss,
+                                 libxl__logdirty_switch *lds,
                                  int rc)
 {
-    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);
 
-    int broke;
-    if (rc) {
-        broke = -1;
-        dss->rc = rc;
-    } else {
-        broke = 0;
-    }
-    libxl__xc_domain_saverestore_async_callback_done(egc, &dss->sws.shs, broke);
+    lds->callback(egc, lds, rc);
 }
 
 /*----- callbacks, called by xc_domain_save -----*/
@@ -397,6 +404,8 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss)
 
     dss->rc = 0;
     logdirty_init(&dss->logdirty);
+    dss->logdirty.ao = ao;
+
     dsps->ao = ao;
     dsps->domid = domid;
     rc = libxl__domain_suspend_init(egc, dsps);
tools/libxl/libxl_internal.h +8 -0
index fb777c1..0b792e3 100644
@@ -3013,6 +3013,11 @@ libxl__stream_write_inuse(const libxl__stream_write_state *stream)
 }
 
 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;
@@ -3426,6 +3431,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
#67 lore raw

PATCH v4 18/25 tools/libxl: export logdirty_init

In reply to Yang Hongyang

We need to enable logdirty on secondary, so we export logdirty_init for internal use. Rename it to libxl__logdirty_init.

---
 tools/libxl/libxl_dom_save.c | 4 ++--
 tools/libxl/libxl_internal.h | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)
tools/libxl/libxl_dom_save.c +2 -2
index ba7fc42..9364a1d 100644
@@ -61,7 +61,7 @@ static void switch_logdirty_xswatch(libxl__egc *egc, libxl__ev_xswatch*,
 static void switch_logdirty_done(libxl__egc *egc,
                                  libxl__logdirty_switch *lds, int rc);
 
-static void logdirty_init(libxl__logdirty_switch *lds)
+void libxl__logdirty_init(libxl__logdirty_switch *lds)
 {
     lds->cmd_path = 0;
     libxl__ev_xswatch_init(&lds->watch);
@@ -403,7 +403,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss)
     }
 
     dss->rc = 0;
-    logdirty_init(&dss->logdirty);
+    libxl__logdirty_init(&dss->logdirty);
     dss->logdirty.ao = ao;
 
     dsps->ao = ao;
tools/libxl/libxl_internal.h +2 -0
index 0b792e3..219176e 100644
@@ -3025,6 +3025,8 @@ typedef struct libxl__logdirty_switch {
     libxl__ev_time timeout;
 } libxl__logdirty_switch;
 
+_hidden void libxl__logdirty_init(libxl__logdirty_switch *lds);
+
 struct libxl__domain_suspend_state {
     /* set by caller of libxl__domain_suspend_init */
     libxl__ao *ao;
Signature · 1 line
1.9.1
#68 lore raw

PATCH v4 19/25 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.
Extend libxl_domain_create_restore API, add a send_fd param to it.
Add LIBXL_HAVE_CREATE_RESTORE_SEND_FD to indicate the API change.

---
 tools/libxl/libxl.c                  |  2 +-
 tools/libxl/libxl.h                  | 30 ++++++++++++++++++++++++++++--
 tools/libxl/libxl_create.c           |  9 +++++----
 tools/libxl/libxl_internal.h         |  2 ++
 tools/libxl/libxl_types.idl          |  1 +
 tools/libxl/xl_cmdimpl.c             |  8 +++++++-
 tools/ocaml/libs/xl/xenlight_stubs.c |  2 +-
 7 files changed, 45 insertions(+), 9 deletions(-)
tools/libxl/libxl.c +1 -1
index 799aead..fcf91f1 100644
@@ -835,7 +835,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.h +28 -2
index 5a7308d..c492d20 100644
@@ -617,6 +617,15 @@ typedef struct libxl__ctx libxl_ctx;
 #define LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS 1
 
 /*
+ * LIBXL_HAVE_DOMAIN_CREATE_RESTORE_SEND_FD 1
+ *
+ * If this is defined, libxl_domain_create_restore()'s API has changed to
+ * include a send_fd param which used for libxl migration back channel
+ * during COLO FT.
+ */
+#define LIBXL_HAVE_DOMAIN_CREATE_RESTORE_SEND_FD 1
+
+/*
  * LIBXL_HAVE_CREATEINFO_PVH
  * If this is defined, then libxl supports creation of a PVH guest.
  */
@@ -1089,7 +1098,7 @@ int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,
                             const libxl_asyncprogress_how *aop_console_how)
                             LIBXL_EXTERNAL_CALLERS_ONLY;
 int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config,
-                                uint32_t *domid, int restore_fd,
+                                uint32_t *domid, int restore_fd, int send_fd,
                                 const libxl_domain_restore_params *params,
                                 const libxl_asyncop_how *ao_how,
                                 const libxl_asyncprogress_how *aop_console_how)
@@ -1110,7 +1119,7 @@ int static inline libxl_domain_create_restore_0x040200(
     libxl_domain_restore_params_init(&params);
 
     ret = libxl_domain_create_restore(
-        ctx, d_config, domid, restore_fd, &params, ao_how, aop_console_how);
+        ctx, d_config, domid, restore_fd, -1, &params, ao_how, aop_console_how);
 
     libxl_domain_restore_params_dispose(&params);
     return ret;
@@ -1118,6 +1127,23 @@ int static inline libxl_domain_create_restore_0x040200(
 
 #define libxl_domain_create_restore libxl_domain_create_restore_0x040200
 
+#elif defined(LIBXL_API_VERSION) && LIBXL_API_VERSION >= 0x040400 \
+                                 && LIBXL_API_VERSION < 0x040600
+
+int static inline libxl_domain_create_restore_0x040400(
+    libxl_ctx *ctx, libxl_domain_config *d_config,
+    uint32_t *domid, int restore_fd,
+    const libxl_domain_restore_params *params,
+    const libxl_asyncop_how *ao_how,
+    const libxl_asyncprogress_how *aop_console_how)
+    LIBXL_EXTERNAL_CALLERS_ONLY
+{
+    return libxl_domain_create_restore(ctx, d_config, domid, restore_fd,
+                                       -1, params, ao_how, aop_console_how);
+}
+
+#define libxl_domain_create_restore libxl_domain_create_restore_0x040400
+
 #endif
 
   /* A progress report will be made via ao_console_how, of type
tools/libxl/libxl_create.c +5 -4
index cbd7693..1d4b13b 100644
@@ -1498,7 +1498,7 @@ 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,
+                            uint32_t *domid, int restore_fd, int send_fd,
                             const libxl_domain_restore_params *params,
                             const libxl_asyncop_how *ao_how,
                             const libxl_asyncprogress_how *aop_console_how)
@@ -1512,6 +1512,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 = cdcs->dcs.libxc_fd = restore_fd;
+    cdcs->dcs.send_fd = send_fd;
     if (restore_fd > -1)
         cdcs->dcs.restore_params = *params;
     cdcs->dcs.callback = domain_create_cb;
@@ -1540,17 +1541,17 @@ 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, NULL,
+    return do_domain_create(ctx, d_config, domid, -1, -1, NULL,
                             ao_how, aop_console_how);
 }
 
 int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config,
-                                uint32_t *domid, int restore_fd,
+                                uint32_t *domid, int restore_fd, int send_fd,
                                 const libxl_domain_restore_params *params,
                                 const libxl_asyncop_how *ao_how,
                                 const libxl_asyncprogress_how *aop_console_how)
 {
-    return do_domain_create(ctx, d_config, domid, restore_fd, params,
+    return do_domain_create(ctx, d_config, domid, restore_fd, send_fd, params,
                             ao_how, aop_console_how);
 }
 
tools/libxl/libxl_internal.h +2 -0
index 219176e..8a36853 100644
@@ -3057,6 +3057,7 @@ struct libxl__domain_save_state {
 
     uint32_t domid;
     int fd;
+    int recv_fd;
     libxl_domain_type type;
     int live;
     int debug;
@@ -3390,6 +3391,7 @@ struct libxl__domain_create_state {
     libxl_domain_config *guest_config;
     libxl_domain_config guest_config_saved; /* vanilla config */
     int restore_fd, libxc_fd;
+    int send_fd;
     libxl_domain_restore_params restore_params;
     libxl__domain_create_cb *callback;
     libxl_asyncprogress_how aop_console_how;
tools/libxl/libxl_types.idl +1 -0
index 94c230e..e8d3647 100644
@@ -210,6 +210,7 @@ libxl_hdtype = Enumeration("hdtype", [
 libxl_checkpointed_stream = Enumeration("checkpointed_stream", [
     (0, "NONE"),
     (1, "REMUS"),
+    (2, "COLO"),
     ])
 
 #
tools/libxl/xl_cmdimpl.c +7 -1
index aa641fd..ace4a65 100644
@@ -157,6 +157,7 @@ struct domain_create {
     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 */
 };
 
@@ -2560,6 +2561,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;
 
@@ -2576,6 +2578,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);
@@ -2764,7 +2767,7 @@ start:
 
         ret = libxl_domain_create_restore(ctx, &d_config,
                                           &domid, restore_fd,
-                                          &params,
+                                          send_fd, &params,
                                           0, autoconnect_console_how);
 
         libxl_domain_restore_params_dispose(&params);
@@ -4306,6 +4309,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 = checkpointed;
 
@@ -4476,6 +4480,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;
@@ -4943,6 +4948,7 @@ int main_create(int argc, char **argv)
     dom_info.quiet = quiet;
     dom_info.config_file = filename;
     dom_info.migrate_fd = -1;
+    dom_info.send_fd = -1;
     dom_info.vnc = vnc;
     dom_info.vncautopass = vncautopass;
     dom_info.console_autoconnect = console_autoconnect;
tools/ocaml/libs/xl/xenlight_stubs.c +1 -1
index 4133527..1c52c2a 100644
@@ -537,7 +537,7 @@ value stub_libxl_domain_create_restore(value ctx, value domain_config, value par
 	restore_fd = Int_val(Field(params, 0));
 
 	caml_enter_blocking_section();
-	ret = libxl_domain_create_restore(CTX, &c_dconfig, &c_domid, restore_fd,
+	ret = libxl_domain_create_restore(CTX, &c_dconfig, &c_domid, restore_fd, -1,
 		&c_params, ao_how, NULL);
 	caml_leave_blocking_section();
 
Signature · 1 line
1.9.1
#69 lore raw

PATCH v4 20/25 tools/libx{l, c}: add back channel to libxc

In reply to Yang Hongyang

In COLO mode, both VMs are running, and are considered in sync if the visible network traffic is identical. After some time, they fall out of sync.

At this point, the two VMs have definitely diverged. Lets call the primary dirty bitmap set A, while the secondary dirty bitmap set B.

Sets A and B are different.

Under normal migration, the page data for set A will be sent form the primary to the secondary.

However, the set difference B - A (lets call this C) is out-of-date on the secondary (with respect to the primary) and will not be sent by the primary, as it was not memory dirtied by the primary. The secondary needs the page data for C to reconstruct an exact copy of the primary at the checkpoint.

The secondary cannot calculate C as it doesn't know A. Instead, the secondary must send B to the primary, at which point the primary calculates the union of A and B (lets call this D) which is all the pages dirtied by both the primary and the secondary, and sends all page data covered by D.

In the general case, D is a superset of both A and B. Without the backchannel dirty bitmap, a COLO checkpoint can't reconstruct a valid copy of the primary.

We transfer the dirty bitmap on libxc side, so we need to introduce back channel to libxc.

commit message:

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxc/include/xenguest.h   |  8 ++++----
 tools/libxc/xc_domain_restore.c  |  4 ++--
 tools/libxc/xc_domain_save.c     |  4 ++--
 tools/libxc/xc_sr_restore.c      |  2 +-
 tools/libxc/xc_sr_save.c         |  2 +-
 tools/libxl/libxl_save_callout.c | 39 ++++++++++++++++++++++++++-------------
 tools/libxl/libxl_save_helper.c  |  8 ++++++--
 7 files changed, 42 insertions(+), 25 deletions(-)
tools/libxc/include/xenguest.h +4 -4
index 6e24b6c..4056955 100644
@@ -91,13 +91,13 @@ struct save_callbacks {
 int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters,
                    uint32_t max_factor, uint32_t flags /* XCFLAGS_xxx */,
                    struct save_callbacks* callbacks, int hvm,
-                   int checkpointed_stream);
+                   int checkpointed_stream, int back_fd);
 
 /* Domain Save v2 */
 int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters,
                     uint32_t max_factor, uint32_t flags,
                     struct save_callbacks* callbacks, int hvm,
-                    int checkpointed_stream);
+                    int checkpointed_stream, int back_fd);
 
 /* callbacks provided by xc_domain_restore */
 struct restore_callbacks {
@@ -140,7 +140,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
                       unsigned long *console_mfn, domid_t console_domid,
                       unsigned int hvm, unsigned int pae, int superpages,
                       int checkpointed_stream,
-                      struct restore_callbacks *callbacks);
+                      struct restore_callbacks *callbacks, int back_fd);
 
 /* Domain Restore v2 */
 int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom,
@@ -149,7 +149,7 @@ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom,
                        unsigned long *console_mfn, domid_t console_domid,
                        unsigned int hvm, unsigned int pae, int superpages,
                        int checkpointed_stream,
-                       struct restore_callbacks *callbacks);
+                       struct restore_callbacks *callbacks, int back_fd);
 /**
  * xc_domain_restore writes a file to disk that contains the device
  * model saved state.
tools/libxc/xc_domain_restore.c +2 -2
index 3cd3483..63d1e6b 100644
@@ -1515,7 +1515,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
                       unsigned long *console_mfn, domid_t console_domid,
                       unsigned int hvm, unsigned int pae, int superpages,
                       int checkpointed_stream,
-                      struct restore_callbacks *callbacks)
+                      struct restore_callbacks *callbacks, int back_fd)
 {
     DECLARE_DOMCTL;
     xc_dominfo_t info;
@@ -1578,7 +1578,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
         return xc_domain_restore2(
             xch, io_fd, dom, store_evtchn, store_mfn,
             store_domid, console_evtchn, console_mfn, console_domid,
-            hvm,  pae,  superpages, checkpointed_stream, callbacks);
+            hvm,  pae,  superpages, checkpointed_stream, callbacks, back_fd);
     }
 
     DPRINTF("%s: starting restore of new domid %u", __func__, dom);
tools/libxc/xc_domain_save.c +2 -2
index 0da3cca..b111384 100644
@@ -803,7 +803,7 @@ static int save_tsc_info(xc_interface *xch, uint32_t dom, int io_fd)
 int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters,
                    uint32_t max_factor, uint32_t flags,
                    struct save_callbacks* callbacks, int hvm,
-                   int checkpointed_stream)
+                   int checkpointed_stream, int back_fd)
 {
     xc_dominfo_t info;
     DECLARE_DOMCTL;
@@ -899,7 +899,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter
     {
         return xc_domain_save2(xch, io_fd, dom, max_iters,
                                max_factor, flags, callbacks, hvm,
-                               checkpointed_stream);
+                               checkpointed_stream, back_fd);
     }
 
     DPRINTF("%s: starting save of domid %u", __func__, dom);
tools/libxc/xc_sr_restore.c +1 -1
index bf1ee15..504463e 100644
@@ -720,7 +720,7 @@ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom,
                        unsigned long *console_gfn, domid_t console_domid,
                        unsigned int hvm, unsigned int pae, int superpages,
                        int checkpointed_stream,
-                       struct restore_callbacks *callbacks)
+                       struct restore_callbacks *callbacks, int back_fd)
 {
     struct xc_sr_context ctx =
         {
tools/libxc/xc_sr_save.c +1 -1
index 6102b66..d12e5b1 100644
@@ -821,7 +821,7 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)
 int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom,
                     uint32_t max_iters, uint32_t max_factor, uint32_t flags,
                     struct save_callbacks* callbacks, int hvm,
-                    int checkpointed_stream)
+                    int checkpointed_stream, int back_fd)
 {
     xen_pfn_t nr_pfns;
     struct xc_sr_context ctx =
tools/libxl/libxl_save_callout.c +26 -13
index f393abc..f8c6cf0 100644
@@ -27,7 +27,7 @@
  */
 static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
                        const char *mode_arg,
-                       int stream_fd,
+                       int stream_fd, int back_fd,
                        const int *preserve_fds, int num_preserve_fds,
                        const unsigned long *argnums, int num_argnums);
 
@@ -50,6 +50,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs,
     /* Convenience aliases */
     const uint32_t domid = dcs->guest_domid;
     const int restore_fd = dcs->libxc_fd;
+    const int send_fd = dcs->send_fd;
     libxl__domain_build_state *const state = &dcs->build_state;
 
     unsigned cbflags =
@@ -72,7 +73,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs,
     shs->need_results = 1;
     shs->toolstack_data_file = 0;
 
-    run_helper(egc, shs, "--restore-domain", restore_fd, 0, 0,
+    run_helper(egc, shs, "--restore-domain", restore_fd, send_fd, 0, 0,
                argnums, ARRAY_SIZE(argnums));
 }
 
@@ -96,7 +97,7 @@ void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_save_state *dss,
     shs->caller_state = dss;
     shs->need_results = 0;
 
-    run_helper(egc, shs, "--save-domain", dss->fd,
+    run_helper(egc, shs, "--save-domain", dss->fd, dss->recv_fd,
                NULL, 0,
                argnums, ARRAY_SIZE(argnums));
     return;
@@ -119,14 +120,29 @@ void libxl__save_helper_init(libxl__save_helper_state *shs)
 }
 
 /*----- helper execution -----*/
+static int dup_fd_helper(libxl__gc *gc, int fd, const char *what)
+{
+    int dup_fd = fd;
+
+    if (fd <= 2) {
+        dup_fd = dup(fd);
+        if (dup_fd < 0) {
+            LOGE(ERROR,"dup %s", what);
+            exit(-1);
+        }
+    }
+    libxl_fd_set_cloexec(CTX, dup_fd, 0);
+
+    return dup_fd;
+}
 
 static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
-                       const char *mode_arg, int stream_fd,
+                       const char *mode_arg, int stream_fd, int back_fd,
                        const int *preserve_fds, int num_preserve_fds,
                        const unsigned long *argnums, int num_argnums)
 {
     STATE_AO_GC(shs->ao);
-    const char *args[4 + num_argnums];
+    const char *args[5 + num_argnums];
     const char **arg = args;
     int i, rc;
 
@@ -154,6 +170,7 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
     *arg++ = getenv("LIBXL_SAVE_HELPER") ?: LIBEXEC_BIN "/" "libxl-save-helper";
     *arg++ = mode_arg;
     const char **stream_fd_arg = arg++;
+    const char **back_fd_arg = arg++;
     for (i=0; i<num_argnums; i++)
         *arg++ = GCSPRINTF("%lu", argnums[i]);
     *arg++ = 0;
@@ -178,16 +195,12 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
 
     pid_t pid = libxl__ev_child_fork(gc, &shs->child, helper_exited);
     if (!pid) {
-        if (stream_fd <= 2) {
-            stream_fd = dup(stream_fd);
-            if (stream_fd < 0) {
-                LOGE(ERROR,"dup migration stream fd");
-                exit(-1);
-            }
-        }
-        libxl_fd_set_cloexec(CTX, stream_fd, 0);
+        stream_fd = dup_fd_helper(gc, stream_fd, "migration stream fd");
         *stream_fd_arg = GCSPRINTF("%d", stream_fd);
 
+        back_fd = dup_fd_helper(gc, back_fd, "migration back channel fd");
+        *back_fd_arg = GCSPRINTF("%d", back_fd);
+
         for (i=0; i<num_preserve_fds; i++)
             if (preserve_fds[i] >= 0) {
                 assert(preserve_fds[i] > 2);
tools/libxl/libxl_save_helper.c +6 -2
index 4c9d34c..9de5694 100644
@@ -235,6 +235,7 @@ static struct restore_callbacks helper_restore_callbacks;
 int main(int argc, char **argv)
 {
     int r;
+    int back_fd;
 
 #define NEXTARG (++argv, assert(*argv), *argv)
 
@@ -244,6 +245,7 @@ int main(int argc, char **argv)
     if (!strcmp(mode,"--save-domain")) {
 
         io_fd =                    atoi(NEXTARG);
+        back_fd =                  atoi(NEXTARG);
         uint32_t dom =             strtoul(NEXTARG,0,10);
         uint32_t max_iters =       strtoul(NEXTARG,0,10);
         uint32_t max_factor =      strtoul(NEXTARG,0,10);
@@ -259,12 +261,14 @@ int main(int argc, char **argv)
         setup_signals(save_signal_handler);
 
         r = xc_domain_save2(xch, io_fd, dom, max_iters, max_factor, flags,
-                           &helper_save_callbacks, hvm, checkpointed_stream);
+                            &helper_save_callbacks, hvm, checkpointed_stream,
+                            back_fd);
         complete(r);
 
     } else if (!strcmp(mode,"--restore-domain")) {
 
         io_fd =                    atoi(NEXTARG);
+        back_fd =                  atoi(NEXTARG);
         uint32_t dom =             strtoul(NEXTARG,0,10);
         unsigned store_evtchn =    strtoul(NEXTARG,0,10);
         domid_t store_domid =      strtoul(NEXTARG,0,10);
@@ -289,7 +293,7 @@ int main(int argc, char **argv)
                               store_domid, console_evtchn, &console_mfn,
                               console_domid, hvm, pae, superpages,
                               checkpointed,
-                              &helper_restore_callbacks);
+                              &helper_restore_callbacks, back_fd);
         helper_stub_restore_results(store_mfn,console_mfn,0);
         complete(r);
 
Signature · 1 line
1.9.1
#70 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 20/25] tools/libx{l, c}: add back channel to libxc

Quoted 24 lines · Yang Hongyang

In COLO mode, both VMs are running, and are considered in sync if the visible network traffic is identical. After some time, they fall out of sync.

At this point, the two VMs have definitely diverged. Lets call the primary dirty bitmap set A, while the secondary dirty bitmap set B.

Sets A and B are different.

Under normal migration, the page data for set A will be sent form the primary to the secondary.

However, the set difference B - A (lets call this C) is out-of-date on the secondary (with respect to the primary) and will not be sent by the primary, as it was not memory dirtied by the primary. The secondary needs the page data for C to reconstruct an exact copy of the primary at the checkpoint.

The secondary cannot calculate C as it doesn't know A. Instead, the secondary must send B to the primary, at which point the primary calculates the union of A and B (lets call this D) which is all the pages dirtied by both the primary and the secondary, and sends all page data covered by D.

Quoted 3 lines

In the general case, D is a superset of both A and B. Without the backchannel dirty bitmap, a COLO checkpoint can't reconstruct a valid copy of the primary.

When Andy (who wrote this) said this via email I replied [0] including:

According to the paper there is no need to resend because the secondary already has a non-dirty copy of any memory which is dirty in B but not A.

So it is not the case that a checkpoint _can't_ reconstruct a valid copy of the primary, clearly it is possible, but for some reason this implementation chooses to deviate from the paper and does things in a way where it indeed cannot reconstruct D but I've yet to see a description of _why_ the implementation produced here differs from the paper.

Quoted 2 lines

We transfer the dirty bitmap on libxc side, so we need to introduce back channel to libxc.

I'm sure you have good practical reasons why the implementation differs from the design and I would like to know what they are because the back channel is adding extra complexity to libxc and libxl so I want to know why it is justified, as I also said this in [1].

Lastly Ian said in [2]:

To be clear, I have no problem if the design has changed since the paper was written. I just want:

* A clear high-level explanation of the actually-implemented arrangements to exist somewhere

* The commit messages, or code, to refer to that explanation

IMHO the addition of this extra commit message doesn't really meet at least the first requirement. Please point us to an up to date design document which describes COLO as actually implemented.

Ian.

[0] http://lists.xen.org/archives/html/xen-devel/2015-07/msg00090.html
[1] http://lists.xen.org/archives/html/xen-devel/2015-07/msg00148.html
[2] http://lists.xen.org/archives/html/xen-devel/2015-07/msg00101.html

Quoted 270 lines

commit message:

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxc/include/xenguest.h   |  8 ++++----
 tools/libxc/xc_domain_restore.c  |  4 ++--
 tools/libxc/xc_domain_save.c     |  4 ++--
 tools/libxc/xc_sr_restore.c      |  2 +-
 tools/libxc/xc_sr_save.c         |  2 +-
 tools/libxl/libxl_save_callout.c | 39 ++++++++++++++++++++++++++-------------
 tools/libxl/libxl_save_helper.c  |  8 ++++++--
 7 files changed, 42 insertions(+), 25 deletions(-)
tools/libxc/include/xenguest.h +4 -4
index 6e24b6c..4056955 100644
@@ -91,13 +91,13 @@ struct save_callbacks {
 int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters,
                    uint32_t max_factor, uint32_t flags /* XCFLAGS_xxx */,
                    struct save_callbacks* callbacks, int hvm,
-                   int checkpointed_stream);
+                   int checkpointed_stream, int back_fd);
 
 /* Domain Save v2 */
 int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters,
                     uint32_t max_factor, uint32_t flags,
                     struct save_callbacks* callbacks, int hvm,
-                    int checkpointed_stream);
+                    int checkpointed_stream, int back_fd);
 
 /* callbacks provided by xc_domain_restore */
 struct restore_callbacks {
@@ -140,7 +140,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
                       unsigned long *console_mfn, domid_t console_domid,
                       unsigned int hvm, unsigned int pae, int superpages,
                       int checkpointed_stream,
-                      struct restore_callbacks *callbacks);
+                      struct restore_callbacks *callbacks, int back_fd);
 
 /* Domain Restore v2 */
 int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom,
@@ -149,7 +149,7 @@ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom,
                        unsigned long *console_mfn, domid_t console_domid,
                        unsigned int hvm, unsigned int pae, int superpages,
                        int checkpointed_stream,
-                       struct restore_callbacks *callbacks);
+                       struct restore_callbacks *callbacks, int back_fd);
 /**
  * xc_domain_restore writes a file to disk that contains the device
  * model saved state.
tools/libxc/xc_domain_restore.c +2 -2
index 3cd3483..63d1e6b 100644
@@ -1515,7 +1515,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
                       unsigned long *console_mfn, domid_t console_domid,
                       unsigned int hvm, unsigned int pae, int superpages,
                       int checkpointed_stream,
-                      struct restore_callbacks *callbacks)
+                      struct restore_callbacks *callbacks, int back_fd)
 {
     DECLARE_DOMCTL;
     xc_dominfo_t info;
@@ -1578,7 +1578,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
         return xc_domain_restore2(
             xch, io_fd, dom, store_evtchn, store_mfn,
             store_domid, console_evtchn, console_mfn, console_domid,
-            hvm,  pae,  superpages, checkpointed_stream, callbacks);
+            hvm,  pae,  superpages, checkpointed_stream, callbacks, back_fd);
     }
 
     DPRINTF("%s: starting restore of new domid %u", __func__, dom);
tools/libxc/xc_domain_save.c +2 -2
index 0da3cca..b111384 100644
@@ -803,7 +803,7 @@ static int save_tsc_info(xc_interface *xch, uint32_t dom, int io_fd)
 int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters,
                    uint32_t max_factor, uint32_t flags,
                    struct save_callbacks* callbacks, int hvm,
-                   int checkpointed_stream)
+                   int checkpointed_stream, int back_fd)
 {
     xc_dominfo_t info;
     DECLARE_DOMCTL;
@@ -899,7 +899,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter
     {
         return xc_domain_save2(xch, io_fd, dom, max_iters,
                                max_factor, flags, callbacks, hvm,
-                               checkpointed_stream);
+                               checkpointed_stream, back_fd);
     }
 
     DPRINTF("%s: starting save of domid %u", __func__, dom);
tools/libxc/xc_sr_restore.c +1 -1
index bf1ee15..504463e 100644
@@ -720,7 +720,7 @@ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom,
                        unsigned long *console_gfn, domid_t console_domid,
                        unsigned int hvm, unsigned int pae, int superpages,
                        int checkpointed_stream,
-                       struct restore_callbacks *callbacks)
+                       struct restore_callbacks *callbacks, int back_fd)
 {
     struct xc_sr_context ctx =
         {
tools/libxc/xc_sr_save.c +1 -1
index 6102b66..d12e5b1 100644
@@ -821,7 +821,7 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)
 int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom,
                     uint32_t max_iters, uint32_t max_factor, uint32_t flags,
                     struct save_callbacks* callbacks, int hvm,
-                    int checkpointed_stream)
+                    int checkpointed_stream, int back_fd)
 {
     xen_pfn_t nr_pfns;
     struct xc_sr_context ctx =
tools/libxl/libxl_save_callout.c +26 -13
index f393abc..f8c6cf0 100644
@@ -27,7 +27,7 @@
  */
 static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
                        const char *mode_arg,
-                       int stream_fd,
+                       int stream_fd, int back_fd,
                        const int *preserve_fds, int num_preserve_fds,
                        const unsigned long *argnums, int num_argnums);
 
@@ -50,6 +50,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs,
     /* Convenience aliases */
     const uint32_t domid = dcs->guest_domid;
     const int restore_fd = dcs->libxc_fd;
+    const int send_fd = dcs->send_fd;
     libxl__domain_build_state *const state = &dcs->build_state;
 
     unsigned cbflags =
@@ -72,7 +73,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs,
     shs->need_results = 1;
     shs->toolstack_data_file = 0;
 
-    run_helper(egc, shs, "--restore-domain", restore_fd, 0, 0,
+    run_helper(egc, shs, "--restore-domain", restore_fd, send_fd, 0, 0,
                argnums, ARRAY_SIZE(argnums));
 }
 
@@ -96,7 +97,7 @@ void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_save_state *dss,
     shs->caller_state = dss;
     shs->need_results = 0;
 
-    run_helper(egc, shs, "--save-domain", dss->fd,
+    run_helper(egc, shs, "--save-domain", dss->fd, dss->recv_fd,
                NULL, 0,
                argnums, ARRAY_SIZE(argnums));
     return;
@@ -119,14 +120,29 @@ void libxl__save_helper_init(libxl__save_helper_state *shs)
 }
 
 /*----- helper execution -----*/
+static int dup_fd_helper(libxl__gc *gc, int fd, const char *what)
+{
+    int dup_fd = fd;
+
+    if (fd <= 2) {
+        dup_fd = dup(fd);
+        if (dup_fd < 0) {
+            LOGE(ERROR,"dup %s", what);
+            exit(-1);
+        }
+    }
+    libxl_fd_set_cloexec(CTX, dup_fd, 0);
+
+    return dup_fd;
+}
 
 static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
-                       const char *mode_arg, int stream_fd,
+                       const char *mode_arg, int stream_fd, int back_fd,
                        const int *preserve_fds, int num_preserve_fds,
                        const unsigned long *argnums, int num_argnums)
 {
     STATE_AO_GC(shs->ao);
-    const char *args[4 + num_argnums];
+    const char *args[5 + num_argnums];
     const char **arg = args;
     int i, rc;
 
@@ -154,6 +170,7 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
     *arg++ = getenv("LIBXL_SAVE_HELPER") ?: LIBEXEC_BIN "/" "libxl-save-helper";
     *arg++ = mode_arg;
     const char **stream_fd_arg = arg++;
+    const char **back_fd_arg = arg++;
     for (i=0; i<num_argnums; i++)
         *arg++ = GCSPRINTF("%lu", argnums[i]);
     *arg++ = 0;
@@ -178,16 +195,12 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
 
     pid_t pid = libxl__ev_child_fork(gc, &shs->child, helper_exited);
     if (!pid) {
-        if (stream_fd <= 2) {
-            stream_fd = dup(stream_fd);
-            if (stream_fd < 0) {
-                LOGE(ERROR,"dup migration stream fd");
-                exit(-1);
-            }
-        }
-        libxl_fd_set_cloexec(CTX, stream_fd, 0);
+        stream_fd = dup_fd_helper(gc, stream_fd, "migration stream fd");
         *stream_fd_arg = GCSPRINTF("%d", stream_fd);
 
+        back_fd = dup_fd_helper(gc, back_fd, "migration back channel fd");
+        *back_fd_arg = GCSPRINTF("%d", back_fd);
+
         for (i=0; i<num_preserve_fds; i++)
             if (preserve_fds[i] >= 0) {
                 assert(preserve_fds[i] > 2);
tools/libxl/libxl_save_helper.c +6 -2
index 4c9d34c..9de5694 100644
@@ -235,6 +235,7 @@ static struct restore_callbacks helper_restore_callbacks;
 int main(int argc, char **argv)
 {
     int r;
+    int back_fd;
 
 #define NEXTARG (++argv, assert(*argv), *argv)
 
@@ -244,6 +245,7 @@ int main(int argc, char **argv)
     if (!strcmp(mode,"--save-domain")) {
 
         io_fd =                    atoi(NEXTARG);
+        back_fd =                  atoi(NEXTARG);
         uint32_t dom =             strtoul(NEXTARG,0,10);
         uint32_t max_iters =       strtoul(NEXTARG,0,10);
         uint32_t max_factor =      strtoul(NEXTARG,0,10);
@@ -259,12 +261,14 @@ int main(int argc, char **argv)
         setup_signals(save_signal_handler);
 
         r = xc_domain_save2(xch, io_fd, dom, max_iters, max_factor, flags,
-                           &helper_save_callbacks, hvm, checkpointed_stream);
+                            &helper_save_callbacks, hvm, checkpointed_stream,
+                            back_fd);
         complete(r);
 
     } else if (!strcmp(mode,"--restore-domain")) {
 
         io_fd =                    atoi(NEXTARG);
+        back_fd =                  atoi(NEXTARG);
         uint32_t dom =             strtoul(NEXTARG,0,10);
         unsigned store_evtchn =    strtoul(NEXTARG,0,10);
         domid_t store_domid =      strtoul(NEXTARG,0,10);
@@ -289,7 +293,7 @@ int main(int argc, char **argv)
                               store_domid, console_evtchn, &console_mfn,
                               console_domid, hvm, pae, superpages,
                               checkpointed,
-                              &helper_restore_callbacks);
+                              &helper_restore_callbacks, back_fd);
         helper_stub_restore_results(store_mfn,console_mfn,0);
         complete(r);
 
#71 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 20/25] tools/libx{l, c}: add back channel to libxc

Quoted 55 lines · Ian Campbell
Quoted 24 lines · Yang Hongyang

In COLO mode, both VMs are running, and are considered in sync if the visible network traffic is identical. After some time, they fall out of sync.

At this point, the two VMs have definitely diverged. Lets call the primary dirty bitmap set A, while the secondary dirty bitmap set B.

Sets A and B are different.

Under normal migration, the page data for set A will be sent form the primary to the secondary.

However, the set difference B - A (lets call this C) is out-of-date on the secondary (with respect to the primary) and will not be sent by the primary, as it was not memory dirtied by the primary. The secondary needs the page data for C to reconstruct an exact copy of the primary at the checkpoint.

The secondary cannot calculate C as it doesn't know A. Instead, the secondary must send B to the primary, at which point the primary calculates the union of A and B (lets call this D) which is all the pages dirtied by both the primary and the secondary, and sends all page data covered by D.

Quoted 3 lines

In the general case, D is a superset of both A and B. Without the backchannel dirty bitmap, a COLO checkpoint can't reconstruct a valid copy of the primary.

When Andy (who wrote this) said this via email I replied [0] including:

According to the paper there is no need to resend because the secondary already has a non-dirty copy of any memory which is dirty in B but not A.

So it is not the case that a checkpoint _can't_ reconstruct a valid copy of the primary, clearly it is possible, but for some reason this implementation chooses to deviate from the paper and does things in a way where it indeed cannot reconstruct D but I've yet to see a description of _why_ the implementation produced here differs from the paper.

Quoted 2 lines

We transfer the dirty bitmap on libxc side, so we need to introduce back channel to libxc.

I'm sure you have good practical reasons why the implementation differs from the design and I would like to know what they are because the back channel is adding extra complexity to libxc and libxl so I want to know why it is justified, as I also said this in [1].

Lastly Ian said in [2]:

To be clear, I have no problem if the design has changed since the paper was written. I just want:

Quoted 8 lines

* A clear high-level explanation of the actually-implemented arrangements to exist somewhere

* The commit messages, or code, to refer to that explanation

IMHO the addition of this extra commit message doesn't really meet at least the first requirement. Please point us to an up to date design document which describes COLO as actually implemented.

The original design of COLO is that:
Secondary should maintain an exact copy of Primary memory. At every checkpoint, we receive the Primary memory into that copy, then flush the memory to Secondary.

We changed the original design to the current one, according to our following concerns:
1. The original design needs extra memory on Secondary host. When there's multiple backups on one host, the memory cost is high.
2. The memory cache code will be another 1k+, it will make the review more time consuming.

The best way to accomplish this is the COW which Andrew mentioned earlier, but that should be further improvement. We will certainly continue to improve this when COW is ready to use.

Is description above can solve your confusion? If so, I will add to the commit log.

Quoted 281 lines

Ian.

[0] http://lists.xen.org/archives/html/xen-devel/2015-07/msg00090.html
[1] http://lists.xen.org/archives/html/xen-devel/2015-07/msg00148.html
[2] http://lists.xen.org/archives/html/xen-devel/2015-07/msg00101.html

Quoted 262 lines

commit message:

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
  tools/libxc/include/xenguest.h   |  8 ++++----
  tools/libxc/xc_domain_restore.c  |  4 ++--
  tools/libxc/xc_domain_save.c     |  4 ++--
  tools/libxc/xc_sr_restore.c      |  2 +-
  tools/libxc/xc_sr_save.c         |  2 +-
  tools/libxl/libxl_save_callout.c | 39 ++++++++++++++++++++++++++-------------
  tools/libxl/libxl_save_helper.c  |  8 ++++++--
  7 files changed, 42 insertions(+), 25 deletions(-)
tools/libxc/include/xenguest.h +4 -4
index 6e24b6c..4056955 100644
@@ -91,13 +91,13 @@ struct save_callbacks {
  int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters,
                     uint32_t max_factor, uint32_t flags /* XCFLAGS_xxx */,
                     struct save_callbacks* callbacks, int hvm,
-                   int checkpointed_stream);
+                   int checkpointed_stream, int back_fd);
 
  /* Domain Save v2 */
  int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters,
                      uint32_t max_factor, uint32_t flags,
                      struct save_callbacks* callbacks, int hvm,
-                    int checkpointed_stream);
+                    int checkpointed_stream, int back_fd);
 
  /* callbacks provided by xc_domain_restore */
  struct restore_callbacks {
@@ -140,7 +140,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
                        unsigned long *console_mfn, domid_t console_domid,
                        unsigned int hvm, unsigned int pae, int superpages,
                        int checkpointed_stream,
-                      struct restore_callbacks *callbacks);
+                      struct restore_callbacks *callbacks, int back_fd);
 
  /* Domain Restore v2 */
  int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom,
@@ -149,7 +149,7 @@ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom,
                         unsigned long *console_mfn, domid_t console_domid,
                         unsigned int hvm, unsigned int pae, int superpages,
                         int checkpointed_stream,
-                       struct restore_callbacks *callbacks);
+                       struct restore_callbacks *callbacks, int back_fd);
  /**
   * xc_domain_restore writes a file to disk that contains the device
   * model saved state.
tools/libxc/xc_domain_restore.c +2 -2
index 3cd3483..63d1e6b 100644
@@ -1515,7 +1515,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
                        unsigned long *console_mfn, domid_t console_domid,
                        unsigned int hvm, unsigned int pae, int superpages,
                        int checkpointed_stream,
-                      struct restore_callbacks *callbacks)
+                      struct restore_callbacks *callbacks, int back_fd)
  {
      DECLARE_DOMCTL;
      xc_dominfo_t info;
@@ -1578,7 +1578,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
          return xc_domain_restore2(
              xch, io_fd, dom, store_evtchn, store_mfn,
              store_domid, console_evtchn, console_mfn, console_domid,
-            hvm,  pae,  superpages, checkpointed_stream, callbacks);
+            hvm,  pae,  superpages, checkpointed_stream, callbacks, back_fd);
      }
 
      DPRINTF("%s: starting restore of new domid %u", __func__, dom);
tools/libxc/xc_domain_save.c +2 -2
index 0da3cca..b111384 100644
@@ -803,7 +803,7 @@ static int save_tsc_info(xc_interface *xch, uint32_t dom, int io_fd)
  int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters,
                     uint32_t max_factor, uint32_t flags,
                     struct save_callbacks* callbacks, int hvm,
-                   int checkpointed_stream)
+                   int checkpointed_stream, int back_fd)
  {
      xc_dominfo_t info;
      DECLARE_DOMCTL;
@@ -899,7 +899,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter
      {
          return xc_domain_save2(xch, io_fd, dom, max_iters,
                                 max_factor, flags, callbacks, hvm,
-                               checkpointed_stream);
+                               checkpointed_stream, back_fd);
      }
 
      DPRINTF("%s: starting save of domid %u", __func__, dom);
tools/libxc/xc_sr_restore.c +1 -1
index bf1ee15..504463e 100644
@@ -720,7 +720,7 @@ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom,
                         unsigned long *console_gfn, domid_t console_domid,
                         unsigned int hvm, unsigned int pae, int superpages,
                         int checkpointed_stream,
-                       struct restore_callbacks *callbacks)
+                       struct restore_callbacks *callbacks, int back_fd)
  {
      struct xc_sr_context ctx =
          {
tools/libxc/xc_sr_save.c +1 -1
index 6102b66..d12e5b1 100644
@@ -821,7 +821,7 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)
  int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom,
                      uint32_t max_iters, uint32_t max_factor, uint32_t flags,
                      struct save_callbacks* callbacks, int hvm,
-                    int checkpointed_stream)
+                    int checkpointed_stream, int back_fd)
  {
      xen_pfn_t nr_pfns;
      struct xc_sr_context ctx =
tools/libxl/libxl_save_callout.c +26 -13
index f393abc..f8c6cf0 100644
@@ -27,7 +27,7 @@
   */
  static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
                         const char *mode_arg,
-                       int stream_fd,
+                       int stream_fd, int back_fd,
                         const int *preserve_fds, int num_preserve_fds,
                         const unsigned long *argnums, int num_argnums);
 
@@ -50,6 +50,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs,
      /* Convenience aliases */
      const uint32_t domid = dcs->guest_domid;
      const int restore_fd = dcs->libxc_fd;
+    const int send_fd = dcs->send_fd;
      libxl__domain_build_state *const state = &dcs->build_state;
 
      unsigned cbflags =
@@ -72,7 +73,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs,
      shs->need_results = 1;
      shs->toolstack_data_file = 0;
 
-    run_helper(egc, shs, "--restore-domain", restore_fd, 0, 0,
+    run_helper(egc, shs, "--restore-domain", restore_fd, send_fd, 0, 0,
                 argnums, ARRAY_SIZE(argnums));
  }
 
@@ -96,7 +97,7 @@ void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_save_state *dss,
      shs->caller_state = dss;
      shs->need_results = 0;
 
-    run_helper(egc, shs, "--save-domain", dss->fd,
+    run_helper(egc, shs, "--save-domain", dss->fd, dss->recv_fd,
                 NULL, 0,
                 argnums, ARRAY_SIZE(argnums));
      return;
@@ -119,14 +120,29 @@ void libxl__save_helper_init(libxl__save_helper_state *shs)
  }
 
  /*----- helper execution -----*/
+static int dup_fd_helper(libxl__gc *gc, int fd, const char *what)
+{
+    int dup_fd = fd;
+
+    if (fd <= 2) {
+        dup_fd = dup(fd);
+        if (dup_fd < 0) {
+            LOGE(ERROR,"dup %s", what);
+            exit(-1);
+        }
+    }
+    libxl_fd_set_cloexec(CTX, dup_fd, 0);
+
+    return dup_fd;
+}
 
  static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
-                       const char *mode_arg, int stream_fd,
+                       const char *mode_arg, int stream_fd, int back_fd,
                         const int *preserve_fds, int num_preserve_fds,
                         const unsigned long *argnums, int num_argnums)
  {
      STATE_AO_GC(shs->ao);
-    const char *args[4 + num_argnums];
+    const char *args[5 + num_argnums];
      const char **arg = args;
      int i, rc;
 
@@ -154,6 +170,7 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
      *arg++ = getenv("LIBXL_SAVE_HELPER") ?: LIBEXEC_BIN "/" "libxl-save-helper";
      *arg++ = mode_arg;
      const char **stream_fd_arg = arg++;
+    const char **back_fd_arg = arg++;
      for (i=0; i<num_argnums; i++)
          *arg++ = GCSPRINTF("%lu", argnums[i]);
      *arg++ = 0;
@@ -178,16 +195,12 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
 
      pid_t pid = libxl__ev_child_fork(gc, &shs->child, helper_exited);
      if (!pid) {
-        if (stream_fd <= 2) {
-            stream_fd = dup(stream_fd);
-            if (stream_fd < 0) {
-                LOGE(ERROR,"dup migration stream fd");
-                exit(-1);
-            }
-        }
-        libxl_fd_set_cloexec(CTX, stream_fd, 0);
+        stream_fd = dup_fd_helper(gc, stream_fd, "migration stream fd");
          *stream_fd_arg = GCSPRINTF("%d", stream_fd);
 
+        back_fd = dup_fd_helper(gc, back_fd, "migration back channel fd");
+        *back_fd_arg = GCSPRINTF("%d", back_fd);
+
          for (i=0; i<num_preserve_fds; i++)
              if (preserve_fds[i] >= 0) {
                  assert(preserve_fds[i] > 2);
tools/libxl/libxl_save_helper.c +5 -1
index 4c9d34c..9de5694 100644
@@ -235,6 +235,7 @@ static struct restore_callbacks helper_restore_callbacks;
  int main(int argc, char **argv)
  {
      int r;
+    int back_fd;
 
  #define NEXTARG (++argv, assert(*argv), *argv)
 
@@ -244,6 +245,7 @@ int main(int argc, char **argv)
      if (!strcmp(mode,"--save-domain")) {
 
          io_fd =                    atoi(NEXTARG);
+        back_fd =                  atoi(NEXTARG);
          uint32_t dom =             strtoul(NEXTARG,0,10);
          uint32_t max_iters =       strtoul(NEXTARG,0,10);
          uint32_t max_factor =      strtoul(NEXTARG,0,10);
@@ -259,12 +261,14 @@ int main(int argc, char **argv)
          setup_signals(save_signal_handler);
 
          r = xc_domain_save2(xch, io_fd, dom, max_iters, max_factor, flags,
-                           &helper_save_callbacks, hvm, checkpointed_stream);
+                            &helper_save_callbacks, hvm, checkpointed_stream,
+                            back_fd);
          complete(r);
 
      } else if (!strcmp(mode,"--restore-domain")) {
 
          io_fd =                    atoi(NEXTARG);
+        back_fd =                  atoi(NEXTARG);
          uint32_t dom =             strtoul(NEXTARG,0,10);
          unsigned store_evtchn =    strtoul(NEXTARG,0,10);
          domid_t store_domid =      strtoul(NEXTARG,0,10);

tools/libxl/libxl_save_helper.c int main(int argc, char **argv) · line 299

Quoted 8 lines
tools/libxl/libxl_save_helper.c +1 -1
@@ -289,7 +293,7 @@ int main(int argc, char **argv)
                                store_domid, console_evtchn, &console_mfn,
                                console_domid, hvm, pae, superpages,
                                checkpointed,
-                              &helper_restore_callbacks);
+                              &helper_restore_callbacks, back_fd);
          helper_stub_restore_results(store_mfn,console_mfn,0);
          complete(r);
 

.

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

Re: [PATCH v4 --for 4.6 COLOPre 20/25] tools/libx{l, c}: add back channel to libxc

Quoted 77 lines · Yang Hongyang
Quoted 55 lines · Ian Campbell
Quoted 24 lines · Yang Hongyang

In COLO mode, both VMs are running, and are considered in sync if the visible network traffic is identical. After some time, they fall out of sync.

At this point, the two VMs have definitely diverged. Lets call the primary dirty bitmap set A, while the secondary dirty bitmap set B.

Sets A and B are different.

Under normal migration, the page data for set A will be sent form the primary to the secondary.

However, the set difference B - A (lets call this C) is out-of-date on the secondary (with respect to the primary) and will not be sent by the primary, as it was not memory dirtied by the primary. The secondary needs the page data for C to reconstruct an exact copy of the primary at the checkpoint.

The secondary cannot calculate C as it doesn't know A. Instead, the secondary must send B to the primary, at which point the primary calculates the union of A and B (lets call this D) which is all the pages dirtied by both the primary and the secondary, and sends all page data covered by D.

Quoted 3 lines

In the general case, D is a superset of both A and B. Without the backchannel dirty bitmap, a COLO checkpoint can't reconstruct a valid copy of the primary.

When Andy (who wrote this) said this via email I replied [0] including:

According to the paper there is no need to resend because the secondary already has a non-dirty copy of any memory which is dirty in B but not A.

So it is not the case that a checkpoint _can't_ reconstruct a valid copy of the primary, clearly it is possible, but for some reason this implementation chooses to deviate from the paper and does things in a way where it indeed cannot reconstruct D but I've yet to see a description of _why_ the implementation produced here differs from the paper.

Quoted 2 lines

We transfer the dirty bitmap on libxc side, so we need to introduce back channel to libxc.

I'm sure you have good practical reasons why the implementation differs from the design and I would like to know what they are because the back channel is adding extra complexity to libxc and libxl so I want to know why it is justified, as I also said this in [1].

Lastly Ian said in [2]:

To be clear, I have no problem if the design has changed since the paper was written. I just want:

Quoted 8 lines

* A clear high-level explanation of the actually-implemented arrangements to exist somewhere

* The commit messages, or code, to refer to that explanation

IMHO the addition of this extra commit message doesn't really meet at least the first requirement. Please point us to an up to date design document which describes COLO as actually implemented.

The original design of COLO is that:
Secondary should maintain an exact copy of Primary memory. At every checkpoint, we receive the Primary memory into that copy, then flush the memory to Secondary.

We changed the original design to the current one, according to our following concerns:
1. The original design needs extra memory on Secondary host. When there's multiple backups on one host, the memory cost is high.
2. The memory cache code will be another 1k+, it will make the review more time consuming.

Quoted 6 lines

The best way to accomplish this is the COW which Andrew mentioned earlier, but that should be further improvement. We will certainly continue to improve this when COW is ready to use.

Is description above can solve your confusion? If so, I will add to the commit log.

I'd much prefer to see this incorporated into an updated design which supersedes the existing paper and is referenced from the wiki etc.

It doesn't need to be anything like as formal as that paper, of course, but I think it does need to cover the overall design of COLO as it is in reality today as a whole and not just as a delta to the paper in the commit log.

Such a document might also usefully _in_addition_ contain a section explaining the delta from the original paper and the reasons for those.

Ian.

Quoted 282 lines
Quoted 281 lines

Ian.

[0] http://lists.xen.org/archives/html/xen-devel/2015-07/msg00090.html
[1] http://lists.xen.org/archives/html/xen-devel/2015-07/msg00148.html
[2] http://lists.xen.org/archives/html/xen-devel/2015-07/msg00101.html

Quoted 262 lines

commit message:

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
---
  tools/libxc/include/xenguest.h   |  8 ++++----
  tools/libxc/xc_domain_restore.c  |  4 ++--
  tools/libxc/xc_domain_save.c     |  4 ++--
  tools/libxc/xc_sr_restore.c      |  2 +-
  tools/libxc/xc_sr_save.c         |  2 +-
  tools/libxl/libxl_save_callout.c | 39 ++++++++++++++++++++++++++-------------
  tools/libxl/libxl_save_helper.c  |  8 ++++++--
  7 files changed, 42 insertions(+), 25 deletions(-)
tools/libxc/include/xenguest.h +4 -4
index 6e24b6c..4056955 100644
@@ -91,13 +91,13 @@ struct save_callbacks {
  int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters,
                     uint32_t max_factor, uint32_t flags /* XCFLAGS_xxx */,
                     struct save_callbacks* callbacks, int hvm,
-                   int checkpointed_stream);
+                   int checkpointed_stream, int back_fd);
 
  /* Domain Save v2 */
  int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters,
                      uint32_t max_factor, uint32_t flags,
                      struct save_callbacks* callbacks, int hvm,
-                    int checkpointed_stream);
+                    int checkpointed_stream, int back_fd);
 
  /* callbacks provided by xc_domain_restore */
  struct restore_callbacks {
@@ -140,7 +140,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
                        unsigned long *console_mfn, domid_t console_domid,
                        unsigned int hvm, unsigned int pae, int superpages,
                        int checkpointed_stream,
-                      struct restore_callbacks *callbacks);
+                      struct restore_callbacks *callbacks, int back_fd);
 
  /* Domain Restore v2 */
  int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom,
@@ -149,7 +149,7 @@ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom,
                         unsigned long *console_mfn, domid_t console_domid,
                         unsigned int hvm, unsigned int pae, int superpages,
                         int checkpointed_stream,
-                       struct restore_callbacks *callbacks);
+                       struct restore_callbacks *callbacks, int back_fd);
  /**
   * xc_domain_restore writes a file to disk that contains the device
   * model saved state.
tools/libxc/xc_domain_restore.c +2 -2
index 3cd3483..63d1e6b 100644
@@ -1515,7 +1515,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
                        unsigned long *console_mfn, domid_t console_domid,
                        unsigned int hvm, unsigned int pae, int superpages,
                        int checkpointed_stream,
-                      struct restore_callbacks *callbacks)
+                      struct restore_callbacks *callbacks, int back_fd)
  {
      DECLARE_DOMCTL;
      xc_dominfo_t info;
@@ -1578,7 +1578,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
          return xc_domain_restore2(
              xch, io_fd, dom, store_evtchn, store_mfn,
              store_domid, console_evtchn, console_mfn, console_domid,
-            hvm,  pae,  superpages, checkpointed_stream, callbacks);
+            hvm,  pae,  superpages, checkpointed_stream, callbacks, back_fd);
      }
 
      DPRINTF("%s: starting restore of new domid %u", __func__, dom);
tools/libxc/xc_domain_save.c +2 -2
index 0da3cca..b111384 100644
@@ -803,7 +803,7 @@ static int save_tsc_info(xc_interface *xch, uint32_t dom, int io_fd)
  int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters,
                     uint32_t max_factor, uint32_t flags,
                     struct save_callbacks* callbacks, int hvm,
-                   int checkpointed_stream)
+                   int checkpointed_stream, int back_fd)
  {
      xc_dominfo_t info;
      DECLARE_DOMCTL;
@@ -899,7 +899,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter
      {
          return xc_domain_save2(xch, io_fd, dom, max_iters,
                                 max_factor, flags, callbacks, hvm,
-                               checkpointed_stream);
+                               checkpointed_stream, back_fd);
      }
 
      DPRINTF("%s: starting save of domid %u", __func__, dom);
tools/libxc/xc_sr_restore.c +1 -1
index bf1ee15..504463e 100644
@@ -720,7 +720,7 @@ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom,
                         unsigned long *console_gfn, domid_t console_domid,
                         unsigned int hvm, unsigned int pae, int superpages,
                         int checkpointed_stream,
-                       struct restore_callbacks *callbacks)
+                       struct restore_callbacks *callbacks, int back_fd)
  {
      struct xc_sr_context ctx =
          {
tools/libxc/xc_sr_save.c +1 -1
index 6102b66..d12e5b1 100644
@@ -821,7 +821,7 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)
  int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom,
                      uint32_t max_iters, uint32_t max_factor, uint32_t flags,
                      struct save_callbacks* callbacks, int hvm,
-                    int checkpointed_stream)
+                    int checkpointed_stream, int back_fd)
  {
      xen_pfn_t nr_pfns;
      struct xc_sr_context ctx =
tools/libxl/libxl_save_callout.c +26 -13
index f393abc..f8c6cf0 100644
@@ -27,7 +27,7 @@
   */
  static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
                         const char *mode_arg,
-                       int stream_fd,
+                       int stream_fd, int back_fd,
                         const int *preserve_fds, int num_preserve_fds,
                         const unsigned long *argnums, int num_argnums);
 
@@ -50,6 +50,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs,
      /* Convenience aliases */
      const uint32_t domid = dcs->guest_domid;
      const int restore_fd = dcs->libxc_fd;
+    const int send_fd = dcs->send_fd;
      libxl__domain_build_state *const state = &dcs->build_state;
 
      unsigned cbflags =
@@ -72,7 +73,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs,
      shs->need_results = 1;
      shs->toolstack_data_file = 0;
 
-    run_helper(egc, shs, "--restore-domain", restore_fd, 0, 0,
+    run_helper(egc, shs, "--restore-domain", restore_fd, send_fd, 0, 0,
                 argnums, ARRAY_SIZE(argnums));
  }
 
@@ -96,7 +97,7 @@ void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_save_state *dss,
      shs->caller_state = dss;
      shs->need_results = 0;
 
-    run_helper(egc, shs, "--save-domain", dss->fd,
+    run_helper(egc, shs, "--save-domain", dss->fd, dss->recv_fd,
                 NULL, 0,
                 argnums, ARRAY_SIZE(argnums));
      return;
@@ -119,14 +120,29 @@ void libxl__save_helper_init(libxl__save_helper_state *shs)
  }
 
  /*----- helper execution -----*/
+static int dup_fd_helper(libxl__gc *gc, int fd, const char *what)
+{
+    int dup_fd = fd;
+
+    if (fd <= 2) {
+        dup_fd = dup(fd);
+        if (dup_fd < 0) {
+            LOGE(ERROR,"dup %s", what);
+            exit(-1);
+        }
+    }
+    libxl_fd_set_cloexec(CTX, dup_fd, 0);
+
+    return dup_fd;
+}
 
  static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
-                       const char *mode_arg, int stream_fd,
+                       const char *mode_arg, int stream_fd, int back_fd,
                         const int *preserve_fds, int num_preserve_fds,
                         const unsigned long *argnums, int num_argnums)
  {
      STATE_AO_GC(shs->ao);
-    const char *args[4 + num_argnums];
+    const char *args[5 + num_argnums];
      const char **arg = args;
      int i, rc;
 
@@ -154,6 +170,7 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
      *arg++ = getenv("LIBXL_SAVE_HELPER") ?: LIBEXEC_BIN "/" "libxl-save-helper";
      *arg++ = mode_arg;
      const char **stream_fd_arg = arg++;
+    const char **back_fd_arg = arg++;
      for (i=0; i<num_argnums; i++)
          *arg++ = GCSPRINTF("%lu", argnums[i]);
      *arg++ = 0;
@@ -178,16 +195,12 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,
 
      pid_t pid = libxl__ev_child_fork(gc, &shs->child, helper_exited);
      if (!pid) {
-        if (stream_fd <= 2) {
-            stream_fd = dup(stream_fd);
-            if (stream_fd < 0) {
-                LOGE(ERROR,"dup migration stream fd");
-                exit(-1);
-            }
-        }
-        libxl_fd_set_cloexec(CTX, stream_fd, 0);
+        stream_fd = dup_fd_helper(gc, stream_fd, "migration stream fd");
          *stream_fd_arg = GCSPRINTF("%d", stream_fd);
 
+        back_fd = dup_fd_helper(gc, back_fd, "migration back channel fd");
+        *back_fd_arg = GCSPRINTF("%d", back_fd);
+
          for (i=0; i<num_preserve_fds; i++)
              if (preserve_fds[i] >= 0) {
                  assert(preserve_fds[i] > 2);
tools/libxl/libxl_save_helper.c +5 -1
index 4c9d34c..9de5694 100644
@@ -235,6 +235,7 @@ static struct restore_callbacks helper_restore_callbacks;
  int main(int argc, char **argv)
  {
      int r;
+    int back_fd;
 
  #define NEXTARG (++argv, assert(*argv), *argv)
 
@@ -244,6 +245,7 @@ int main(int argc, char **argv)
      if (!strcmp(mode,"--save-domain")) {
 
          io_fd =                    atoi(NEXTARG);
+        back_fd =                  atoi(NEXTARG);
          uint32_t dom =             strtoul(NEXTARG,0,10);
          uint32_t max_iters =       strtoul(NEXTARG,0,10);
          uint32_t max_factor =      strtoul(NEXTARG,0,10);
@@ -259,12 +261,14 @@ int main(int argc, char **argv)
          setup_signals(save_signal_handler);
 
          r = xc_domain_save2(xch, io_fd, dom, max_iters, max_factor, flags,
-                           &helper_save_callbacks, hvm, checkpointed_stream);
+                            &helper_save_callbacks, hvm, checkpointed_stream,
+                            back_fd);
          complete(r);
 
      } else if (!strcmp(mode,"--restore-domain")) {
 
          io_fd =                    atoi(NEXTARG);
+        back_fd =                  atoi(NEXTARG);
          uint32_t dom =             strtoul(NEXTARG,0,10);
          unsigned store_evtchn =    strtoul(NEXTARG,0,10);
          domid_t store_domid =      strtoul(NEXTARG,0,10);

tools/libxl/libxl_save_helper.c int main(int argc, char **argv) · line 299

Quoted 8 lines
tools/libxl/libxl_save_helper.c +1 -1
@@ -289,7 +293,7 @@ int main(int argc, char **argv)
                                store_domid, console_evtchn, &console_mfn,
                                console_domid, hvm, pae, superpages,
                                checkpointed,
-                              &helper_restore_callbacks);
+                              &helper_restore_callbacks, back_fd);
          helper_stub_restore_results(store_mfn,console_mfn,0);
          complete(r);
 

.

#73 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 20/25] tools/libx{l, c}: add back channel to libxc

In reply to Yang Hongyang
Quoted 37 lines · Yang Hongyang

In COLO mode, both VMs are running, and are considered in sync if the visible network traffic is identical. After some time, they fall out of sync.

At this point, the two VMs have definitely diverged. Lets call the primary dirty bitmap set A, while the secondary dirty bitmap set B.

Sets A and B are different.

Under normal migration, the page data for set A will be sent form the primary to the secondary.

However, the set difference B - A (lets call this C) is out-of-date on the secondary (with respect to the primary) and will not be sent by the primary, as it was not memory dirtied by the primary. The secondary needs the page data for C to reconstruct an exact copy of the primary at the checkpoint.

The secondary cannot calculate C as it doesn't know A. Instead, the secondary must send B to the primary, at which point the primary calculates the union of A and B (lets call this D) which is all the pages dirtied by both the primary and the secondary, and sends all page data covered by D.

In the general case, D is a superset of both A and B. Without the backchannel dirty bitmap, a COLO checkpoint can't reconstruct a valid copy of the primary.

We transfer the dirty bitmap on libxc side, so we need to introduce back channel to libxc.

commit message:

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
Quoted 9 lines
---
 tools/libxc/include/xenguest.h   |  8 ++++----
 tools/libxc/xc_domain_restore.c  |  4 ++--
 tools/libxc/xc_domain_save.c     |  4 ++--
 tools/libxc/xc_sr_restore.c      |  2 +-
 tools/libxc/xc_sr_save.c         |  2 +-
 tools/libxl/libxl_save_callout.c | 39 ++++++++++++++++++++++++++-------------
 tools/libxl/libxl_save_helper.c  |  8 ++++++--
 7 files changed, 42 insertions(+), 25 deletions(-)

You have not patched xc_nomigrate.c, which means this will break the ARM build. (I fell into the same trap, requiring c/s f50fe3a5 as a fixup).

Having said that, I plan to throw together some cleanup patches removing files like xc_domain_{save,restore}.c and dropping most of the parameters from the parameter list, as they are superfluous.

I will try to get my cleanup done shortly, which should make this prereq series easier, although I am focusing on some hypervisor side fixes right at the moment.

~Andrew

#74 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 20/25] tools/libx{l, c}: add back channel to libxc

Quoted 48 lines · Andrew Cooper
Quoted 37 lines · Yang Hongyang

In COLO mode, both VMs are running, and are considered in sync if the visible network traffic is identical. After some time, they fall out of sync.

At this point, the two VMs have definitely diverged. Lets call the primary dirty bitmap set A, while the secondary dirty bitmap set B.

Sets A and B are different.

Under normal migration, the page data for set A will be sent form the primary to the secondary.

However, the set difference B - A (lets call this C) is out-of-date on the secondary (with respect to the primary) and will not be sent by the primary, as it was not memory dirtied by the primary. The secondary needs the page data for C to reconstruct an exact copy of the primary at the checkpoint.

The secondary cannot calculate C as it doesn't know A. Instead, the secondary must send B to the primary, at which point the primary calculates the union of A and B (lets call this D) which is all the pages dirtied by both the primary and the secondary, and sends all page data covered by D.

In the general case, D is a superset of both A and B. Without the backchannel dirty bitmap, a COLO checkpoint can't reconstruct a valid copy of the primary.

We transfer the dirty bitmap on libxc side, so we need to introduce back channel to libxc.

commit message:

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
Quoted 9 lines
---
  tools/libxc/include/xenguest.h   |  8 ++++----
  tools/libxc/xc_domain_restore.c  |  4 ++--
  tools/libxc/xc_domain_save.c     |  4 ++--
  tools/libxc/xc_sr_restore.c      |  2 +-
  tools/libxc/xc_sr_save.c         |  2 +-
  tools/libxl/libxl_save_callout.c | 39 ++++++++++++++++++++++++++-------------
  tools/libxl/libxl_save_helper.c  |  8 ++++++--
  7 files changed, 42 insertions(+), 25 deletions(-)
Quoted 2 lines

You have not patched xc_nomigrate.c, which means this will break the ARM build. (I fell into the same trap, requiring c/s f50fe3a5 as a fixup).

Thank you for pointing this out, I will look at that commit.

Quoted 7 lines

Having said that, I plan to throw together some cleanup patches removing files like xc_domain_{save,restore}.c and dropping most of the parameters from the parameter list, as they are superfluous.

I will try to get my cleanup done shortly, which should make this prereq series easier,

That would be great, thanks!

although I am focusing on some hypervisor side fixes

Quoted 5 lines

right at the moment.

~Andrew
.

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

PATCH v4 21/25 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 2e4c944..3cb3ae9 100644
@@ -62,7 +62,7 @@ else
 LIBXL_OBJS-y += libxl_no_convert_callout.o
 endif
 
-LIBXL_OBJS-y += libxl_remus.o libxl_remus_device.o libxl_remus_disk_drbd.o
+LIBXL_OBJS-y += libxl_remus.o libxl_checkpoint_device.o libxl_remus_disk_drbd.o
 
 LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o
 LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
tools/libxl/libxl_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

300 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

192 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 e8d3647..1d676ef 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"),
     (-22, "ABORTED"),
Signature · 1 line
1.9.1
#76 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 21/25] tools/libxl: rename remus device to checkpoint device

Quoted 2 lines · 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

This patch does not appear to have been formatted with git format-patch -M as requested last time around.

#77 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 21/25] tools/libxl: rename remus device to checkpoint device

Quoted 6 lines · Ian Campbell
Quoted 2 lines · 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

This patch does not appear to have been formatted with git format-patch -M as requested last time around.

Sorry I missed this :(
will do in the next version. btw, I have a dump question...how to specify -M for only this patch while it is in a series?

Quoted 4 lines

.

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

Re: [PATCH v4 --for 4.6 COLOPre 21/25] tools/libxl: rename remus device to checkpoint device

Quoted 8 lines · Yang Hongyang
Quoted 5 lines · Ian Campbell
Quoted 3 lines · 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

Quoted 7 lines
Quoted 2 lines

This patch does not appear to have been formatted with git format-patch -M as requested last time around.

Sorry I missed this :(
will do in the next version. btw, I have a dump question...how to specify -M
for only this patch while it is in a series?

Just format the entire series using -M. In most cases it will be a no-op and there will be no change in the generated patch.

~Andrew

#79 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 21/25] tools/libxl: rename remus device to checkpoint device

Quoted 12 lines · Andrew Cooper
Quoted 11 lines · Yang Hongyang
Quoted 7 lines · Ian Campbell
Quoted 3 lines · 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

This patch does not appear to have been formatted with git format-patch -M as requested last time around.

Quoted 7 lines
Quoted 4 lines

Sorry I missed this :(
will do in the next version. btw, I have a dump question...how to specify -M
for only this patch while it is in a series?

Just format the entire series using -M. In most cases it will be a no-op and there will be no change in the generated patch.

Thanks for your help!

Quoted 4 lines

~Andrew
.

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

Re: [PATCH v4 --for 4.6 COLOPre 21/25] tools/libxl: rename remus device to checkpoint device

In reply to Yang Hongyang
Quoted 7 lines · Yang Hongyang
 tools/libxl/libxl_types.idl           |   4 +-
tools/libxl/libxl_types.idl +0 -0
index e8d3647..1d676ef 100644

tools/libxl/libxl_types.idl libxl_error = Enumeration("error", [ · line 68

Quoted 10 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"),
     (-20, "VNUMA_CONFIG_INVALID"),
     (-21, "DOMAIN_NOTFOUND"),
     (-22, "ABORTED"),

This is an API change, which I think we discussed before.

In <[email protected]> you said you would add an extra patch to deal with that, and I think that needs to come before this automatic renaming so that there is no bisect hazard. I don't see any such patch even after this point though (from grepping your colo-v8 branch).

Ian.

#81 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 21/25] tools/libxl: rename remus device to checkpoint device

Quoted 12 lines · Ian Campbell
Quoted 11 lines · Yang Hongyang
  tools/libxl/libxl_types.idl           |   4 +-
tools/libxl/libxl_types.idl +0 -1
index e8d3647..1d676ef 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"),
Quoted 8 lines

tools/libxl/libxl_types.idl libxl_error = Enumeration("error", [ · line 68

Quoted 6 lines
tools/libxl/libxl_types.idl +2 -1
-    (-19, "REMUS_DEVICE_NOT_SUPPORTED"),
+    (-18, "CHECKPOINT_DEVOPS_DOES_NOT_MATCH"),
+    (-19, "CHECKPOINT_DEVICE_NOT_SUPPORTED"),
      (-20, "VNUMA_CONFIG_INVALID"),
      (-21, "DOMAIN_NOTFOUND"),
      (-22, "ABORTED"),

This is an API change, which I think we discussed before.

Also missed this one, sorry.

Quoted 3 lines

In <[email protected]> you said you would add an extra patch to deal with that, and I think that needs to come before this automatic

will add the patch before the automatic renaming.

Quoted 7 lines

renaming so that there is no bisect hazard. I don't see any such patch even after this point though (from grepping your colo-v8 branch).

Ian.

.

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

Re: [PATCH v4 --for 4.6 COLOPre 21/25] tools/libxl: rename remus device to checkpoint device

In reply to Ian Campbell
Quoted 21 lines · Ian Campbell
Quoted 7 lines · Yang Hongyang
  tools/libxl/libxl_types.idl           |   4 +-
tools/libxl/libxl_types.idl +0 -0
index e8d3647..1d676ef 100644

tools/libxl/libxl_types.idl libxl_error = Enumeration("error", [ · line 68

Quoted 10 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"),
      (-20, "VNUMA_CONFIG_INVALID"),
      (-21, "DOMAIN_NOTFOUND"),
      (-22, "ABORTED"),

This is an API change, which I think we discussed before.

Quoted 3 lines

In <[email protected]> you said you would add an extra patch to deal with that, and I think that needs to come before this automatic renaming so that there is no bisect hazard.

Seems either before or after will break the bisection...Only merge in one patch will makes sense...

I don't see any such patch

Quoted 6 lines

even after this point though (from grepping your colo-v8 branch).

Ian.

.

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

Re: [PATCH v4 --for 4.6 COLOPre 21/25] tools/libxl: rename remus device to checkpoint device

Quoted 23 lines · Yang Hongyang
Quoted 21 lines · Ian Campbell
Quoted 7 lines · Yang Hongyang
  tools/libxl/libxl_types.idl           |   4 +-
tools/libxl/libxl_types.idl +0 -0
index e8d3647..1d676ef 100644

tools/libxl/libxl_types.idl libxl_error = Enumeration("error", [ · line 68

Quoted 10 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"),
      (-20, "VNUMA_CONFIG_INVALID"),
      (-21, "DOMAIN_NOTFOUND"),
      (-22, "ABORTED"),

This is an API change, which I think we discussed before.

Quoted 6 lines
Quoted 3 lines

In <[email protected]> you said you would add an extra patch to deal with that, and I think that needs to come before this automatic renaming so that there is no bisect hazard.

Seems either before or after will break the bisection...Only merge in one patch will makes sense...

If you break out this specific renaming into a precursor patch then you can add the compat stuff in at that time. Please don't combine all that into this one patch.

Quoted 8 lines

I don't see any such patch

Quoted 6 lines

even after this point though (from grepping your colo-v8 branch).

Ian.

.

#84 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 21/25] tools/libxl: rename remus device to checkpoint device

Quoted 28 lines · Ian Campbell
Quoted 27 lines · Yang Hongyang
Quoted 24 lines · Ian Campbell
Quoted 7 lines · Yang Hongyang
   tools/libxl/libxl_types.idl           |   4 +-
tools/libxl/libxl_types.idl +0 -0
index e8d3647..1d676ef 100644

tools/libxl/libxl_types.idl libxl_error = Enumeration("error", [ · line 68

Quoted 10 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"),
       (-20, "VNUMA_CONFIG_INVALID"),
       (-21, "DOMAIN_NOTFOUND"),
       (-22, "ABORTED"),

This is an API change, which I think we discussed before.

In <[email protected]> you said you would add an extra patch to deal with that, and I think that needs to come before this automatic renaming so that there is no bisect hazard.

Quoted 6 lines
Quoted 2 lines

Seems either before or after will break the bisection...Only merge in one patch will makes sense...

If you break out this specific renaming into a precursor patch then you can add the compat stuff in at that time. Please don't combine all that into this one patch.

The fix is trival though, can I just quash them and also mention this backword compatibility fix in the commit log?

commit cdfc734337b008a811c1896f9248256474906c82

Author: Yang Hongyang <[email protected]>
Date:   Thu Jul 16 17:23:25 2015 +0800

tools/libxl: fix backword compatibility after the automatic renaming

The error code ERROR_REMUS_XXX was introduced in Xen 4.5, and changed to ERROR_CHECKPOINT_XXX after previous renaming. The patch fix the backword compatibility.

tools/libxl/libxl.h +13 -0
index c492d20..cb3d14f 100644
@@ -835,6 +835,19 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src);
  */
 #define LIBXL_HAVE_SRM_V1 1
 
+/* Remus stuff */
+/*
+ * ERROR_REMUS_XXX error code only exists from Xen 4.5, and in Xen 4.6
+ * it is changed to ERROR_CHECKPOINT_XXX
+ */
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION >= 0x040500 \
+                               && LIBXL_API_VERSION < 0x040600
+#define ERROR_REMUS_DEVOPS_DOES_NOT_MATCH \
+        ERROR_CHECKPOINT_DEVOPS_DOES_NOT_MATCH
+#define ERROR_REMUS_DEVICE_NOT_SUPPORTED \
+        ERROR_CHECKPOINT_DEVICE_NOT_SUPPORTED
+#endif
+
 typedef char **libxl_string_list;
 void libxl_string_list_dispose(libxl_string_list *sl);
 int libxl_string_list_length(const libxl_string_list *sl);
Quoted 13 lines
Quoted 9 lines

I don't see any such patch

Quoted 6 lines

even after this point though (from grepping your colo-v8 branch).

Ian.

.

.

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

Re: [PATCH v4 --for 4.6 COLOPre 21/25] tools/libxl: rename remus device to checkpoint device

Quoted 33 lines · Yang Hongyang
Quoted 31 lines · Ian Campbell
Quoted 29 lines · Yang Hongyang
Quoted 21 lines · Ian Campbell
Quoted 7 lines · Yang Hongyang
   tools/libxl/libxl_types.idl           |   4 +-
tools/libxl/libxl_types.idl +0 -0
index e8d3647..1d676ef 100644

tools/libxl/libxl_types.idl libxl_error = Enumeration("error", [ · line 68

Quoted 10 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"),
       (-20, "VNUMA_CONFIG_INVALID"),
       (-21, "DOMAIN_NOTFOUND"),
       (-22, "ABORTED"),

This is an API change, which I think we discussed before.

Quoted 3 lines

In <[email protected]> you said you would add an extra patch to deal with that, and I think that needs to come before this automatic renaming so that there is no bisect hazard.

Seems either before or after will break the bisection...Only merge in one patch will makes sense...

Quoted 6 lines
Quoted 3 lines

If you break out this specific renaming into a precursor patch then you can add the compat stuff in at that time. Please don't combine all that into this one patch.

The fix is trival though, can I just quash them and also mention this backword compatibility fix in the commit log?

At the moment this particular patch is entirely mechanical (a long list of sed expression), this would make it no longer so.

Ian.

Quoted 54 lines

commit cdfc734337b008a811c1896f9248256474906c82

Author: Yang Hongyang <[email protected]>
Date:   Thu Jul 16 17:23:25 2015 +0800

tools/libxl: fix backword compatibility after the automatic renaming

The error code ERROR_REMUS_XXX was introduced in Xen 4.5, and changed to ERROR_CHECKPOINT_XXX after previous renaming. The patch fix the backword compatibility.

tools/libxl/libxl.h +13 -0
index c492d20..cb3d14f 100644
@@ -835,6 +835,19 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, 
 libxl_mac *src);
   */
  #define LIBXL_HAVE_SRM_V1 1
 
+/* Remus stuff */
+/*
+ * ERROR_REMUS_XXX error code only exists from Xen 4.5, and in Xen 4.6
+ * it is changed to ERROR_CHECKPOINT_XXX
+ */
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION >= 0x040500 \
+                               && LIBXL_API_VERSION < 0x040600
+#define ERROR_REMUS_DEVOPS_DOES_NOT_MATCH \
+        ERROR_CHECKPOINT_DEVOPS_DOES_NOT_MATCH
+#define ERROR_REMUS_DEVICE_NOT_SUPPORTED \
+        ERROR_CHECKPOINT_DEVICE_NOT_SUPPORTED
+#endif
+
  typedef char **libxl_string_list;
  void libxl_string_list_dispose(libxl_string_list *sl);
  int libxl_string_list_length(const libxl_string_list *sl);
Quoted 13 lines
Quoted 9 lines

I don't see any such patch

Quoted 6 lines

even after this point though (from grepping your colo-v8 branch).

Ian.

.

.

#86 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 21/25] tools/libxl: rename remus device to checkpoint device

Quoted 38 lines · Ian Campbell
Quoted 37 lines · Yang Hongyang
Quoted 34 lines · Ian Campbell
Quoted 23 lines · Yang Hongyang
Quoted 21 lines · Ian Campbell
Quoted 7 lines · Yang Hongyang
    tools/libxl/libxl_types.idl           |   4 +-
tools/libxl/libxl_types.idl +0 -0
index e8d3647..1d676ef 100644

tools/libxl/libxl_types.idl libxl_error = Enumeration("error", [ · line 68

Quoted 10 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"),
        (-20, "VNUMA_CONFIG_INVALID"),
        (-21, "DOMAIN_NOTFOUND"),
        (-22, "ABORTED"),

This is an API change, which I think we discussed before.

Quoted 6 lines
Quoted 3 lines

In <[email protected]> you said you would add an extra patch to deal with that, and I think that needs to come before this automatic renaming so that there is no bisect hazard.

Seems either before or after will break the bisection...Only merge in one patch will makes sense...

If you break out this specific renaming into a precursor patch then you can add the compat stuff in at that time. Please don't combine all that into this one patch.

Quoted 5 lines
Quoted 2 lines

The fix is trival though, can I just quash them and also mention this backword compatibility fix in the commit log?

At the moment this particular patch is entirely mechanical (a long list of sed expression), this would make it no longer so.

Ok, I will break out this specific renaming into a precursor patch...

Quoted 61 lines

Ian.

Quoted 37 lines

commit cdfc734337b008a811c1896f9248256474906c82

Author: Yang Hongyang <[email protected]>
Date:   Thu Jul 16 17:23:25 2015 +0800

tools/libxl: fix backword compatibility after the automatic renaming

The error code ERROR_REMUS_XXX was introduced in Xen 4.5, and changed to ERROR_CHECKPOINT_XXX after previous renaming. The patch fix the backword compatibility.

tools/libxl/libxl.h +13 -0
index c492d20..cb3d14f 100644
@@ -835,6 +835,19 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst,
 libxl_mac *src);
    */
   #define LIBXL_HAVE_SRM_V1 1
 
+/* Remus stuff */
+/*
+ * ERROR_REMUS_XXX error code only exists from Xen 4.5, and in Xen 4.6
+ * it is changed to ERROR_CHECKPOINT_XXX
+ */
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION >= 0x040500 \
+                               && LIBXL_API_VERSION < 0x040600
+#define ERROR_REMUS_DEVOPS_DOES_NOT_MATCH \
+        ERROR_CHECKPOINT_DEVOPS_DOES_NOT_MATCH
+#define ERROR_REMUS_DEVICE_NOT_SUPPORTED \
+        ERROR_CHECKPOINT_DEVICE_NOT_SUPPORTED
+#endif
+
   typedef char **libxl_string_list;
   void libxl_string_list_dispose(libxl_string_list *sl);
Quoted 17 lines
   int libxl_string_list_length(const libxl_string_list *sl);
Quoted 13 lines
Quoted 9 lines

I don't see any such patch

Quoted 6 lines

even after this point though (from grepping your colo-v8 branch).

Ian.

.

.

.

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

PATCH v4 22/25 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 901e216..af992fc 100644
@@ -2765,7 +2765,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
@@ -2826,7 +2827,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
@@ -2834,7 +2836,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;
@@ -2847,7 +2849,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).
      */
@@ -2909,13 +2912,13 @@ struct libxl__checkpoint_device {
 _hidden void libxl__checkpoint_devices_setup(libxl__egc *egc,
                                         libxl__checkpoint_devices_state *cds);
 _hidden void libxl__checkpoint_devices_teardown(libxl__egc *egc,
-                                           libxl__checkpoint_devices_state *cds);
+                                        libxl__checkpoint_devices_state *cds);
 _hidden void libxl__checkpoint_devices_postsuspend(libxl__egc *egc,
-                                              libxl__checkpoint_devices_state *cds);
+                                        libxl__checkpoint_devices_state *cds);
 _hidden void libxl__checkpoint_devices_preresume(libxl__egc *egc,
-                                            libxl__checkpoint_devices_state *cds);
+                                        libxl__checkpoint_devices_state *cds);
 _hidden void libxl__checkpoint_devices_commit(libxl__egc *egc,
-                                         libxl__checkpoint_devices_state *cds);
+                                        libxl__checkpoint_devices_state *cds);
 _hidden int libxl__netbuffer_enabled(libxl__gc *gc);
 
 /*----- Legacy conversion helper -----*/
Signature · 1 line
1.9.1
#88 lore raw

PATCH v4 23/25 tools/libxl: store remus_ops in checkpoint device state

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.

This patch and the following 2 will seperate remus from checkpoint device layer.

We use remus ops directly in checkpoint device. Store it in checkpoint device state so that we do not aware of remus_ops in the checkpoint device layer.

it is pure refactoring and no functional changes.

---
 tools/libxl/libxl_checkpoint_device.c | 10 +---------
 tools/libxl/libxl_internal.h          |  2 ++
 tools/libxl/libxl_remus.c             |  9 +++++++++
 3 files changed, 12 insertions(+), 9 deletions(-)
tools/libxl/libxl_checkpoint_device.c +1 -9
index 226f159..bbc6dc4 100644
@@ -17,14 +17,6 @@
 
 #include "libxl_internal.h"
 
-extern const libxl__checkpoint_device_instance_ops remus_device_nic;
-extern const libxl__checkpoint_device_instance_ops remus_device_drbd_disk;
-static const libxl__checkpoint_device_instance_ops *remus_ops[] = {
-    &remus_device_nic,
-    &remus_device_drbd_disk,
-    NULL,
-};
-
 /*----- helper functions -----*/
 
 static int init_device_subkind(libxl__checkpoint_devices_state *cds)
@@ -172,7 +164,7 @@ static void device_setup_iterate(libxl__egc *egc, libxl__ao_device *aodev)
         goto out;
 
     do {
-        dev->ops = remus_ops[++dev->ops_index];
+        dev->ops = dev->cds->ops[++dev->ops_index];
         if (!dev->ops) {
             libxl_device_nic * nic = NULL;
             libxl_device_disk * disk = NULL;
tools/libxl/libxl_internal.h +2 -0
index af992fc..d92eabc 100644
@@ -2842,6 +2842,8 @@ struct libxl__checkpoint_devices_state {
     uint32_t domid;
     libxl__checkpoint_callback *callback;
     int device_kind_flags;
+    /* The ops must be pointer array, and the last ops must be NULL */
+    const libxl__checkpoint_device_instance_ops **ops;
 
     /*----- private for abstract layer only -----*/
 
tools/libxl/libxl_remus.c +9 -0
index fb21b6d..d2e4d42 100644
@@ -18,6 +18,14 @@
 
 #include "libxl_internal.h"
 
+extern const libxl__checkpoint_device_instance_ops remus_device_nic;
+extern const libxl__checkpoint_device_instance_ops remus_device_drbd_disk;
+static const libxl__checkpoint_device_instance_ops *remus_ops[] = {
+    &remus_device_nic,
+    &remus_device_drbd_disk,
+    NULL,
+};
+
 /*-------------------- Remus setup and teardown ---------------------*/
 
 static void remus_setup_done(libxl__egc *egc,
@@ -48,6 +56,7 @@ void libxl__remus_setup(libxl__egc *egc,
     cds->ao = ao;
     cds->domid = dss->domid;
     cds->callback = remus_setup_done;
+    cds->ops = remus_ops;
 
     libxl__checkpoint_devices_setup(egc, cds);
     return;
Signature · 1 line
1.9.1
Acked-by on v4 23/25
#89 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 23/25] tools/libxl: store remus_ops in checkpoint device state

Quoted 7 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.

This patch and the following 2 will seperate remus from checkpoint device layer.

Quoted 8 lines

We use remus ops directly in checkpoint device. Store it in checkpoint device state so that we do not aware of remus_ops in the checkpoint device layer.

it is pure refactoring and no functional changes.

tools/libxl/libxl_checkpoint_device.c static void device_setup_iterate(libxl__egc *egc, libxl__ao_device *aodev) · line 167

Quoted 6 lines
tools/libxl/libxl_checkpoint_device.c +1 -1
@@ -172,7 +164,7 @@ static void device_setup_iterate(libxl__egc *egc, libxl__ao_device *aodev)
         goto out;
 
     do {
-        dev->ops = remus_ops[++dev->ops_index];
+        dev->ops = dev->cds->ops[++dev->ops_index];

This do/while loop is really quite confusingly structured, but that's not your fault.

Ian.

#90 lore raw

PATCH v4 24/25 tools/libxl: move remus state into a seperate structure

In reply to Yang Hongyang

Add a new structure remus state, and move concrete layer's private member to remus state.
it is pure refactoring and no functional changes.

---
 tools/libxl/libxl.c                 |  2 +-
 tools/libxl/libxl_dom_save.c        |  3 +--
 tools/libxl/libxl_internal.h        | 38 ++++++++++++++++-----------
 tools/libxl/libxl_netbuffer.c       | 51 +++++++++++++++++++++----------------
 tools/libxl/libxl_remus.c           | 38 ++++++++++++++-------------
 tools/libxl/libxl_remus_disk_drbd.c |  8 +++---
 6 files changed, 79 insertions(+), 61 deletions(-)
tools/libxl/libxl.c +1 -1
index fcf91f1..5502709 100644
@@ -845,7 +845,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
     assert(info);
 
     /* Point of no return */
-    libxl__remus_setup(egc, dss);
+    libxl__remus_setup(egc, &dss->rs);
     return AO_INPROGRESS;
 
  out:
tools/libxl/libxl_dom_save.c +1 -2
index 9364a1d..9b7159f 100644
@@ -428,7 +428,6 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss)
           | (dss->hvm ? XCFLAGS_HVM : 0);
 
     if (dss->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_REMUS) {
-        dss->interval = r_info->interval;
         if (libxl_defbool_val(r_info->compression))
             dss->xcflags |= XCFLAGS_CHECKPOINT_COMPRESS;
     }
@@ -578,7 +577,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 +23 -15
index d92eabc..9c81d8d 100644
@@ -2864,16 +2864,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;
 };
 
 /*
@@ -2921,6 +2911,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);
 
 /*----- Legacy conversion helper -----*/
@@ -3073,9 +3083,7 @@ struct libxl__domain_save_state {
     int hvm;
     int xcflags;
     libxl__domain_suspend_state dsps;
-    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__stream_write_state sws;
     libxl__logdirty_switch logdirty;
     /* private for libxl__domain_save_device_model */
@@ -3490,9 +3498,9 @@ _hidden void libxl__remus_domain_save_checkpoint_callback(void *data);
 _hidden void libxl__remus_domain_restore_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 +20 -18
index d2e4d42..91abf8e 100644
@@ -33,11 +33,12 @@ static void remus_setup_done(libxl__egc *egc,
 static void remus_setup_failed(libxl__egc *egc,
                                libxl__checkpoint_devices_state *cds, int rc);
 
-void libxl__remus_setup(libxl__egc *egc,
-                        libxl__domain_save_state *dss)
+void libxl__remus_setup(libxl__egc *egc, libxl__remus_state *rs)
 {
+    libxl__domain_save_state *dss = CONTAINER_OF(rs, *dss, rs);
+
     /* Convenience aliases */
-    libxl__checkpoint_devices_state *const cds = &dss->cds;
+    libxl__checkpoint_devices_state *const cds = &rs->cds;
     const libxl_domain_remus_info *const info = dss->remus;
 
     STATE_AO_GC(dss->ao);
@@ -57,6 +58,7 @@ void libxl__remus_setup(libxl__egc *egc,
     cds->domid = dss->domid;
     cds->callback = remus_setup_done;
     cds->ops = remus_ops;
+    rs->interval = info->interval;
 
     libxl__checkpoint_devices_setup(egc, cds);
     return;
@@ -68,7 +70,7 @@ out:
 static void remus_setup_done(libxl__egc *egc,
                                    libxl__checkpoint_devices_state *cds, int rc)
 {
-    libxl__domain_save_state *dss = CONTAINER_OF(cds, *dss, cds);
+    libxl__domain_save_state *dss = CONTAINER_OF(cds, *dss, rs.cds);
     STATE_AO_GC(dss->ao);
 
     if (!rc) {
@@ -85,7 +87,7 @@ static void remus_setup_done(libxl__egc *egc,
 static void remus_setup_failed(libxl__egc *egc,
                                libxl__checkpoint_devices_state *cds, int rc)
 {
-    libxl__domain_save_state *dss = CONTAINER_OF(cds, *dss, cds);
+    libxl__domain_save_state *dss = CONTAINER_OF(cds, *dss, rs.cds);
     STATE_AO_GC(dss->ao);
 
     if (rc)
@@ -99,22 +101,22 @@ static void remus_teardown_done(libxl__egc *egc,
                                 libxl__checkpoint_devices_state *cds,
                                 int rc);
 void libxl__remus_teardown(libxl__egc *egc,
-                           libxl__domain_save_state *dss,
+                           libxl__remus_state *rs,
                            int rc)
 {
     EGC_GC;
 
     LOG(WARN, "Remus: Domain suspend terminated with rc %d,"
         " teardown Remus devices...", rc);
-    dss->cds.callback = remus_teardown_done;
-    libxl__checkpoint_devices_teardown(egc, &dss->cds);
+    rs->cds.callback = remus_teardown_done;
+    libxl__checkpoint_devices_teardown(egc, &rs->cds);
 }
 
 static void remus_teardown_done(libxl__egc *egc,
                                 libxl__checkpoint_devices_state *cds,
                                 int rc)
 {
-    libxl__domain_save_state *dss = CONTAINER_OF(cds, *dss, cds);
+    libxl__domain_save_state *dss = CONTAINER_OF(cds, *dss, rs.cds);
     STATE_AO_GC(dss->ao);
 
     if (rc)
@@ -154,7 +156,7 @@ static void remus_domain_suspend_callback_common_done(libxl__egc *egc,
     if (rc)
         goto out;
 
-    libxl__checkpoint_devices_state *const cds = &dss->cds;
+    libxl__checkpoint_devices_state *const cds = &dss->rs.cds;
     cds->callback = remus_devices_postsuspend_cb;
     libxl__checkpoint_devices_postsuspend(egc, cds);
     return;
@@ -168,7 +170,7 @@ static void remus_devices_postsuspend_cb(libxl__egc *egc,
                                          libxl__checkpoint_devices_state *cds,
                                          int rc)
 {
-    libxl__domain_save_state *dss = CONTAINER_OF(cds, *dss, cds);
+    libxl__domain_save_state *dss = CONTAINER_OF(cds, *dss, rs.cds);
 
     if (rc)
         goto out;
@@ -188,7 +190,7 @@ void libxl__remus_domain_resume_callback(void *data)
     libxl__domain_save_state *dss = shs->caller_state;
     STATE_AO_GC(dss->ao);
 
-    libxl__checkpoint_devices_state *const cds = &dss->cds;
+    libxl__checkpoint_devices_state *const cds = &dss->rs.cds;
     cds->callback = remus_devices_preresume_cb;
     libxl__checkpoint_devices_preresume(egc, cds);
 }
@@ -197,7 +199,7 @@ static void remus_devices_preresume_cb(libxl__egc *egc,
                                        libxl__checkpoint_devices_state *cds,
                                        int rc)
 {
-    libxl__domain_save_state *dss = CONTAINER_OF(cds, *dss, cds);
+    libxl__domain_save_state *dss = CONTAINER_OF(cds, *dss, rs.cds);
     STATE_AO_GC(dss->ao);
 
     if (rc)
@@ -244,7 +246,7 @@ static void remus_checkpoint_stream_written(
     libxl__domain_save_state *dss = CONTAINER_OF(sws, *dss, sws);
 
     /* Convenience aliases */
-    libxl__checkpoint_devices_state *const cds = &dss->cds;
+    libxl__checkpoint_devices_state *const cds = &dss->rs.cds;
 
     STATE_AO_GC(dss->ao);
 
@@ -266,7 +268,7 @@ static void remus_devices_commit_cb(libxl__egc *egc,
                                     libxl__checkpoint_devices_state *cds,
                                     int rc)
 {
-    libxl__domain_save_state *dss = CONTAINER_OF(cds, *dss, cds);
+    libxl__domain_save_state *dss = CONTAINER_OF(cds, *dss, rs.cds);
 
     STATE_AO_GC(dss->ao);
 
@@ -284,9 +286,9 @@ static void remus_devices_commit_cb(libxl__egc *egc,
      */
 
     /* Set checkpoint interval timeout */
-    rc = libxl__ev_time_register_rel(ao, &dss->checkpoint_timeout,
+    rc = libxl__ev_time_register_rel(ao, &dss->rs.checkpoint_timeout,
                                      remus_next_checkpoint,
-                                     dss->interval);
+                                     dss->rs.interval);
 
     if (rc)
         goto out;
@@ -302,7 +304,7 @@ static void remus_next_checkpoint(libxl__egc *egc, libxl__ev_time *ev,
                                   int rc)
 {
     libxl__domain_save_state *dss =
-                            CONTAINER_OF(ev, *dss, checkpoint_timeout);
+                            CONTAINER_OF(ev, *dss, rs.checkpoint_timeout);
 
     STATE_AO_GC(dss->ao);
 
tools/libxl/libxl_remus_disk_drbd.c +5 -3
index b6448f6..616d87e 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
#91 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 24/25] tools/libxl: move remus state into a seperate structure

Quoted 4 lines · Yang Hongyang
tools/libxl/libxl_internal.h +0 -0
@@ -2921,6 +2911,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);

tools/libxl/libxl_internal.h _hidden void libxl__checkpoint_devices_preresume(libxl__egc *egc, · line 2923

Quoted 10 lines
tools/libxl/libxl_internal.h +10 -0
+
+/*----- 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;

This mostly makes sense, I think, but this one field feels like it will be wanted by colo too. Does that mean we will end up with dss->rs.cds and dss->colo.cds doing effectively the same thing?

Ian.

#92 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 24/25] tools/libxl: move remus state into a seperate structure

Quoted 11 lines · Ian Campbell
Quoted 10 lines · Yang Hongyang
tools/libxl/libxl_internal.h +6 -0
@@ -2921,6 +2911,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 */
Quoted 8 lines

tools/libxl/libxl_internal.h _hidden void libxl__checkpoint_devices_preresume(libxl__egc *egc, · line 2923

Quoted 4 lines
tools/libxl/libxl_internal.h +4 -0
+    int interval; /* checkpoint interval */
+
+    /* abstract layer */
+    libxl__checkpoint_devices_state cds;

This mostly makes sense, I think, but this one field feels like it will be wanted by colo too. Does that mean we will end up with dss->rs.cds and dss->colo.cds doing effectively the same thing?

Yes, checkpoint device is an abstract layer, used by both Remus & colo, in the abstract layer, we do not aware of remus or colo, in Remus or colo, we can use container of cds to retrive Remus/colo state.

Quoted 5 lines

Ian.

.

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

Re: [PATCH v4 --for 4.6 COLOPre 24/25] tools/libxl: move remus state into a seperate structure

Quoted 22 lines · Yang Hongyang
Quoted 11 lines · Ian Campbell
Quoted 10 lines · Yang Hongyang
tools/libxl/libxl_internal.h +6 -0
@@ -2921,6 +2911,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 */
Quoted 8 lines

tools/libxl/libxl_internal.h _hidden void libxl__checkpoint_devices_preresume(libxl__egc *egc, · line 2923

Quoted 4 lines
tools/libxl/libxl_internal.h +4 -0
+    int interval; /* checkpoint interval */
+
+    /* abstract layer */
+    libxl__checkpoint_devices_state cds;

This mostly makes sense, I think, but this one field feels like it will be wanted by colo too. Does that mean we will end up with dss->rs.cds and dss->colo.cds doing effectively the same thing?

Quoted 3 lines

Yes, checkpoint device is an abstract layer, used by both Remus & colo, in the abstract layer, we do not aware of remus or colo, in Remus or colo, we can use container of cds to retrive Remus/colo state.

This is because the cds callbacks receive a libxl__checkpoint_devices_state * but are specific to either Remus of Colo?

I think the usual way to solve that would be for the callback to take a void *data "closure" field, which is registered along with the callbacks and passed to all callbacks, or in this case perhaps you can get away with just including it in the cds itself.

Ian, what do you think?

Ian.

#94 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 24/25] tools/libxl: move remus state into a seperate structure

Ian Campbell writes ("Re: [Xen-devel] [PATCH v4 --for 4.6 COLOPre 24/25] tools/libxl: move remus state into a seperate structure"):

Quoted 9 lines · Yang Hongyang
Quoted 3 lines

Yes, checkpoint device is an abstract layer, used by both Remus & colo, in the abstract layer, we do not aware of remus or colo, in Remus or colo, we can use container of cds to retrive Remus/colo state.

This is because the cds callbacks receive a libxl__checkpoint_devices_state * but are specific to either Remus of Colo?

Quoted 6 lines

I think the usual way to solve that would be for the callback to take a void *data "closure" field, which is registered along with the callbacks and passed to all callbacks, or in this case perhaps you can get away with just including it in the cds itself.

Ian, what do you think?

This is rather an unusual situation. Normally there are two patterns:

1.

Things like:

static void device_disk_add(libxl__egc *egc, uint32_t domid,

                           libxl_device_disk *disk,
                           libxl__ao_device *aodev,
                           char *get_vdev(libxl__gc *, void *,
                                          xs_transaction_t),
                           void *get_vdev_user)

and similar patterns in much code in libxl and elsewhere. This is the normal case. (It is of course essential to use this when there are multiple call sites, so the void* data pointer might vary.)

2.

Things like (NB not very like real code):

  struct libxl_some_operation_state {
    libxl_inner_generic_operation_state igos;

  void someop_innerop_make_happen(libxl_some_operation_state *sos) {
    sos->igos.callback = someop_innerop_done;

  void someop_innerop_done(libxl_inner_generic_operation_state *igos) {
    sos = CONTAINER_OF(igos);

Here the callback someop_innerop_done can be sure that CONTAINER_OF is correct because the callback is set up only in one place where it is obvious that the igos is part of a sos.

IMO this is an exception to the usual rule that you have to accompany the function pointer with a void*. The exception is justified because it is very easy to see that the code is correct. And, if any mistake is made, the setup is unconditional, so it will _always_ get the wrong container and go wrong (which will hopefully be spotted in testing).

In this particular situation the plumbing that relates a particular callback to the remus or colo state is rather more complicated. I don't think it will be as obvious that the appropriate CONTAINER_OF is being used, let alone obvious that this it's always the same.

OTOH for any particular callback the context pointer is supposed to be a particular CONTAINER_OF. It would be nice to write this in the code.

I think in this case the best answer would be:

  struct libxl__checkpoint_devices_state {
      void (*postsuspend)(libxl__egc *egc, libxl__remus_device *dev);
      void *callbacks_context;

and in the callback

  void libxl__remus_devices_postsuspend(libxl__egc *egc,
                                libxl__check_devices_state *cds)
  {
      libxl__remus_state *rs = cds->callbacks_context;
      assert(cds = &rs->cds);

or some such.

Thanks,
Ian.

#95 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 24/25] tools/libxl: move remus state into a seperate structure

Quoted 66 lines · Ian Jackson

Ian Campbell writes ("Re: [Xen-devel] [PATCH v4 --for 4.6 COLOPre 24/25] tools/libxl: move remus state into a seperate structure"):

Quoted 9 lines · Yang Hongyang
Quoted 3 lines

Yes, checkpoint device is an abstract layer, used by both Remus & colo, in the abstract layer, we do not aware of remus or colo, in Remus or colo, we can use container of cds to retrive Remus/colo state.

This is because the cds callbacks receive a libxl__checkpoint_devices_state * but are specific to either Remus of Colo?

Quoted 6 lines

I think the usual way to solve that would be for the callback to take a void *data "closure" field, which is registered along with the callbacks and passed to all callbacks, or in this case perhaps you can get away with just including it in the cds itself.

Ian, what do you think?

This is rather an unusual situation. Normally there are two patterns:

1.

Things like:

static void device_disk_add(libxl__egc *egc, uint32_t domid,

                           libxl_device_disk *disk,
                           libxl__ao_device *aodev,
                           char *get_vdev(libxl__gc *, void *,
                                          xs_transaction_t),
                           void *get_vdev_user)

and similar patterns in much code in libxl and elsewhere. This is the normal case. (It is of course essential to use this when there are multiple call sites, so the void* data pointer might vary.)

2.

Things like (NB not very like real code):

  struct libxl_some_operation_state {
    libxl_inner_generic_operation_state igos;

  void someop_innerop_make_happen(libxl_some_operation_state *sos) {
    sos->igos.callback = someop_innerop_done;

  void someop_innerop_done(libxl_inner_generic_operation_state *igos) {
    sos = CONTAINER_OF(igos);

Here the callback someop_innerop_done can be sure that CONTAINER_OF is correct because the callback is set up only in one place where it is obvious that the igos is part of a sos.

IMO this is an exception to the usual rule that you have to accompany the function pointer with a void*. The exception is justified because it is very easy to see that the code is correct. And, if any mistake is made, the setup is unconditional, so it will _always_ get the wrong container and go wrong (which will hopefully be spotted in testing).

In this particular situation the plumbing that relates a particular callback to the remus or colo state is rather more complicated. I don't think it will be as obvious that the appropriate CONTAINER_OF is being used, let alone obvious that this it's always the same.

Quoted 8 lines

OTOH for any particular callback the context pointer is supposed to be a particular CONTAINER_OF. It would be nice to write this in the code.

I think in this case the best answer would be:

  struct libxl__checkpoint_devices_state {
      void (*postsuspend)(libxl__egc *egc, libxl__remus_device *dev);

ITYM s/libxl__remus_device/libxl__checkpoint_devices_state here?

If so then this is pretty much what I meant by "in this case perhaps you can get away with just including it in the cds itself", but more clearly explained.

Quoted 15 lines
      void *callbacks_context;

and in the callback

  void libxl__remus_devices_postsuspend(libxl__egc *egc,
                                libxl__check_devices_state *cds)
  {
      libxl__remus_state *rs = cds->callbacks_context;
      assert(cds = &rs->cds);

or some such.

Thanks,
Ian.

#96 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 24/25] tools/libxl: move remus state into a seperate structure

In reply to Yang Hongyang

Yang Hongyang writes ("[Xen-devel] [PATCH v4 --for 4.6 COLOPre 24/25] tools/libxl: move remus state into a seperate structure"):

Quoted 3 lines

Add a new structure remus state, and move concrete layer's private member to remus state.
it is pure refactoring and no functional changes.

Thanks. I don't have much to add to what Ian Campbell has said, but

Quoted 4 lines
     if (dss->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_REMUS) {
-        dss->interval = r_info->interval;
         if (libxl_defbool_val(r_info->compression))
             dss->xcflags |= XCFLAGS_CHECKPOINT_COMPRESS;

In your next version it would be worth mentioning the movement of this initialisation in the commit message.

Ian.

#97 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 24/25] tools/libxl: move remus state into a seperate structure

Quoted 7 lines · Ian Jackson

Yang Hongyang writes ("[Xen-devel] [PATCH v4 --for 4.6 COLOPre 24/25] tools/libxl: move remus state into a seperate structure"):

Quoted 3 lines

Add a new structure remus state, and move concrete layer's private member to remus state.
it is pure refactoring and no functional changes.

Thanks. I don't have much to add to what Ian Campbell has said, but

Quoted 7 lines
Quoted 4 lines
      if (dss->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_REMUS) {
-        dss->interval = r_info->interval;
          if (libxl_defbool_val(r_info->compression))
              dss->xcflags |= XCFLAGS_CHECKPOINT_COMPRESS;

In your next version it would be worth mentioning the movement of this initialisation in the commit message.

Ok, thanks!

Quoted 4 lines

Ian.
.

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

PATCH v4 25/25 tools/libxl: seperate device init/cleanup from checkpoint device layer

In reply to Yang Hongyang

we call (init|cleanup)_subkind_nic and (init|cleanup)_subkind_drbd_disk directly in checkpoint device. Move them to libxl_remus.c, Call them before calling libxl__checkpoint_devices_setup() or after calling libxl__checkpoint_devices_teardown().
it is pure refactoring and no functional changes.

---
 tools/libxl/libxl_checkpoint_device.c | 42 ++---------------------------------
 tools/libxl/libxl_remus.c             | 42 +++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 40 deletions(-)
tools/libxl/libxl_checkpoint_device.c +2 -40
index bbc6dc4..0a16dbb 100644
@@ -17,38 +17,6 @@
 
 #include "libxl_internal.h"
 
-/*----- helper functions -----*/
-
-static int init_device_subkind(libxl__checkpoint_devices_state *cds)
-{
-    /* init device subkind-specific state in the libxl ctx */
-    int rc;
-    STATE_AO_GC(cds->ao);
-
-    if (libxl__netbuffer_enabled(gc)) {
-        rc = init_subkind_nic(cds);
-        if (rc) goto out;
-    }
-
-    rc = init_subkind_drbd_disk(cds);
-    if (rc) goto out;
-
-    rc = 0;
-out:
-    return rc;
-}
-
-static void cleanup_device_subkind(libxl__checkpoint_devices_state *cds)
-{
-    /* cleanup device subkind-specific state in the libxl ctx */
-    STATE_AO_GC(cds->ao);
-
-    if (libxl__netbuffer_enabled(gc))
-        cleanup_subkind_nic(cds);
-
-    cleanup_subkind_drbd_disk(cds);
-}
-
 /*----- setup() and teardown() -----*/
 
 /* callbacks */
@@ -86,14 +54,10 @@ static void checkpoint_devices_setup(libxl__egc *egc,
 void libxl__checkpoint_devices_setup(libxl__egc *egc,
                                      libxl__checkpoint_devices_state *cds)
 {
-    int i, rc;
+    int i;
 
     STATE_AO_GC(cds->ao);
 
-    rc = init_device_subkind(cds);
-    if (rc)
-        goto out;
-
     cds->num_devices = 0;
     cds->num_nics = 0;
     cds->num_disks = 0;
@@ -126,7 +90,7 @@ void libxl__checkpoint_devices_setup(libxl__egc *egc,
     return;
 
 out:
-    cds->callback(egc, cds, rc);
+    cds->callback(egc, cds, 0);
 }
 
 static void checkpoint_devices_setup(libxl__egc *egc,
@@ -263,8 +227,6 @@ static void devices_teardown_cb(libxl__egc *egc,
     cds->disks = NULL;
     cds->num_disks = 0;
 
-    cleanup_device_subkind(cds);
-
     cds->callback(egc, cds, rc);
 }
 
tools/libxl/libxl_remus.c +42 -0

66 lines not on this page · raw message

Signature · 1 line
1.9.1
Acked-by on v4 25/25
#99 lore raw

Re: [PATCH v4 --for 4.6 COLOPre 25/25] tools/libxl: seperate device init/cleanup from checkpoint device layer

Quoted 8 lines · Yang Hongyang

we call (init|cleanup)_subkind_nic and (init|cleanup)_subkind_drbd_disk directly in checkpoint device. Move them to libxl_remus.c, Call them before calling libxl__checkpoint_devices_setup() or after calling libxl__checkpoint_devices_teardown().
it is pure refactoring and no functional changes.

Quoted 17 lines
tools/libxl/libxl_checkpoint_device.c +1 -5
@@ -86,14 +54,10 @@ static void checkpoint_devices_setup(libxl__egc *egc,
 void libxl__checkpoint_devices_setup(libxl__egc *egc,
                                      libxl__checkpoint_devices_state *cds)
 {
-    int i, rc;
+    int i;
 
     STATE_AO_GC(cds->ao);
 
-    rc = init_device_subkind(cds);
-    if (rc)
-        goto out;
-
     cds->num_devices = 0;
     cds->num_nics = 0;
     cds->num_disks = 0;

tools/libxl/libxl_checkpoint_device.c void libxl__checkpoint_devices_setup(libxl__egc *egc, · line 93

Quoted 5 lines
tools/libxl/libxl_checkpoint_device.c +1 -1
@@ -126,7 +90,7 @@ void libxl__checkpoint_devices_setup(libxl__egc *egc,
     return;
 
 out:
-    cds->callback(egc, cds, rc);
+    cds->callback(egc, cds, 0);

This change highlights a slightly odd (non-error) flow of code when there are no NICs or disks. I think having remus_devices_setup (with its new name) handle by passing its operation and calling all_devices_setup_cb directly if there are no devices would be more natural.

A cleanup for another time though.

#100 lore raw
In reply to Yang Hongyang

Seems my reply emails last night are lost. they didn't appear on the list, I'm going to repost them.

Quoted 102 lines · Yang Hongyang

This patchset is Prerequisite for COLO feature. Refer to:
http://wiki.xen.org/wiki/COLO_-_Coarse_Grain_Lock_Stepping

This patchse is based on Andrew Cooper's Libxl migration v4.1:
http://xenbits.xen.org/gitweb/?p=people/andrewcoop/xen.git;a=shortlog;h=refs/heads/libxl-migv2-v4.1

In this version, I moved some of the COLO specific patches down to the COLO main series, so most patches of this series are refactoring and can be applied first.

I've done some simple test. Both Remus and normal migration work after apply this patchset. The patch to fix Remus on migration v2 will be sent later as a seperate patch.

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

v3->v4:
- Rebased to the latest migration v2 branch
- Addressed comments from last round

v2->v3:
- Merge '[PATCH v2 0/6] Misc cleanups for libxl' into this patchset for easy review
- Addressed review comments
- Add back channel to libxc
- Introduce should_checkpoint callback
- Introduce DIRTY_BITMAP record on libxc side
- Introduce COLO_CONTEXT record on libxl side
- Ported to Libxl migration v2

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

Wen Congyang (2):
tools/libxc: support to resume uncooperative HVM guests tools/libxl: Add back channel to allow migration target send data back

Yang Hongyang (23):
tools/libxl: rename libxl__domain_suspend to libxl__domain_save
A tools/libxl: move domain suspend code into libxl_dom_suspend.c A tools/libxl: move domain resume code into libxl_dom_suspend.c
tools/libxl: rename remus checkpoint callbacks libxl/remus: introduce libxl__remus_setup
libxl/remus: introduce libxl__remus_teardown
libxl/remus: init checkpoint_callback in Remus checkpoint callback tools/libxl: move remus code into libxl_remus.c
A tools/libxl: move save/restore code into libxl_dom_save.c
libxl/save: Refactor libxl__domain_suspend_state tools/libxl: introduce enum type libxl_checkpointed_stream migration/save: pass checkpointed_stream from libxl to libxc tools/libxl: introduce libxl__domain_restore_device_model to load qemu
state
tools/libxl: check QEMU state before resume dm tools/libxl: Update libxl_domain_unpause() to support qemu-xen
A tools/libxl: introduce libxl__domain_common_switch_qemu_logdirty() A tools/libxl: export logdirty_init
tools/libx{l,c}: add back channel to libxc
tools/libxl: rename remus device to checkpoint device
A tools/libxl: adjust the indentation
tools/libxl: store remus_ops in checkpoint device state tools/libxl: move remus state into a seperate structure tools/libxl: seperate device init/cleanup from checkpoint device layer

  tools/libxc/include/xenguest.h        |   13 +-
  tools/libxc/xc_domain_restore.c       |    4 +-
  tools/libxc/xc_domain_save.c          |    6 +-
  tools/libxc/xc_nomigrate.c            |    3 +-
  tools/libxc/xc_resume.c               |   22 +-
  tools/libxc/xc_sr_common.h            |    2 +-
  tools/libxc/xc_sr_restore.c           |    2 +-
  tools/libxc/xc_sr_save.c              |    5 +-
  tools/libxl/Makefile                  |    5 +-
  tools/libxl/libxl.c                   |  119 +---
  tools/libxl/libxl.h                   |   30 +-
  tools/libxl/libxl_checkpoint_device.c |  282 ++++++++
  tools/libxl/libxl_create.c            |   33 +-
  tools/libxl/libxl_dom.c               | 1243 ---------------------------------
  tools/libxl/libxl_dom_save.c          |  721 +++++++++++++++++++
  tools/libxl/libxl_dom_suspend.c       |  503 +++++++++++++
  tools/libxl/libxl_internal.h          |  246 ++++---
  tools/libxl/libxl_netbuffer.c         |  117 ++--
  tools/libxl/libxl_nonetbuffer.c       |   10 +-
  tools/libxl/libxl_qmp.c               |   10 +
  tools/libxl/libxl_remus.c             |  395 +++++++++++
  tools/libxl/libxl_remus_device.c      |  327 ---------
  tools/libxl/libxl_remus_disk_drbd.c   |   56 +-
  tools/libxl/libxl_save_callout.c      |   43 +-
  tools/libxl/libxl_save_helper.c       |    9 +-
  tools/libxl/libxl_stream_write.c      |   14 +-
  tools/libxl/libxl_types.idl           |   10 +-
  tools/libxl/xl_cmdimpl.c              |   21 +-
  tools/ocaml/libs/xl/xenlight_stubs.c  |    2 +-
  29 files changed, 2321 insertions(+), 1932 deletions(-)

create mode 100644 tools/libxl/libxl_checkpoint_device.c create mode 100644 tools/libxl/libxl_dom_save.c create mode 100644 tools/libxl/libxl_dom_suspend.c create mode 100644 tools/libxl/libxl_remus.c delete mode 100644 tools/libxl/libxl_remus_device.c

Signature · 2 lines
Thanks,
Yang.