Skip to content

Commit 020e460

Browse files
committed
[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
1 parent 50f4840 commit 020e460

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

nova/tests/unit/virt/libvirt/test_host.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1970,4 +1970,4 @@ def test_loaders(self):
19701970
])
19711971
mock_glob.assert_called_once_with(
19721972
'/usr/share/qemu/firmware/*.json')
1973-
mock_open.assert_called_once_with('10_fake.json')
1973+
mock_open.assert_called_once_with('10_fake.json', 'rb')

nova/virt/libvirt/host.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def _get_loaders():
108108
continue
109109

110110
for spec_path in sorted(glob.glob(f'{path}/*.json')):
111-
with open(spec_path) as fh:
111+
with open(spec_path, 'rb') as fh:
112112
spec = jsonutils.load(fh)
113113

114114
_loaders.append(spec)

0 commit comments

Comments
 (0)