summaryrefslogtreecommitdiffstats
path: root/scripts/qapi
Commit message (Collapse)AuthorAgeFilesLines
...
* qapi/schema: Rename QAPISchemaObjectType{Variant,Variants}Markus Armbruster2020-03-171-11/+11
| | | | | | | | | | | QAPISchemaObjectTypeVariants represents both object type and alternate type variants. Rename to QAPISchemaVariants. Rename QAPISchemaObjectTypeVariant the same way. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20200317115459.31821-19-armbru@redhat.com>
* qapi/schema: Reorder classes so related ones are togetherMarkus Armbruster2020-03-171-134/+134
| | | | | | | | | | Move QAPISchemaAlternateType up some, so that all QAPISchemaFOOType are together. Move QAPISchemaObjectTypeVariants right behind its users. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20200317115459.31821-18-armbru@redhat.com>
* qapi/schema: Change _make_features() to a take feature listMarkus Armbruster2020-03-171-8/+9
| | | | | | | | | | | QAPISchema._make_features() takes a definition expression, and extracts its 'features' member. The other ._make_FOO() leave destructuring expressions to their callers. Change ._make_features() to match them. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20200317115459.31821-17-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* qapi/introspect: Factor out _make_tree()Markus Armbruster2020-03-171-20/+24
| | | | | | | | | | | The value of @qmp_schema_qlit is generated from an expression tree. Tree nodes are created in several places. Factor out the common code into _make_tree(). This isn't much of a win now. It will pay off when we add feature flags in the next few commits. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20200317115459.31821-16-armbru@redhat.com>
* qapi/introspect: Rename *qlit* to reduce confusionMarkus Armbruster2020-03-171-17/+18
| | | | | | | | | | | | | | We generate the value of qmp_schema_qlit from an expression tree. The function doing that is named to_qlit(), and its inputs are accumulated in QAPISchemaGenIntrospectVisitor._qlits. We call both its input and its output "qlit". This is confusing. Use "tree" for input, and "qlit" only for output: rename to_qlit() to _tree_to_qlit(), ._qlits to ._trees, ._gen_qlit() to ._gen_tree(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20200317115459.31821-15-armbru@redhat.com>
* qapi: Consistently put @features parameter right after @ifcondMarkus Armbruster2020-03-176-36/+34Star
| | | | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20200317115459.31821-14-armbru@redhat.com>
* qapi: Add feature flags to remaining definitionsMarkus Armbruster2020-03-177-74/+80
| | | | | | | | | | | | | | | | | In v4.1.0, we added feature flags just to struct types (commit 6a8c0b5102^..f3ed93d545), to satisfy an immediate need (commit c9d4070991 "file-posix: Add dynamic-auto-read-only QAPI feature"). In v4.2.0, we added them to commands (commit 23394b4c39 "qapi: Add feature flags to commands") to satisfy another immediate need (commit d76744e65e "qapi: Allow introspecting fix for savevm's cooperation with blockdev"). Add them to the remaining definitions: enumeration types, union types, alternate types, and events. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20200317115459.31821-13-armbru@redhat.com>
* qapi/schema: Clean up around QAPISchemaEntity.connect_doc()Markus Armbruster2020-03-171-4/+9
| | | | | | | | | | | | QAPISchemaEntity calls doc.connect_feature() in .check(). Improper since commit ee1e6a1f6c8 split .connect_doc() off .check(). Move the call. Requires making the children call super().connect_doc() as they should. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20200317115459.31821-12-armbru@redhat.com>
* qemu-storage-daemon: Add --monitor optionKevin Wolf2020-03-061-0/+5
| | | | | | | | | | | | | | | | | This adds and parses the --monitor option, so that a QMP monitor can be used in the storage daemon. The monitor offers commands defined in the QAPI schema at storage-daemon/qapi/qapi-schema.json. The --monitor options currently allows to create multiple monitors with the same ID. This part of the interface is considered unstable. We will reject such configurations as soon as we have a design for the monitor subsystem to perform these checks. (In the system emulator, we depend on QemuOpts rejecting duplicate IDs.) Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20200224143008.13362-21-kwolf@redhat.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qapi: Brush off some (py)lintMarkus Armbruster2020-03-056-18/+15Star
| | | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20200304155932.20452-5-armbru@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
* qapi: Use super() now we have Python 3Markus Armbruster2020-03-059-44/+43Star
| | | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20200304155932.20452-4-armbru@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
* qapi: Drop conditionals for Python 2Markus Armbruster2020-03-053-15/+3Star
| | | | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20200304155932.20452-3-armbru@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
* qapi: Inheriting from object is pointless with Python 3, dropMarkus Armbruster2020-03-054-12/+12
| | | | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20200304155932.20452-2-armbru@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
* drop "from __future__ import print_function"Paolo Bonzini2020-02-071-1/+0Star
| | | | | | | | | | | | This is only needed for Python 2, which we do not support anymore. Cc: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: Alex Bennée <alex.bennee@linaro.org> Acked-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20200204160604.19883-1-pbonzini@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
* qapi: Fix code generation with Python 3.5Markus Armbruster2020-01-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recent commit 3e7fb5811b "qapi: Fix code generation for empty modules" modules" switched QAPISchema.visit() from for entity in self._entity_list: effectively to for mod in self._module_dict.values(): for entity in mod._entity_list: Visits in the same order as long as .values() is in insertion order. That's the case only for Python 3.6 and later. Before, it's in some arbitrary order, which results in broken generated code. Fix by making self._module_dict an OrderedDict rather than a dict. Fixes: 3e7fb5811baab213dcc7149c3aa69442d683c26c Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Tested-by: Thomas Huth <thuth@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> Tested-by: BALATON Zoltan <balaton@eik.bme.hu> Tested-by: Alex Bennée <alex.bennee@linaro.org> Message-id: 20200116202558.31473-1-armbru@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* qapi: Simplify QAPISchemaModularCVisitorMarkus Armbruster2020-01-145-22/+23
| | | | | | | | | Since the previous commit, QAPISchemaVisitor.visit_module() is called just once. Simplify QAPISchemaModularCVisitor accordingly. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191120182551.23795-7-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* qapi: Fix code generation for empty modulesMarkus Armbruster2020-01-141-11/+13
| | | | | | | | | | | | | | | | | | | When a sub-module doesn't contain any definitions, we don't generate code for it, but we do generate the #include. We generate code only for modules that get visited. QAPISchema.visit() visits only modules that have definitions. It can visit modules multiple times. Clean this up as follows. Collect entities in their QAPISchemaModule. Have QAPISchema.visit() call QAPISchemaModule.visit() for each module. Have QAPISchemaModule.visit() call .visit_module() for itself, and QAPISchemaEntity.visit() for each of its entities. This way, we visit each module exactly once. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191120182551.23795-6-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* qapi: Proper intermediate representation for modulesMarkus Armbruster2020-01-141-20/+43
| | | | | | | | | | | | | | | | Modules are represented only by their names so far. Introduce class QAPISchemaModule. So far, it merely wraps the name. The next patch will put it to more interesting use. Once again, arrays spice up the patch a bit. For any other type, @info points to the definition, which lets us map from @info to module. For arrays, there is no definition, and @info points to the first use instead. We have to use the element type's module instead, which is only available after .check(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191120182551.23795-5-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* qapi: Generate command registration stuff into separate filesMarkus Armbruster2020-01-141-4/+11
| | | | | | | | | | | | Having to include qapi-commands.h just for qmp_init_marshal() is suboptimal. Generate it into separate files. This lets monitor/misc.c, qga/main.c, and the generated qapi-commands-FOO.h include less. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191120182551.23795-4-armbru@redhat.com> [Typos in docs/devel/qapi-code-gen.txt fixed] Reviewed-by: Eric Blake <eblake@redhat.com>
* qapi: Tweak "command returns a nice type" check for clarityMarkus Armbruster2020-01-141-4/+5
| | | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191120182551.23795-2-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* qapi: Check feature documentation against the schemaMarkus Armbruster2019-10-292-9/+24
| | | | | | | | | Commit f3ed93d545 "qapi: Allow documentation for features" neglected to check documentation against the schema. Fix that: check them the same way we check arguments. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-20-armbru@redhat.com>
* qapi: Polish reporting of bogus member documentationMarkus Armbruster2019-10-291-2/+4
| | | | | | | | | | | | | | | Improve error messages from the following documented members are not in the declaration: a the following documented members are not in the declaration: aa, bb to the more concise documented member 'a' does not exist documented members 'aa', 'bb' do not exist Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-19-armbru@redhat.com>
* qapi: Lift features into QAPISchemaEntityMarkus Armbruster2019-10-291-21/+11Star
| | | | | | | | | | | | | | Commit 6a8c0b5102 "qapi: Add feature flags to struct types" added features to QAPISchemaObjectType. Commit a95daa5093 "qapi: Add feature flags to commands in qapi" added them to QAPISchemaCommand, duplicating the code. Tolerable, but the duplication will only get worse as we add features to more definitions. To de-duplicate, lift features from QAPISchemaObjectType and QAPISchemaCommand into QAPISchemaEntity. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-18-armbru@redhat.com>
* qapi: Fold normalize_enum() into check_enum()Markus Armbruster2019-10-291-7/+2Star
| | | | | | | | check_features() is always called together with normalize_features(). Fold the latter into the former. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-17-armbru@redhat.com>
* qapi: Fold normalize_features() into check_features()Markus Armbruster2019-10-291-8/+2Star
| | | | | | | | | check_features() is always called together with normalize_features(): the former in check_struct() and check_command(), the latter in their caller check_exprs(). Fold the latter into the former. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-16-armbru@redhat.com>
* qapi: Fold normalize_if() into check_if()Markus Armbruster2019-10-291-12/+1Star
| | | | | | | | check_if() is always called together with normalize_if(). Fold the latter into the former. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-15-armbru@redhat.com>
* qapi: Eliminate .check_doc() overridesMarkus Armbruster2019-10-291-21/+2Star
| | | | | | | | | | | | All sub-classes of QAPISchemaEntity now override .check_doc() the same way, except for QAPISchemaType and and QAPISchemaArrayType. Put the overrides' code in QAPISchemaEntity.check_doc(), and drop the overrides. QAPISchemaType doesn't care because it's abstract. QAPISchemaArrayType doesn't care because its .doc is always None. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-14-armbru@redhat.com>
* qapi: Simplify ._make_implicit_object_type()Markus Armbruster2019-10-291-7/+6Star
| | | | | | | All callers now pass doc=None. Drop the argument. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-13-armbru@redhat.com>
* qapi: Fix doc comment checking for commands and eventsMarkus Armbruster2019-10-292-2/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a command's 'data' is an object, its doc comment describes the arguments defined there. When 'data' names a type, the doc comment does not describe arguments. Instead, the doc generator inserts a pointer to the named type. An event's doc comment works the same. We don't actually check doc comments for commands and events. Instead, QAPISchema._def_command() forwards the doc comment to the implicit argument type, where it gets checked. Works because the check only cares for the implicit argument type's members. Not only is this needlessly hard to understand, it actually falls apart in two cases: * When 'data' is empty, there is nothing to forward to, and the doc comment remains unchecked. Demonstrated by test doc-bad-event-arg. * When 'data' names a type, we can't forward, as the type has its own doc comment. The command or event's doc comment remains unchecked. Demonstrated by test doc-bad-boxed-command-arg. The forwarding goes back to commit 069fb5b250 "qapi: Prepare for requiring more complete documentation", put to use in commit 816a57cd6e "qapi: Fix detection of bogus member documentation". That fix was incomplete. To fix this, make QAPISchemaCommand and QAPISchemaEvent check doc comments, and drop the forwarding of doc comments to implicit argument types. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-12-armbru@redhat.com>
* qapi: Clean up doc comment checking for implicit union baseMarkus Armbruster2019-10-291-11/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An object type's doc comment describes the type's members, less the ones defined in a named base type. Cases: * Struct: the members are defined in 'data' and inherited from 'base'. Since the base type cannot be implicit, the doc comment describes just 'data'. * Simple union: the only member is the implicit tag member @type, and the doc comment describes it. * Flat union with implicit base type: the members are defined in 'base', and the doc comment describes it. * Flat union with named base type: the members are inherited from 'base'. The doc comment describes no members. Before we can check a doc comment with .check_doc(), we need .connect_doc() connect each of its "argument sections" to the member it documents. For structs and simple unions, this is straightforward: the members in question are in .local_members, and .connect_doc() connects them. For flat unions with a named base type, it's trivial: .local_members is empty, and .connect_doc() does nothing. For flat unions with an implicit base type, it's tricky. We have QAPISchema._make_implicit_object_type() forward the union's doc comment to the implicit base type, so that the base type's .connect_doc() connects the members. The union's .connect_doc() does nothing, as .local_members is empty. Dirt effect: we check the doc comment twice, once for the union type, and once for the implicit base type. This is needlessly brittle and hard to understand. Clean up as follows. Make the union's .connect_doc() connect an implicit base's members itself. Do not forward the union's doc comment to its implicit base type. Requires extending .connect_doc() so it can work with a doc comment other than self.doc. Add an optional argument for that. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-11-armbru@redhat.com>
* qapi: Fix enum doc comment checkingMarkus Armbruster2019-10-291-0/+4
| | | | | | | | | | | Enumeration type documentation comments are not checked, as demonstrated by test doc-bad-enum-member. This is because we neglect to call self.doc.check() for enumeration types. Messed up in 816a57cd6e "qapi: Fix detection of bogus member documentation". Fix it. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-10-armbru@redhat.com>
* qapi: Split .connect_doc(), .check_doc() off .check()Markus Armbruster2019-10-291-7/+27
| | | | | | | | | Splitting documentation checking off the .check() methods makes them a bit more focused, which is welcome, as some of them are pretty big. It also prepares the ground for the following commits. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-9-armbru@redhat.com>
* qapi: De-duplicate entity documentation generation codeMarkus Armbruster2019-10-291-42/+40Star
| | | | | | | | | | | | QAPISchemaGenDocVisitor.visit_command() duplicates texi_entity() for its boxed arguments case. The previous commit added another copy in .visit_event(). Replace texi_entity() by texi_type() and texi_msg(). Use texi_msg() for the boxed arguments case as well. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-8-armbru@redhat.com>
* qapi: Implement boxed event argument documentationMarkus Armbruster2019-10-291-1/+9
| | | | | | | | | | | | Generate a reference "Arguments: the members of ...", just like we do for commands since commit c2dd311cb7 "qapi2texi: Implement boxed argument documentation". No change to generated QMP documentation; we don't yet use boxed events outside tests/. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191024110237.30963-7-armbru@redhat.com>
* qapi: Add feature flags to commandsPeter Krempa2019-10-225-22/+49
| | | | | | | | | | | | | | Similarly to features for struct types introduce the feature flags also for commands. This will allow notifying management layers of fixes and compatible changes in the behaviour of a command which may not be detectable any other way. The changes were heavily inspired by commit 6a8c0b51025. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191018081454.21369-3-armbru@redhat.com>
* qapi: Clear scripts/qapi/doc.py executable bits againMarkus Armbruster2019-10-221-1/+0Star
| | | | | | | | | Commit fbf09a2fa4 "qapi: add 'ifcond' to visitor methods" brought back the executable bits. Fix that. Drop the #! line for good measure. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20191018074345.24034-8-armbru@redhat.com>
* qapi: Split up scripts/qapi/common.pyMarkus Armbruster2019-10-2213-2324/+2408
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The QAPI code generator clocks in at some 3100 SLOC in 8 source files. Almost 60% of the code is in qapi/common.py. Split it into more focused modules: * Move QAPISchemaPragma and QAPISourceInfo to qapi/source.py. * Move QAPIError and its sub-classes to qapi/error.py. * Move QAPISchemaParser and QAPIDoc to parser.py. Use the opportunity to put QAPISchemaParser first. * Move check_expr() & friends to qapi/expr.py. Use the opportunity to put the code into a more sensible order. * Move QAPISchema & friends to qapi/schema.py * Move QAPIGen and its sub-classes, ifcontext, QAPISchemaModularCVisitor, and QAPISchemaModularCVisitor to qapi/gen.py * Delete camel_case(), it's unused since commit e98859a9b9 "qapi: Clean up after recent conversions to QAPISchemaVisitor" A number of helper functions remain in qapi/common.py. I considered moving the code generator helpers to qapi/gen.py, but decided not to. Perhaps we should rewrite them as methods of QAPIGen some day. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20191018074345.24034-7-armbru@redhat.com> [Add "# -*- coding: utf-8 -*-" lines]
* qapi: Move gen_enum(), gen_enum_lookup() back to qapi/types.pyMarkus Armbruster2019-10-223-59/+60
| | | | | | | | | | | | | | | | | | | | | | The next commit will split up qapi/common.py. gen_enum() needs QAPISchemaEnumMember, and that's in the way. Move it to qapi/types.py along with its buddy gen_enum_lookup(). Permit me a short a digression on history: how did gen_enum() end up in qapi/common.py? Commit 21cd70dfc1 "qapi script: add event support" duplicated qapi-types.py's gen_enum() and gen_enum_lookup() in qapi-event.py. Simply importing them would have been cleaner, but wasn't possible as qapi-types.py was a program, not a module. Commit efd2eaa6c2 "qapi: De-duplicate enum code generation" de-duplicated by moving them to qapi.py, which was a module. Since then, program qapi-types.py has morphed into module types.py. It's where gen_enum() and gen_enum_lookup() started, and where they belong. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20191018074345.24034-6-armbru@redhat.com>
* qapi: Eliminate accidental global frontend stateMarkus Armbruster2019-10-221-2/+3
| | | | | | | | | | | | | | | | | The frontend can't be run more than once due to its global state. A future commit will want to do that. The only global frontend state remaining is accidental: QAPISchemaParser.__init__()'s parameter previously_included=[]. Python evaluates the default once, at definition time. Any modifications to it are visible in subsequent calls. Well-known Python trap. Change the default to None and replace it by the real default in the function body. Use the opportunity to convert previously_included to a set. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20191018074345.24034-4-armbru@redhat.com>
* qapi: Store pragma state in QAPISourceInfo, not global stateMarkus Armbruster2019-10-221-17/+19
| | | | | | | | | | | | | | | | The frontend can't be run more than once due to its global state. A future commit will want to do that. Recent commit "qapi: Move context-sensitive checking to the proper place" got rid of many global variables already, but pragma state is still stored in global variables (that's why a pragma directive's scope is the complete schema). Move the pragma state to QAPISourceInfo. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20191018074345.24034-3-armbru@redhat.com>
* qapi: Don't suppress doc generation without pragma doc-requiredMarkus Armbruster2019-10-221-2/+0Star
| | | | | | | | | | | | | | | | | | | | | | | Commit bc52d03ff5 "qapi: Make doc comments optional where we don't need them" made scripts/qapi2texi.py fail[*] unless the schema had pragma 'doc-required': true. The stated reason was inability to cope with incomplete documentation. When commit fb0bc835e5 "qapi-gen: New common driver for code and doc generators" folded scripts/qapi2texi.py into scripts/qapi-gen.py, it turned the failure into silent suppression. The doc generator can cope with incomplete documentation now. I don't know since when, or what the problem was, or even whether it ever existed. Drop the silent suppression. [*] The fail part was broken, fixed in commit e8ba07ea9a. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20191018074345.24034-2-armbru@redhat.com>
* qapi: Improve source file read error handlingMarkus Armbruster2019-09-281-20/+26
| | | | | | | | | | | | | | | | | | | | qapi-gen.py crashes when it can't open the main schema file, and when it can't read from any schema file. Lazy. Change QAPISchema.__init__() to take a file name instead of a file object. Move the open code from _include() to __init__(), so it's used for the main schema file, too. Move the read into the try for good measure, and rephrase the error message. Reporting open or read failure for the main schema file needs a QAPISourceInfo representing "no source". Make QAPISourceInfo cope with fname=None. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20190927134639.4284-27-armbru@redhat.com>
* qapi: Improve reporting of redefinitionMarkus Armbruster2019-09-281-0/+5
| | | | | | | | Point to the previous definition, unless it's a built-in. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20190927134639.4284-26-armbru@redhat.com>
* qapi: Improve reporting of missing documentation commentMarkus Armbruster2019-09-281-10/+8Star
| | | | | | | | | Have check_exprs() check this later, so the error message gains an "in definition line". Tweak the error message. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20190927134639.4284-25-armbru@redhat.com>
* qapi: Eliminate check_keys(), rename check_known_keys()Markus Armbruster2019-09-281-19/+21
| | | | | | | | | | | check_keys() has become a trivial wrapper for check_known_keys(). Eliminate it. This makes its name available. Rename check_known_keys(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20190927134639.4284-24-armbru@redhat.com>
* qapi: Improve reporting of invalid 'if' furtherMarkus Armbruster2019-09-281-11/+16
| | | | | | | | | | | | | | | | check_if()'s errors don't point to the offending part of the expression. For instance: tests/qapi-schema/alternate-branch-if-invalid.json:2: 'if' condition ' ' makes no sense Other check_FOO() do, with the help of a @source argument. Make check_if() do that, too. The example above improves to: tests/qapi-schema/alternate-branch-if-invalid.json:2: 'if' condition ' ' of 'data' member 'branch' makes no sense Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20190927134639.4284-23-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* qapi: Avoid redundant definition references in error messagesMarkus Armbruster2019-09-281-80/+49Star
| | | | | | | | | Many error messages refer to the offending definition even though they're preceded by an "in definition" line. Rephrase them. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20190927134639.4284-22-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* qapi: Improve reporting of missing / unknown definition keysMarkus Armbruster2019-09-281-21/+19Star
| | | | | | | | | | | | | | Have check_exprs() call check_keys() later, so its error messages gain an "in definition" line. Both check_keys() and check_name_is_str() check the definition's name is a string. Since check_keys() now runs after check_name_is_str() rather than before, its check is dead. Bury it. Checking values in check_keys() is unclean anyway. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20190927134639.4284-21-armbru@redhat.com>
* qapi: Improve reporting of invalid flagsMarkus Armbruster2019-09-281-10/+12
| | | | | | | | | | | | Split check_flags() off check_keys() and have check_exprs() call it later, so its error messages gain an "in definition" line. Tweak the error messages. Checking values in a function named check_keys() is unclean anyway. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20190927134639.4284-20-armbru@redhat.com>
* qapi: Improve reporting of invalid 'if' errorsMarkus Armbruster2019-09-281-2/+2
| | | | | | | | | | | | | | | | | | Move check_if() from check_keys() to check_exprs() and call it later, so its error messages gain an "in definition" line. Checking values in a function named check_keys() is unclean anyway. The original sin was commit 0545f6b887 "qapi: Better error messages for bad expressions", which checks the value of key 'name'. More sinning in commit 2cbf09925a "qapi: More rigorous checking for type safety bypass", commit c818408e44 "qapi: Implement boxed types for commands/events", and commit 967c885108 "qapi: add 'if' to top-level expressions". This commit does penance for the latter. The next commits will do penance for the others. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20190927134639.4284-19-armbru@redhat.com>