[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC Patch v3 22/22] colo: cmdline switches and config vars to control colo-agent



Add cmdline switches to 'xl migrate-receive' command to specify
a domain-specific hotplug script to setup COLO agent.

Add a new config var 'colo.default.agentscript' to xl.conf, that
allows the user to override the default global script used to
setup COLO agent.

Signed-off-by: Wen Congyang <wency@xxxxxxxxxxxxxx>
---
 docs/man/xl.conf.pod.5        |  6 ++++++
 docs/man/xl.pod.1             |  1 -
 tools/libxl/libxl_colo_save.c |  6 ++++++
 tools/libxl/libxl_create.c    | 17 +++++++++++++---
 tools/libxl/libxl_internal.h  |  1 +
 tools/libxl/libxl_types.idl   |  1 +
 tools/libxl/xl.c              |  3 +++
 tools/libxl/xl.h              |  1 +
 tools/libxl/xl_cmdimpl.c      | 47 ++++++++++++++++++++++++++++++++-----------
 9 files changed, 67 insertions(+), 16 deletions(-)

diff --git a/docs/man/xl.conf.pod.5 b/docs/man/xl.conf.pod.5
index 8ae19bb..c65213d 100644
--- a/docs/man/xl.conf.pod.5
+++ b/docs/man/xl.conf.pod.5
@@ -111,6 +111,12 @@ Configures the default script used by Remus to setup 
network buffering.
 
 Default: C</etc/xen/scripts/remus-netbuf-setup>
 
+=item B<colo.default.agentscript="PATH">
+
+Configures the default script used by COLO to setup colo-agent.
+
+Default: C</etc/xen/scripts/colo-agent-setup>
+
 =item B<output_format="json|sxp">
 
 Configures the default output format used by xl when printing "machine
diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1
index d528e7a..b22bc23 100644
--- a/docs/man/xl.pod.1
+++ b/docs/man/xl.pod.1
@@ -434,7 +434,6 @@ N.B: Remus support in xl is still in experimental 
(proof-of-concept) phase.
      Disk replication support is limited to DRBD disks.
 
      COLO support in xl is still in experimental (proof-of-concept) phase.
-     There is no support for network at the moment.
      Disk replication support is limited to blktap2 disks.
 
 B<OPTIONS>
diff --git a/tools/libxl/libxl_colo_save.c b/tools/libxl/libxl_colo_save.c
index d9f151e..98e4f25 100644
--- a/tools/libxl/libxl_colo_save.c
+++ b/tools/libxl/libxl_colo_save.c
@@ -231,6 +231,12 @@ void libxl__colo_save_setup(libxl__egc *egc, 
libxl__colo_save_state *css)
     css->vm_fd = -1;
     libxl__ev_child_init(&css->child);
 
+    if (dss->remus->netbufscript)
+        css->colo_agent_script = libxl__strdup(gc, dss->remus->netbufscript);
+    else
+        css->colo_agent_script = GCSPRINTF("%s/colo-agent-setup",
+                                           libxl__xen_script_dir_path());
+
     cds->device_kind_flags = (1 << LIBXL__DEVICE_KIND_CHECKPOINT_DISK) |
                              (1 << LIBXL__DEVICE_KIND_CHECKPOINT_NIC);
     cds->ops = colo_ops;
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index b3a2f33..e14046f 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1104,6 +1104,11 @@ static void domcreate_bootloader_done(libxl__egc *egc,
         crs->superpages = superpages;
         crs->pae = pae;
         crs->callback = libxl__colo_restore_setup_done;
+        if (dcs->colo_agent_script)
+            crs->colo_agent_script = libxl__strdup(gc, dcs->colo_agent_script);
+        else
+            crs->colo_agent_script = GCSPRINTF("%s/colo-agent-setup",
+                                               libxl__xen_script_dir_path());
         libxl__colo_restore_setup(egc, crs);
     } else
         libxl__xc_domain_restore(egc, dcs,
@@ -1554,6 +1559,7 @@ static void domain_create_cb(libxl__egc *egc,
 static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config,
                             uint32_t *domid, int restore_fd,
                             int send_fd, int checkpointed_stream,
+                            const char *colo_agent_script,
                             const libxl_asyncop_how *ao_how,
                             const libxl_asyncprogress_how *aop_console_how)
 {
@@ -1567,6 +1573,7 @@ static int do_domain_create(libxl_ctx *ctx, 
libxl_domain_config *d_config,
     cdcs->dcs.send_fd = send_fd;
     cdcs->dcs.callback = domain_create_cb;
     cdcs->dcs.checkpointed_stream = checkpointed_stream;
+    cdcs->dcs.colo_agent_script = colo_agent_script;
     libxl__ao_progress_gethow(&cdcs->dcs.aop_console_how, aop_console_how);
     cdcs->domid_out = domid;
 
@@ -1593,7 +1600,7 @@ int libxl_domain_create_new(libxl_ctx *ctx, 
libxl_domain_config *d_config,
                             const libxl_asyncop_how *ao_how,
                             const libxl_asyncprogress_how *aop_console_how)
 {
-    return do_domain_create(ctx, d_config, domid, -1, -1, 0,
+    return do_domain_create(ctx, d_config, domid, -1, -1, 0, NULL,
                             ao_how, aop_console_how);
 }
 
@@ -1604,12 +1611,16 @@ int libxl_domain_create_restore(libxl_ctx *ctx, 
libxl_domain_config *d_config,
                                 const libxl_asyncprogress_how *aop_console_how)
 {
     int send_fd = -1;
+    char *colo_agent_script = NULL;
 
-    if (params->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_COLO)
+    if (params->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_COLO) {
         send_fd = params->send_fd;
+        colo_agent_script = params->colo_agent_script;
+    }
 
     return do_domain_create(ctx, d_config, domid, restore_fd, send_fd,
-                            params->checkpointed_stream, ao_how, 
aop_console_how);
+                            params->checkpointed_stream, colo_agent_script,
+                            ao_how, aop_console_how);
 }
 
 /*
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 00dfa1e..3851b07 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -3097,6 +3097,7 @@ struct libxl__domain_create_state {
     /* private to domain_create */
     int guest_domid;
     int checkpointed_stream;
+    const char *colo_agent_script;
     libxl__domain_build_state build_state;
     libxl__colo_restore_state crs;
     libxl__bootloader_state bl;
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index dbefe09..346c471 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -316,6 +316,7 @@ libxl_domain_create_info = Struct("domain_create_info",[
 libxl_domain_restore_params = Struct("domain_restore_params", [
     ("checkpointed_stream", integer),
     ("send_fd", integer),
+    ("colo_agent_script", string),
     ])
 
 libxl_domain_sched_params = Struct("domain_sched_params",[
diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c
index f014306..3d746f5 100644
--- a/tools/libxl/xl.c
+++ b/tools/libxl/xl.c
@@ -45,6 +45,7 @@ char *default_bridge = NULL;
 char *default_gatewaydev = NULL;
 char *default_vifbackend = NULL;
 char *default_remus_netbufscript = NULL;
+char *default_colo_agent_script = NULL;
 enum output_format default_output_format = OUTPUT_FORMAT_JSON;
 int claim_mode = 1;
 bool progress_use_cr = 0;
@@ -179,6 +180,8 @@ static void parse_global_config(const char *configfile,
 
     xlu_cfg_replace_string (config, "remus.default.netbufscript",
         &default_remus_netbufscript, 0);
+    xlu_cfg_replace_string (config, "colo.default.agentscript",
+        &default_colo_agent_script, 0);
 
     xlu_cfg_destroy(config);
 }
diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h
index 087eb8c..e273640 100644
--- a/tools/libxl/xl.h
+++ b/tools/libxl/xl.h
@@ -171,6 +171,7 @@ extern char *default_bridge;
 extern char *default_gatewaydev;
 extern char *default_vifbackend;
 extern char *default_remus_netbufscript;
+extern char *default_colo_agent_script;
 extern char *blkdev_start;
 
 enum output_format {
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 945f604..3aef24d 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -150,6 +150,7 @@ struct domain_create {
     const char *config_file;
     const char *extra_config; /* extra config string */
     const char *restore_file;
+    char *colo_agent_script;
     int migrate_fd; /* -1 means none */
     int send_fd; /* -1 means none */
     char **migration_domname_r; /* from malloc */
@@ -2254,6 +2255,7 @@ start:
         libxl_domain_restore_params params;
         params.checkpointed_stream = dom_info->checkpointed_stream;
         params.send_fd = send_fd;
+        params.colo_agent_script = dom_info->colo_agent_script;
         ret = libxl_domain_create_restore(ctx, &d_config,
                                           &domid, restore_fd,
                                           &params,
@@ -3767,7 +3769,8 @@ 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 remus,
+                            char *colo_agent_script)
 {
     uint32_t domid;
     int rc, rc2;
@@ -3794,6 +3797,7 @@ static void migrate_receive(int debug, int daemonize, int 
monitor,
     dom_info.send_fd = send_fd;
     dom_info.migration_domname_r = &migration_domname;
     dom_info.checkpointed_stream = remus;
+    dom_info.colo_agent_script = colo_agent_script;
     if (remus == LIBXL_CHECKPOINTED_STREAM_COLO)
         /* COLO uses stdout to send control message to master */
         dom_info.quiet = 1;
@@ -3988,8 +3992,9 @@ int main_migrate_receive(int argc, char **argv)
 {
     int debug = 0, daemonize = 1, monitor = 1, remus = 0;
     int opt;
+    char *script = NULL;
 
-    SWITCH_FOREACH_OPT(opt, "Fedrc", NULL, "migrate-receive", 0) {
+    SWITCH_FOREACH_OPT(opt, "Fedrcn:", NULL, "migrate-receive", 0) {
     case 'F':
         daemonize = 0;
         break;
@@ -4005,6 +4010,8 @@ int main_migrate_receive(int argc, char **argv)
         break;
     case 'c':
         remus = LIBXL_CHECKPOINTED_STREAM_COLO;
+    case 'n':
+        script = optarg;
     }
 
     if (argc-optind != 0) {
@@ -4013,7 +4020,7 @@ int main_migrate_receive(int argc, char **argv)
     }
     migrate_receive(debug, daemonize, monitor,
                     STDOUT_FILENO, STDIN_FILENO,
-                    remus);
+                    remus, script);
 
     return 0;
 }
@@ -7353,14 +7360,20 @@ int main_remus(int argc, char **argv)
         if (!interval)
             r_info.interval = 0;
 
-        if (r_info.interval || libxl_defbool_val(r_info.blackhole)) {
-            perror("option -c is conflict with -i or -b");
+        if (r_info.interval || libxl_defbool_val(r_info.blackhole) ||
+            !libxl_defbool_is_default(r_info.netbuf) ||
+            !libxl_defbool_is_default(r_info.diskbuf)) {
+            perror("option -c is conflict with -i, -d, -n or -b");
             exit(-1);
         }
     }
 
-    if (!r_info.netbufscript)
-        r_info.netbufscript = default_remus_netbufscript;
+    if (!r_info.netbufscript) {
+        if (libxl_defbool_val(r_info.colo))
+            r_info.netbufscript = default_colo_agent_script;
+        else
+            r_info.netbufscript = default_remus_netbufscript;
+    }
 
     if (libxl_defbool_val(r_info.blackhole)) {
         send_fd = open("/dev/null", O_RDWR, 0644);
@@ -7373,11 +7386,21 @@ int main_remus(int argc, char **argv)
         if (!ssh_command[0]) {
             rune = host;
         } else {
-            if (asprintf(&rune, "exec %s %s xl migrate-receive %s %s",
-                         ssh_command, host,
-                         libxl_defbool_val(r_info.colo) ? "-c" : "-r",
-                         daemonize ? "" : " -e") < 0)
-                return 1;
+            if (!libxl_defbool_val(r_info.colo)) {
+                if (asprintf(&rune, "exec %s %s xl migrate-receive %s %s",
+                             ssh_command, host,
+                             "-r",
+                             daemonize ? "" : " -e") < 0)
+                    return 1;
+            } else {
+                if (asprintf(&rune, "exec %s %s xl migrate-receive %s %s %s 
%s",
+                             ssh_command, host,
+                             "-c",
+                             r_info.netbufscript ? "-n" : "",
+                             r_info.netbufscript ? r_info.netbufscript : "",
+                             daemonize ? "" : " -e") < 0)
+                    return 1;
+            }
         }
 
         save_domain_core_begin(domid, NULL, &config_data, &config_len);
-- 
1.9.3


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.