qemu-e2k/tests
Markus Armbruster 39a1815816 qapi: New QMP command query-qmp-schema for QMP introspection
qapi/introspect.json defines the introspection schema.  It's designed
for QMP introspection, but should do for similar uses, such as QGA.

The introspection schema does not reflect all the rules and
restrictions that apply to QAPI schemata.  A valid QAPI schema has an
introspection value conforming to the introspection schema, but the
converse is not true.

Introspection lowers away a number of schema details, and makes
implicit things explicit:

* The built-in types are declared with their JSON type.

  All integer types are mapped to 'int', because how many bits we use
  internally is an implementation detail.  It could be pressed into
  external interface service as very approximate range information,
  but that's a bad idea.  If we need range information, we better do
  it properly.

* Implicit type definitions are made explicit, and given
  auto-generated names:

  - Array types, named by appending "List" to the name of their
    element type, like in generated C.

  - The enumeration types implicitly defined by simple union types,
    named by appending "Kind" to the name of their simple union type,
    like in generated C.

  - Types that don't occur in generated C.  Their names start with ':'
    so they don't clash with the user's names.

* All type references are by name.

* The struct and union types are generalized into an object type.

* Base types are flattened.

* Commands take a single argument and return a single result.

  Dictionary argument or list result is an implicit type definition.

  The empty object type is used when a command takes no arguments or
  produces no results.

  The argument is always of object type, but the introspection schema
  doesn't reflect that.

  The 'gen': false directive is omitted as implementation detail.

  The 'success-response' directive is omitted as well for now, even
  though it's not an implementation detail, because it's not used by
  QMP.

* Events carry a single data value.

  Implicit type definition and empty object type use, just like for
  commands.

  The value is of object type, but the introspection schema doesn't
  reflect that.

* Types not used by commands or events are omitted.

  Indirect use counts as use.

* Optional members have a default, which can only be null right now

  Instead of a mandatory "optional" flag, we have an optional default.
  No default means mandatory, default null means optional without
  default value.  Non-null is available for optional with default
  (possible future extension).

* Clients should *not* look up types by name, because type names are
  not ABI.  Look up the command or event you're interested in, then
  follow the references.

  TODO Should we hide the type names to eliminate the temptation?

New generator scripts/qapi-introspect.py computes an introspection
value for its input, and generates a C variable holding it.

It can generate awfully long lines.  Marked TODO.

A new test-qmp-input-visitor test case feeds its result for both
tests/qapi-schema/qapi-schema-test.json and qapi-schema.json to a
QmpInputVisitor to verify it actually conforms to the schema.

New QMP command query-qmp-schema takes its return value from that
variable.  Its reply is some 85KiBytes for me right now.

If this turns out to be too much, we have a couple of options:

* We can use shorter names in the JSON.  Not the QMP style.

* Optionally return the sub-schema for commands and events given as
  arguments.

  Right now qmp_query_schema() sends the string literal computed by
  qmp-introspect.py.  To compute sub-schema at run time, we'd have to
  duplicate parts of qapi-introspect.py in C.  Unattractive.

* Let clients cache the output of query-qmp-schema.

  It changes only on QEMU upgrades, i.e. rarely.  Provide a command
  query-qmp-schema-hash.  Clients can have a cache indexed by hash,
  and re-query the schema only when they don't have it cached.  Even
  simpler: put the hash in the QMP greeting.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2015-09-21 09:56:49 +02:00
..
acpi-test-data acpi: update expected files for memory unplug 2015-05-11 09:21:37 +02:00
image-fuzzer typofixes - v4 2015-09-11 10:45:43 +03:00
libqos qtest/ahci: export generate_pattern 2015-09-18 10:58:56 -04:00
multiboot
qapi-schema qapi: New QMP command query-qmp-schema for QMP introspection 2015-09-21 09:56:49 +02:00
qemu-iotests iotests: Add test for checking large image files 2015-09-14 16:51:37 +02:00
rocker rocker: tests: don't need to specify master/self when setting vlans 2015-07-07 13:13:22 +01:00
tcg maint: remove unused include for signal.h 2015-09-11 10:21:38 +03:00
vmstate-static-checker-data
.gitignore qapi: New QMP command query-qmp-schema for QMP introspection 2015-09-21 09:56:49 +02:00
ac97-test.c
ahci-test.c qtest/ahci: export generate_pattern 2015-09-18 10:58:56 -04:00
bios-tables-test.c maint: avoid useless "if (foo) free(foo)" pattern 2015-09-11 10:21:38 +03:00
boot-order-test.c
check-block.sh
check-qdict.c check-qdict: Test cases for new functions 2015-06-12 16:58:06 +02:00
check-qfloat.c
check-qint.c
check-qjson.c qobject: Use 'bool' for qbool 2015-06-22 17:40:00 +02:00
check-qlist.c
check-qom-interface.c
check-qom-proplist.c qom: Don't pass string table to object_get_enum() function 2015-06-19 18:42:48 +02:00
check-qstring.c
crypto-tls-x509-helpers.c crypto: add sanity checking of TLS x509 credentials 2015-09-15 15:05:09 +01:00
crypto-tls-x509-helpers.h crypto: add sanity checking of TLS x509 credentials 2015-09-15 15:05:09 +01:00
display-vga-test.c virtio-gpu: add to display-vga test 2015-07-07 11:23:18 +02:00
drive_del-test.c
ds1338-test.c i.MX: Add qtest support for I2C device emulator. 2015-09-07 10:39:31 +01:00
e1000-test.c tests: Use qtest_add_data_func() consistently 2015-06-19 10:29:14 +02:00
eepro100-test.c tests: Use qtest_add_data_func() consistently 2015-06-19 10:29:14 +02:00
endianness-test.c tests: Use qtest_add_data_func() consistently 2015-06-19 10:29:14 +02:00
es1370-test.c
fdc-test.c fdc-test: Test state for existing cases more thoroughly 2015-06-02 13:34:45 -04:00
fw_cfg-test.c
hd-geo-test.c
i440fx-test.c
i82801b11-test.c
ide-test.c ide-test: add cdrom dma test 2015-09-18 10:58:56 -04:00
intel-hda-test.c
ioh3420-test.c
ipoctal232-test.c
libqtest.c qtest: pre-buffer hex nibs 2015-05-22 15:58:22 -04:00
libqtest.h qtest: Add base64 encoded read/write 2015-05-22 15:58:22 -04:00
m48t59-test.c
Makefile qapi: New QMP command query-qmp-schema for QMP introspection 2015-09-21 09:56:49 +02:00
ne2000-test.c
nvme-test.c
pc-cpu-test.c tests: Use qtest_add_data_func() consistently 2015-06-19 10:29:14 +02:00
pcnet-test.c
pkix_asn1_tab.c crypto: add sanity checking of TLS x509 credentials 2015-09-15 15:05:09 +01:00
pvpanic-test.c
q35-test.c q35: add test for SMRAM.D_LCK 2015-06-05 19:45:09 +02:00
qemu-iotests-quick.sh
qom-test.c tests: Use qtest_add_data_func() consistently 2015-06-19 10:29:14 +02:00
rcutorture.c
rtc-test.c
rtl8139-test.c timer: rename NSEC_PER_SEC due to Mac OS X header clash 2015-07-20 17:01:00 +01:00
spapr-phb-test.c
tco-test.c tco-test: fix up config accesses and re-enable 2015-07-08 12:38:30 +03:00
test-aio.c AioContext: fix broken ctx->dispatching optimization 2015-07-22 12:41:40 +01:00
test-bitops.c
test-coroutine.c
test-crypto-cipher.c crypto: extend unit tests to cover decryption too 2015-07-27 12:22:01 +02:00
test-crypto-hash.c crypto: introduce new module for computing hash digests 2015-07-07 12:04:07 +02:00
test-crypto-tlscredsx509.c crypto: add sanity checking of TLS x509 credentials 2015-09-15 15:05:09 +01:00
test-crypto-tlssession.c crypto: introduce new module for handling TLS sessions 2015-09-15 15:07:43 +01:00
test-cutils.c cutils: work around platform differences in strto{l,ul,ll,ull} 2015-09-10 10:02:00 +02:00
test-hbitmap.c maint: avoid useless "if (foo) free(foo)" pattern 2015-09-11 10:21:38 +03:00
test-int128.c
test-iov.c
test-mul64.c
test-opts-visitor.c QemuOpts: Wean off qerror_report_err() 2015-06-22 18:20:39 +02:00
test-qdev-global-props.c
test-qemu-opts.c QemuOpts: Wean off qerror_report_err() 2015-06-22 18:20:39 +02:00
test-qmp-commands.c qapi: Introduce a first class 'any' type 2015-09-21 09:56:49 +02:00
test-qmp-event.c qapi-event: Clean up how name of enum QAPIEvent is made 2015-09-04 15:47:13 +02:00
test-qmp-input-strict.c qapi: New QMP command query-qmp-schema for QMP introspection 2015-09-21 09:56:49 +02:00
test-qmp-input-visitor.c qapi: Introduce a first class 'any' type 2015-09-21 09:56:49 +02:00
test-qmp-output-visitor.c qapi: Introduce a first class 'any' type 2015-09-21 09:56:49 +02:00
test-rcu-list.c rcu: actually register threads that have RCU read-side critical sections 2015-07-24 13:57:45 +02:00
test-rfifolock.c
test-string-input-visitor.c
test-string-output-visitor.c
test-thread-pool.c
test-throttle.c throttle: add throttle_max_is_missing_limit() test 2015-08-05 12:53:48 +01:00
test-visitor-serialization.c qapi: Drop tests for inline nested structs 2015-05-05 18:39:02 +02:00
test-vmstate.c
test-write-threshold.c
test-x86-cpuid.c
test-xbzrle.c maint: remove unused include for strings.h 2015-09-11 10:21:38 +03:00
tmp105-test.c
tpci200-test.c
usb-hcd-ehci-test.c
usb-hcd-ohci-test.c
usb-hcd-uhci-test.c
usb-hcd-xhci-test.c
vhost-user-test.c
virtio-9p-test.c
virtio-balloon-test.c
virtio-blk-test.c
virtio-console-test.c
virtio-net-test.c tests: test rx recovery from cont 2015-08-04 09:41:28 +01:00
virtio-rng-test.c
virtio-scsi-test.c virtio-scsi-test: Add test case for tail unaligned WRITE SAME 2015-07-30 15:44:49 +02:00
virtio-serial-test.c
vmxnet3-test.c
wdt_ib700-test.c timer: rename NSEC_PER_SEC due to Mac OS X header clash 2015-07-20 17:01:00 +01:00