Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:olh:xen-unstable
xen
xen.sr-max_iters.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xen.sr-max_iters.patch of Package xen
From: Olaf Hering <olaf@aepfle.de> Date: Sat, 9 Jan 2021 11:32:17 +0100 Subject: sr max_iters tools: add --max_iters to libxl_domain_suspend Migrating a large, and potentially busy, domU will take more time than neccessary due to excessive number of copying iterations. Allow to host admin to control the number of iterations which copy cumulated domU dirty pages to the target host. The default remains 5, which means one initial iteration to copy the entire domU memory, and up to 4 additional iterations to copy dirty memory from the still running domU. After the given number of iterations the domU is suspended, remaining dirty memory is copied and the domU is finally moved to the target host. This patch adjusts xl(1) and the libxl API. External users check LIBXL_HAVE_DOMAIN_SUSPEND_PROPS for the availibility of the new .max_iters property. Signed-off-by: Olaf Hering <olaf@aepfle.de> --- docs/man/xl.1.pod.in | 4 ++++ tools/include/libxl.h | 1 + tools/libs/light/libxl_dom_save.c | 2 +- tools/libs/light/libxl_domain.c | 1 + tools/libs/light/libxl_internal.h | 1 + tools/xl/xl_cmdtable.c | 3 ++- tools/xl/xl_migrate.c | 10 ++++++++- 7 files changed, 19 insertions(+), 3 deletions(-) --- a/docs/man/xl.1.pod.in +++ b/docs/man/xl.1.pod.in @@ -486,24 +486,28 @@ both sides. =item B<-p> Leave the domain on the receive side paused after migration. =item B<-D> Preserve the B<domain-id> in the domain coniguration that is transferred such that it will be identical on the destination host, unless that configuration is overridden using the B<-C> option. Note that it is not possible to use this option for a 'localhost' migration. +=item B<--max_iters> I<iterations> + +Number of copy iterations before final suspend+move (default: 5) + =back =item B<remus> [I<OPTIONS>] I<domain-id> I<host> Enable Remus HA or COLO HA for domain. By default B<xl> relies on ssh as a transport mechanism between the two hosts. B<NOTES> =over 4 Remus support in xl is still in experimental (proof-of-concept) phase. --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -1786,24 +1786,25 @@ static inline int libxl_retrieve_domain_configuration_0x041200( #define libxl_retrieve_domain_configuration \ libxl_retrieve_domain_configuration_0x041200 #endif /* * LIBXL_HAVE_DOMAIN_SUSPEND_PROPS indicates that the * libxl_domain_suspend_props() function takes a props struct. */ #define LIBXL_HAVE_DOMAIN_SUSPEND_PROPS 1 typedef struct { uint32_t flags; /* LIBXL_SUSPEND_* */ + uint32_t max_iters; } libxl_domain_suspend_props; #define LIBXL_SUSPEND_DEBUG 1 #define LIBXL_SUSPEND_LIVE 2 int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd, libxl_domain_suspend_props *props, const libxl_asyncop_how *ao_how) LIBXL_EXTERNAL_CALLERS_ONLY; #if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041600 static inline int libxl_domain_suspend_0x041500(libxl_ctx *ctx, uint32_t domid, int fd, int flags, /* LIBXL_SUSPEND_* */ const libxl_asyncop_how *ao_how) --- a/tools/libs/light/libxl_dom_save.c +++ b/tools/libs/light/libxl_dom_save.c @@ -374,25 +374,25 @@ int libxl__save_emulator_xenstore_data(libxl__domain_save_state *dss, } static int libxl__domain_save_precopy_policy(struct precopy_stats stats, void *user) { libxl__save_helper_state *shs = user; libxl__domain_save_state *dss = shs->caller_state; STATE_AO_GC(dss->ao); LOGD(DEBUG, shs->domid, "iteration %u dirty_count %ld total_written %lu", stats.iteration, stats.dirty_count, stats.total_written); if (stats.dirty_count >= 0 && stats.dirty_count < LIBXL_XGS_POLICY_TARGET_DIRTY_COUNT) goto stop_copy; - if (stats.iteration >= LIBXL_XGS_POLICY_MAX_ITERATIONS) + if (stats.iteration >= dss->max_iters) goto stop_copy; return XGS_POLICY_CONTINUE_PRECOPY; stop_copy: return XGS_POLICY_STOP_AND_COPY; } /*----- main code for saving, in order of execution -----*/ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) { STATE_AO_GC(dss->ao); --- a/tools/libs/light/libxl_domain.c +++ b/tools/libs/light/libxl_domain.c @@ -515,24 +515,25 @@ int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd, goto out_err; } libxl__domain_save_state *dss; GCNEW(dss); dss->ao = ao; dss->callback = domain_suspend_cb; dss->domid = domid; dss->fd = fd; dss->type = type; + dss->max_iters = props->max_iters ?: LIBXL_XGS_POLICY_MAX_ITERATIONS; dss->live = props->flags & LIBXL_SUSPEND_LIVE; dss->debug = props->flags & LIBXL_SUSPEND_DEBUG; dss->checkpointed_stream = LIBXL_CHECKPOINTED_STREAM_NONE; rc = libxl__fd_flags_modify_save(gc, dss->fd, ~(O_NONBLOCK|O_NDELAY), 0, &dss->fdfl); if (rc < 0) goto out_err; libxl__domain_save(egc, dss); return AO_INPROGRESS; --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -3648,24 +3648,25 @@ struct libxl__domain_save_state { /* set by caller of libxl__domain_save */ libxl__ao *ao; libxl__domain_save_cb *callback; uint32_t domid; int fd; int fdfl; /* original flags on fd */ int recv_fd; libxl_domain_type type; int live; int debug; int checkpointed_stream; + uint32_t max_iters; const libxl_domain_remus_info *remus; /* private */ int rc; int xcflags; libxl__domain_suspend_state dsps; union { /* for Remus */ libxl__remus_state rs; /* for COLO */ libxl__colo_save_state css; }; libxl__checkpoint_devices_state cds; --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -165,25 +165,26 @@ const struct cmd_spec cmd_table[] = { &main_migrate, 0, 1, "Migrate a domain to another host", "[options] <Domain> <host>", "-h Print this help.\n" "-C <config> Send <config> instead of config file from creation.\n" "-s <sshcommand> Use <sshcommand> instead of ssh. String will be passed\n" " to sh. If empty, run <host> instead of ssh <host> xl\n" " migrate-receive [-d -e]\n" "-e Do not wait in the background (on <host>) for the death\n" " of the domain.\n" "--debug Enable verification mode.\n" "-p Do not unpause domain after migrating it.\n" - "-D Preserve the domain id" + "-D Preserve the domain id\n" + "--max_iters N Number of copy iterations before final stop+move" }, { "restore", &main_restore, 0, 1, "Restore a domain from a saved state", "[options] [<ConfigFile>] <CheckpointFile>", "-h Print this help.\n" "-p Do not unpause domain after restoring it.\n" "-e Do not wait in the background for the death of the domain.\n" "-d Enable debug messages.\n" "-V, --vncviewer Connect to the VNC display after the domain is created.\n" "-A, --vncviewer-autopass Pass VNC password to viewer via stdin." }, --- a/tools/xl/xl_migrate.c +++ b/tools/xl/xl_migrate.c @@ -169,35 +169,37 @@ static void migrate_do_preamble(int send_fd, int recv_fd, pid_t child, close(send_fd); migration_child_report(recv_fd); exit(EXIT_FAILURE); } save_domain_core_writeconfig(send_fd, "migration stream", config_data, config_len); } static void migrate_domain(uint32_t domid, int preserve_domid, const char *rune, int debug, + uint32_t max_iters, const char *override_config_file) { pid_t child = -1; int rc; int send_fd = -1, recv_fd = -1; char *away_domname; char rc_buf; uint8_t *config_data; int config_len; libxl_domain_suspend_props props = { .flags = LIBXL_SUSPEND_LIVE, + .max_iters = max_iters, }; save_domain_core_begin(domid, preserve_domid, override_config_file, &config_data, &config_len); if (!config_len) { fprintf(stderr, "No config file stored for running domain and " "none supplied - cannot migrate.\n"); exit(EXIT_FAILURE); } child = create_migration_child(rune, &send_fd, &recv_fd); @@ -533,26 +535,28 @@ int main_migrate_receive(int argc, char **argv) return EXIT_SUCCESS; } int main_migrate(int argc, char **argv) { uint32_t domid; const char *config_filename = NULL; const char *ssh_command = "ssh"; char *rune = NULL; char *host; int opt, daemonize = 1, monitor = 1, debug = 0, pause_after_migration = 0; int preserve_domid = 0; + uint32_t max_iters = 0; static struct option opts[] = { {"debug", 0, 0, 0x100}, + {"max_iters", 1, 0, 0x101}, {"live", 0, 0, 0x200}, COMMON_LONG_OPTS }; SWITCH_FOREACH_OPT(opt, "FC:s:epD", opts, "migrate", 2) { case 'C': config_filename = optarg; break; case 's': ssh_command = optarg; break; case 'F': @@ -562,24 +566,27 @@ int main_migrate(int argc, char **argv) daemonize = 0; monitor = 0; break; case 'p': pause_after_migration = 1; break; case 'D': preserve_domid = 1; break; case 0x100: /* --debug */ debug = 1; break; + case 0x101: /* --max_iters */ + max_iters = atoi(optarg); + break; case 0x200: /* --live */ /* ignored for compatibility with xm */ break; } domid = find_domain(argv[optind]); host = argv[optind + 1]; bool pass_tty_arg = progress_use_cr || (isatty(2) > 0); if (!ssh_command[0]) { rune= host; @@ -596,25 +603,26 @@ int main_migrate(int argc, char **argv) verbose_len = (minmsglevel_default - minmsglevel) + 2; } xasprintf(&rune, "exec %s %s xl%s%s%.*s migrate-receive%s%s%s", ssh_command, host, pass_tty_arg ? " -t" : "", timestamps ? " -T" : "", verbose_len, verbose_buf, daemonize ? "" : " -e", debug ? " -d" : "", pause_after_migration ? " -p" : ""); } - migrate_domain(domid, preserve_domid, rune, debug, config_filename); + migrate_domain(domid, preserve_domid, rune, debug, + max_iters, config_filename); return EXIT_SUCCESS; } int main_remus(int argc, char **argv) { uint32_t domid; int opt, rc, daemonize = 1; const char *ssh_command = "ssh"; char *host = NULL, *rune = NULL; libxl_domain_remus_info r_info; int send_fd = -1, recv_fd = -1; pid_t child = -1;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor