All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Yang Hongyang <yanghy@cn.fujitsu.com>, xen-devel@lists.xen.org
Cc: wei.liu2@citrix.com, ian.campbell@citrix.com,
	wency@cn.fujitsu.com, guijianfeng@cn.fujitsu.com,
	yunhong.jiang@intel.com, eddie.dong@intel.com,
	rshriram@cs.ubc.ca, ian.jackson@eu.citrix.com
Subject: Re: [PATCH v8 --for 4.6 COLO 08/25] tools/libxl: handle colo_context records in a libxl migration v2 read stream
Date: Wed, 15 Jul 2015 18:44:19 +0100	[thread overview]
Message-ID: <55A69BF3.3030100@citrix.com> (raw)
In-Reply-To: <1436951936-3447-9-git-send-email-yanghy@cn.fujitsu.com>

On 15/07/15 10:18, Yang Hongyang wrote:
> Read a colo_context and call stream->checkpoint_callback to handle it.
>
> Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---
>  tools/libxl/libxl_internal.h    |  3 +++
>  tools/libxl/libxl_stream_read.c | 51 +++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 54 insertions(+)
>
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 05cee04..1be2a4a 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -3369,6 +3369,7 @@ struct libxl__stream_read_state {
>      int rc;
>      bool running;
>      bool in_checkpoint;
> +    bool in_colo_context;
>      libxl__save_helper_state shs;
>      libxl__conversion_helper_state chs;
>  
> @@ -3396,6 +3397,8 @@ _hidden void libxl__stream_read_start(libxl__egc *egc,
>                                        libxl__stream_read_state *stream);
>  _hidden void libxl__stream_read_start_checkpoint(libxl__egc *egc,
>                                                   libxl__stream_read_state *stream);
> +_hidden void libxl__stream_read_colo_context(libxl__egc *egc,
> +                                             libxl__stream_read_state *stream);
>  _hidden void libxl__stream_read_abort(libxl__egc *egc,
>                                        libxl__stream_read_state *stream, int rc);
>  static inline bool
> diff --git a/tools/libxl/libxl_stream_read.c b/tools/libxl/libxl_stream_read.c
> index b924f05..ab47251 100644
> --- a/tools/libxl/libxl_stream_read.c
> +++ b/tools/libxl/libxl_stream_read.c
> @@ -152,6 +152,13 @@ static void write_emulator_done(libxl__egc *egc,
>                                  libxl__datacopier_state *dc,
>                                  int rc, int onwrite, int errnoval);
>  
> +/* Handlers for colo context mini-loop */
> +static void handle_colo_context(libxl__egc *egc,
> +                                libxl__stream_read_state *stream,
> +                                libxl__sr_record_buf *rec);
> +static void colo_context_done(libxl__egc *egc,
> +                              libxl__stream_read_state *stream, int rc);
> +
>  /*----- Helpers -----*/
>  
>  /* Helper to set up reading some data from the stream. */
> @@ -569,6 +576,15 @@ static bool process_record(libxl__egc *egc,
>          checkpoint_done(egc, stream, 0);
>          break;
>  
> +    case REC_TYPE_COLO_CONTEXT:
> +        if (!stream->in_colo_context) {
> +            LOG(ERROR, "Unexpected COLO_CONTEXT record in stream");
> +            rc = ERROR_FAIL;
> +            goto err;
> +        }
> +        handle_colo_context(egc, stream, rec);
> +        break;
> +
>      default:
>          LOG(ERROR, "Unrecognised record 0x%08x", rec->hdr.type);
>          rc = ERROR_FAIL;
> @@ -678,6 +694,11 @@ static void stream_complete(libxl__egc *egc,
>          return;
>      }
>  
> +    if (stream->in_colo_context) {
> +        colo_context_done(egc, stream, rc);
> +        return;
> +    }
> +
>      if (!stream->rc)
>          stream->rc = rc;
>      stream_done(egc, stream);
> @@ -794,6 +815,36 @@ static void check_all_finished(libxl__egc *egc,
>      stream->completion_callback(egc, stream, stream->rc);
>  }
>  
> +/*----- COLO context handlers -----*/
> +
> +void libxl__stream_read_colo_context(libxl__egc *egc,
> +                                     libxl__stream_read_state *stream)

A name like this makes the erroneous assumption that a COLO\_CONTEXT
record is what is going to be found next in the stream.

Where and when is a COLO\_CONTEXT record expected, and is it only in the
backchannel?

> +{
> +    assert(stream->running);
> +    assert(!stream->in_checkpoint);
> +    assert(!stream->in_colo_context);
> +    stream->in_colo_context = true;
> +
> +    setup_read_record(egc, stream);
> +}
> +
> +static void handle_colo_context(libxl__egc *egc,
> +                                libxl__stream_read_state *stream,
> +                                libxl__sr_record_buf *rec)
> +{
> +    libxl_sr_colo_context *colo_context = rec->body;
> +
> +    colo_context_done(egc, stream, colo_context->id);

A handler this trivial should just be done in the switch statement in
process_record().  No need for its own function for a single forward call.

~Andrew

  reply	other threads:[~2015-07-15 17:44 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-15  9:18 [PATCH v8 --for 4.6 COLO 00/25] COarse-grain LOck-stepping Virtual Machines for Non-stop Service Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 01/25] docs: add colo readme Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 02/25] docs/libxl: Introduce COLO_CONTEXT to support migration v2 colo streams Yang Hongyang
2015-07-15 16:52   ` Andrew Cooper
2015-07-16  6:32     ` Yang Hongyang
2015-07-16  9:45       ` Andrew Cooper
2015-07-16  9:47         ` Andrew Cooper
2015-07-16 10:11         ` Yang Hongyang
2015-07-16 10:20           ` Andrew Cooper
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 03/25] libxc/migration: Specification update for DIRTY_BITMAP records Yang Hongyang
2015-07-15 17:13   ` Andrew Cooper
2015-07-16  7:18     ` Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 04/25] libxc/migration: export read_record for common use Yang Hongyang
2015-07-15 17:14   ` Andrew Cooper
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 05/25] tools/libxl: add back channel support to write stream Yang Hongyang
2015-07-15 17:25   ` Andrew Cooper
2015-07-16  7:21     ` Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 06/25] tools/libxl: write colo_context records into the stream Yang Hongyang
2015-07-15 17:35   ` Andrew Cooper
2015-07-16  7:24     ` Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 07/25] tools/libxl: add back channel support to read stream Yang Hongyang
2015-07-15 17:38   ` Andrew Cooper
2015-07-16  7:25     ` Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 08/25] tools/libxl: handle colo_context records in a libxl migration v2 " Yang Hongyang
2015-07-15 17:44   ` Andrew Cooper [this message]
2015-07-16  7:52     ` Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 09/25] tools/libx{l, c}: introduce should_checkpoint callback Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 10/25] tools/libx{l, c}: add postcopy/suspend callback to restore side Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 11/25] secondary vm suspend/resume/checkpoint code Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 12/25] primary " Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 13/25] libxc/restore: support COLO restore Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 14/25] libxc/restore: send dirty bitmap to primary when checkpoint under colo Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 15/25] send store mfn and console mfn to xl before resuming secondary vm Yang Hongyang
2015-07-15 18:15   ` Andrew Cooper
2015-07-16  7:56     ` Yang Hongyang
2015-07-16  9:49       ` Andrew Cooper
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 16/25] libxc/save: support COLO save Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 17/25] implement the cmdline for COLO Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 18/25] Support colo mode for qemu disk Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 19/25] COLO: use qemu block replication Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 20/25] COLO proxy: implement setup/teardown of COLO proxy module Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 21/25] COLO proxy: preresume, postresume and checkpoint Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 22/25] COLO nic: implement COLO nic subkind Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 23/25] setup and control colo proxy on primary side Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 24/25] setup and control colo proxy on secondary side Yang Hongyang
2015-07-15  9:18 ` [PATCH v8 --for 4.6 COLO 25/25] cmdline switches and config vars to control colo-proxy Yang Hongyang

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=55A69BF3.3030100@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=eddie.dong@intel.com \
    --cc=guijianfeng@cn.fujitsu.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=rshriram@cs.ubc.ca \
    --cc=wei.liu2@citrix.com \
    --cc=wency@cn.fujitsu.com \
    --cc=xen-devel@lists.xen.org \
    --cc=yanghy@cn.fujitsu.com \
    --cc=yunhong.jiang@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.