]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
tools/python: Adjust migration v2 library to warn about zero-content records
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 30 Mar 2017 16:32:33 +0000 (17:32 +0100)
committerWei Liu <wei.liu2@citrix.com>
Thu, 6 Apr 2017 09:37:32 +0000 (10:37 +0100)
These records shouldn't be in a stream, but accidentally are.  Warn about
them, but don't abort the verification.

While here, add a missing length check to the X86_PV_P2M_FRAMES record
checker.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
tools/python/xen/migration/libxc.py

index 6fd3f6dcdfcc0bd6bc25460e0ada84cc85bd22f7..f24448a9eff7614d28e1e960493a0011d87296a7 100644 (file)
@@ -312,6 +312,10 @@ class VerifyLibxc(VerifyBase):
     def verify_record_x86_pv_p2m_frames(self, content):
         """ x86 PV p2m frames record """
 
+        if len(content) < 8:
+            raise RecordError("x86_pv_p2m_frames: record length must be at"
+                              " least 8 bytes long")
+
         if len(content) % 8 != 0:
             raise RecordError("Length expected to be a multiple of 8, not %d"
                               % (len(content), ))
@@ -324,10 +328,14 @@ class VerifyLibxc(VerifyBase):
         """ Generic for all REC_TYPE_x86_pv_vcpu_{basic,extended,xsave,msrs} """
         minsz = calcsize(X86_PV_VCPU_HDR_FORMAT)
 
-        if len(content) <= minsz:
+        if len(content) < minsz:
             raise RecordError("X86_PV_VCPU_%s record length must be at least %d"
                               " bytes long" % (name, minsz))
 
+        if len(content) == minsz:
+            self.info("Warning: X86_PV_VCPU_%s record with zero content"
+                      % (name, ))
+
         vcpuid, res1 = unpack(X86_PV_VCPU_HDR_FORMAT, content[:minsz])
 
         if res1 != 0:
@@ -385,6 +393,9 @@ class VerifyLibxc(VerifyBase):
         if rsvd != 0:
             raise RecordError("Reserved field not zero (0x%04x)" % (rsvd, ))
 
+        if count == 0:
+            self.info("Warning: HVM_PARAMS record with zero content")
+
         sz += count * calcsize(HVM_PARAMS_ENTRY_FORMAT)
 
         if len(content) != sz: