diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2020-09-04 23:24:02 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2020-09-04 23:24:03 +0100 |
commit | 8ca019b9c9ff916414371dd13d265bbab308b14a (patch) | |
tree | 9ae2ae7b22494462d7c8db9fb9e66e85b6803990 /scripts | |
parent | 1133ce5ec9674d594a84fad2696adc30d292a234 (diff) | |
parent | 923fbd4cbd485dc72e9f2578cd891607ec43ac70 (diff) | |
download | qemu-8ca019b9c9ff916414371dd13d265bbab308b14a.zip qemu-8ca019b9c9ff916414371dd13d265bbab308b14a.tar.gz qemu-8ca019b9c9ff916414371dd13d265bbab308b14a.tar.bz2 |
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2020-09-03' into staging
QAPI patches patches for 2020-09-03
# gpg: Signature made Thu 03 Sep 2020 09:00:37 BST
# gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg: issuer "armbru@redhat.com"
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653
* remotes/armbru/tags/pull-qapi-2020-09-03:
docs/qdev-device-use: Don't suggest -drive and -net can do USB
qapi: Document event VSERPORT_CHANGE is rate-limited
docs/interop/qmp-spec: Point to the QEMU QMP reference manual
scripts/qmp/qom-fuse: Fix getattr(), read() for files in /
scripts/qmp/qom-fuse: Port to current Python module fuse
scripts/qmp/qom-fuse: Unbreak import of QEMUMonitorProtocol
qapi/block-core.json: Remove stale description of 'blockdev-add'
qapi: enable use of g_autoptr with QAPI types
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/qapi/types.py | 1 | ||||
-rwxr-xr-x | scripts/qmp/qom-fuse | 107 |
2 files changed, 58 insertions, 50 deletions
diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index 3ad33af..3640f17 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -213,6 +213,7 @@ def gen_type_cleanup_decl(name): ret = mcgen(''' void qapi_free_%(c_name)s(%(c_name)s *obj); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(%(c_name)s, qapi_free_%(c_name)s) ''', c_name=c_name(name)) return ret diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse index 5fa6b3b..7c7cff8 100755 --- a/scripts/qmp/qom-fuse +++ b/scripts/qmp/qom-fuse @@ -3,17 +3,19 @@ # QEMU Object Model test tools # # Copyright IBM, Corp. 2012 +# Copyright (C) 2020 Red Hat, Inc. # # Authors: # Anthony Liguori <aliguori@us.ibm.com> +# Markus Armbruster <armbru@redhat.com> # # This work is licensed under the terms of the GNU GPL, version 2 or later. See # the COPYING file in the top-level directory. ## import fuse, stat -from fuse import Fuse -import os, posix +from fuse import FUSE, FuseOSError, Operations +import os, posix, sys from errno import * sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) @@ -21,9 +23,8 @@ from qemu.qmp import QEMUMonitorProtocol fuse.fuse_python_api = (0, 2) -class QOMFS(Fuse): - def __init__(self, qmp, *args, **kwds): - Fuse.__init__(self, *args, **kwds) +class QOMFS(Operations): + def __init__(self, qmp): self.qmp = qmp self.qmp.connect() self.ino_map = {} @@ -44,8 +45,10 @@ class QOMFS(Fuse): return False def is_property(self, path): + path, prop = path.rsplit('/', 1) + if path == '': + path = '/' try: - path, prop = path.rsplit('/', 1) for item in self.qmp.command('qom-list', path=path): if item['name'] == prop: return True @@ -54,8 +57,10 @@ class QOMFS(Fuse): return False def is_link(self, path): + path, prop = path.rsplit('/', 1) + if path == '': + path = '/' try: - path, prop = path.rsplit('/', 1) for item in self.qmp.command('qom-list', path=path): if item['name'] == prop: if item['type'].startswith('link<'): @@ -65,21 +70,23 @@ class QOMFS(Fuse): except: return False - def read(self, path, length, offset): + def read(self, path, length, offset, fh): if not self.is_property(path): return -ENOENT path, prop = path.rsplit('/', 1) + if path == '': + path = '/' try: - data = str(self.qmp.command('qom-get', path=path, property=prop)) + data = self.qmp.command('qom-get', path=path, property=prop) data += '\n' # make values shell friendly except: - return -EPERM + raise FuseOSError(EPERM) if offset > len(data): return '' - return str(data[offset:][:length]) + return bytes(data[offset:][:length], encoding='utf-8') def readlink(self, path): if not self.is_link(path): @@ -89,52 +96,52 @@ class QOMFS(Fuse): return prefix + str(self.qmp.command('qom-get', path=path, property=prop)) - def getattr(self, path): + def getattr(self, path, fh=None): if self.is_link(path): - value = posix.stat_result((0o755 | stat.S_IFLNK, - self.get_ino(path), - 0, - 2, - 1000, - 1000, - 4096, - 0, - 0, - 0)) + value = { 'st_mode': 0o755 | stat.S_IFLNK, + 'st_ino': self.get_ino(path), + 'st_dev': 0, + 'st_nlink': 2, + 'st_uid': 1000, + 'st_gid': 1000, + 'st_size': 4096, + 'st_atime': 0, + 'st_mtime': 0, + 'st_ctime': 0 } elif self.is_object(path): - value = posix.stat_result((0o755 | stat.S_IFDIR, - self.get_ino(path), - 0, - 2, - 1000, - 1000, - 4096, - 0, - 0, - 0)) + value = { 'st_mode': 0o755 | stat.S_IFDIR, + 'st_ino': self.get_ino(path), + 'st_dev': 0, + 'st_nlink': 2, + 'st_uid': 1000, + 'st_gid': 1000, + 'st_size': 4096, + 'st_atime': 0, + 'st_mtime': 0, + 'st_ctime': 0 } elif self.is_property(path): - value = posix.stat_result((0o644 | stat.S_IFREG, - self.get_ino(path), - 0, - 1, - 1000, - 1000, - 4096, - 0, - 0, - 0)) + value = { 'st_mode': 0o644 | stat.S_IFREG, + 'st_ino': self.get_ino(path), + 'st_dev': 0, + 'st_nlink': 1, + 'st_uid': 1000, + 'st_gid': 1000, + 'st_size': 4096, + 'st_atime': 0, + 'st_mtime': 0, + 'st_ctime': 0 } else: - value = -ENOENT + raise FuseOSError(ENOENT) return value - def readdir(self, path, offset): - yield fuse.Direntry('.') - yield fuse.Direntry('..') + def readdir(self, path, fh): + yield '.' + yield '..' for item in self.qmp.command('qom-list', path=path): - yield fuse.Direntry(str(item['name'])) + yield str(item['name']) if __name__ == '__main__': - import sys, os + import os - fs = QOMFS(QEMUMonitorProtocol(os.environ['QMP_SOCKET'])) - fs.main(sys.argv) + fuse = FUSE(QOMFS(QEMUMonitorProtocol(os.environ['QMP_SOCKET'])), + sys.argv[1], foreground=True) |