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>
This commit is contained in:
parent
d4fa8436ce
commit
25d54654da
@ -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]:
|
||||
|
Loading…
Reference in New Issue
Block a user