Skip to contentSkip to conversation

libxl - Remus support

PATCH Superseded [email protected] 2 participants 6 messages Jan 31, 2012

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl - Remus support

This patch series introduces a basic framework to incorporate Remus into the libxl toolstack. The only functionality currently implemented is memory checkpointing.

These patches depend on "libxl: refactor suspend/resume code" patch series.

Changes since previous version:
* Receiving end of remus is now part of migrate-receive
* Re-use code already present for live migration (refactored in the above mentioned patch series)

Shriram

#1 lore raw

PATCH 1/1 libxl: Remus - suspend/postflush/commit callbacks

# HG changeset patch
# User Shriram Rajagopalan <[email protected]> # Date 1327972786 28800
# Node ID 0129989da2cda789f86f2bc83d9c642a0bcebe60 # Parent ffc99e708e90eb140b0a6f2e7087d567e71e9d0f
libxl: Remus - suspend/postflush/commit callbacks

* Add libxl callback functions for Remus checkpoint suspend, postflush (aka resume) and checkpoint commit callbacks.
* suspend callback is a stub that just bounces off libxl__domain_suspend_common_callback - which suspends the domain and saves the devices model state to a file.
* resume callback currently just resumes the domain (and the device model).
* commit callback just writes out the saved device model state to the network and sleeps for the checkpoint interval.

* Future patches will augument these callbacks with more functionalities like issuing network buffer plug/unplug commands, disk checkpoint commands, etc.

tools/libxl/libxl.c +3 -1
diff -r ffc99e708e90 -r 0129989da2cd tools/libxl/libxl.c
@@ -480,7 +480,9 @@ int libxl_domain_suspend(libxl_ctx *ctx,
     int debug = info != NULL && info->flags & XL_SUSPEND_DEBUG;
     int rc = 0;
 
-    rc = libxl__domain_suspend_common(gc, domid, fd, type, live, debug);
+    rc = libxl__domain_suspend_common(gc, domid, fd, type, live, debug,
+                                      /* No Remus */ NULL);
+
     if (!rc && type == LIBXL_DOMAIN_TYPE_HVM)
         rc = libxl__domain_save_device_model(gc, domid, fd);
     GC_FREE;
tools/libxl/libxl_dom.c +68 -2

100 lines not on this page · raw message

tools/libxl/libxl_internal.h +2 -1
diff -r ffc99e708e90 -r 0129989da2cd tools/libxl/libxl_internal.h
@@ -275,7 +275,8 @@ _hidden int libxl__domain_restore_common
                                          int fd);
 _hidden int libxl__domain_suspend_common(libxl__gc *gc, uint32_t domid, int fd,
                                          libxl_domain_type type,
-                                         int live, int debug);
+                                         int live, int debug,
+                                         const libxl_domain_remus_info *r_info);
 _hidden const char *libxl__device_model_savefile(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__domain_suspend_device_model(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid);
tools/libxl/libxl_types.idl +6 -0
diff -r ffc99e708e90 -r 0129989da2cd tools/libxl/libxl_types.idl
@@ -397,3 +397,9 @@ libxl_sched_sedf = Struct("sched_sedf", 
     ("extratime", integer),
     ("weight", integer),
     ], dispose_fn=None)
+
+libxl_domain_remus_info = Struct("domain_remus_info",[
+    ("interval",     integer),
+    ("blackhole",    bool),
+    ("compression",  bool),
+    ])
#4 lore raw

PATCH 1/1 libxl: Remus - xl remus command

In reply to [email protected]

# HG changeset patch
# User Shriram Rajagopalan <[email protected]> # Date 1327972788 28800
# Node ID 070f78ba4244cf8239ded3a69ccd54ac6e1bd24d # Parent 0129989da2cda789f86f2bc83d9c642a0bcebe60
libxl: Remus - xl remus command

xl remus acts as a frontend to enable remus for a given domain.
* At the moment, only memory checkpointing and blackhole replication is supported. Support for disk checkpointing and network buffering will be added in future.
* Replication is done over ssh connection currently (like live migration with xl). Future versions will have an option to use simple tcp socket based replication channel (for both Remus & live migration).

tools/libxl/libxl.c +34 -0
diff -r 0129989da2cd -r 070f78ba4244 tools/libxl/libxl.c
@@ -471,6 +471,40 @@ libxl_vminfo * libxl_list_vm(libxl_ctx *
     return ptr;
 }
 
+int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
+                             uint32_t domid, int fd)
+{
+    GC_INIT(ctx);
+    libxl_domain_type type = libxl__domain_type(gc, domid);
+    int rc = 0;
+
+    if (info == NULL) {
+        LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+                   "No remus_info structure supplied for domain %d", domid);
+        rc = -1;
+        goto remus_fail;
+    }
+
+    /* TBD: Remus setup - i.e. attach qdisc, enable disk buffering, etc */
+
+    /* Point of no return */
+    rc = libxl__domain_suspend_common(gc, domid, fd, type, /* live */ 1,
+                                      /* debug */ 0, info);
+
+    /* 
+     * With Remus, if we reach this point, it means either
+     * backup died or some network error occurred preventing us
+     * from sending checkpoints.
+     */
+
+    /* TBD: Remus cleanup - i.e. detach qdisc, release other
+     * resources.
+     */
+ remus_fail:
+    GC_FREE;
+    return rc;
+}
+
 int libxl_domain_suspend(libxl_ctx *ctx, libxl_domain_suspend_info *info,
                          uint32_t domid, int fd)
 {
tools/libxl/libxl.h +2 -0
diff -r 0129989da2cd -r 070f78ba4244 tools/libxl/libxl.h
@@ -266,6 +266,8 @@ typedef int (*libxl_console_ready)(libxl
 int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid);
 int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid, int restore_fd);
 void libxl_domain_config_dispose(libxl_domain_config *d_config);
+int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
+                             uint32_t domid, int fd);
 int libxl_domain_suspend(libxl_ctx *ctx, libxl_domain_suspend_info *info,
                           uint32_t domid, int fd);
 int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid, int fast);
tools/libxl/xl.h +1 -0
diff -r 0129989da2cd -r 070f78ba4244 tools/libxl/xl.h
@@ -94,6 +94,7 @@ int main_cpupoolnumasplit(int argc, char
 int main_getenforce(int argc, char **argv);
 int main_setenforce(int argc, char **argv);
 int main_loadpolicy(int argc, char **argv);
+int main_remus(int argc, char **argv);
 
 void help(const char *command);
 
tools/libxl/xl_cmdimpl.c +128 -4

170 lines not on this page · raw message

tools/libxl/xl_cmdtable.c +14 -0
diff -r 0129989da2cd -r 070f78ba4244 tools/libxl/xl_cmdtable.c
@@ -412,6 +412,20 @@ struct cmd_spec cmd_table[] = {
       "Loads a new policy int the Flask Xen security module",
       "<policy file>",
     },
+    { "remus",
+      &main_remus, 0,
+      "Enable Remus HA for domain",
+      "[options] <Domain> [<host>]",
+      "-i MS                   Checkpoint domain memory every MS milliseconds (def. 200ms).\n"
+      "-b                      Replicate memory checkpoints to /dev/null (blackhole)\n"
+      "-u                      Disable memory checkpoint compression.\n"
+      "-s <sshcommand>         Use <sshcommand> instead of ssh.  String will be passed\n"
+      "                        to sh. If empty, run <host> instead of \n"
+      "                        ssh <host> xl migrate-receive -r\n"
+      "-e                      Do not wait in the background (on <host>) for the death\n"
+      "                        of the domain."
+
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
#2 lore raw

Re: [PATCH 1 of 2] libxl: Remus - suspend/postflush/commit callbacks

In reply to [email protected]
Quoted 10 lines
tools/libxl/libxl_dom.c +5 -1
@@ -669,7 +715,27 @@ int libxl__domain_suspend_common(libxl__
     }
 
     memset(&callbacks, 0, sizeof(callbacks));
-    callbacks.suspend = libxl__domain_suspend_common_callback;
+    if (r_info != NULL) {
+        /* save_callbacks:
+         * suspend - called after expiration of checkpoint interval,
+         *           to *suspend* the domain.
+         *

tools/libxl/libxl_dom.c int libxl__domain_suspend_common(libxl__ · line 732

Quoted 10 lines
tools/libxl/libxl_dom.c +10 -0
+         * postcopy - called after the domain's dirty pages have been
+         *            copied into an output buffer. We *resume* the domain
+         *            & the device model, return to the caller. Caller then
+         *            flushes the output buffer, while the domain continues to run.
+         *
+         * checkpoint - called after the memory checkpoint has been flushed out
+         *              into the network. Send the saved device state, *wait*
+         *              for checkpoint ack and *release* the network buffer (TBD).
+         *              Then *sleep* for the checkpoint interval.
+         */

Please can you put this next to the definition of the struct (in xenguest.h). Otherwise this patch looks ok to me.

Ian.

#5 lore raw

Re: [PATCH 2 of 2] libxl: Remus - xl remus command

In reply to [email protected]
Quoted 21 lines · On Tue, 2012-01-31 at 01:22 +0000, [email protected] wrote:

# HG changeset patch
# User Shriram Rajagopalan <[email protected]> # Date 1327972788 28800
# Node ID 070f78ba4244cf8239ded3a69ccd54ac6e1bd24d # Parent 0129989da2cda789f86f2bc83d9c642a0bcebe60
libxl: Remus - xl remus command

xl remus acts as a frontend to enable remus for a given domain.
* At the moment, only memory checkpointing and blackhole replication is supported. Support for disk checkpointing and network buffering will be added in future.
* Replication is done over ssh connection currently (like live migration with xl). Future versions will have an option to use simple tcp socket based replication channel (for both Remus & live migration).

diff -r 0129989da2cd -r 070f78ba4244 tools/libxl/libxl.c

tools/libxl/libxl.c libxl_vminfo * libxl_list_vm(libxl_ctx * · line 475

Quoted 5 lines
tools/libxl/libxl.c +2 -0
@@ -471,6 +471,40 @@ libxl_vminfo * libxl_list_vm(libxl_ctx *
     return ptr;
 }
 
+int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
+                             uint32_t domid, int fd)

This new function probably belongs in patch 1/2 with the other libxl changes.

tools/libxl/libxl.c libxl_vminfo * libxl_list_vm(libxl_ctx * · line 484

Quoted 9 lines
tools/libxl/libxl.c +9 -0
+{
+    GC_INIT(ctx);
+    libxl_domain_type type = libxl__domain_type(gc, domid);
+    int rc = 0;
+
+    if (info == NULL) {
+        LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+                   "No remus_info structure supplied for domain %d", domid);
+        rc = -1;

libxl functions should return one of ERROR_* not -1 one. In this case ERROR_INVAL I suppose.

[...]

tools/libxl/xl_cmdtable.c struct cmd_spec cmd_table[] = { · line 415

Quoted 8 lines

diff -r 0129989da2cd -r 070f78ba4244 tools/libxl/xl_cmdtable.c

tools/libxl/xl_cmdtable.c +1 -0
@@ -412,6 +412,20 @@ struct cmd_spec cmd_table[] = {
       "Loads a new policy int the Flask Xen security module",
       "<policy file>",
     },
+    { "remus",

Please also add this command to docs/man/xl.pod.1.

Otherwise this patch looks good, thanks.

Ian.

#3 lore raw

Re: [PATCH 1 of 2] libxl: Remus - suspend/postflush/commit callbacks

In reply to Ian Campbell
Quoted 23 lines · Ian Campbell

tools/libxl/libxl_dom.c int libxl__domain_suspend_common(libxl__ · line 724

Quoted 12 lines
tools/libxl/libxl_dom.c +7 -1
@@ -669,7 +715,27 @@ int libxl__domain_suspend_common(libxl__
     }
 
     memset(&callbacks, 0, sizeof(callbacks));
-    callbacks.suspend = libxl__domain_suspend_common_callback;
+    if (r_info != NULL) {
+        /* save_callbacks:
+         * suspend - called after expiration of checkpoint interval,
+         *           to *suspend* the domain.
+         *
+         * postcopy - called after the domain's dirty pages have been
+         *            copied into an output buffer. We *resume* the

domain

Review int libxl__domain_suspend_common(libxl__ · line 725

Quoted 1 line
(quoted diff) +1 -0
+         *            & the device model, return to the caller. Caller

then

Review int libxl__domain_suspend_common(libxl__ · line 726

Quoted 1 line
(quoted diff) +1 -0
+         *            flushes the output buffer, while the domain

continues to run.

Review int libxl__domain_suspend_common(libxl__ · line 728

Quoted 2 lines
(quoted diff) +2 -0
+         *
+         * checkpoint - called after the memory checkpoint has been

flushed out

Review int libxl__domain_suspend_common(libxl__ · line 729

Quoted 1 line
(quoted diff) +1 -0
+         *              into the network. Send the saved device state,

*wait*

Review int libxl__domain_suspend_common(libxl__ · line 730

Quoted 1 line
(quoted diff) +1 -0
+         *              for checkpoint ack and *release* the network
Quoted 11 lines

buffer (TBD).

tools/libxl/libxl_dom.c int libxl__domain_suspend_common(libxl__ · line 732

Quoted 2 lines
tools/libxl/libxl_dom.c +2 -0
+         *              Then *sleep* for the checkpoint interval.
+         */

Please can you put this next to the definition of the struct (in xenguest.h). Otherwise this patch looks ok to me.

Ian.

struct save_callbacks already has comments on these callbacks, it is generic though,
as the postcopy and checkpoint callbacks could be used even without Remus. One need
not necessarily do all the actions specified in the above comment.

But, with libxl/remus, it seemed proper to add more detailed comments to the code
that does other things in the callback, specific to remus/checkpointing.

shriram

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