From: Jennifer Herbert <Jennifer.Herbert@citrix.com>
To: Ian Jackson <ian.jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>,
xen-devel@lists.xenproject.org, jtotto@uwaterloo.ca
Cc: Jennifer Herbert <Jennifer.Herbert@citrix.com>
Subject: [PATCH v2 3/3] RFC: migration: defer precopy policy to libxl
Date: Tue, 19 Sep 2017 19:06:27 +0100 [thread overview]
Message-ID: <1505844387-2224-4-git-send-email-Jennifer.Herbert@citrix.com> (raw)
In-Reply-To: <1505844387-2224-1-git-send-email-Jennifer.Herbert@citrix.com>
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@uwaterloo.ca>
---
I have included this patch, as rfc, as requested by Ian, to show how
libxl can provide a migration precopy policy. This was part of the
same larger patch from Joshua - I have not changed or tested it.
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@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-09-19 18:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-19 18:06 [PATCH v2 0/3] Introduce migration precopy policy Jennifer Herbert
2017-09-19 18:06 ` [PATCH v2 1/3] Tidy libxc xc_domain_save Jennifer Herbert
2017-09-19 18:06 ` [PATCH v2 2/3] Introduce migration precopy policy Jennifer Herbert
2017-09-20 8:35 ` Paul Durrant
2017-09-20 10:20 ` Roger Pau Monné
2017-09-20 16:18 ` Jennifer Herbert
2017-09-21 11:08 ` Roger Pau Monné
2017-09-21 11:13 ` Wei Liu
2017-09-21 14:44 ` Roger Pau Monné
2017-09-19 18:06 ` Jennifer Herbert [this message]
2017-09-20 10:37 ` [PATCH v2 3/3] RFC: migration: defer precopy policy to libxl Roger Pau Monné
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1505844387-2224-4-git-send-email-Jennifer.Herbert@citrix.com \
--to=jennifer.herbert@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jtotto@uwaterloo.ca \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).