xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Bruno Alvisio <bruno.alvisio@gmail.com>
To: xen-devel@lists.xen.org, wei.liu2@citrix.com, dave@recoil.org,
	ian.jackson@eu.citrix.com
Subject: [PATCH RFC v3 RESEND 08/12] Migration with Local Disks Mirroring: New stream phase type for libxl streams
Date: Sat, 23 Dec 2017 14:03:32 +0000	[thread overview]
Message-ID: <1514037816-40864-9-git-send-email-bruno.alvisio@gmail.com> (raw)
In-Reply-To: <1514037816-40864-1-git-send-email-bruno.alvisio@gmail.com>

The libxl streams are classified by a stream phase parameter (stream_phase):

0. DEFAULT: This is the stream phase when no local disks are being mirrored as
part of the domain save or restore flow. (=0)

1. POST_MIRROR_DISKS: This stream phase happens during the migration flow after
the disks have been completely mirrored. In time order, this is the second libxl
stream of the migration flow. (=1)

2. PRE_MIRROR_DISKS: This stream happens before the disks start to be mirrored
to the destination. In time order, this is the first libxl stream of the
migration flow. (=2)

libxl__xc_mirror_disks_restore_returned is the callback function in the
libxl_read_stream that is registered for the return of libxc_mirror_disks
stream.

Signed-off-by: Bruno Alvisio <bruno.alvisio@gmail.com>
---
 tools/libxc/include/xenguest.h   |  3 ++-
 tools/libxc/xc_nomigrate.c       |  3 ++-
 tools/libxc/xc_sr_restore.c      |  3 ++-
 tools/libxl/libxl_colo_restore.c |  4 ++--
 tools/libxl/libxl_internal.h     | 12 +++++++++++-
 tools/libxl/libxl_save_callout.c | 13 +++++++++----
 tools/libxl/libxl_save_helper.c  |  5 ++++-
 tools/libxl/libxl_stream_read.c  | 24 ++++++++++++++++++++++--
 tools/libxl/libxl_types.idl      |  6 ++++++
 9 files changed, 60 insertions(+), 13 deletions(-)

diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h
index b4b2e19..014dee0 100644
--- a/tools/libxc/include/xenguest.h
+++ b/tools/libxc/include/xenguest.h
@@ -199,7 +199,8 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
                       unsigned long *console_mfn, uint32_t console_domid,
                       unsigned int hvm, unsigned int pae,
                       xc_migration_stream_t stream_type,
-                      struct restore_callbacks *callbacks, int send_back_fd);
+                      struct restore_callbacks *callbacks, int send_back_fd,
+                      int stream_phase);
 
 /**
  * This function will create a domain for a paravirtualized Linux
diff --git a/tools/libxc/xc_nomigrate.c b/tools/libxc/xc_nomigrate.c
index 6d6169d..75fe560 100644
--- a/tools/libxc/xc_nomigrate.c
+++ b/tools/libxc/xc_nomigrate.c
@@ -34,7 +34,8 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
                       unsigned long *console_mfn, uint32_t console_domid,
                       unsigned int hvm, unsigned int pae,
                       xc_migration_stream_t stream_type,
-                      struct restore_callbacks *callbacks, int send_back_fd)
+                      struct restore_callbacks *callbacks, int send_back_fd,
+                      int stream_phase)
 {
     errno = ENOSYS;
     return -1;
diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c
index ea7b033..7f74d28 100644
--- a/tools/libxc/xc_sr_restore.c
+++ b/tools/libxc/xc_sr_restore.c
@@ -829,7 +829,8 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
                       unsigned long *console_gfn, uint32_t console_domid,
                       unsigned int hvm, unsigned int pae,
                       xc_migration_stream_t stream_type,
-                      struct restore_callbacks *callbacks, int send_back_fd)
+                      struct restore_callbacks *callbacks, int send_back_fd,
+                      int stream_phase)
 {
     xen_pfn_t nr_pfns;
     struct xc_sr_context ctx =
diff --git a/tools/libxl/libxl_colo_restore.c b/tools/libxl/libxl_colo_restore.c
index 0c535bd..a45bf51 100644
--- a/tools/libxl/libxl_colo_restore.c
+++ b/tools/libxl/libxl_colo_restore.c
@@ -132,7 +132,7 @@ static void colo_resume_vm(libxl__egc *egc,
         return;
     }
 
-    libxl__xc_domain_restore_done(egc, dcs, 0, 0, 0);
+    libxl__xc_domain_restore_done(egc, dcs, dcs->srs, 0, 0, 0);
 
     return;
 }
@@ -325,7 +325,7 @@ void libxl__colo_restore_teardown(libxl__egc *egc, void *dcs_void,
         /* crcs->status is LIBXL_COLO_SETUPED */
         dcs->srs.completion_callback = NULL;
     }
-    libxl__xc_domain_restore_done(egc, dcs, ret, retval, errnoval);
+    libxl__xc_domain_restore_done(egc, dcs, dcs->srs, ret, retval, errnoval);
 
     if (crs->qdisk_setuped) {
         libxl__qmp_stop_replication(gc, crs->domid, false);
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index feb9370..76bbe48 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -3825,13 +3825,23 @@ _hidden int libxl__restore_emulator_xenstore_data
 _hidden void libxl__xc_domain_restore(libxl__egc *egc,
                                       libxl__domain_create_state *dcs,
                                       libxl__save_helper_state *shs,
-                                      int hvm, int pae);
+                                      int hvm, int pae, int stream_phase);
 /* If rc==0 then retval is the return value from xc_domain_save
  * and errnoval is the errno value it provided.
  * If rc!=0, retval and errnoval are undefined. */
 _hidden void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void,
+                                           libxl__stream_read_state *stream,
                                            int rc, int retval, int errnoval);
 
+_hidden void libxl__xc_domain_restore_returned(libxl__egc *egc, void *dcs_void,
+                                               int rc, int retval,
+                                               int errnoval);
+
+_hidden void libxl__xc_mirror_disks_restore_returned(libxl__egc *egc,
+                                                     void *dcs_void,
+                                                     int rc, int retval,
+                                                     int errnoval);
+
 _hidden void libxl__save_helper_init(libxl__save_helper_state *shs);
 _hidden void libxl__save_helper_abort(libxl__egc *egc,
                                       libxl__save_helper_state *shs);
diff --git a/tools/libxl/libxl_save_callout.c b/tools/libxl/libxl_save_callout.c
index 6452d70..0ff9a01 100644
--- a/tools/libxl/libxl_save_callout.c
+++ b/tools/libxl/libxl_save_callout.c
@@ -43,7 +43,7 @@ static void helper_done(libxl__egc *egc, libxl__save_helper_state *shs);
 
 void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs,
                               libxl__save_helper_state *shs,
-                              int hvm, int pae)
+                              int hvm, int pae, int stream_phase)
 {
     STATE_AO_GC(dcs->ao);
 
@@ -63,16 +63,21 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs,
         state->console_domid,
         hvm, pae,
         cbflags, dcs->restore_params.checkpointed_stream,
+        stream_phase,
     };
 
     shs->ao = ao;
     shs->domid = domid;
     shs->recv_callback = libxl__srm_callout_received_restore;
     if (dcs->restore_params.checkpointed_stream ==
-        LIBXL_CHECKPOINTED_STREAM_COLO)
+        LIBXL_CHECKPOINTED_STREAM_COLO) {
         shs->completion_callback = libxl__colo_restore_teardown;
-    else
-        shs->completion_callback = libxl__xc_domain_restore_done;
+    } else {
+        if ( stream_phase != LIBXL_STREAM_PHASE_PRE_MIRROR_DISKS )
+            shs->completion_callback = libxl__xc_domain_restore_returned;
+        else
+            shs->completion_callback = libxl__xc_mirror_disks_restore_returned;
+    }
     shs->caller_state = dcs;
     shs->need_results = 1;
 
diff --git a/tools/libxl/libxl_save_helper.c b/tools/libxl/libxl_save_helper.c
index 38089a0..f1e8dca 100644
--- a/tools/libxl/libxl_save_helper.c
+++ b/tools/libxl/libxl_save_helper.c
@@ -279,6 +279,7 @@ int main(int argc, char **argv)
         unsigned int pae =                  strtoul(NEXTARG,0,10);
         unsigned cbflags =                  strtoul(NEXTARG,0,10);
         xc_migration_stream_t stream_type = strtoul(NEXTARG,0,10);
+        int stream_phase =                  atoi(NEXTARG);
         assert(!*++argv);
 
         helper_setcallbacks_restore(&helper_restore_callbacks, cbflags);
@@ -293,7 +294,9 @@ int main(int argc, char **argv)
                               store_domid, console_evtchn, &console_mfn,
                               console_domid, hvm, pae,
                               stream_type,
-                              &helper_restore_callbacks, send_back_fd);
+                              &helper_restore_callbacks, send_back_fd,
+                              stream_phase);
+
         helper_stub_restore_results(store_mfn,console_mfn,0);
         complete(r);
 
diff --git a/tools/libxl/libxl_stream_read.c b/tools/libxl/libxl_stream_read.c
index fcb39ee..4c845c5 100644
--- a/tools/libxl/libxl_stream_read.c
+++ b/tools/libxl/libxl_stream_read.c
@@ -561,6 +561,7 @@ static bool process_record(libxl__egc *egc,
 {
     STATE_AO_GC(stream->ao);
     libxl__domain_create_state *dcs = stream->dcs;
+    int create_mirror_disks = stream->dcs->mirror_disks;
     libxl__sr_record_buf *rec;
     libxl_sr_checkpoint_state *srcs;
     bool further_action_needed = false;
@@ -580,7 +581,9 @@ static bool process_record(libxl__egc *egc,
         break;
 
     case REC_TYPE_LIBXC_CONTEXT:
-        libxl__xc_domain_restore(egc, dcs, &stream->shs, 0, 0);
+        libxl__xc_domain_restore(egc, dcs, &stream->shs, 0, 0,
+                                 stream->mirror_disks +
+                                 create_mirror_disks);
         break;
 
     case REC_TYPE_EMULATOR_XENSTORE_DATA:
@@ -834,10 +837,10 @@ static void stream_done(libxl__egc *egc,
 }
 
 void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void,
+                                   libxl__stream_read_state *stream,
                                    int rc, int retval, int errnoval)
 {
     libxl__domain_create_state *dcs = dcs_void;
-    libxl__stream_read_state *stream = &dcs->srs;
     STATE_AO_GC(dcs->ao);
 
     /* convenience aliases */
@@ -894,6 +897,23 @@ void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void,
     }
 }
 
+void libxl__xc_domain_restore_returned(libxl__egc *egc, void *dcs_void,
+                                       int rc, int retval, int errnoval)
+{
+    libxl__domain_create_state *dcs = dcs_void;
+    libxl__stream_read_state *stream = &dcs->srs;
+    libxl__xc_domain_restore_done(egc, dcs_void, stream, rc, retval, errnoval);
+}
+
+void libxl__xc_mirror_disks_restore_returned(libxl__egc *egc, void *dcs_void,
+                                             int rc, int retval, int errnoval)
+{
+    libxl__domain_create_state *dcs = dcs_void;
+    libxl__stream_read_state *stream = &dcs->srs_mirror_disks;
+    libxl__xc_domain_restore_done(egc, dcs_void, stream, rc, retval, errnoval);
+
+}
+
 static void conversion_done(libxl__egc *egc,
                             libxl__conversion_helper_state *chs, int rc)
 {
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index a239324..3775f25 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -242,6 +242,12 @@ libxl_checkpointed_stream = Enumeration("checkpointed_stream", [
     (2, "COLO"),
     ])
 
+libxl_stream_phase = Enumeration("stream_phase", [
+    (0, "DEFAULT"),
+    (1, "POST_MIRROR_DISKS"),
+    (2, "PRE_MIRROR_DISKS"),
+    ])
+
 libxl_vuart_type = Enumeration("vuart_type", [
     (0, "unknown"),
     (1, "sbsa_uart"),
-- 
2.3.2 (Apple Git-55)


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

  parent reply	other threads:[~2017-12-23 14:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-23 14:03 [PATCH RFC v3 RESEND 00/12] Migration with Local Disks Mirroring Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 01/12] Migration with Local Disks Mirroring: Added support in libxl to handle QMP events Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 02/12] Migration with Local Disks Mirroring: Added QMP commands used for mirroring disks Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 03/12] Migration with Local Disks Mirroring: Refactored migrate_read_fixedmessage Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 04/12] Migration with Local Disks Mirroring: Added a new '-q' flag to xl migrate for disk mirorring Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 05/12] Migration with Local Disks Mirroring: QEMU process is started with '-incoming defer' option Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 06/12] Migration with Local Disks Mirroring: Added 'mirror_disks' field to domain_create_state Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 07/12] Migration with Local Disks Mirroring: Added new libxl_read_stream and callbacks in restore flow Bruno Alvisio
2017-12-23 14:03 ` Bruno Alvisio [this message]
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 09/12] Migration with Local Disks Mirroring: New stream phase type for libxc streams Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 10/12] Migration with Local Disks Mirroring: libxl save flow support Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 11/12] Migration with Local Disks Mirroring: libxl write stream support for stream phase type Bruno Alvisio
2017-12-23 14:03 ` [PATCH RFC v3 RESEND 12/12] Migration with Local Disks Mirroring: Introduce pre_mirror_disks_stream_phase op to xc_sr_save_ops Bruno Alvisio

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=1514037816-40864-9-git-send-email-bruno.alvisio@gmail.com \
    --to=bruno.alvisio@gmail.com \
    --cc=dave@recoil.org \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.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).