[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC v2 2/8] Modified xl stack to receieve mirror QEMU disk option
--- tools/ocaml/libs/xl/xenlight_stubs.c | 4 +-- tools/xl/xl.h | 1 + tools/xl/xl_migrate.c | 47 +++++++++++++++++++++++++++++------- tools/xl/xl_saverestore.c | 2 +- tools/xl/xl_vmcontrol.c | 5 ++-- 5 files changed, 45 insertions(+), 14 deletions(-) diff --git a/tools/ocaml/libs/xl/xenlight_stubs.c b/tools/ocaml/libs/xl/xenlight_stubs.c index 98b52b9..9e19009 100644 --- a/tools/ocaml/libs/xl/xenlight_stubs.c +++ b/tools/ocaml/libs/xl/xenlight_stubs.c @@ -538,7 +538,7 @@ value stub_libxl_domain_create_restore(value ctx, value domain_config, value par caml_enter_blocking_section(); ret = libxl_domain_create_restore(CTX, &c_dconfig, &c_domid, restore_fd, - -1, &c_params, ao_how, NULL); + -1, 0, &c_params, ao_how, NULL); caml_leave_blocking_section(); free(ao_how); @@ -611,7 +611,7 @@ value stub_libxl_domain_suspend(value ctx, value domid, value fd, value async, v libxl_asyncop_how *ao_how = aohow_val(async); caml_enter_blocking_section(); - ret = libxl_domain_suspend(CTX, c_domid, c_fd, 0, ao_how); + ret = libxl_domain_suspend(CTX, c_domid, c_fd, 0, NULL, ao_how); caml_leave_blocking_section(); free(ao_how); diff --git a/tools/xl/xl.h b/tools/xl/xl.h index 01c2af6..070bac1 100644 --- a/tools/xl/xl.h +++ b/tools/xl/xl.h @@ -35,6 +35,7 @@ struct domain_create { int daemonize; int monitor; /* handle guest reboots etc */ int paused; + int mirror_qemu_disk; int dryrun; int quiet; int vnc; diff --git a/tools/xl/xl_migrate.c b/tools/xl/xl_migrate.c index 1f0e87d..fee726f 100644 --- a/tools/xl/xl_migrate.c +++ b/tools/xl/xl_migrate.c @@ -177,7 +177,8 @@ static void migrate_do_preamble(int send_fd, int recv_fd, pid_t child, } static void migrate_domain(uint32_t domid, const char *rune, int debug, - const char *override_config_file) + const char *override_config_file, + int mirror_qemu_disks, const char* hostname) { pid_t child = -1; int rc; @@ -205,7 +206,9 @@ static void migrate_domain(uint32_t domid, const char *rune, int debug, if (debug) flags |= LIBXL_SUSPEND_DEBUG; - rc = libxl_domain_suspend(ctx, domid, send_fd, flags, NULL); + if(mirror_qemu_disks) + flags |= LIBXL_SUSPEND_MIRROR_QEMU_DISKS; + rc = libxl_domain_suspend(ctx, domid, send_fd, flags, hostname, NULL); if (rc) { fprintf(stderr, "migration sender: libxl_domain_suspend failed" " (rc=%d)\n", rc); @@ -316,7 +319,7 @@ static void migrate_domain(uint32_t domid, const char *rune, int debug, } static void migrate_receive(int debug, int daemonize, int monitor, - int pause_after_migration, + int pause_after_migration, int mirror_qemu_disks, int send_fd, int recv_fd, libxl_checkpointed_stream checkpointed, char *colo_proxy_script, @@ -343,6 +346,7 @@ static void migrate_receive(int debug, int daemonize, int monitor, dom_info.daemonize = daemonize; dom_info.monitor = monitor; dom_info.paused = 1; + dom_info.mirror_qemu_disks = mirror_qemu_disks; dom_info.migrate_fd = recv_fd; dom_info.send_back_fd = send_fd; dom_info.migration_domname_r = &migration_domname; @@ -423,6 +427,17 @@ static void migrate_receive(int debug, int daemonize, int monitor, fprintf(stderr, "migration target: Got permission, starting domain.\n"); + if(mirror_qemu_disks){ + fprintf(stderr, "migration target: Stopping NBD server\n"); + rc = libxl__nbd_server_stop(ctx, domid); + if (rc){ + rc = 0; //For now, mask the error if NBD server fails to stop + fprintf(stderr, "Failed to stop NBD server\n"); + }else{ + fprintf(stderr, "Stopped NBD server successfully\n"); + } + } + if (migration_domname) { rc = libxl_domain_rename(ctx, domid, migration_domname, common_domname); if (rc) goto perhaps_destroy_notify_rc; @@ -478,6 +493,7 @@ static void migrate_receive(int debug, int daemonize, int monitor, int main_migrate_receive(int argc, char **argv) { int debug = 0, daemonize = 1, monitor = 1, pause_after_migration = 0; + int mirror_qemu_disks = 0; libxl_checkpointed_stream checkpointed = LIBXL_CHECKPOINTED_STREAM_NONE; int opt; bool userspace_colo_proxy = false; @@ -490,7 +506,7 @@ int main_migrate_receive(int argc, char **argv) COMMON_LONG_OPTS }; - SWITCH_FOREACH_OPT(opt, "Fedrp", opts, "migrate-receive", 0) { + SWITCH_FOREACH_OPT(opt, "Fedrpq", opts, "migrate-receive", 0) { case 'F': daemonize = 0; break; @@ -516,6 +532,9 @@ int main_migrate_receive(int argc, char **argv) case 'p': pause_after_migration = 1; break; + case 'q': + mirror_qemu_disks = 1; + break; } if (argc-optind != 0) { @@ -523,7 +542,7 @@ int main_migrate_receive(int argc, char **argv) return EXIT_FAILURE; } migrate_receive(debug, daemonize, monitor, pause_after_migration, - STDOUT_FILENO, STDIN_FILENO, + mirror_qemu_disks, STDOUT_FILENO, STDIN_FILENO, checkpointed, script, userspace_colo_proxy); return EXIT_SUCCESS; @@ -536,14 +555,16 @@ int main_migrate(int argc, char **argv) const char *ssh_command = "ssh"; char *rune = NULL; char *host; + char *hostname; int opt, daemonize = 1, monitor = 1, debug = 0, pause_after_migration = 0; + int mirror_qemu_disks = 0; static struct option opts[] = { {"debug", 0, 0, 0x100}, {"live", 0, 0, 0x200}, COMMON_LONG_OPTS }; - SWITCH_FOREACH_OPT(opt, "FC:s:ep", opts, "migrate", 2) { + SWITCH_FOREACH_OPT(opt, "FC:s:epq", opts, "migrate", 2) { case 'C': config_filename = optarg; break; @@ -560,6 +581,9 @@ int main_migrate(int argc, char **argv) case 'p': pause_after_migration = 1; break; + case 'q': + mirror_qemu_disks = 1; + break; case 0x100: /* --debug */ debug = 1; break; @@ -571,6 +595,9 @@ int main_migrate(int argc, char **argv) domid = find_domain(argv[optind]); host = argv[optind + 1]; + hostname = strchr(host, '@'); + hostname++; + bool pass_tty_arg = progress_use_cr || (isatty(2) > 0); if (!ssh_command[0]) { @@ -587,16 +614,18 @@ int main_migrate(int argc, char **argv) } else { verbose_len = (minmsglevel_default - minmsglevel) + 2; } - xasprintf(&rune, "exec %s %s xl%s%.*s migrate-receive%s%s%s", + xasprintf(&rune, "exec %s %s xl%s%.*s migrate-receive%s%s%s%s", ssh_command, host, pass_tty_arg ? " -t" : "", verbose_len, verbose_buf, daemonize ? "" : " -e", debug ? " -d" : "", - pause_after_migration ? " -p" : ""); + pause_after_migration ? " -p" : "", + mirror_qemu_disks ? "-q" :""); } - migrate_domain(domid, rune, debug, config_filename); + migrate_domain(domid, rune, debug, config_filename, mirror_qemu_disks, + hostname); return EXIT_SUCCESS; } diff --git a/tools/xl/xl_saverestore.c b/tools/xl/xl_saverestore.c index 9afeade..b1679ba 100644 --- a/tools/xl/xl_saverestore.c +++ b/tools/xl/xl_saverestore.c @@ -141,7 +141,7 @@ static int save_domain(uint32_t domid, const char *filename, int checkpoint, save_domain_core_writeconfig(fd, filename, config_data, config_len); - int rc = libxl_domain_suspend(ctx, domid, fd, 0, NULL); + int rc = libxl_domain_suspend(ctx, domid, fd, 0, NULL, NULL); close(fd); if (rc < 0) { diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index 89c2b25..47ec546 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -882,8 +882,9 @@ start: ret = libxl_domain_create_restore(ctx, &d_config, &domid, restore_fd, - send_back_fd, ¶ms, - 0, autoconnect_console_how); + send_back_fd, + dom_info->mirror_qemu_disks, + ¶ms, 0, autoconnect_console_how); libxl_domain_restore_params_dispose(¶ms); -- 2.3.2 (Apple Git-55) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |