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

[Xen-devel] [PATCH RFC 3/6] COLO-Proxy: Setup userspace colo-proxy on secondary side



In this patch we add a function to close
kernel COLO-Proxy on secondary side.

Signed-off-by: Zhang Chen <zhangchen.fnst@xxxxxxxxxxxxxx>
---
 tools/libxl/libxl_colo_restore.c |  9 +++++++--
 tools/libxl/libxl_create.c       |  9 +++++++--
 tools/libxl/libxl_types.idl      |  1 +
 tools/libxl/xl_cmdimpl.c         | 18 +++++++++++++++---
 4 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/tools/libxl/libxl_colo_restore.c b/tools/libxl/libxl_colo_restore.c
index 6a96328..1d42539 100644
--- a/tools/libxl/libxl_colo_restore.c
+++ b/tools/libxl/libxl_colo_restore.c
@@ -774,8 +774,13 @@ static void colo_setup_checkpoint_devices(libxl__egc *egc,
 
     STATE_AO_GC(crs->ao);
 
-    cds->device_kind_flags = (1 << LIBXL__DEVICE_KIND_VIF) |
-                             (1 << LIBXL__DEVICE_KIND_VBD);
+    if (crs->cps.is_userspace_proxy) {
+        cds->device_kind_flags = (1 << LIBXL__DEVICE_KIND_VBD);
+    } else {
+        cds->device_kind_flags = (1 << LIBXL__DEVICE_KIND_VIF) |
+                                 (1 << LIBXL__DEVICE_KIND_VBD);
+    }
+
     cds->callback = colo_restore_setup_cds_done;
     cds->ao = ao;
     cds->domid = crs->domid;
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index e3bc257..d230ecd 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1609,6 +1609,7 @@ static int do_domain_create(libxl_ctx *ctx, 
libxl_domain_config *d_config,
                             uint32_t *domid, int restore_fd, int send_back_fd,
                             const libxl_domain_restore_params *params,
                             const char *colo_proxy_script,
+                            const bool userspace_colo_proxy,
                             const libxl_asyncop_how *ao_how,
                             const libxl_asyncprogress_how *aop_console_how)
 {
@@ -1633,6 +1634,7 @@ static int do_domain_create(libxl_ctx *ctx, 
libxl_domain_config *d_config,
     cdcs->dcs.callback = domain_create_cb;
     cdcs->dcs.domid_soft_reset = INVALID_DOMID;
     cdcs->dcs.colo_proxy_script = colo_proxy_script;
+    cdcs->dcs.crs.cps.is_userspace_proxy = userspace_colo_proxy;
     libxl__ao_progress_gethow(&cdcs->dcs.aop_console_how, aop_console_how);
     cdcs->domid_out = domid;
 
@@ -1821,7 +1823,7 @@ int libxl_domain_create_new(libxl_ctx *ctx, 
libxl_domain_config *d_config,
 {
     unset_disk_colo_restore(d_config);
     return do_domain_create(ctx, d_config, domid, -1, -1, NULL, NULL,
-                            ao_how, aop_console_how);
+                            false, ao_how, aop_console_how);
 }
 
 int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config,
@@ -1832,16 +1834,19 @@ int libxl_domain_create_restore(libxl_ctx *ctx, 
libxl_domain_config *d_config,
                                 const libxl_asyncprogress_how *aop_console_how)
 {
     char *colo_proxy_script = NULL;
+    bool userspace_colo_proxy = false;
 
     if (params->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_COLO) {
         colo_proxy_script = params->colo_proxy_script;
+        userspace_colo_proxy = libxl_defbool_val(params->userspace_colo_proxy);
         set_disk_colo_restore(d_config);
     } else {
         unset_disk_colo_restore(d_config);
     }
 
     return do_domain_create(ctx, d_config, domid, restore_fd, send_back_fd,
-                            params, colo_proxy_script, ao_how, 
aop_console_how);
+                            params, colo_proxy_script, userspace_colo_proxy,
+                            ao_how, aop_console_how);
 }
 
 int libxl_domain_soft_reset(libxl_ctx *ctx,
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 1bd2057..89c2c9d 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -390,6 +390,7 @@ libxl_domain_restore_params = 
Struct("domain_restore_params", [
     ("checkpointed_stream", integer),
     ("stream_version", uint32, {'init_val': '1'}),
     ("colo_proxy_script", string),
+    ("userspace_colo_proxy", libxl_defbool),
     ])
 
 libxl_sched_params = Struct("sched_params",[
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 905c5f6..1620bd7 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -162,6 +162,7 @@ struct domain_create {
     char *extra_config; /* extra config string */
     const char *restore_file;
     char *colo_proxy_script;
+    bool userspace_colo_proxy;
     int migrate_fd; /* -1 means none */
     int send_back_fd; /* -1 means none */
     char **migration_domname_r; /* from malloc */
@@ -3024,6 +3025,8 @@ start:
         params.stream_version =
             (hdr.mandatory_flags & XL_MANDATORY_FLAG_STREAMv2) ? 2 : 1;
         params.colo_proxy_script = dom_info->colo_proxy_script;
+        libxl_defbool_set(&params.userspace_colo_proxy,
+                          dom_info->userspace_colo_proxy);
 
         ret = libxl_domain_create_restore(ctx, &d_config,
                                           &domid, restore_fd,
@@ -4824,7 +4827,8 @@ static void migrate_receive(int debug, int daemonize, int 
monitor,
                             int pause_after_migration,
                             int send_fd, int recv_fd,
                             libxl_checkpointed_stream checkpointed,
-                            char *colo_proxy_script)
+                            char *colo_proxy_script,
+                            bool userspace_colo_proxy)
 {
     uint32_t domid;
     int rc, rc2;
@@ -4852,6 +4856,7 @@ static void migrate_receive(int debug, int daemonize, int 
monitor,
     dom_info.migration_domname_r = &migration_domname;
     dom_info.checkpointed_stream = checkpointed;
     dom_info.colo_proxy_script = colo_proxy_script;
+    dom_info.userspace_colo_proxy = userspace_colo_proxy;
 
     rc = create_domain(&dom_info);
     if (rc < 0) {
@@ -5051,11 +5056,13 @@ int main_migrate_receive(int argc, char **argv)
     int debug = 0, daemonize = 1, monitor = 1, pause_after_migration = 0;
     libxl_checkpointed_stream checkpointed = LIBXL_CHECKPOINTED_STREAM_NONE;
     int opt;
+    bool userspace_colo_proxy = false;
     char *script = NULL;
     static struct option opts[] = {
         {"colo", 0, 0, 0x100},
         /* It is a shame that the management code for disk is not here. */
         {"coloft-script", 1, 0, 0x200},
+        {"userspace-colo-proxy", 0, 0, 0x300},
         COMMON_LONG_OPTS
     };
 
@@ -5079,6 +5086,9 @@ int main_migrate_receive(int argc, char **argv)
     case 0x200:
         script = optarg;
         break;
+    case 0x300:
+        userspace_colo_proxy = true;
+        break;
     case 'p':
         pause_after_migration = 1;
         break;
@@ -5090,7 +5100,7 @@ int main_migrate_receive(int argc, char **argv)
     }
     migrate_receive(debug, daemonize, monitor, pause_after_migration,
                     STDOUT_FILENO, STDIN_FILENO,
-                    checkpointed, script);
+                    checkpointed, script, userspace_colo_proxy);
 
     return EXIT_SUCCESS;
 }
@@ -8984,11 +8994,13 @@ int main_remus(int argc, char **argv)
                           "-r",
                           daemonize ? "" : " -e");
             } else {
-                xasprintf(&rune, "exec %s %s xl migrate-receive %s %s %s %s",
+                xasprintf(&rune, "exec %s %s xl migrate-receive %s %s %s %s 
%s",
                           ssh_command, host,
                           "--colo",
                           r_info.netbufscript ? "--coloft-script" : "",
                           r_info.netbufscript ? r_info.netbufscript : "",
+                          libxl_defbool_val(r_info.userspace_colo_proxy) ?
+                          "--userspace-colo-proxy" : "",
                           daemonize ? "" : " -e");
             }
         }
-- 
2.7.4




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

 


Rackspace

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