[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/72] scripts/qom-fuse: ensure QOMFuse.read always returns bytes
From: |
John Snow |
Subject: |
[PULL 14/72] scripts/qom-fuse: ensure QOMFuse.read always returns bytes |
Date: |
Fri, 18 Jun 2021 19:03:57 -0400 |
- 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>
---
scripts/qmp/qom-fuse | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse
index 703a97e75f..0d11f73152 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')
--
2.31.1
- [PULL 00/72] Python patches, John Snow, 2021/06/18
- [PULL 02/72] python/qmp: Fix type of SocketAddrT, John Snow, 2021/06/18
- [PULL 05/72] python/qmp: add qom script entry points, John Snow, 2021/06/18
- [PULL 07/72] scripts/qom-fuse: apply isort rules, John Snow, 2021/06/18
- [PULL 12/72] scripts/qom-fuse: Convert to QOMCommand, John Snow, 2021/06/18
- [PULL 14/72] scripts/qom-fuse: ensure QOMFuse.read always returns bytes,
John Snow <=
- [PULL 06/72] scripts/qmp: redirect qom-xxx scripts to python/qemu/qmp/, John Snow, 2021/06/18
- [PULL 09/72] python: Add 'fh' to known-good variable names, John Snow, 2021/06/18
- [PULL 17/72] scripts/qom-fuse: move to python/qemu/qmp/qom_fuse.py, John Snow, 2021/06/18
- [PULL 01/72] python/pipenv: Update Pipfile.lock, John Snow, 2021/06/18
- [PULL 08/72] scripts/qom-fuse: apply flake8 rules, John Snow, 2021/06/18
- [PULL 15/72] scripts/qom-fuse: add static type hints, John Snow, 2021/06/18
- [PULL 11/72] scripts/qom-fuse: Add docstrings, John Snow, 2021/06/18
- [PULL 16/72] python: add optional FUSE dependencies, John Snow, 2021/06/18
- [PULL 30/72] scripts/qemu-ga-client: Add forwarder shim, John Snow, 2021/06/18
- [PULL 35/72] scripts/qmp-shell: fix connect method signature, John Snow, 2021/06/18