[Arm64][libvirt] Fix read bytes from json files
This fix issue that we might get str stream from json files instead of bytes and make sure we read bytes from json files under QEMU_FIRMWARE_DESCRIPTOR_PATHS. Add `rb` mode ([1]) to return contents as bytes objects. [1] https://docs.python.org/3.8/library/functions.html#open Closes-Bug: #1921075 Change-Id: I446be58f7f3e972d8e10cc5cbf83ebd42edb34e3
This commit is contained in:
parent
50f4840048
commit
020e46094a
|
@ -1970,4 +1970,4 @@ class LoadersTestCase(test.NoDBTestCase):
|
||||||
])
|
])
|
||||||
mock_glob.assert_called_once_with(
|
mock_glob.assert_called_once_with(
|
||||||
'/usr/share/qemu/firmware/*.json')
|
'/usr/share/qemu/firmware/*.json')
|
||||||
mock_open.assert_called_once_with('10_fake.json')
|
mock_open.assert_called_once_with('10_fake.json', 'rb')
|
||||||
|
|
|
@ -108,7 +108,7 @@ def _get_loaders():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for spec_path in sorted(glob.glob(f'{path}/*.json')):
|
for spec_path in sorted(glob.glob(f'{path}/*.json')):
|
||||||
with open(spec_path) as fh:
|
with open(spec_path, 'rb') as fh:
|
||||||
spec = jsonutils.load(fh)
|
spec = jsonutils.load(fh)
|
||||||
|
|
||||||
_loaders.append(spec)
|
_loaders.append(spec)
|
||||||
|
|
Loading…
Reference in New Issue