diff mbox

[v3,3/3] RFC: migration: defer precopy policy to libxl

Message ID 1506365735-133776-4-git-send-email-Jennifer.Herbert@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jennifer Herbert Sept. 25, 2017, 6:55 p.m. UTC
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>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 tools/libxl/libxl_dom_save.c       | 20 ++++++++++++++++++++
 tools/libxl/libxl_save_msgs_gen.pl |  4 +++-
 2 files changed, 23 insertions(+), 1 deletion(-)

Comments

Wei Liu Sept. 26, 2017, 8:48 a.m. UTC | #1
On Mon, Sep 25, 2017 at 07:55:35PM +0100, Jennifer Herbert wrote:
> 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>
> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

The code looks plausible but it is not really usable by libxl users
as-is, because a public API is still missing.
Jennifer Herbert Sept. 26, 2017, 9:42 a.m. UTC | #2
On 26/09/17 09:48, Wei Liu wrote:
> On Mon, Sep 25, 2017 at 07:55:35PM +0100, Jennifer Herbert wrote:
>> 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>
>> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
> The code looks plausible but it is not really usable by libxl users
> as-is, because a public API is still missing.

This is why I excluded it to start with, and now labelled  it RFC.
Its only the first two patches I would like to see pulled atm.

Cheers
diff mbox

Patch

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,