All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>,
	Ian Jackson <Ian.Jackson@citrix.com>
Subject: [Xen-devel] [PATCH v2 06/17] libxc/restore: Support v3 streams and handle STATIC_DATA_END
Date: Mon, 27 Jan 2020 14:34:33 +0000	[thread overview]
Message-ID: <20200127143444.25538-7-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20200127143444.25538-1-andrew.cooper3@citrix.com>

Higher level toolstacks may wish to know when the static data is complete, so
introduce a restore_callback for the purpose.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Ian Jackson <Ian.Jackson@citrix.com>
CC: Wei Liu <wl@xen.org>

v2:
 * Split/rearranged from v1
---
 tools/libxc/include/xenguest.h |  3 +++
 tools/libxc/xc_sr_common.h     |  3 +++
 tools/libxc/xc_sr_restore.c    | 29 +++++++++++++++++++++++++++--
 3 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h
index 19d828a7f2..efd90b0d42 100644
--- a/tools/libxc/include/xenguest.h
+++ b/tools/libxc/include/xenguest.h
@@ -139,6 +139,9 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom,
 
 /* callbacks provided by xc_domain_restore */
 struct restore_callbacks {
+    /* Called once the STATIC_DATA_END record has been received. */
+    int (*static_data_done)(void *data);
+
     /* Called after a new checkpoint to suspend the guest. */
     int (*suspend)(void *data);
 
diff --git a/tools/libxc/xc_sr_common.h b/tools/libxc/xc_sr_common.h
index 5dd51ccb15..ae0ab70f76 100644
--- a/tools/libxc/xc_sr_common.h
+++ b/tools/libxc/xc_sr_common.h
@@ -253,6 +253,9 @@ struct xc_sr_context
             /* Currently buffering records between a checkpoint */
             bool buffer_all_records;
 
+            /* Whether a STATIC_DATA_END record has been seen. */
+            bool seen_static_data_end;
+
 /*
  * With Remus/COLO, we buffer the records sent by the primary at checkpoint,
  * in case the primary will fail, we can recover from the last
diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c
index dc2ffcf855..9c924387ae 100644
--- a/tools/libxc/xc_sr_restore.c
+++ b/tools/libxc/xc_sr_restore.c
@@ -35,9 +35,9 @@ static int read_headers(struct xc_sr_context *ctx)
         return -1;
     }
 
-    if ( ihdr.version != 2 )
+    if ( ihdr.version < 2 || ihdr.version > 3 )
     {
-        ERROR("Invalid Version: Expected 2, Got %d",
+        ERROR("Invalid Version: Expected 2 <= ver <= 3, Got %d",
               ihdr.version);
         return -1;
     }
@@ -631,6 +631,27 @@ static int buffer_record(struct xc_sr_context *ctx, struct xc_sr_record *rec)
     return 0;
 }
 
+static int handle_static_data_end(struct xc_sr_context *ctx)
+{
+    xc_interface *xch = ctx->xch;
+    int rc = 0;
+
+    if ( ctx->restore.seen_static_data_end )
+    {
+        ERROR("Multiple STATIC_DATA_END records found");
+        return -1;
+    }
+
+    ctx->restore.seen_static_data_end = true;
+
+    if ( ctx->restore.callbacks->static_data_done &&
+         (rc = ctx->restore.callbacks->static_data_done(
+             ctx->restore.callbacks->data) != 0) )
+        ERROR("static_data_done() callback failed: %d\n", rc);
+
+    return rc;
+}
+
 static int process_record(struct xc_sr_context *ctx, struct xc_sr_record *rec)
 {
     xc_interface *xch = ctx->xch;
@@ -654,6 +675,10 @@ static int process_record(struct xc_sr_context *ctx, struct xc_sr_record *rec)
         rc = handle_checkpoint(ctx);
         break;
 
+    case REC_TYPE_STATIC_DATA_END:
+        rc = handle_static_data_end(ctx);
+        break;
+
     default:
         rc = ctx->restore.ops.process_record(ctx, rec);
         break;
-- 
2.11.0


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

  parent reply	other threads:[~2020-01-27 14:35 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-27 14:34 [Xen-devel] [PATCH v2 00/17] Support CPUID/MSR data in migration streams Andrew Cooper
2020-01-27 14:34 ` [Xen-devel] [PATCH v2 01/17] tools/libxl: Remove libxl_cpuid_{set, apply_policy}() from the API Andrew Cooper
2020-02-24 16:35   ` Andrew Cooper
2020-01-27 14:34 ` [Xen-devel] [PATCH v2 02/17] tools/libxl: Simplify callback handling in libxl-save-helper Andrew Cooper
2020-02-24 17:21   ` Ian Jackson
2020-01-27 14:34 ` [Xen-devel] [PATCH v2 03/17] tools/migration: Drop IHDR_VERSION constant from libxc and python Andrew Cooper
2020-02-24 17:25   ` Ian Jackson
2020-02-24 17:32     ` Andrew Cooper
2020-03-05 17:11       ` Ian Jackson
2020-04-14 18:16         ` Andrew Cooper
2020-04-27 16:07           ` [PATCH v2 03/17] tools/migration: Drop IHDR_VERSION constant from libxc and python [and 1 more messages] Ian Jackson
2020-01-27 14:34 ` [Xen-devel] [PATCH v2 04/17] docs/migration Specify migration v3 and STATIC_DATA_END Andrew Cooper
2020-01-27 14:34 ` [Xen-devel] [PATCH v2 05/17] python/migration: Update validation logic to understand a v3 stream Andrew Cooper
2020-02-24 17:28   ` Ian Jackson
2020-01-27 14:34 ` Andrew Cooper [this message]
2020-02-24 17:29   ` [Xen-devel] [PATCH v2 06/17] libxc/restore: Support v3 streams and handle STATIC_DATA_END Ian Jackson
2020-01-27 14:34 ` [Xen-devel] [PATCH v2 07/17] libxc/restore: STATIC_DATA_END inference for v2 compatibility Andrew Cooper
2020-02-24 17:32   ` Ian Jackson
2020-02-28 14:51     ` Andrew Cooper
2020-03-05 16:24       ` Ian Jackson
2020-04-14 18:43         ` Andrew Cooper
2020-05-29 15:53           ` Ian Jackson
2020-01-27 14:34 ` [Xen-devel] [PATCH v2 08/17] libxc/save: Write a v3 stream Andrew Cooper
2020-01-27 14:34 ` [Xen-devel] [PATCH v2 09/17] tools/libxl: Provide a static_data_done callback for domain restore Andrew Cooper
2020-01-27 14:34 ` [Xen-devel] [PATCH v2 10/17] tools/libxl: Plumb a restore boolean down into libxl__build_pre() Andrew Cooper
2020-02-24 17:39   ` Ian Jackson
2020-02-28 18:50     ` Andrew Cooper
2020-03-05 17:07       ` Ian Jackson
2020-04-14 20:23   ` [PATCH v3 10/17] tools/libxl: Plumb a restore boolean into libxl__domain_build_state Andrew Cooper
2020-04-27 16:02     ` Ian Jackson
2020-01-27 14:34 ` [Xen-devel] [PATCH v2 11/17] tools/libxl: Re-position CPUID handling during domain construction Andrew Cooper
2020-02-24 16:46   ` [Xen-devel] [PATCH v2.1 " Andrew Cooper
2020-01-27 14:34 ` [Xen-devel] [PATCH v2 12/17] docs/migration: Specify X86_{CPUID, MSR}_POLICY records Andrew Cooper
2020-02-24 17:41   ` Ian Jackson
2020-01-27 14:34 ` [Xen-devel] [PATCH v2 13/17] libxc/restore: Handle X86_{CPUID, MSR}_DATA records Andrew Cooper
2020-01-27 14:34 ` [Xen-devel] [PATCH v2 14/17] libxc/save: Write " Andrew Cooper
2020-04-14 20:24   ` Ping [PATCH v2 14/17] libxc/save: Write X86_{CPUID,MSR}_DATA records Andrew Cooper
2020-04-27 16:12   ` Ian Jackson
2020-01-27 14:34 ` [Xen-devel] [PATCH v2 15/17] tools/libx[cl]: Plumb 'missing' through static_data_done() up into libxl Andrew Cooper
2020-02-24 16:50   ` [Xen-devel] [PATCH v2.1 " Andrew Cooper
2020-02-26 12:02     ` Ian Jackson
2020-01-27 14:34 ` [Xen-devel] [PATCH v2 16/17] tools/libxc: Restore CPUID/MSR data found in the migration stream Andrew Cooper
2020-01-27 14:51   ` Jan Beulich
2020-01-27 15:52     ` Andrew Cooper
2020-01-27 14:34 ` [Xen-devel] [PATCH v2 17/17] docs/xl.cfg: Rewrite cpuid= section Andrew Cooper
2020-04-14 20:25   ` Ping " Andrew Cooper
2020-05-29 15:47   ` Ian Jackson

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=20200127143444.25538-7-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Jackson@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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 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.