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

[xen master] libxc/save: Write a v3 stream



commit a6a2b9d1eae3e18ee8d9be5da448655ac918a827
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Tue Dec 17 12:29:42 2019 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Fri May 29 17:33:03 2020 +0100

    libxc/save: Write a v3 stream
    
    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 compatibly logic in libxc.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxc/xc_sr_common.h                 | 10 ++++++++--
 tools/libxc/xc_sr_save.c                   | 20 +++++++++++++++++++-
 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, 47 insertions(+), 8 deletions(-)

diff --git a/tools/libxc/xc_sr_common.h b/tools/libxc/xc_sr_common.h
index 51e3d3ee3b..fd7fb67305 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 02e140b300..80b1d5de1f 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 = {
@@ -54,6 +54,16 @@ static int write_end_record(struct xc_sr_context *ctx)
     return write_record(ctx, &end);
 }
 
+/*
+ * 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.
  */
@@ -856,6 +866,14 @@ static int save(struct xc_sr_context *ctx, uint16_t 
guest_type)
     if ( rc )
         goto err;
 
+    rc = ctx->save.ops.static_data(ctx);
+    if ( rc )
+        goto err;
+
+    rc = write_static_data_end_record(ctx);
+    if ( rc )
+        goto err;
+
     rc = 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 7d3f3ddb8f..bab9bd2877 100644
--- a/tools/libxc/xc_sr_save_x86_hvm.c
+++ b/tools/libxc/xc_sr_save_x86_hvm.c
@@ -169,6 +169,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;
@@ -227,6 +232,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 f3ccf5bb4b..46019d962d 100644
--- a/tools/libxc/xc_sr_save_x86_pv.c
+++ b/tools/libxc/xc_sr_save_x86_pv.c
@@ -1052,14 +1052,15 @@ static int x86_pv_setup(struct xc_sr_context *ctx)
     return 0;
 }
 
+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
@@ -1126,6 +1127,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)
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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