tools/python: handle libxl__physmap_info.name properly in convert-legacy-stream
authorOlaf Hering <olaf@aepfle.de>
Thu, 1 Jul 2021 09:56:00 +0000 (11:56 +0200)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 6 Jul 2021 09:49:58 +0000 (10:49 +0100)
commitc8f88810db2a25d6aacf65c1c60bc4f5d848a483
tree77f368abc0e547517382a93d185c19c4c4f45293
parent918b8842a852e0e7446286f546724b1c63c56c66
tools/python: handle libxl__physmap_info.name properly in convert-legacy-stream

The trailing member name[] in libxl__physmap_info is written as a
cstring into the stream. The current code does a sanity check if the
last byte is zero. This attempt fails with python3 because name[-1]
returns a type int. As a result the comparison with byte(\00) fails:

  File "/usr/lib/xen/bin/convert-legacy-stream", line 347, in read_libxl_toolstack
    raise StreamError("physmap name not NUL terminated")
  StreamError: physmap name not NUL terminated

To handle both python variants, cast to bytearray().

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
tools/python/scripts/convert-legacy-stream