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

Re: [Xen-devel] [PATCH v8 --for 4.6 COLO 07/25] tools/libxl: add back channel support to read stream



On 07/16/2015 01:38 AM, Andrew Cooper wrote:
On 15/07/15 10:18, Yang Hongyang wrote:
This is used by primay to read records sent by secondary.

Signed-off-by: Yang Hongyang <yanghy@xxxxxxxxxxxxxx>
---
  tools/libxl/libxl_create.c      |  1 +
  tools/libxl/libxl_internal.h    |  1 +
  tools/libxl/libxl_stream_read.c | 17 +++++++++++++++++
  3 files changed, 19 insertions(+)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 1d4b13b..1af7103 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -978,6 +978,7 @@ static void domcreate_bootloader_done(libxl__egc *egc,
      dcs->srs.dcs = dcs;
      dcs->srs.fd = restore_fd;
      dcs->srs.legacy = (dcs->restore_params.stream_version == 1);
+    dcs->srs.back_channel = false;
      dcs->srs.completion_callback = domcreate_stream_done;

      libxl__stream_read_start(egc, &dcs->srs);
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 2634836..05cee04 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -3358,6 +3358,7 @@ struct libxl__stream_read_state {
      libxl__domain_create_state *dcs;
      int fd;
      bool legacy;
+    bool back_channel;
      void (*completion_callback)(libxl__egc *egc,
                                  libxl__stream_read_state *srs,
                                  int rc);
diff --git a/tools/libxl/libxl_stream_read.c b/tools/libxl/libxl_stream_read.c
index 2d17403..b924f05 100644
--- a/tools/libxl/libxl_stream_read.c
+++ b/tools/libxl/libxl_stream_read.c
@@ -104,6 +104,15 @@
   * Depending on the contents of the stream, there are likely to be several
   * parallel tasks being managed.  check_all_finished() is used to join all
   * tasks in both success and error cases.
+ *
+ * For back channel stream:
+ * - libxl__stream_read_start()
+ *    - Set up the stream to running state
+ *
+ * - libxl__stream_read_continue()
+ *     - Set up reading the next record from a started stream.
+ *       Add some codes to process_record() to handle the record.
+ *       Then call stream->checkpoint_callback() to return.
   */

  /* Success/error/cleanup handling. */
@@ -200,6 +209,9 @@ void libxl__stream_read_start(libxl__egc *egc,
      stream->running = true;
      stream->phase   = SRS_PHASE_NORMAL;

+    if (stream->back_channel)
+        return;
+
      if (stream->legacy) {
          /* Convert the legacy stream. */
          libxl__conversion_helper_state *chs = &stream->chs;
@@ -700,6 +712,11 @@ static void stream_done(libxl__egc *egc,
      assert(!stream->in_checkpoint);
      stream->running = false;

+    if (stream->back_channel) {
+        stream->completion_callback(egc, stream, stream->rc);
+        return;
+    }
+

This should be in stream_complete() not stream_done().  stream_done() is
strictly called once, and cleans stuff up.

Ok, will look into the code closely.


~Andrew
.


--
Thanks,
Yang.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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