It's time to expose QMP 'netdev_add' through introspection, and to add boxed commands/events so that we can drastically reduce the number of C parameters needed to implement a command that matches a large QAPI type.
Prerequistes: Markus' qapi-next branch (weak; series also applies on master) available as a tag at: git fetch git://repo.or.cz/qemu/ericb.git qapi-cleanupv9f or as part of my qapi branch: git fetch git://repo.or.cz/qemu/ericb.git qapi v8 was here: https://lists.gnu.org/archive/html/qemu-devel/2016-07/msg00302.html Since then, I've addressed Markus' comments: - s/box/boxed/ - fix a useless Python override of c_name() - comment and formatting tweaks - defer event collision prevention until later; for 2.7, we are focusing on the bare minimum needed to take advantage of boxing - implement a promised followup that allows netdev_add to still parse strings the way it did with QemuOpts (thanks Dan for starting that effort) The diffstat from v8 looks big, but a lot of it is mechanical due to the spelling change. It's late at night, and we're close to hard freeze, so to maximize review time I'm posting now; if I weren't feeling quite as rushed, I might would have swapped the order of 14 vs. 15-17 to avoid even a temporary behavior change in netdev_add. On the other hand, 14 has had review, while 15-17 are effectively new, and it is feasible that we may be comfortable enough with the new type-safety constraints of 14 to not want to bother with 15-17 loosening things back up, given that we are already in soft freeze. 001/17:[----] [--] 'net: use Netdev instead of NetClientOptions in client init' 002/17:[----] [--] 'qapi: Require all branches of flat union enum to be covered' 003/17:[down] 'qapi: Special case c_name() for empty type' 004/17:[----] [--] 'qapi: Hide tag_name data member of variants' 005/17:[----] [-C] 'qapi: Add type.is_empty() helper' 006/17:[----] [--] 'qapi: Drop useless gen_err_check()' 007/17:[0002] [FC] 'qapi-event: Simplify visit of non-implicit data' 008/17:[down] 'qapi: Plumb in 'boxed' to qapi generator lower levels' 009/17:[0100] [FC] 'qapi: Implement boxed types for commands/events' 010/17:[0002] [FC] 'block: Simplify block_set_io_throttle' 011/17:[0002] [FC] 'block: Simplify drive-mirror' 012/17:[----] [--] 'qapi: Change Netdev into a flat union' 013/17:[----] [--] 'net: Use correct type for bool flag' 014/17:[0002] [FC] 'net: Complete qapi-fication of netdev_add' 015/17:[down] 'option: make parse_option_bool/number non-static' 016/17:[down] 'qapi: Tweak QmpInputVisitor to optionally do string conversion' 017/17:[down] 'qapi: Restore autocast behavior in 'netdev_add'' Daniel P. Berrange (1): option: make parse_option_bool/number non-static Eric Blake (15): qapi: Require all branches of flat union enum to be covered qapi: Special case c_name() for empty type qapi: Hide tag_name data member of variants qapi: Add type.is_empty() helper qapi: Drop useless gen_err_check() qapi-event: Simplify visit of non-implicit data qapi: Plumb in 'boxed' to qapi generator lower levels qapi: Implement boxed types for commands/events block: Simplify block_set_io_throttle block: Simplify drive-mirror qapi: Change Netdev into a flat union net: Use correct type for bool flag net: Complete qapi-fication of netdev_add qapi: Tweak QmpInputVisitor to optionally do string conversion qapi: Restore autocast behavior in 'netdev_add' Kővágó, Zoltán (1): net: use Netdev instead of NetClientOptions in client init qapi-schema.json | 66 +++++--- qapi/block-core.json | 40 ++++- scripts/qapi.py | 131 +++++++++++---- scripts/qapi-commands.py | 36 ++-- scripts/qapi-event.py | 48 ++++-- scripts/qapi-introspect.py | 4 +- scripts/qapi-types.py | 2 +- scripts/qapi-visit.py | 8 +- include/net/net.h | 8 +- include/qapi/qmp-input-visitor.h | 24 ++- include/qemu/option.h | 4 + net/clients.h | 20 +-- blockdev.c | 187 ++++++++------------- hmp.c | 72 +++----- hw/arm/musicpal.c | 2 +- hw/core/qdev-properties-system.c | 2 +- hw/net/allwinner_emac.c | 2 +- hw/net/cadence_gem.c | 2 +- hw/net/dp8393x.c | 2 +- hw/net/e1000.c | 2 +- hw/net/e1000e.c | 2 +- hw/net/eepro100.c | 2 +- hw/net/etraxfs_eth.c | 2 +- hw/net/fsl_etsec/etsec.c | 2 +- hw/net/imx_fec.c | 2 +- hw/net/lan9118.c | 2 +- hw/net/lance.c | 2 +- hw/net/mcf_fec.c | 2 +- hw/net/milkymist-minimac2.c | 2 +- hw/net/mipsnet.c | 2 +- hw/net/ne2000-isa.c | 2 +- hw/net/ne2000.c | 2 +- hw/net/opencores_eth.c | 2 +- hw/net/pcnet-pci.c | 2 +- hw/net/rocker/rocker_fp.c | 2 +- hw/net/rtl8139.c | 2 +- hw/net/smc91c111.c | 2 +- hw/net/spapr_llan.c | 2 +- hw/net/stellaris_enet.c | 2 +- hw/net/vhost_net.c | 20 +-- hw/net/virtio-net.c | 10 +- hw/net/vmxnet3.c | 2 +- hw/net/xen_nic.c | 2 +- hw/net/xgmac.c | 2 +- hw/net/xilinx_axienet.c | 2 +- hw/net/xilinx_ethlite.c | 2 +- hw/usb/dev-network.c | 4 +- monitor.c | 14 +- net/dump.c | 8 +- net/filter.c | 2 +- net/hub.c | 24 +-- net/l2tpv3.c | 8 +- net/net.c | 164 +++++++++++------- net/netmap.c | 6 +- net/slirp.c | 8 +- net/socket.c | 10 +- net/tap-win32.c | 8 +- net/tap.c | 28 +-- net/vde.c | 8 +- net/vhost-user.c | 22 +-- qapi/opts-visitor.c | 19 +-- qapi/qmp-input-visitor.c | 100 +++++++++-- qmp.c | 2 +- qom/qom-qobject.c | 2 +- tests/check-qnull.c | 2 +- tests/test-qmp-commands.c | 10 +- tests/test-qmp-input-strict.c | 2 +- tests/test-qmp-input-visitor.c | 150 ++++++++++++++++- tests/test-visitor-serialization.c | 2 +- util/qemu-option.c | 27 +-- docs/qapi-code-gen.txt | 37 +++- qmp-commands.hx | 2 +- tests/Makefile.include | 6 + tests/qapi-schema/args-bad-box.err | 1 + tests/qapi-schema/args-bad-box.exit | 1 + tests/qapi-schema/args-bad-box.json | 2 + tests/qapi-schema/args-bad-box.out | 0 tests/qapi-schema/args-box-anon.err | 1 + tests/qapi-schema/args-box-anon.exit | 1 + tests/qapi-schema/args-box-anon.json | 2 + tests/qapi-schema/args-box-anon.out | 0 tests/qapi-schema/args-box-empty.err | 1 + tests/qapi-schema/args-box-empty.exit | 1 + tests/qapi-schema/args-box-empty.json | 3 + tests/qapi-schema/args-box-empty.out | 0 tests/qapi-schema/args-box-string.err | 1 + tests/qapi-schema/args-box-string.exit | 1 + tests/qapi-schema/args-box-string.json | 2 + tests/qapi-schema/args-box-string.out | 0 tests/qapi-schema/args-union.err | 2 +- tests/qapi-schema/args-union.json | 3 +- tests/qapi-schema/event-box-empty.err | 1 + tests/qapi-schema/event-box-empty.exit | 1 + tests/qapi-schema/event-box-empty.json | 2 + tests/qapi-schema/event-box-empty.out | 0 tests/qapi-schema/event-case.out | 1 + tests/qapi-schema/flat-union-incomplete-branch.err | 1 + .../qapi-schema/flat-union-incomplete-branch.exit | 1 + .../qapi-schema/flat-union-incomplete-branch.json | 9 + tests/qapi-schema/flat-union-incomplete-branch.out | 0 tests/qapi-schema/ident-with-escape.out | 2 +- tests/qapi-schema/indented-expr.out | 4 +- tests/qapi-schema/qapi-schema-test.json | 4 + tests/qapi-schema/qapi-schema-test.out | 37 +++- tests/qapi-schema/test-qapi.py | 11 +- 105 files changed, 968 insertions(+), 543 deletions(-) create mode 100644 tests/qapi-schema/args-bad-box.err create mode 100644 tests/qapi-schema/args-bad-box.exit create mode 100644 tests/qapi-schema/args-bad-box.json create mode 100644 tests/qapi-schema/args-bad-box.out create mode 100644 tests/qapi-schema/args-box-anon.err create mode 100644 tests/qapi-schema/args-box-anon.exit create mode 100644 tests/qapi-schema/args-box-anon.json create mode 100644 tests/qapi-schema/args-box-anon.out create mode 100644 tests/qapi-schema/args-box-empty.err create mode 100644 tests/qapi-schema/args-box-empty.exit create mode 100644 tests/qapi-schema/args-box-empty.json create mode 100644 tests/qapi-schema/args-box-empty.out create mode 100644 tests/qapi-schema/args-box-string.err create mode 100644 tests/qapi-schema/args-box-string.exit create mode 100644 tests/qapi-schema/args-box-string.json create mode 100644 tests/qapi-schema/args-box-string.out create mode 100644 tests/qapi-schema/event-box-empty.err create mode 100644 tests/qapi-schema/event-box-empty.exit create mode 100644 tests/qapi-schema/event-box-empty.json create mode 100644 tests/qapi-schema/event-box-empty.out create mode 100644 tests/qapi-schema/flat-union-incomplete-branch.err create mode 100644 tests/qapi-schema/flat-union-incomplete-branch.exit create mode 100644 tests/qapi-schema/flat-union-incomplete-branch.json create mode 100644 tests/qapi-schema/flat-union-incomplete-branch.out -- 2.5.5