From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Julien Grall <julien.grall@arm.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: [PATCH for-4.9 3/4] tools/python: Adjust migration v2 library to warn about zero-content records
Date: Thu, 30 Mar 2017 17:32:33 +0100 [thread overview]
Message-ID: <1490891554-28597-4-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1490891554-28597-1-git-send-email-andrew.cooper3@citrix.com>
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>
---
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Julien Grall <julien.grall@arm.com>
---
tools/python/xen/migration/libxc.py | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/tools/python/xen/migration/libxc.py b/tools/python/xen/migration/libxc.py
index 6fd3f6d..f24448a 100644
--- a/tools/python/xen/migration/libxc.py
+++ b/tools/python/xen/migration/libxc.py
@@ -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:
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-03-30 16:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-30 16:32 [PATCH for-4.9 0/4] Fix migration of PV guests on modern AMD hardware Andrew Cooper
2017-03-30 16:32 ` [PATCH for-4.9 1/4] tools/libxc: Tolerate specific zero-content records in migration v2 streams Andrew Cooper
2017-03-30 16:32 ` [PATCH for-4.9 2/4] tools/libxc: Avoid generating inappropriate zero-content records Andrew Cooper
2017-03-31 7:46 ` Jan Beulich
2017-04-05 11:55 ` Wei Liu
2017-03-30 16:32 ` Andrew Cooper [this message]
2017-03-30 16:32 ` [PATCH for-4.9 4/4] docs: Clarify the expected behaviour of " Andrew Cooper
2017-03-31 7:51 ` Jan Beulich
2017-04-06 9:35 ` Wei Liu
2017-04-05 11:55 ` Wei Liu
2017-04-05 11:23 ` [PATCH for-4.9 0/4] Fix migration of PV guests on modern AMD hardware Julien Grall
2017-04-05 11:25 ` Wei Liu
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=1490891554-28597-4-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=julien.grall@arm.com \
--cc=xen-devel@lists.xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).