[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-commits] [qemu/qemu] 5891c3: qobject-input-visitor: Reject non-fin
From: |
GitHub |
Subject: |
[Qemu-commits] [qemu/qemu] 5891c3: qobject-input-visitor: Reject non-finite numbers w... |
Date: |
Thu, 01 Jun 2017 10:10:47 -0700 |
Branch: refs/heads/master
Home: https://github.com/qemu/qemu
Commit: 5891c388bbdd48ba0440d2738155f364589a432a
https://github.com/qemu/qemu/commit/5891c388bbdd48ba0440d2738155f364589a432a
Author: Markus Armbruster <address@hidden>
Date: 2017-05-31 (Wed, 31 May 2017)
Changed paths:
M qapi/qobject-input-visitor.c
M tests/test-qobject-input-visitor.c
Log Message:
-----------
qobject-input-visitor: Reject non-finite numbers with keyval
The QObject input visitor can produce only finite numbers when its
input comes out of the JSON parser, because the the JSON parser
implements RFC 7159, which provides no syntax for infinity and NaN.
However, it can produce infinity and NaN when its input comes out of
keyval_parse(), because we parse with strtod() then.
The keyval variant should not be able to express things the JSON
variant can't. Rejecting non-finite numbers there is the conservative
fix. It's also minimally invasive.
We could instead extend our JSON dialect to provide for infinity and
NaN. Not today.
Note that the JSON formatter can emit non-finite numbers (marked FIXME
in commit 6e8e5cb).
Signed-off-by: Markus Armbruster <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Commit: 8339fa266ccd03a43d4a9f196f1098fa3c6924f2
https://github.com/qemu/qemu/commit/8339fa266ccd03a43d4a9f196f1098fa3c6924f2
Author: Markus Armbruster <address@hidden>
Date: 2017-05-31 (Wed, 31 May 2017)
Changed paths:
M include/qapi/visitor.h
Log Message:
-----------
qapi: Document visit_type_any() issues with keyval input
It's already documented in keyval.c (commit 0ee9ae7), but visitor.h
can use a note, too.
Signed-off-by: Markus Armbruster <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Commit: 8168ca8ea3699b9fca4d8c948c7fa6ecdedc4a97
https://github.com/qemu/qemu/commit/8168ca8ea3699b9fca4d8c948c7fa6ecdedc4a97
Author: Markus Armbruster <address@hidden>
Date: 2017-05-31 (Wed, 31 May 2017)
Changed paths:
M tests/qapi-schema/alternate-clash.json
M tests/qapi-schema/alternate-nested.json
M tests/qapi-schema/args-alternate.json
M tests/qapi-schema/doc-bad-alternate-member.json
M tests/qapi-schema/qapi-schema-test.json
M tests/qapi-schema/qapi-schema-test.out
M tests/qapi-schema/returns-alternate.json
M tests/test-clone-visitor.c
M tests/test-qobject-input-visitor.c
M tests/test-qobject-output-visitor.c
Log Message:
-----------
tests/qapi-schema: Avoid 'str' in alternate test cases
The next commit is going to make alternate members of type 'str'
conflict with other scalar types. Would break a few test cases that
don't actually require 'str'. Flip them from 'str' to 'bool' or
'EnumOne'.
Signed-off-by: Markus Armbruster <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Commit: c0644771ebedbd8f47f3c24816445e30111d226b
https://github.com/qemu/qemu/commit/c0644771ebedbd8f47f3c24816445e30111d226b
Author: Markus Armbruster <address@hidden>
Date: 2017-05-31 (Wed, 31 May 2017)
Changed paths:
M scripts/qapi.py
M tests/Makefile.include
M tests/qapi-schema/alternate-conflict-dict.json
A tests/qapi-schema/alternate-conflict-enum-bool.err
A tests/qapi-schema/alternate-conflict-enum-bool.exit
A tests/qapi-schema/alternate-conflict-enum-bool.json
A tests/qapi-schema/alternate-conflict-enum-bool.out
A tests/qapi-schema/alternate-conflict-enum-int.err
A tests/qapi-schema/alternate-conflict-enum-int.exit
A tests/qapi-schema/alternate-conflict-enum-int.json
A tests/qapi-schema/alternate-conflict-enum-int.out
M tests/qapi-schema/alternate-conflict-string.err
M tests/qapi-schema/alternate-conflict-string.json
M tests/qapi-schema/qapi-schema-test.json
M tests/qapi-schema/qapi-schema-test.out
M tests/test-keyval.c
M util/keyval.c
Log Message:
-----------
qapi: Reject alternates that can't work with keyval_parse()
Alternates are sum types like unions, but use the JSON type on the
wire / QType in QObject instead of an explicit tag. That's why we
require alternate members to have distinct QTypes.
The recently introduced keyval_parse() (commit d454dbe) can only
produce string scalars. The qobject_input_visitor_new_keyval() input
visitor mostly hides the difference, so code using a QObject input
visitor doesn't have to care whether its input was parsed from JSON or
KEY=VALUE,... The difference leaks for alternates, as noted in commit
0ee9ae7: a non-string, non-enum scalar alternate value can't currently
be expressed.
In part, this is just our insufficiently sophisticated implementation.
Consider alternate type 'GuestFileWhence'. It has an integer member
and a 'QGASeek' member. The latter is an enumeration with values
'set', 'cur', 'end'. The meaning of b=set, b=cur, b=end, b=0, b=1 and
so forth is perfectly obvious. However, our current implementation
falls apart at run time for b=0, b=1, and so forth. Fixable, but not
today; add a test case and a TODO comment.
Now consider an alternate type with a string and an integer member.
What's the meaning of a=42? Is it the string "42" or the integer 42?
Whichever meaning you pick makes the other inexpressible. This isn't
just an implementation problem, it's fundamental. Our current
implementation will pick string.
So far, we haven't needed such alternates. To make sure we stop and
think before we add one that cannot sanely work with keyval_parse(),
let's require alternate members to have sufficiently distinct
representation in KEY=VALUE,... syntax:
* A string member clashes with any other scalar member
* An enumeration member clashes with bool members when it has value
'on' or 'off'.
* An enumeration member clashes with numeric members when it has a
value that starts with '-', '+', or a decimal digit. This is a
rather lazy approximation of the actual number syntax accepted by
the visitor.
Note that enumeration values starting with '-' and '+' are rejected
elsewhere already, but better safe than sorry.
Signed-off-by: Markus Armbruster <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Commit: 43771d5d92312504305c19abe29ec5bfabd55f01
https://github.com/qemu/qemu/commit/43771d5d92312504305c19abe29ec5bfabd55f01
Author: Peter Maydell <address@hidden>
Date: 2017-06-01 (Thu, 01 Jun 2017)
Changed paths:
M include/qapi/visitor.h
M qapi/qobject-input-visitor.c
M scripts/qapi.py
M tests/Makefile.include
M tests/qapi-schema/alternate-clash.json
M tests/qapi-schema/alternate-conflict-dict.json
A tests/qapi-schema/alternate-conflict-enum-bool.err
A tests/qapi-schema/alternate-conflict-enum-bool.exit
A tests/qapi-schema/alternate-conflict-enum-bool.json
A tests/qapi-schema/alternate-conflict-enum-bool.out
A tests/qapi-schema/alternate-conflict-enum-int.err
A tests/qapi-schema/alternate-conflict-enum-int.exit
A tests/qapi-schema/alternate-conflict-enum-int.json
A tests/qapi-schema/alternate-conflict-enum-int.out
M tests/qapi-schema/alternate-conflict-string.err
M tests/qapi-schema/alternate-conflict-string.json
M tests/qapi-schema/alternate-nested.json
M tests/qapi-schema/args-alternate.json
M tests/qapi-schema/doc-bad-alternate-member.json
M tests/qapi-schema/qapi-schema-test.json
M tests/qapi-schema/qapi-schema-test.out
M tests/qapi-schema/returns-alternate.json
M tests/test-clone-visitor.c
M tests/test-keyval.c
M tests/test-qobject-input-visitor.c
M tests/test-qobject-output-visitor.c
M util/keyval.c
Log Message:
-----------
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 <address@hidden>"
# gpg: aka "Markus Armbruster <address@hidden>"
# 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 <address@hidden>
Compare: https://github.com/qemu/qemu/compare/c077a998eb3f...43771d5d9231
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-commits] [qemu/qemu] 5891c3: qobject-input-visitor: Reject non-finite numbers w...,
GitHub <=