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>,
	"Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>,
	"Wei Liu" <wl@xen.org>, "Ian Jackson" <Ian.Jackson@citrix.com>
Subject: [Xen-devel] [PATCH 09/12] libxc/save: Write a v3 stream
Date: Tue, 24 Dec 2019 15:19:29 +0000	[thread overview]
Message-ID: <20191224151932.6304-10-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20191224151932.6304-1-andrew.cooper3@citrix.com>

Introduce a new static_data() hook which is responsible for writing out
any static data records.  The HVM side continues to be a no-op, while
the PV side moves write_x86_pv_info() into this earlier hook.  The the
common code writes out a STATIC_DATA_END record, and the stream version
is bumped to 3.

Update convert-legacy-stream to write a v3 stream, because this will
bypass the compatiblity logic in libxc.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Ian Jackson <Ian.Jackson@citrix.com>
CC: Wei Liu <wl@xen.org>
CC: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
 tools/libxc/xc_sr_common.h                 | 10 ++++++++--
 tools/libxc/xc_sr_save.c                   | 14 +++++++++++++-
 tools/libxc/xc_sr_save_x86_hvm.c           |  6 ++++++
 tools/libxc/xc_sr_save_x86_pv.c            | 10 ++++++----
 tools/python/scripts/convert-legacy-stream |  9 ++++++++-
 5 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/tools/libxc/xc_sr_common.h b/tools/libxc/xc_sr_common.h
index 2e9a4bc587..3f52ef7d53 100644
--- a/tools/libxc/xc_sr_common.h
+++ b/tools/libxc/xc_sr_common.h
@@ -63,8 +63,14 @@ struct xc_sr_save_ops
     int (*setup)(struct xc_sr_context *ctx);
 
     /**
-     * Send records which need to be at the start of the stream.  This is
-     * called once, after the Image and Domain headers are written.
+     * Send static records at the head of the stream.  This is called once,
+     * after the Image and Domain headers are written.
+     */
+    int (*static_data)(struct xc_sr_context *ctx);
+
+    /**
+     * Send dynamic records which need to be at the start of the stream.  This
+     * is called after the STATIC_DATA_END record is written.
      */
     int (*start_of_stream)(struct xc_sr_context *ctx);
 
diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c
index fa1a2e6c2a..f24dd0d00b 100644
--- a/tools/libxc/xc_sr_save.c
+++ b/tools/libxc/xc_sr_save.c
@@ -13,7 +13,7 @@ static int write_headers(struct xc_sr_context *ctx, uint16_t guest_type)
     struct xc_sr_ihdr ihdr = {
         .marker  = IHDR_MARKER,
         .id      = htonl(IHDR_ID),
-        .version = htonl(2),
+        .version = htonl(3),
         .options = htons(IHDR_OPT_LITTLE_ENDIAN),
     };
     struct xc_sr_dhdr dhdr = {
@@ -55,6 +55,16 @@ static int write_end_record(struct xc_sr_context *ctx)
 }
 
 /*
+ * Writes a STATIC_DATA_END record into the stream.
+ */
+static int write_static_data_end_record(struct xc_sr_context *ctx)
+{
+    struct xc_sr_record end = { .type = REC_TYPE_STATIC_DATA_END };
+
+    return write_record(ctx, &end);
+}
+
+/*
  * Writes a CHECKPOINT record into the stream.
  */
 static int write_checkpoint_record(struct xc_sr_context *ctx)
@@ -846,6 +856,8 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)
     xc_report_progress_single(xch, "Start of stream");
 
     rc = (write_headers(ctx, guest_type) ?:
+          ctx->save.ops.static_data(ctx) ?:
+          write_static_data_end_record(ctx) ?:
           ctx->save.ops.start_of_stream(ctx));
     if ( rc )
         goto err;
diff --git a/tools/libxc/xc_sr_save_x86_hvm.c b/tools/libxc/xc_sr_save_x86_hvm.c
index 58722118ae..c146e827bc 100644
--- a/tools/libxc/xc_sr_save_x86_hvm.c
+++ b/tools/libxc/xc_sr_save_x86_hvm.c
@@ -170,6 +170,11 @@ static int x86_hvm_setup(struct xc_sr_context *ctx)
     return 0;
 }
 
+static int x86_hvm_static_data(struct xc_sr_context *ctx)
+{
+    return 0;
+}
+
 static int x86_hvm_start_of_stream(struct xc_sr_context *ctx)
 {
     return 0;
@@ -213,6 +218,7 @@ struct xc_sr_save_ops save_ops_x86_hvm =
     .pfn_to_gfn          = x86_hvm_pfn_to_gfn,
     .normalise_page      = x86_hvm_normalise_page,
     .setup               = x86_hvm_setup,
+    .static_data         = x86_hvm_static_data,
     .start_of_stream     = x86_hvm_start_of_stream,
     .start_of_checkpoint = x86_hvm_start_of_checkpoint,
     .end_of_checkpoint   = x86_hvm_end_of_checkpoint,
diff --git a/tools/libxc/xc_sr_save_x86_pv.c b/tools/libxc/xc_sr_save_x86_pv.c
index c1c6892666..9d1ca6ead7 100644
--- a/tools/libxc/xc_sr_save_x86_pv.c
+++ b/tools/libxc/xc_sr_save_x86_pv.c
@@ -1028,14 +1028,15 @@ static int x86_pv_setup(struct xc_sr_context *ctx)
             map_p2m(ctx));
 }
 
+static int x86_pv_static_data(struct xc_sr_context *ctx)
+{
+    return write_x86_pv_info(ctx);
+}
+
 static int x86_pv_start_of_stream(struct xc_sr_context *ctx)
 {
     int rc;
 
-    rc = write_x86_pv_info(ctx);
-    if ( rc )
-        return rc;
-
     /*
      * Ideally should be able to change during migration.  Currently
      * corruption will occur if the contents or location of the P2M changes
@@ -1090,6 +1091,7 @@ struct xc_sr_save_ops save_ops_x86_pv =
     .pfn_to_gfn          = x86_pv_pfn_to_gfn,
     .normalise_page      = x86_pv_normalise_page,
     .setup               = x86_pv_setup,
+    .static_data         = x86_pv_static_data,
     .start_of_stream     = x86_pv_start_of_stream,
     .start_of_checkpoint = x86_pv_start_of_checkpoint,
     .end_of_checkpoint   = x86_pv_end_of_checkpoint,
diff --git a/tools/python/scripts/convert-legacy-stream b/tools/python/scripts/convert-legacy-stream
index 02a194178f..ca93a93848 100755
--- a/tools/python/scripts/convert-legacy-stream
+++ b/tools/python/scripts/convert-legacy-stream
@@ -79,7 +79,7 @@ def write_libxc_ihdr():
     stream_write(pack(libxc.IHDR_FORMAT,
                       libxc.IHDR_MARKER,  # Marker
                       libxc.IHDR_IDENT,   # Ident
-                      2,                  # Version
+                      3,                  # Version
                       libxc.IHDR_OPT_LE,  # Options
                       0, 0))              # Reserved
 
@@ -166,6 +166,9 @@ def write_libxc_hvm_params(params):
                  pack(libxc.HVM_PARAMS_FORMAT, len(params) / 2, 0),
                  pack("Q" * len(params), *params))
 
+def write_libxc_static_data_end():
+    write_record(libxc.REC_TYPE_static_data_end)
+
 def write_libxl_end():
     write_record(libxl.REC_TYPE_end)
 
@@ -590,6 +593,10 @@ def read_legacy_stream(vm):
 
         if pv:
             read_pv_extended_info(vm)
+
+        write_libxc_static_data_end()
+
+        if pv:
             read_pv_p2m_frames(vm)
 
         read_chunks(vm)
-- 
2.11.0


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

  parent reply	other threads:[~2019-12-24 15:20 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-24 15:19 [Xen-devel] [PATCH 00/12] Support CPUID/MSR data in migration streams Andrew Cooper
2019-12-24 15:19 ` [Xen-devel] [PATCH 01/12] libxc/save: Shrink code volume where possible Andrew Cooper
2020-01-14 16:48   ` Ian Jackson
2020-01-14 16:55     ` Ian Jackson
2020-01-15 19:22     ` Andrew Cooper
2020-04-27 17:19       ` Ian Jackson
2020-04-27 19:55         ` Wei Liu
2020-04-27 20:00           ` Andrew Cooper
2020-04-28  9:46             ` Wei Liu
2019-12-24 15:19 ` [Xen-devel] [PATCH 02/12] libxc/restore: Introduce functionality to simplify blob handling Andrew Cooper
2020-01-14 16:50   ` Ian Jackson
2019-12-24 15:19 ` [Xen-devel] [PATCH 03/12] libxc/migration: Rationalise the 'checkpointed' field to 'stream_type' Andrew Cooper
2020-01-14 15:58   ` Ian Jackson
2019-12-24 15:19 ` [Xen-devel] [PATCH 04/12] libxc/migration: Adjust layout of struct xc_sr_context Andrew Cooper
2020-01-14 16:04   ` Ian Jackson
2019-12-24 15:19 ` [Xen-devel] [PATCH 05/12] tools/migration: Drop IHDR_VERSION constant from libxc and python Andrew Cooper
2020-01-14 16:05   ` Ian Jackson
2020-01-15 15:29     ` Andrew Cooper
2019-12-24 15:19 ` [Xen-devel] [PATCH 06/12] docs/migration Specify migration v3 and STATIC_DATA_END Andrew Cooper
2020-01-03 14:44   ` Jan Beulich
2020-01-09 14:54     ` Andrew Cooper
2020-01-14 16:07   ` Ian Jackson
2019-12-24 15:19 ` [Xen-devel] [PATCH 07/12] python/migration: Update validation logic to understand a v3 stream Andrew Cooper
2019-12-24 15:19 ` [Xen-devel] [PATCH 08/12] libxc/restore: Support v3 streams, and cope with v2 compatibilty Andrew Cooper
2020-01-14 17:02   ` Ian Jackson
2019-12-24 15:19 ` Andrew Cooper [this message]
2020-01-14 17:05   ` [Xen-devel] [PATCH 09/12] libxc/save: Write a v3 stream Ian Jackson
2019-12-24 15:19 ` [Xen-devel] [PATCH 10/12] docs/migration: Specify X86_{CPUID, MSR}_POLICY records Andrew Cooper
2020-01-03 14:49   ` Jan Beulich
2020-01-03 14:55     ` Andrew Cooper
2020-01-03 15:30       ` Jan Beulich
2020-01-09 15:30         ` Andrew Cooper
2020-01-14 16:12           ` Ian Jackson
2020-01-15 15:48             ` Andrew Cooper
2020-01-14 16:08   ` Ian Jackson
2020-01-15 15:36     ` Andrew Cooper
2019-12-24 15:19 ` [Xen-devel] [PATCH 11/12] libxc/restore: Handle X86_{CPUID, MSR}_DATA records Andrew Cooper
2020-01-14 17:16   ` Ian Jackson
2019-12-24 15:19 ` [Xen-devel] [PATCH 12/12] libxc/save: Write " Andrew Cooper
2020-01-14 17:21   ` Ian Jackson
2020-01-15 15:52     ` Andrew Cooper
2020-01-03 13:06 ` [Xen-devel] [PATCH] Use CPUID/MSR data from migration streams Andrew Cooper
2020-01-03 13:06   ` [Xen-devel] [PATCH 15/20] fixup tools/migration: Formatting and style cleanup Andrew Cooper
2020-01-03 13:06   ` [Xen-devel] [PATCH 16/20] tools/libxl: Simplify callback handling in libxl-save-helper Andrew Cooper
2020-01-14 17:27     ` Ian Jackson
2020-01-15 16:16       ` Andrew Cooper
2020-01-03 13:06   ` [Xen-devel] [PATCH 17/20] tools/libx[cl]: Plumb static_data_done() up into libxl Andrew Cooper
2020-01-14 17:30     ` Ian Jackson
2020-01-15 16:34       ` Andrew Cooper
2020-05-29 15:58         ` Ian Jackson
2020-01-03 13:06   ` [Xen-devel] [PATCH 18/20] tools/libxl: Plumb domain_create_state down into libxl__build_pre() Andrew Cooper
2020-01-14 17:32     ` Ian Jackson
2020-01-03 13:06   ` [Xen-devel] [PATCH 19/20] tools/libxl: Re-position CPUID handling during domain construction Andrew Cooper
2020-01-14 17:33     ` Ian Jackson
2020-01-14 17:51       ` Andrew Cooper
2020-01-14 18:12         ` Ian Jackson
2020-01-03 13:06   ` [Xen-devel] [PATCH 20/20] tools/libxc: Restore CPUID/MSR data found in the migration stream Andrew Cooper
2020-01-14 17:34     ` Ian Jackson
2020-01-15 18:53 ` [Xen-devel] [PATCH 0.5/12] tools/migration: Formatting and style cleanup Andrew Cooper
2020-01-15 21:26   ` 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=20191224151932.6304-10-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Jackson@citrix.com \
    --cc=marmarek@invisiblethingslab.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.