An update of a series previously posted v1: https://lists.gnu.org/archive/html/qemu-devel/2016-02/msg04618.html v2: https://lists.gnu.org/archive/html/qemu-devel/2016-03/msg01454.html v3: https://lists.gnu.org/archive/html/qemu-devel/2016-03/msg02498.html v4: https://lists.gnu.org/archive/html/qemu-devel/2016-05/msg01661.html v5: https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg00485.html v6: https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg03876.html v7: https://lists.gnu.org/archive/html/qemu-devel/2016-07/msg00919.html v8: https://lists.gnu.org/archive/html/qemu-devel/2016-07/msg03115.html v9: https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg02653.html v10: https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg02694.html v11: https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg00652.html v12: https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg03559.html v13: https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg04212.html v14: https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg07037.html
This series provides the infrastructure to allow use of non-scalar properties with the -object CLI arg, and object_add monitor commands. eg a property which is a list of structs. The syntax used for this is intentionally compatible with the syntax used by the block layer. This will allow the qdict_crumple method to be used by the block layer to convert from QemuOpts into structured QAPI block layer structs at a future date. It is already used by one of Max's patch series, by Kevin's -blockdev series, and by my own ACL series. This patch series has grown a fair bit larger since previous postings (19^H^H21 patches instead of 6). This was to avoid trying to squish too much into one patch, to make it easier to review. It does not neccessarily need to be merged in one go. There are three logical blocks of patches here. Patches 1-8 are the core support for visiting QemuOpts using the QObjectInputVisitor class. Merging this would unblock at least Kevin's blockdev series, and probably Max's series too. The patches 9-14 add enhancements to the code to support various special cases / edge cases needed to provide fully semantic replacement of the OptsVisitor Patches 15-21 deal with converting code over to use the new visitor logic. Once this is merged, there is also scope to further enhance the QObjectInputVisitor to deal with visiting single-properties, which would let us delete StringInputVisitor too. This would mean we have a single input visitor class, instead of the current three. Changed in v15: - Re-arranged patch series to allow easier incremental merge of core functionality - Extra error checking of some scenarios to be avoided (Eric) - Misc typos (Eric) - Rename QEMU_OPTS_REPEAT_POLICY_LIST to QEMU_OPTS_REPEAT_POLICY_ALL, and add QEMU_OPTS_REPEAT_POLICY_ERROR (Eric) Changed in v14: - Extend qemu_opts_to_qdict to optionally handle case of repeated keys without dropping them. - Support parsing of integer ranges for "list of int" visits for back compat with OptsVisitor - Support visiting nested structs which are represented as a flat keyspace for back compat with OptsVisitor - Add trace events for visitor functions to facilitate debugging - Add a QObjectInputVisitor constructor which takes a QemuOpts object, to avoid repeated code patterns in callers - Greater test coverage of -object to validate correct handling of "list of ints" legacy OptsVisitor syntax - Convert all other use of OptsVisitor to QObjectInputVisitor - Delete OptsVisitor Changed in v13: - Fix typos (Kevin) - Remove unneeded line breaks (Kevin) Changed in v12: - More user friendly error message for mixing dict/list keys (Kevin) - Report error instead of assert for non-contiguous list keys (Kevin) - Fix tests for non-contiguous list keys (Kevin) - Add tests for escaping of '.' when crumpling (Kevin) - Fix remaining references to Qmp(In|Out)putVisitor (Markus) - Misc typos / whitespace fixes (Eric, Kevin) - Avoid touching 'ret' when parsing int64 fails (Eric) - Testing of more edge cases in QObjectInputVisitor (Eric) - Simplify API doc format (Markus) - Use parse_option_size instead of qemu_strtosz_suffix for consistency (Kevin) - Use safer qobject_to_qdict casts (Eric) Changed in v11: - Split QAPI/QOM patches off from the access control patches Changed in v10: - Fixed stupid build mistake Changed in v9: - Rename QmpInputVisitor -> QObjectInputVisitor (Markus/Eric) - Rename QmpOutputVisitor -> QObjectOutputVisitor (Markus/Eric) - Drop "strict" param from qobject_string_visitor_new() (Marus) - Misc docs typos - Add a visitor able to use strict or string types (for Eric's netdev series) - Add a authorization API implementation that uses PAM Changed in v8: - Rebase due to merge of Visitor API changes (Eric) Changed in v7: - Misc typos in API docs (Marc-André) - Fix parsing of properties using type_size visitor (Marc-André) - Mark based auth class as abstract (Marc-André) - Fix QAPI version annotations to say 2.7 (Marc-André) Changed in v6: - Switch from while() to for() loop for iterating over dicts (Markus) - Avoid redundant strdup (Markus) - Rewrap comments at 70 chars (Markus) - Change qdict_list_size() to qdict_is_list() (Markus) - Misc docs changes (Markus) - Change QmpInputVisitor so the code for handling the string types is separate from code using native scalar types (Paolo) - Centralize code parsing bool strings (Markus) - Centralize code parsing int strings (Markus) Changed in v5: - Resolved conflicts with Eric's visitor refactoring which made it stricter about struct begin/end calls - Added support for ACLs to migration code now its TLS support is merged. - Fixed typos in example in commit message Changed in v4: - Ensure examples use shell escaping for '*' (Eric) - Add more tests for crumple impl (Eric) - Raise error if sasl-acl/tls-acl are requested but sasl/tls auth are not enabled (Eric) - Document return codes for auth check more clearly (Eric) - Don't silently turn a glob match into a strcmp - Other misc small typos/fixes (Eric) Changed in v3: - Created separate qdict_list_size method (Max) - Added unit tests for case of empty dict (Max) - Fix variable names to use underscore separator (Max) - Fix potential free of uninitialized variables (Max) - Use QObject APIs for casts, instead of C type casts (Max) Changed in v2: - Adapt to changes in qapi visitor APIs - Add a 'bool recursive' flag to qdict_crumple (Max) - Fix memory leaks in qdict_crumple (Max) - Split out key splitting code from qdict_crumple (Max) - Use saner variable names in qdict_crumple (Max) - Added some tests for bad inputs to qdict_crumple Daniel P. Berrange (21): option: make parse_option_bool/number non-static qdict: implement a qdict_crumple method for un-flattening a dict qapi: add trace events for visitor qapi: rename QmpInputVisitor to QObjectInputVisitor qapi: rename QmpOutputVisitor to QObjectOutputVisitor qapi: don't pass two copies of TestInputVisitorData to tests qapi: permit scalar type conversions in QObjectInputVisitor qapi: allow QObjectInputVisitor to be created with QemuOpts qapi: permit auto-creating single element lists qapi: permit auto-creating nested structs qapi: add integer range support for QObjectInputVisitor option: allow qemu_opts_to_qdict to merge repeated options qdict: allow qdict_crumple to accept compound types as values qapi: allow repeated opts with qobject_input_visitor_new_opts qom: support non-scalar properties with -object hmp: support non-scalar properties with object_add numa: convert to use QObjectInputVisitor for -numa block: convert crypto driver to use QObjectInputVisitor acpi: convert to QObjectInputVisitor for -acpi parsing net: convert to QObjectInputVisitor for -net/-netdev parsing qapi: delete unused OptsVisitor code Makefile.objs | 1 + block/crypto.c | 14 +- block/qapi.c | 4 +- blockdev.c | 11 +- docs/qapi-code-gen.txt | 4 +- hmp.c | 25 +- hw/acpi/core.c | 14 +- include/qapi/opts-visitor.h | 40 -- include/qapi/qmp-input-visitor.h | 30 - include/qapi/qmp/qdict.h | 1 + include/qapi/qobject-input-visitor.h | 130 ++++ ...p-output-visitor.h => qobject-output-visitor.h} | 10 +- include/qapi/visitor.h | 6 +- include/qemu/option.h | 17 +- include/sysemu/numa_int.h | 11 + monitor.c | 5 +- net/net.c | 18 +- numa.c | 36 +- qapi/Makefile.objs | 6 +- qapi/opts-visitor.c | 561 --------------- qapi/qapi-clone-visitor.c | 2 +- qapi/qapi-visit-core.c | 27 + qapi/qmp-input-visitor.c | 412 ----------- qapi/qmp-output-visitor.c | 256 ------- qapi/qobject-input-visitor.c | 785 +++++++++++++++++++++ qapi/qobject-output-visitor.c | 254 +++++++ qapi/trace-events | 33 + qemu-img.c | 12 +- qemu-io-cmds.c | 3 +- qemu-io.c | 6 +- qemu-nbd.c | 3 +- qmp.c | 4 +- qobject/qdict.c | 302 ++++++++ qom/object_interfaces.c | 42 +- qom/qom-qobject.c | 8 +- scripts/qapi-commands.py | 8 +- scripts/qapi-event.py | 4 +- stubs/Makefile.objs | 5 + stubs/exec.c | 6 + stubs/hostmem.c | 14 + stubs/memory.c | 41 ++ stubs/qdev.c | 8 + stubs/vl.c | 8 + stubs/vmstate.c | 4 + target-s390x/cpu_models.c | 4 +- tests/.gitignore | 6 +- tests/Makefile.include | 27 +- tests/check-qdict.c | 436 ++++++++++++ tests/check-qnull.c | 8 +- tests/check-qom-proplist.c | 367 +++++++++- tests/qemu-iotests/051.out | 6 +- tests/qemu-iotests/051.pc.out | 6 +- tests/qemu-iotests/137.out | 4 +- tests/test-numa.c | 116 +++ tests/test-opts-visitor.c | 268 ------- tests/test-qemu-opts.c | 132 ++++ tests/test-qmp-commands.c | 4 +- ...-input-strict.c => test-qobject-input-strict.c} | 6 +- ...nput-visitor.c => test-qobject-input-visitor.c} | 637 +++++++++++++++-- ...put-visitor.c => test-qobject-output-visitor.c} | 6 +- tests/test-replication.c | 9 +- tests/test-string-input-visitor.c | 2 +- tests/test-string-output-visitor.c | 2 +- tests/test-visitor-serialization.c | 8 +- util/qemu-option.c | 91 ++- util/qemu-sockets.c | 4 +- vl.c | 1 - 67 files changed, 3566 insertions(+), 1775 deletions(-) delete mode 100644 include/qapi/opts-visitor.h delete mode 100644 include/qapi/qmp-input-visitor.h create mode 100644 include/qapi/qobject-input-visitor.h rename include/qapi/{qmp-output-visitor.h => qobject-output-visitor.h} (66%) create mode 100644 include/sysemu/numa_int.h delete mode 100644 qapi/opts-visitor.c delete mode 100644 qapi/qmp-input-visitor.c delete mode 100644 qapi/qmp-output-visitor.c create mode 100644 qapi/qobject-input-visitor.c create mode 100644 qapi/qobject-output-visitor.c create mode 100644 qapi/trace-events create mode 100644 stubs/exec.c create mode 100644 stubs/hostmem.c create mode 100644 stubs/memory.c create mode 100644 stubs/qdev.c create mode 100644 stubs/vl.c create mode 100644 tests/test-numa.c delete mode 100644 tests/test-opts-visitor.c rename tests/{test-qmp-input-strict.c => test-qobject-input-strict.c} (98%) rename tests/{test-qmp-input-visitor.c => test-qobject-input-visitor.c} (57%) rename tests/{test-qmp-output-visitor.c => test-qobject-output-visitor.c} (99%) -- 2.7.4