Skip to content

Commit 69d1f78

Browse files
author
Fabiano Rosas
committed
migration: Fix parsing of s390 stream
The parsing for the S390StorageAttributes section is currently leaving an unconsumed token that is later interpreted by the generic code as QEMU_VM_EOF, cutting the parsing short. The migration will issue a STATTR_FLAG_DONE between iterations, which the script consumes correctly, but there's a final STATTR_FLAG_EOS at .save_complete that the script is ignoring. Since the EOS flag is a u64 0x1ULL and the stream is big endian, on little endian hosts a byte read from it will be 0x0, the same as QEMU_VM_EOF. Fixes: 81c2c9d ("tests/qtest/migration-test: Fix analyze-migration.py for s390x") Reviewed-by: Peter Xu <[email protected]> Message-Id: <[email protected]> Signed-off-by: Fabiano Rosas <[email protected]>
1 parent 2aead53 commit 69d1f78

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

scripts/analyze-migration.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ def readvar(self, size = None):
6565
def tell(self):
6666
return self.file.tell()
6767

68+
def seek(self, a, b):
69+
return self.file.seek(a, b)
70+
6871
# The VMSD description is at the end of the file, after EOF. Look for
6972
# the last NULL byte, then for the beginning brace of JSON.
7073
def read_migration_debug_json(self):
@@ -272,11 +275,24 @@ def __init__(self, file, version_id, device, section_key):
272275
self.section_key = section_key
273276

274277
def read(self):
278+
pos = 0
275279
while True:
276280
addr_flags = self.file.read64()
277281
flags = addr_flags & 0xfff
278-
if (flags & (self.STATTR_FLAG_DONE | self.STATTR_FLAG_EOS)):
282+
283+
if flags & self.STATTR_FLAG_DONE:
284+
pos = self.file.tell()
285+
continue
286+
elif flags & self.STATTR_FLAG_EOS:
279287
return
288+
else:
289+
# No EOS came after DONE, that's OK, but rewind the
290+
# stream because this is not our data.
291+
if pos:
292+
self.file.seek(pos, os.SEEK_SET)
293+
return
294+
raise Exception("Unknown flags %x", flags)
295+
280296
if (flags & self.STATTR_FLAG_ERROR):
281297
raise Exception("Error in migration stream")
282298
count = self.file.read64()

0 commit comments

Comments
 (0)