[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH RFC v2 09/23] libxl/migration: wire up the precopy policy RPC callback



From: Joshua Otto <jtotto@xxxxxxxxxxxx>

Permit libxl to implement the xc_domain_save() precopy_policy callback
by adding it to the RPC generation machinery and implementing a policy
in libxl with the same semantics as the old one.

No functional change.

Signed-off-by: Joshua Otto <jtotto@xxxxxxxxxxxx>
---
 tools/libxc/xc_sr_save.c           | 17 +----------------
 tools/libxl/libxl_dom_save.c       | 23 +++++++++++++++++++++++
 tools/libxl/libxl_save_msgs_gen.pl |  4 +++-
 3 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c
index 55b77ff..48d403b 100644
--- a/tools/libxc/xc_sr_save.c
+++ b/tools/libxc/xc_sr_save.c
@@ -1001,17 +1001,6 @@ static int save(struct xc_sr_context *ctx, uint16_t 
guest_type)
     return rc;
 };
 
-static int simple_precopy_policy(struct precopy_stats stats, void *user)
-{
-    if (stats.dirty_count >= 0 && stats.dirty_count < 50)
-        return XGS_POLICY_STOP_AND_COPY;
-
-    if (stats.iteration >= 5)
-        return XGS_POLICY_STOP_AND_COPY;
-
-    return XGS_POLICY_CONTINUE_PRECOPY;
-}
-
 int xc_domain_save(xc_interface *xch, const struct domain_save_params *params,
                    const struct save_callbacks* callbacks)
 {
@@ -1021,12 +1010,8 @@ int xc_domain_save(xc_interface *xch, const struct 
domain_save_params *params,
             .fd = params->save_fd,
         };
 
-    /* XXX use this to shim our precopy_policy in before moving it to libxl */
-    struct save_callbacks overridden_callbacks = *callbacks;
-    overridden_callbacks.precopy_policy = simple_precopy_policy;
-
     /* GCC 4.4 (of CentOS 6.x vintage) can' t initialise anonymous unions. */
-    ctx.save.callbacks = &overridden_callbacks;
+    ctx.save.callbacks = callbacks;
     ctx.save.live  = params->live;
     ctx.save.debug = params->debug;
     ctx.save.checkpointed = params->stream_type;
diff --git a/tools/libxl/libxl_dom_save.c b/tools/libxl/libxl_dom_save.c
index c27813a..b65135d 100644
--- a/tools/libxl/libxl_dom_save.c
+++ b/tools/libxl/libxl_dom_save.c
@@ -328,6 +328,28 @@ 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_precopy_policy(
+    struct precopy_stats stats, void *user)
+{
+    if (stats.dirty_count >= 0 && stats.dirty_count < 50)
+        return XGS_POLICY_STOP_AND_COPY;
+
+    if (stats.iteration >= 5)
+        return XGS_POLICY_STOP_AND_COPY;
+
+    return XGS_POLICY_CONTINUE_PRECOPY;
+}
+
 /*----- main code for saving, in order of execution -----*/
 
 void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss)
@@ -390,6 +412,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_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 27845bb..50c97b4 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,
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.