summaryrefslogtreecommitdiffstats
path: root/scripts/qapi.py
diff options
context:
space:
mode:
authorPeter Maydell2017-06-01 17:39:16 +0200
committerPeter Maydell2017-06-01 17:39:16 +0200
commit43771d5d92312504305c19abe29ec5bfabd55f01 (patch)
tree9dc7719fb3b71f42f669b190126b1cf4731a1d08 /scripts/qapi.py
parentMerge remote-tracking branch 'remotes/riku/tags/pull-linux-user-20170531' int... (diff)
parentqapi: Reject alternates that can't work with keyval_parse() (diff)
downloadqemu-43771d5d92312504305c19abe29ec5bfabd55f01.tar.gz
qemu-43771d5d92312504305c19abe29ec5bfabd55f01.tar.xz
qemu-43771d5d92312504305c19abe29ec5bfabd55f01.zip
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2017-05-31' into staging
QAPI patches for 2017-05-31 # gpg: Signature made Wed 31 May 2017 18:06:39 BST # gpg: using RSA key 0x3870B400EB918653 # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2017-05-31: qapi: Reject alternates that can't work with keyval_parse() tests/qapi-schema: Avoid 'str' in alternate test cases qapi: Document visit_type_any() issues with keyval input qobject-input-visitor: Reject non-finite numbers with keyval Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/qapi.py')
-rw-r--r--scripts/qapi.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 6c4d554165..b7a25e4759 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -812,11 +812,26 @@ def check_alternate(expr, info):
if not qtype:
raise QAPISemError(info, "Alternate '%s' member '%s' cannot use "
"type '%s'" % (name, key, value))
- if qtype in types_seen:
+ conflicting = set([qtype])
+ if qtype == 'QTYPE_QSTRING':
+ enum_expr = enum_types.get(value)
+ if enum_expr:
+ for v in enum_expr['data']:
+ if v in ['on', 'off']:
+ conflicting.add('QTYPE_QBOOL')
+ if re.match(r'[-+0-9.]', v): # lazy, could be tightened
+ conflicting.add('QTYPE_QINT')
+ conflicting.add('QTYPE_QFLOAT')
+ else:
+ conflicting.add('QTYPE_QINT')
+ conflicting.add('QTYPE_QFLOAT')
+ conflicting.add('QTYPE_QBOOL')
+ if conflicting & set(types_seen):
raise QAPISemError(info, "Alternate '%s' member '%s' can't "
"be distinguished from member '%s'"
% (name, key, types_seen[qtype]))
- types_seen[qtype] = key
+ for qt in conflicting:
+ types_seen[qt] = key
def check_enum(expr, info):