diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2017-01-25 16:14:17 +0000 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2017-01-31 17:11:18 +0000 |
commit | 25d54654da2a2d1c612c827e6155d3bec0e1201f (patch) | |
tree | f5121430d672e078ae315d1907883f980f0d7589 /scripts/simpletrace.py | |
parent | d4fa8436ce37f125d29d015b06b8cd0e00d6051a (diff) | |
download | qemu-25d54654da2a2d1c612c827e6155d3bec0e1201f.zip qemu-25d54654da2a2d1c612c827e6155d3bec0e1201f.tar.gz qemu-25d54654da2a2d1c612c827e6155d3bec0e1201f.tar.bz2 |
trace: improve error reporting when parsing simpletrace header
When loading a simpletrace binary file we just report
"Not a valid trace file!" which is not very helpful. Report
exactly which field we found to be invalid.
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 20170125161417.31949-9-berrange@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'scripts/simpletrace.py')
-rwxr-xr-x | scripts/simpletrace.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/scripts/simpletrace.py b/scripts/simpletrace.py index 4ca903d..4c99004 100755 --- a/scripts/simpletrace.py +++ b/scripts/simpletrace.py @@ -73,10 +73,14 @@ def read_record(edict, idtoname, fobj): def read_trace_header(fobj): """Read and verify trace file header""" header = read_header(fobj, log_header_fmt) - if header is None or \ - header[0] != header_event_id or \ - header[1] != header_magic: + if header is None: raise ValueError('Not a valid trace file!') + if header[0] != header_event_id: + raise ValueError('Not a valid trace file, header id %d != %d' % + (header[0], header_event_id)) + if header[1] != header_magic: + raise ValueError('Not a valid trace file, header magic %d != %d' % + (header[1], header_magic)) log_version = header[2] if log_version not in [0, 2, 3, 4]: |