diff options
author | John Snow <jsnow@redhat.com> | 2021-06-02 20:37:14 -0400 |
---|---|---|
committer | John Snow <jsnow@redhat.com> | 2021-06-18 16:10:06 -0400 |
commit | 2cea7134620749b106af167322d921716ef61144 (patch) | |
tree | a341cd54610c2d779169019148c10759f9bef42a | |
parent | 9ec8a3869480a9826ba77b480bb7ca567aa3d26b (diff) | |
download | qemu-2cea7134620749b106af167322d921716ef61144.zip qemu-2cea7134620749b106af167322d921716ef61144.tar.gz qemu-2cea7134620749b106af167322d921716ef61144.tar.bz2 |
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 <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20210603003719.1321369-15-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
-rwxr-xr-x | scripts/qmp/qom-fuse | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index 703a97e..0d11f73 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') |