From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>
Subject: [PATCH 4/4] tools/python: Adjust migration v2 library to warn about zero-length records
Date: Thu, 21 Jul 2016 18:17:37 +0100 [thread overview]
Message-ID: <1469121457-365-5-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1469121457-365-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>
---
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.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 85a78f4..2037c85 100644
--- a/tools/python/xen/migration/libxc.py
+++ b/tools/python/xen/migration/libxc.py
@@ -308,6 +308,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), ))
@@ -320,10 +324,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:
@@ -381,6 +389,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:[~2016-07-21 17:17 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-21 17:17 [PATCH RFC 0/4] Fix issues with zero-length records in migration v2 Andrew Cooper
2016-07-21 17:17 ` [PATCH 1/4] docs: Clarify the expected behaviour of zero length records Andrew Cooper
2016-07-25 9:45 ` Wei Liu
2016-07-25 10:21 ` David Vrabel
2016-07-25 10:25 ` Andrew Cooper
2016-07-25 10:35 ` David Vrabel
2016-07-25 10:38 ` Andrew Cooper
2016-07-25 10:44 ` David Vrabel
2016-07-25 10:45 ` Andrew Cooper
2016-07-25 11:18 ` Ian Jackson
2016-07-21 17:17 ` [PATCH 2/4] tools/libxc: Tolerate zero-length records in migration v2 streams Andrew Cooper
2016-07-25 9:46 ` Wei Liu
2016-07-25 12:21 ` David Vrabel
2016-07-25 12:46 ` Andrew Cooper
2016-07-25 13:00 ` David Vrabel
2016-07-21 17:17 ` [PATCH 3/4] tools/libxc: Avoid generating inappropriate zero-length records Andrew Cooper
2016-07-25 9:45 ` Wei Liu
2016-07-25 9:57 ` Andrew Cooper
2016-07-25 10:14 ` Wei Liu
2016-07-25 10:32 ` David Vrabel
2016-07-25 11:44 ` Ian Jackson
2016-07-25 17:15 ` Ian Jackson
2016-07-26 9:23 ` Wei Liu
2016-07-26 13:37 ` Ian Jackson
2016-07-21 17:17 ` Andrew Cooper [this message]
2016-07-25 9:46 ` [PATCH 4/4] tools/python: Adjust migration v2 library to warn about " Wei Liu
2017-03-14 13:20 ` [PATCH RFC 0/4] Fix issues with zero-length records in migration v2 Julien Grall
2017-03-14 13:50 ` Andrew Cooper
2017-03-14 14:21 ` Wei Liu
2017-03-28 18:24 ` Julien Grall
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=1469121457-365-5-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=wei.liu2@citrix.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).