diff options
author | Markus Armbruster <armbru@redhat.com> | 2017-03-15 13:56:54 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2017-03-16 07:13:02 +0100 |
commit | 1554a8fae984cad4704fb94a8cef3c9b42ef6185 (patch) | |
tree | 78d963a98ad801e050bfbd0c6943bd4e9fc30c0c /scripts/qapi.py | |
parent | 700dc9f503c61cdd1180e9bf84a225105b22b227 (diff) | |
download | qemu-1554a8fae984cad4704fb94a8cef3c9b42ef6185.zip |
qapi: Have each QAPI schema declare its returns white-list
qapi.py has a hardcoded white-list of command names that may violate
the rules on permitted return types. Add a new pragma directive
'returns-whitelist', and use it to replace the hard-coded white-list.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1489582656-31133-6-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'scripts/qapi.py')
-rw-r--r-- | scripts/qapi.py | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/scripts/qapi.py b/scripts/qapi.py index fe9d3cf36d..1d86d85d49 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -41,26 +41,7 @@ builtin_types = { doc_required = False # Whitelist of commands allowed to return a non-dictionary -returns_whitelist = [ - # From QMP: - 'human-monitor-command', - 'qom-get', - 'query-migrate-cache-size', - 'query-tpm-models', - 'query-tpm-types', - 'ringbuf-read', - - # From QGA: - 'guest-file-open', - 'guest-fsfreeze-freeze', - 'guest-fsfreeze-freeze-list', - 'guest-fsfreeze-status', - 'guest-fsfreeze-thaw', - 'guest-get-time', - 'guest-set-vcpus', - 'guest-sync', - 'guest-sync-delimited', -] +returns_whitelist = [] # Whitelist of entities allowed to violate case conventions case_whitelist = [ @@ -321,12 +302,19 @@ class QAPISchemaParser(object): self.docs.extend(exprs_include.docs) def _pragma(self, name, value, info): - global doc_required + global doc_required, returns_whitelist if name == 'doc-required': if not isinstance(value, bool): raise QAPISemError(info, "Pragma 'doc-required' must be boolean") doc_required = value + elif name == 'returns-whitelist': + if (not isinstance(value, list) + or any([not isinstance(elt, str) for elt in value])): + raise QAPISemError(info, + "Pragma returns-whitelist must be" + " a list of strings") + returns_whitelist = value else: raise QAPISemError(info, "Unknown pragma '%s'" % name) |