From: John Snow Date: Thu, 3 Jun 2021 00:37:14 +0000 (-0400) Subject: scripts/qom-fuse: ensure QOMFuse.read always returns bytes X-Git-Tag: v6.1.0-rc0~66^2~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2cea7134620749b106af167322d921716ef61144;p=thirdparty%2Fqemu.git scripts/qom-fuse: ensure QOMFuse.read always returns bytes - Use FuseOSError to signal ENOENT instead of returning it - Wrap qom-get in str(), as we don't always know its type - The empty return should be b'', not ''. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daudé Message-id: 20210603003719.1321369-15-jsnow@redhat.com Signed-off-by: John Snow --- diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index 703a97e75ff..0d11f731526 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -127,19 +127,19 @@ class QOMFuse(QOMCommand, Operations): def read(self, path, size, offset, fh): if not self.is_property(path): - return -ENOENT + raise FuseOSError(ENOENT) path, prop = path.rsplit('/', 1) if path == '': path = '/' try: - data = self.qmp.command('qom-get', path=path, property=prop) + data = str(self.qmp.command('qom-get', path=path, property=prop)) data += '\n' # make values shell friendly except QMPResponseError as err: raise FuseOSError(EPERM) from err if offset > len(data): - return '' + return b'' return bytes(data[offset:][:size], encoding='utf-8')