[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3 3/3] RFC: migration: defer precopy policy to libxl
Provide an implementation of the old policy as a callback in libxl and plumb it through the IPC machinery to libxc. This serves as an example for defining a libxl policy, and provides no advantage over the default policy in libxc. Signed-off-by: Joshua Otto <jtotto@xxxxxxxxxxxx> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> --- tools/libxl/libxl_dom_save.c | 20 ++++++++++++++++++++ tools/libxl/libxl_save_msgs_gen.pl | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_dom_save.c b/tools/libxl/libxl_dom_save.c index 77fe30e..6d28cce 100644 --- a/tools/libxl/libxl_dom_save.c +++ b/tools/libxl/libxl_dom_save.c @@ -328,6 +328,25 @@ int libxl__save_emulator_xenstore_data(libxl__domain_save_state *dss, return rc; } +/* + * This is the live migration precopy policy - it's called periodically during + * the precopy phase of live migrations, and is responsible for deciding when + * the precopy phase should terminate and what should be done next. + * + * The policy implemented here behaves identically to the policy previously + * hard-coded into xc_domain_save() - it proceeds to the stop-and-copy phase of + * the live migration when there are either fewer than 50 dirty pages, or more + * than 5 precopy rounds have completed. + */ +static int libxl__save_live_migration_simple_precopy_policy( + struct precopy_stats stats, void *user) +{ + return ((stats.dirty_count >= 0 && stats.dirty_count < 50) || + stats.iteration >= 5) + ? XGS_POLICY_STOP_AND_COPY + : XGS_POLICY_CONTINUE_PRECOPY; +} + /*----- main code for saving, in order of execution -----*/ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) @@ -401,6 +420,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) if (dss->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_NONE) callbacks->suspend = libxl__domain_suspend_callback; + callbacks->precopy_policy = libxl__save_live_migration_simple_precopy_policy; callbacks->switch_qemu_logdirty = libxl__domain_suspend_common_switch_qemu_logdirty; dss->sws.ao = dss->ao; diff --git a/tools/libxl/libxl_save_msgs_gen.pl b/tools/libxl/libxl_save_msgs_gen.pl index 3ae7373..bb1d4e9 100755 --- a/tools/libxl/libxl_save_msgs_gen.pl +++ b/tools/libxl/libxl_save_msgs_gen.pl @@ -33,6 +33,7 @@ our @msgs = ( 'xen_pfn_t', 'console_gfn'] ], [ 9, 'srW', "complete", [qw(int retval int errnoval)] ], + [ 10, 'scxW', "precopy_policy", ['struct precopy_stats', 'stats'] ] ); #---------------------------------------- @@ -141,7 +142,8 @@ static void bytes_put(unsigned char *const buf, int *len, END -foreach my $simpletype (qw(int uint16_t uint32_t unsigned), 'unsigned long', 'xen_pfn_t') { +foreach my $simpletype (qw(int uint16_t uint32_t unsigned), + 'unsigned long', 'xen_pfn_t', 'struct precopy_stats') { my $typeid = typeid($simpletype); $out_body{'callout'} .= <<END; static int ${typeid}_get(const unsigned char **msg, -- 1.8.3.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |