qemu-e2k/scripts
Markus Armbruster c0644771eb 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 <armbru@redhat.com>
Message-Id: <1495471335-23707-5-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-05-31 16:04:09 +02:00
..
coccinelle qobject: Add helper macros for common scalar insertions 2017-05-08 20:32:14 +02:00
kvm vmxcap: update for September 2016 SDM 2017-03-03 16:40:02 +01:00
modules
qemu-guest-agent
qemugdb scripts/qemugdb/mtree.py: fix up mtree dump 2017-04-07 15:24:56 +01:00
qmp scripts/qmp/qom-set: fix the value argument passed to srv.command() 2017-05-23 13:28:17 +02:00
tracetool trace: disallow more than 10 arguments per trace event 2017-05-08 09:38:30 -04:00
analyse-9p-simpletrace.py
analyze-inclusions
analyze-migration.py
check-qerror.sh
checkpatch.pl trivial patches for 2017-05-10 2017-05-10 12:31:19 -04:00
clean-header-guards.pl scripts: Switch to more portable Perl shebang 2017-05-10 10:19:24 +03:00
clean-includes
cleanup-trace-events.pl scripts: Switch to more portable Perl shebang 2017-05-10 10:19:24 +03:00
cocci-macro-file.h
coverity-model.c coverity-model: model address_space_read/write 2017-03-15 13:59:16 +01:00
create_config
disas-objdump.pl scripts: Switch to more portable Perl shebang 2017-05-10 10:19:24 +03:00
dump-guest-memory.py scripts/dump-guest-memory.py: fix int128_get64 on recent gcc 2017-03-14 13:26:36 +01:00
extract-vsssdk-headers
feature_to_c.sh
get_maintainer.pl trivial patches for 2017-05-10 2017-05-10 12:31:19 -04:00
gtester-cat
hxtool hxtool: emit Texinfo headings as @subsection 2017-01-16 17:52:35 +01:00
make-release
make_device_config.sh
ordereddict.py
qapi-commands.py qapi: Make pylint a bit happier 2017-03-16 07:13:04 +01:00
qapi-event.py qapi: Prefer single-quoted strings more consistently 2017-03-16 07:13:02 +01:00
qapi-introspect.py qapi: Prefer single-quoted strings more consistently 2017-03-16 07:13:02 +01:00
qapi-types.py qapi: Prefer single-quoted strings more consistently 2017-03-16 07:13:02 +01:00
qapi-visit.py qapi: Make pylint a bit happier 2017-03-16 07:13:04 +01:00
qapi.py qapi: Reject alternates that can't work with keyval_parse() 2017-05-31 16:04:09 +02:00
qapi2texi.py qapi2texi: Fix translation of *strong* and _emphasized_ 2017-03-21 10:42:58 +01:00
qemu-binfmt-conf.sh scripts/qemu-binfmt-conf.sh: Fix shell portability issue 2017-05-10 10:19:23 +03:00
qemu-gdb.py
qemu.py
qtest.py
refresh-pxe-roms.sh
shaderinclude.pl scripts: Switch to more portable Perl shebang 2017-05-10 10:19:24 +03:00
show-fixed-bugs.sh
signrom.py
simpletrace.py simpletrace: document Analyzer method signatures 2017-04-21 10:45:35 +01:00
switch-timer-api scripts: Switch to more portable Perl shebang 2017-05-10 10:19:24 +03:00
texi2pod.pl scripts: Switch to more portable Perl shebang 2017-05-10 10:19:24 +03:00
tracetool.py trace: switch to modular code generation for sub-directories 2017-01-31 17:11:18 +00:00
update-linux-headers.sh linux-headers: update 2017-05-19 12:29:01 +02:00
vmstate-static-checker.py vmstate-static-checker: update white list with spapr_pci 2017-02-28 11:30:22 +00:00