[v2,05/17] python/migration: Update validation logic to understand a v3 stream
diff mbox series

Message ID 20200127143444.25538-6-andrew.cooper3@citrix.com
State New, archived
Headers show
Series
  • Support CPUID/MSR data in migration streams
Related show

Commit Message

Andrew Cooper Jan. 27, 2020, 2:34 p.m. UTC
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/python/xen/migration/libxc.py | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

Comments

Ian Jackson Feb. 24, 2020, 5:28 p.m. UTC | #1
Andrew Cooper writes ("[PATCH v2 05/17] python/migration: Update validation logic to understand a v3 stream"):
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

I'm not sure if I comment about manifest constants for `2' apply here.
This is a validation program, not a production tool, AIUI, so it's
less critical to be able to get it right.  What do you think ?

Thanks,
Ian.

Patch
diff mbox series

diff --git a/tools/python/xen/migration/libxc.py b/tools/python/xen/migration/libxc.py
index d0c4f3527d..5fb51b56ac 100644
--- a/tools/python/xen/migration/libxc.py
+++ b/tools/python/xen/migration/libxc.py
@@ -119,6 +119,7 @@  class VerifyLibxc(VerifyBase):
     def __init__(self, info, read):
         VerifyBase.__init__(self, info, read)
 
+        self.version = 0
         self.squashed_pagedata_records = 0
 
 
@@ -145,9 +146,12 @@  def verify_ihdr(self):
             raise StreamError("Bad image id: Expected 0x%x, got 0x%x" %
                               (IHDR_IDENT, ident))
 
-        if version != 2:
-            raise StreamError("Unknown image version: Expected 2, got %d" %
-                              (version, ))
+        if not (2 <= version <= 3):
+            raise StreamError(
+                "Unknown image version: Expected 2 <= ver <= 3, got %d" %
+                (version, ))
+
+        self.version = version
 
         if options & IHDR_OPT_RESZ_MASK:
             raise StreamError("Reserved bits set in image options field: 0x%x" %
@@ -164,7 +168,8 @@  def verify_ihdr(self):
                 "Stream is not native endianess - unable to validate")
 
         endian = ["little", "big"][options & IHDR_OPT_LE]
-        self.info("Libxc Image Header: %s endian" % (endian, ))
+        self.info("Libxc Image Header: Version %d, %s endian" %
+                  (version, endian))
 
 
     def verify_dhdr(self):
@@ -424,6 +429,16 @@  def verify_record_checkpoint_dirty_pfn_list(self, content):
         raise RecordError("Found checkpoint dirty pfn list record in stream")
 
 
+    def verify_record_static_data_end(self, content):
+        """ static data end record """
+
+        if len(content) != 0:
+            raise RecordError("End record with non-zero length")
+
+        if self.version < 3:
+            raise RecordError("Static data end record found in v2 stream")
+
+
 record_verifiers = {
     REC_TYPE_end:
         VerifyLibxc.verify_record_end,
@@ -465,4 +480,7 @@  def verify_record_checkpoint_dirty_pfn_list(self, content):
         VerifyLibxc.verify_record_checkpoint,
     REC_TYPE_checkpoint_dirty_pfn_list:
         VerifyLibxc.verify_record_checkpoint_dirty_pfn_list,
+
+    REC_TYPE_static_data_end:
+        VerifyLibxc.verify_record_static_data_end,
     }