From fb0bc835e56b894cbc7236294921e5393c786ad8 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 26 Feb 2018 13:48:58 -0600 Subject: qapi-gen: New common driver for code and doc generators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Whenever qapi-schema.json changes, we run six programs eleven times to update eleven files. Similar for qga/qapi-schema.json. This is silly. Replace the six programs by a single program that spits out all eleven files. The programs become modules in new Python package qapi, along with the helper library. This requires moving them to scripts/qapi/. While moving them, consistently drop executable mode bits. Signed-off-by: Markus Armbruster Reviewed-by: Marc-André Lureau Message-Id: <20180211093607.27351-9-armbru@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Michael Roth [eblake: move change to one-line 'blurb' earlier in series, mention mode bit change as intentional, update qapi-code-gen.txt to match actual generated events.c file] Signed-off-by: Eric Blake --- scripts/qapi/introspect.py | 188 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 scripts/qapi/introspect.py (limited to 'scripts/qapi/introspect.py') diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py new file mode 100644 index 0000000000..1e4f065164 --- /dev/null +++ b/scripts/qapi/introspect.py @@ -0,0 +1,188 @@ +""" +QAPI introspection generator + +Copyright (C) 2015-2018 Red Hat, Inc. + +Authors: + Markus Armbruster + +This work is licensed under the terms of the GNU GPL, version 2. +See the COPYING file in the top-level directory. +""" + +from qapi.common import * + + +# Caveman's json.dumps() replacement (we're stuck at Python 2.4) +# TODO try to use json.dumps() once we get unstuck +def to_json(obj, level=0): + if obj is None: + ret = 'null' + elif isinstance(obj, str): + ret = '"' + obj.replace('"', r'\"') + '"' + elif isinstance(obj, list): + elts = [to_json(elt, level + 1) + for elt in obj] + ret = '[' + ', '.join(elts) + ']' + elif isinstance(obj, dict): + elts = ['"%s": %s' % (key.replace('"', r'\"'), + to_json(obj[key], level + 1)) + for key in sorted(obj.keys())] + ret = '{' + ', '.join(elts) + '}' + else: + assert False # not implemented + if level == 1: + ret = '\n' + ret + return ret + + +def to_c_string(string): + return '"' + string.replace('\\', r'\\').replace('"', r'\"') + '"' + + +class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor): + def __init__(self, prefix, unmask): + self._prefix = prefix + self._unmask = unmask + self.defn = None + self.decl = None + self._schema = None + self._jsons = None + self._used_types = None + self._name_map = None + + def visit_begin(self, schema): + self._schema = schema + self._jsons = [] + self._used_types = [] + self._name_map = {} + + def visit_end(self): + # visit the types that are actually used + jsons = self._jsons + self._jsons = [] + for typ in self._used_types: + typ.visit(self) + # generate C + # TODO can generate awfully long lines + jsons.extend(self._jsons) + name = c_name(self._prefix, protect=False) + 'qmp_schema_json' + self.decl = mcgen(''' +extern const char %(c_name)s[]; +''', + c_name=c_name(name)) + lines = to_json(jsons).split('\n') + c_string = '\n '.join([to_c_string(line) for line in lines]) + self.defn = mcgen(''' +const char %(c_name)s[] = %(c_string)s; +''', + c_name=c_name(name), + c_string=c_string) + self._schema = None + self._jsons = None + self._used_types = None + self._name_map = None + + def visit_needed(self, entity): + # Ignore types on first pass; visit_end() will pick up used types + return not isinstance(entity, QAPISchemaType) + + def _name(self, name): + if self._unmask: + return name + if name not in self._name_map: + self._name_map[name] = '%d' % len(self._name_map) + return self._name_map[name] + + def _use_type(self, typ): + # Map the various integer types to plain int + if typ.json_type() == 'int': + typ = self._schema.lookup_type('int') + elif (isinstance(typ, QAPISchemaArrayType) and + typ.element_type.json_type() == 'int'): + typ = self._schema.lookup_type('intList') + # Add type to work queue if new + if typ not in self._used_types: + self._used_types.append(typ) + # Clients should examine commands and events, not types. Hide + # type names to reduce the temptation. Also saves a few + # characters. + if isinstance(typ, QAPISchemaBuiltinType): + return typ.name + if isinstance(typ, QAPISchemaArrayType): + return '[' + self._use_type(typ.element_type) + ']' + return self._name(typ.name) + + def _gen_json(self, name, mtype, obj): + if mtype not in ('command', 'event', 'builtin', 'array'): + name = self._name(name) + obj['name'] = name + obj['meta-type'] = mtype + self._jsons.append(obj) + + def _gen_member(self, member): + ret = {'name': member.name, 'type': self._use_type(member.type)} + if member.optional: + ret['default'] = None + return ret + + def _gen_variants(self, tag_name, variants): + return {'tag': tag_name, + 'variants': [self._gen_variant(v) for v in variants]} + + def _gen_variant(self, variant): + return {'case': variant.name, 'type': self._use_type(variant.type)} + + def visit_builtin_type(self, name, info, json_type): + self._gen_json(name, 'builtin', {'json-type': json_type}) + + def visit_enum_type(self, name, info, values, prefix): + self._gen_json(name, 'enum', {'values': values}) + + def visit_array_type(self, name, info, element_type): + element = self._use_type(element_type) + self._gen_json('[' + element + ']', 'array', {'element-type': element}) + + def visit_object_type_flat(self, name, info, members, variants): + obj = {'members': [self._gen_member(m) for m in members]} + if variants: + obj.update(self._gen_variants(variants.tag_member.name, + variants.variants)) + self._gen_json(name, 'object', obj) + + def visit_alternate_type(self, name, info, variants): + self._gen_json(name, 'alternate', + {'members': [{'type': self._use_type(m.type)} + for m in variants.variants]}) + + def visit_command(self, name, info, arg_type, ret_type, + gen, success_response, boxed): + arg_type = arg_type or self._schema.the_empty_object_type + ret_type = ret_type or self._schema.the_empty_object_type + self._gen_json(name, 'command', + {'arg-type': self._use_type(arg_type), + 'ret-type': self._use_type(ret_type)}) + + def visit_event(self, name, info, arg_type, boxed): + arg_type = arg_type or self._schema.the_empty_object_type + self._gen_json(name, 'event', {'arg-type': self._use_type(arg_type)}) + + +def gen_introspect(schema, output_dir, prefix, opt_unmask): + blurb = ' * QAPI/QMP schema introspection' + genc = QAPIGenC(blurb, __doc__) + genh = QAPIGenH(blurb, __doc__) + + genc.add(mcgen(''' +#include "qemu/osdep.h" +#include "%(prefix)sqmp-introspect.h" + +''', + prefix=prefix)) + + vis = QAPISchemaGenIntrospectVisitor(prefix, opt_unmask) + schema.visit(vis) + genc.add(vis.defn) + genh.add(vis.decl) + genc.write(output_dir, prefix + 'qmp-introspect.c') + genh.write(output_dir, prefix + 'qmp-introspect.h') -- cgit 1.4.1 From 71b3f0459c460c9e16a47372ccddbfa6e2c7aadf Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 26 Feb 2018 13:50:08 -0600 Subject: qapi: Make code-generating visitors use QAPIGen more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The use of QAPIGen is rather shallow so far: most of the output accumulation is not converted. Take the next step: convert output accumulation in the code-generating visitor classes. Helper functions outside these classes are not converted. Signed-off-by: Markus Armbruster Message-Id: <20180211093607.27351-20-armbru@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Marc-André Lureau Reviewed-by: Michael Roth [eblake: rebase to earlier guardstart cleanup] Signed-off-by: Eric Blake --- scripts/qapi/commands.py | 71 ++++++++++++++++----------------------- scripts/qapi/common.py | 13 ++++++++ scripts/qapi/doc.py | 74 ++++++++++++++++++++--------------------- scripts/qapi/events.py | 55 ++++++++++++------------------- scripts/qapi/introspect.py | 56 +++++++++++++------------------ scripts/qapi/types.py | 81 +++++++++++++++++++-------------------------- scripts/qapi/visit.py | 82 ++++++++++++++++++++-------------------------- 7 files changed, 189 insertions(+), 243 deletions(-) (limited to 'scripts/qapi/introspect.py') diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 05fe33a03b..46757db771 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -223,44 +223,15 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds) return ret -class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): +class QAPISchemaGenCommandVisitor(QAPISchemaMonolithicCVisitor): + def __init__(self, prefix): - self._prefix = prefix - self.decl = None - self.defn = None - self._regy = None - self._visited_ret_types = None - - def visit_begin(self, schema): - self.decl = '' - self.defn = '' + QAPISchemaMonolithicCVisitor.__init__( + self, prefix, 'qmp-commands', + ' * Schema-defined QAPI/QMP commands', __doc__) self._regy = '' self._visited_ret_types = set() - - def visit_end(self): - self.defn += gen_registry(self._regy, self._prefix) - self._regy = None - self._visited_ret_types = None - - def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed): - if not gen: - return - self.decl += gen_command_decl(name, arg_type, boxed, ret_type) - if ret_type and ret_type not in self._visited_ret_types: - self._visited_ret_types.add(ret_type) - self.defn += gen_marshal_output(ret_type) - self.decl += gen_marshal_decl(name) - self.defn += gen_marshal(name, arg_type, boxed, ret_type) - self._regy += gen_register_command(name, success_response) - - -def gen_commands(schema, output_dir, prefix): - blurb = ' * Schema-defined QAPI/QMP commands' - genc = QAPIGenC(blurb, __doc__) - genh = QAPIGenH(blurb, __doc__) - - genc.add(mcgen(''' + self._genc.add(mcgen(''' #include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/module.h" @@ -275,19 +246,33 @@ def gen_commands(schema, output_dir, prefix): #include "%(prefix)sqmp-commands.h" ''', - prefix=prefix)) - - genh.add(mcgen(''' + prefix=prefix)) + self._genh.add(mcgen(''' #include "%(prefix)sqapi-types.h" #include "qapi/qmp/dispatch.h" void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds); ''', - prefix=prefix, c_prefix=c_name(prefix, protect=False))) + prefix=prefix, + c_prefix=c_name(prefix, protect=False))) + + def visit_end(self): + self._genc.add(gen_registry(self._regy, self._prefix)) + + def visit_command(self, name, info, arg_type, ret_type, + gen, success_response, boxed): + if not gen: + return + self._genh.add(gen_command_decl(name, arg_type, boxed, ret_type)) + if ret_type and ret_type not in self._visited_ret_types: + self._visited_ret_types.add(ret_type) + self._genc.add(gen_marshal_output(ret_type)) + self._genh.add(gen_marshal_decl(name)) + self._genc.add(gen_marshal(name, arg_type, boxed, ret_type)) + self._regy += gen_register_command(name, success_response) + +def gen_commands(schema, output_dir, prefix): vis = QAPISchemaGenCommandVisitor(prefix) schema.visit(vis) - genc.add(vis.defn) - genh.add(vis.decl) - genc.write(output_dir, prefix + 'qmp-commands.c') - genh.write(output_dir, prefix + 'qmp-commands.h') + vis.write(output_dir) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 2c5c40ec0a..23437b558f 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -2050,3 +2050,16 @@ class QAPIGenDoc(QAPIGen): def _top(self, fname): return (QAPIGen._top(self, fname) + '@c AUTOMATICALLY GENERATED, DO NOT MODIFY\n\n') + + +class QAPISchemaMonolithicCVisitor(QAPISchemaVisitor): + + def __init__(self, prefix, what, blurb, pydoc): + self._prefix = prefix + self._what = what + self._genc = QAPIGenC(blurb, pydoc) + self._genh = QAPIGenH(blurb, pydoc) + + def write(self, output_dir): + self._genc.write(output_dir, self._prefix + self._what + '.c') + self._genh.write(output_dir, self._prefix + self._what + '.h') diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py index cc4d5a43fb..0ea68bf813 100644 --- a/scripts/qapi/doc.py +++ b/scripts/qapi/doc.py @@ -197,33 +197,35 @@ def texi_entity(doc, what, base=None, variants=None, class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVisitor): - def __init__(self): - self.out = None + def __init__(self, prefix): + self._prefix = prefix + self._gen = qapi.common.QAPIGenDoc() self.cur_doc = None - def visit_begin(self, schema): - self.out = '' + def write(self, output_dir): + self._gen.write(output_dir, self._prefix + 'qapi-doc.texi') def visit_enum_type(self, name, info, values, prefix): doc = self.cur_doc - self.out += TYPE_FMT(type='Enum', - name=doc.symbol, - body=texi_entity(doc, 'Values', - member_func=texi_enum_value)) + self._gen.add(TYPE_FMT(type='Enum', + name=doc.symbol, + body=texi_entity(doc, 'Values', + member_func=texi_enum_value))) def visit_object_type(self, name, info, base, members, variants): doc = self.cur_doc if base and base.is_implicit(): base = None - self.out += TYPE_FMT(type='Object', - name=doc.symbol, - body=texi_entity(doc, 'Members', base, variants)) + self._gen.add(TYPE_FMT(type='Object', + name=doc.symbol, + body=texi_entity(doc, 'Members', + base, variants))) def visit_alternate_type(self, name, info, variants): doc = self.cur_doc - self.out += TYPE_FMT(type='Alternate', - name=doc.symbol, - body=texi_entity(doc, 'Members')) + self._gen.add(TYPE_FMT(type='Alternate', + name=doc.symbol, + body=texi_entity(doc, 'Members'))) def visit_command(self, name, info, arg_type, ret_type, gen, success_response, boxed): @@ -235,44 +237,38 @@ class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVisitor): body += texi_sections(doc) else: body = texi_entity(doc, 'Arguments') - self.out += MSG_FMT(type='Command', - name=doc.symbol, - body=body) + self._gen.add(MSG_FMT(type='Command', + name=doc.symbol, + body=body)) def visit_event(self, name, info, arg_type, boxed): doc = self.cur_doc - self.out += MSG_FMT(type='Event', - name=doc.symbol, - body=texi_entity(doc, 'Arguments')) + self._gen.add(MSG_FMT(type='Event', + name=doc.symbol, + body=texi_entity(doc, 'Arguments'))) def symbol(self, doc, entity): - if self.out: - self.out += '\n' + if self._gen._body: + self._gen.add('\n') self.cur_doc = doc entity.visit(self) self.cur_doc = None def freeform(self, doc): assert not doc.args - if self.out: - self.out += '\n' - self.out += texi_body(doc) + texi_sections(doc) + if self._gen._body: + self._gen.add('\n') + self._gen.add(texi_body(doc) + texi_sections(doc)) -def texi_schema(schema): - """Convert QAPI schema documentation to Texinfo""" - gen = QAPISchemaGenDocVisitor() - gen.visit_begin(schema) +def gen_doc(schema, output_dir, prefix): + if not qapi.common.doc_required: + return + vis = QAPISchemaGenDocVisitor(prefix) + vis.visit_begin(schema) for doc in schema.docs: if doc.symbol: - gen.symbol(doc, schema.lookup_entity(doc.symbol)) + vis.symbol(doc, schema.lookup_entity(doc.symbol)) else: - gen.freeform(doc) - return gen.out - - -def gen_doc(schema, output_dir, prefix): - if qapi.common.doc_required: - gen = qapi.common.QAPIGenDoc() - gen.add(texi_schema(schema)) - gen.write(output_dir, prefix + 'qapi-doc.texi') + vis.freeform(doc) + vis.write(output_dir) diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index b7dc82004f..81ab3abb30 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -148,35 +148,15 @@ out: return ret -class QAPISchemaGenEventVisitor(QAPISchemaVisitor): +class QAPISchemaGenEventVisitor(QAPISchemaMonolithicCVisitor): + def __init__(self, prefix): + QAPISchemaMonolithicCVisitor.__init__( + self, prefix, 'qapi-event', + ' * Schema-defined QAPI/QMP events', __doc__) self._enum_name = c_name(prefix + 'QAPIEvent', protect=False) - self.decl = None - self.defn = None - self._event_names = None - - def visit_begin(self, schema): - self.decl = '' - self.defn = '' self._event_names = [] - - def visit_end(self): - self.decl += gen_enum(self._enum_name, self._event_names) - self.defn += gen_enum_lookup(self._enum_name, self._event_names) - self._event_names = None - - def visit_event(self, name, info, arg_type, boxed): - self.decl += gen_event_send_decl(name, arg_type, boxed) - self.defn += gen_event_send(name, arg_type, boxed, self._enum_name) - self._event_names.append(name) - - -def gen_events(schema, output_dir, prefix): - blurb = ' * Schema-defined QAPI/QMP events' - genc = QAPIGenC(blurb, __doc__) - genh = QAPIGenH(blurb, __doc__) - - genc.add(mcgen(''' + self._genc.add(mcgen(''' #include "qemu/osdep.h" #include "qemu-common.h" #include "%(prefix)sqapi-event.h" @@ -187,18 +167,25 @@ def gen_events(schema, output_dir, prefix): #include "qapi/qmp-event.h" ''', - prefix=prefix)) - - genh.add(mcgen(''' + prefix=prefix)) + self._genh.add(mcgen(''' #include "qapi/util.h" #include "%(prefix)sqapi-types.h" ''', - prefix=prefix)) + prefix=prefix)) + def visit_end(self): + self._genh.add(gen_enum(self._enum_name, self._event_names)) + self._genc.add(gen_enum_lookup(self._enum_name, self._event_names)) + + def visit_event(self, name, info, arg_type, boxed): + self._genh.add(gen_event_send_decl(name, arg_type, boxed)) + self._genc.add(gen_event_send(name, arg_type, boxed, self._enum_name)) + self._event_names.append(name) + + +def gen_events(schema, output_dir, prefix): vis = QAPISchemaGenEventVisitor(prefix) schema.visit(vis) - genc.add(vis.defn) - genh.add(vis.decl) - genc.write(output_dir, prefix + 'qapi-event.c') - genh.write(output_dir, prefix + 'qapi-event.h') + vis.write(output_dir) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 1e4f065164..f571cc134c 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -40,22 +40,26 @@ def to_c_string(string): return '"' + string.replace('\\', r'\\').replace('"', r'\"') + '"' -class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor): +class QAPISchemaGenIntrospectVisitor(QAPISchemaMonolithicCVisitor): + def __init__(self, prefix, unmask): - self._prefix = prefix + QAPISchemaMonolithicCVisitor.__init__( + self, prefix, 'qmp-introspect', + ' * QAPI/QMP schema introspection', __doc__) self._unmask = unmask - self.defn = None - self.decl = None self._schema = None - self._jsons = None - self._used_types = None - self._name_map = None - - def visit_begin(self, schema): - self._schema = schema self._jsons = [] self._used_types = [] self._name_map = {} + self._genc.add(mcgen(''' +#include "qemu/osdep.h" +#include "%(prefix)sqmp-introspect.h" + +''', + prefix=prefix)) + + def visit_begin(self, schema): + self._schema = schema def visit_end(self): # visit the types that are actually used @@ -67,21 +71,21 @@ class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor): # TODO can generate awfully long lines jsons.extend(self._jsons) name = c_name(self._prefix, protect=False) + 'qmp_schema_json' - self.decl = mcgen(''' + self._genh.add(mcgen(''' extern const char %(c_name)s[]; ''', - c_name=c_name(name)) + c_name=c_name(name))) lines = to_json(jsons).split('\n') c_string = '\n '.join([to_c_string(line) for line in lines]) - self.defn = mcgen(''' + self._genc.add(mcgen(''' const char %(c_name)s[] = %(c_string)s; ''', - c_name=c_name(name), - c_string=c_string) + c_name=c_name(name), + c_string=c_string)) self._schema = None - self._jsons = None - self._used_types = None - self._name_map = None + self._jsons = [] + self._used_types = [] + self._name_map = {} def visit_needed(self, entity): # Ignore types on first pass; visit_end() will pick up used types @@ -169,20 +173,6 @@ const char %(c_name)s[] = %(c_string)s; def gen_introspect(schema, output_dir, prefix, opt_unmask): - blurb = ' * QAPI/QMP schema introspection' - genc = QAPIGenC(blurb, __doc__) - genh = QAPIGenH(blurb, __doc__) - - genc.add(mcgen(''' -#include "qemu/osdep.h" -#include "%(prefix)sqmp-introspect.h" - -''', - prefix=prefix)) - vis = QAPISchemaGenIntrospectVisitor(prefix, opt_unmask) schema.visit(vis) - genc.add(vis.defn) - genh.add(vis.decl) - genc.write(output_dir, prefix + 'qmp-introspect.c') - genh.write(output_dir, prefix + 'qmp-introspect.h') + vis.write(output_dir) diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index aa3c01e750..d2b8423479 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -167,36 +167,41 @@ void qapi_free_%(c_name)s(%(c_name)s *obj) return ret -class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): - def __init__(self, opt_builtins): +class QAPISchemaGenTypeVisitor(QAPISchemaMonolithicCVisitor): + + def __init__(self, prefix, opt_builtins): + QAPISchemaMonolithicCVisitor.__init__( + self, prefix, 'qapi-types', ' * Schema-defined QAPI types', + __doc__) self._opt_builtins = opt_builtins - self.decl = None - self.defn = None - self._fwdecl = None - self._btin = None + self._genc.preamble_add(mcgen(''' +#include "qemu/osdep.h" +#include "qapi/dealloc-visitor.h" +#include "%(prefix)sqapi-types.h" +#include "%(prefix)sqapi-visit.h" +''', + prefix=prefix)) + self._genh.preamble_add(mcgen(''' +#include "qapi/util.h" +''')) + self._btin = '\n' + guardstart('QAPI_TYPES_BUILTIN') def visit_begin(self, schema): # gen_object() is recursive, ensure it doesn't visit the empty type objects_seen.add(schema.the_empty_object_type.name) - self.decl = '' - self.defn = '' - self._fwdecl = '' - self._btin = '\n' + guardstart('QAPI_TYPES_BUILTIN') def visit_end(self): - self.decl = self._fwdecl + self.decl - self._fwdecl = None # To avoid header dependency hell, we always generate # declarations for built-in types in our header files and # simply guard them. See also opt_builtins (command line # option -b). self._btin += guardend('QAPI_TYPES_BUILTIN') - self.decl = self._btin + self.decl + self._genh.preamble_add(self._btin) self._btin = None def _gen_type_cleanup(self, name): - self.decl += gen_type_cleanup_decl(name) - self.defn += gen_type_cleanup(name) + self._genh.add(gen_type_cleanup_decl(name)) + self._genc.add(gen_type_cleanup(name)) def visit_enum_type(self, name, info, values, prefix): # Special case for our lone builtin enum type @@ -204,10 +209,10 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): if not info: self._btin += gen_enum(name, values, prefix) if self._opt_builtins: - self.defn += gen_enum_lookup(name, values, prefix) + self._genc.add(gen_enum_lookup(name, values, prefix)) else: - self._fwdecl += gen_enum(name, values, prefix) - self.defn += gen_enum_lookup(name, values, prefix) + self._genh.preamble_add(gen_enum(name, values, prefix)) + self._genc.add(gen_enum_lookup(name, values, prefix)) def visit_array_type(self, name, info, element_type): if isinstance(element_type, QAPISchemaBuiltinType): @@ -215,20 +220,20 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): self._btin += gen_array(name, element_type) self._btin += gen_type_cleanup_decl(name) if self._opt_builtins: - self.defn += gen_type_cleanup(name) + self._genc.add(gen_type_cleanup(name)) else: - self._fwdecl += gen_fwd_object_or_array(name) - self.decl += gen_array(name, element_type) + self._genh.preamble_add(gen_fwd_object_or_array(name)) + self._genh.add(gen_array(name, element_type)) self._gen_type_cleanup(name) def visit_object_type(self, name, info, base, members, variants): # Nothing to do for the special empty builtin if name == 'q_empty': return - self._fwdecl += gen_fwd_object_or_array(name) - self.decl += gen_object(name, base, members, variants) + self._genh.preamble_add(gen_fwd_object_or_array(name)) + self._genh.add(gen_object(name, base, members, variants)) if base and not base.is_implicit(): - self.decl += gen_upcast(name, base) + self._genh.add(gen_upcast(name, base)) # TODO Worth changing the visitor signature, so we could # directly use rather than repeat type.is_implicit()? if not name.startswith('q_'): @@ -236,31 +241,13 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): self._gen_type_cleanup(name) def visit_alternate_type(self, name, info, variants): - self._fwdecl += gen_fwd_object_or_array(name) - self.decl += gen_object(name, None, [variants.tag_member], variants) + self._genh.preamble_add(gen_fwd_object_or_array(name)) + self._genh.add(gen_object(name, None, + [variants.tag_member], variants)) self._gen_type_cleanup(name) def gen_types(schema, output_dir, prefix, opt_builtins): - blurb = ' * Schema-defined QAPI types' - genc = QAPIGenC(blurb, __doc__) - genh = QAPIGenH(blurb, __doc__) - - genc.add(mcgen(''' -#include "qemu/osdep.h" -#include "qapi/dealloc-visitor.h" -#include "%(prefix)sqapi-types.h" -#include "%(prefix)sqapi-visit.h" -''', - prefix=prefix)) - - genh.add(mcgen(''' -#include "qapi/util.h" -''')) - - vis = QAPISchemaGenTypeVisitor(opt_builtins) + vis = QAPISchemaGenTypeVisitor(prefix, opt_builtins) schema.visit(vis) - genc.add(vis.defn) - genh.add(vis.decl) - genc.write(output_dir, prefix + 'qapi-types.c') - genh.write(output_dir, prefix + 'qapi-types.h') + vis.write(output_dir) diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 3ed78165d7..3d09d44265 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -263,17 +263,28 @@ out: c_name=c_name(name)) -class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): - def __init__(self, opt_builtins): +class QAPISchemaGenVisitVisitor(QAPISchemaMonolithicCVisitor): + + def __init__(self, prefix, opt_builtins): + QAPISchemaMonolithicCVisitor.__init__( + self, prefix, 'qapi-visit', ' * Schema-defined QAPI visitors', + __doc__) self._opt_builtins = opt_builtins - self.decl = None - self.defn = None - self._btin = None + self._genc.preamble_add(mcgen(''' +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "qapi/error.h" +#include "qapi/qmp/qerror.h" +#include "%(prefix)sqapi-visit.h" +''', + prefix=prefix)) + self._genh.preamble_add(mcgen(''' +#include "qapi/visitor.h" +#include "%(prefix)sqapi-types.h" - def visit_begin(self, schema): - self.decl = '' - self.defn = '' - self._btin = '\n' + guardstart('QAPI_VISIT_BUILTIN') +''', + prefix=prefix)) + self._btin = guardstart('QAPI_VISIT_BUILTIN') def visit_end(self): # To avoid header dependency hell, we always generate @@ -281,7 +292,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): # simply guard them. See also opt_builtins (command line # option -b). self._btin += guardend('QAPI_VISIT_BUILTIN') - self.decl = self._btin + self.decl + self._genh.preamble_add(self._btin) self._btin = None def visit_enum_type(self, name, info, values, prefix): @@ -290,10 +301,10 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): if not info: self._btin += gen_visit_decl(name, scalar=True) if self._opt_builtins: - self.defn += gen_visit_enum(name) + self._genc.add(gen_visit_enum(name)) else: - self.decl += gen_visit_decl(name, scalar=True) - self.defn += gen_visit_enum(name) + self._genh.add(gen_visit_decl(name, scalar=True)) + self._genc.add(gen_visit_enum(name)) def visit_array_type(self, name, info, element_type): decl = gen_visit_decl(name) @@ -301,53 +312,30 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): if isinstance(element_type, QAPISchemaBuiltinType): self._btin += decl if self._opt_builtins: - self.defn += defn + self._genc.add(defn) else: - self.decl += decl - self.defn += defn + self._genh.add(decl) + self._genc.add(defn) def visit_object_type(self, name, info, base, members, variants): # Nothing to do for the special empty builtin if name == 'q_empty': return - self.decl += gen_visit_members_decl(name) - self.defn += gen_visit_object_members(name, base, members, variants) + self._genh.add(gen_visit_members_decl(name)) + self._genc.add(gen_visit_object_members(name, base, members, variants)) # TODO Worth changing the visitor signature, so we could # directly use rather than repeat type.is_implicit()? if not name.startswith('q_'): # only explicit types need an allocating visit - self.decl += gen_visit_decl(name) - self.defn += gen_visit_object(name, base, members, variants) + self._genh.add(gen_visit_decl(name)) + self._genc.add(gen_visit_object(name, base, members, variants)) def visit_alternate_type(self, name, info, variants): - self.decl += gen_visit_decl(name) - self.defn += gen_visit_alternate(name, variants) + self._genh.add(gen_visit_decl(name)) + self._genc.add(gen_visit_alternate(name, variants)) def gen_visit(schema, output_dir, prefix, opt_builtins): - blurb = ' * Schema-defined QAPI visitors' - genc = QAPIGenC(blurb, __doc__) - genh = QAPIGenH(blurb, __doc__) - - genc.add(mcgen(''' -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "qapi/error.h" -#include "qapi/qmp/qerror.h" -#include "%(prefix)sqapi-visit.h" -''', - prefix=prefix)) - - genh.add(mcgen(''' -#include "qapi/visitor.h" -#include "%(prefix)sqapi-types.h" - -''', - prefix=prefix)) - - vis = QAPISchemaGenVisitVisitor(opt_builtins) + vis = QAPISchemaGenVisitVisitor(prefix, opt_builtins) schema.visit(vis) - genc.add(vis.defn) - genh.add(vis.decl) - genc.write(output_dir, prefix + 'qapi-visit.c') - genh.write(output_dir, prefix + 'qapi-visit.h') + vis.write(output_dir) -- cgit 1.4.1 From eb815e248f50cde9ab86eddd57eca5019b71ca78 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 11 Feb 2018 10:36:05 +0100 Subject: qapi: Move qapi-schema.json to qapi/, rename generated files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move qapi-schema.json to qapi/, so it's next to its modules, and all files get generated to qapi/, not just the ones generated for modules. Consistently name the generated files qapi-MODULE.EXT: qmp-commands.[ch] become qapi-commands.[ch], qapi-event.[ch] become qapi-events.[ch], and qmp-introspect.[ch] become qapi-introspect.[ch]. This gets rid of the temporary hacks in scripts/qapi/commands.py, scripts/qapi/events.py, and scripts/qapi/common.py. Signed-off-by: Markus Armbruster Message-Id: <20180211093607.27351-28-armbru@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Marc-André Lureau Reviewed-by: Michael Roth [eblake: Fix trailing dot in tpm.c, undo temporary hack for OSX toolchain] Signed-off-by: Eric Blake --- .gitignore | 16 +++---- Makefile | 42 ++++++++-------- Makefile.objs | 21 ++++---- backends/hostmem.c | 2 +- docs/devel/qapi-code-gen.txt | 30 ++++++------ docs/devel/writing-qmp-commands.txt | 2 +- docs/interop/qmp-intro.txt | 2 +- hmp.c | 2 +- include/qapi/qmp/qobject.h | 2 +- include/qapi/visitor.h | 2 +- include/qom/object.h | 2 +- monitor.c | 6 +-- net/filter-buffer.c | 2 +- qapi-schema.json | 95 ------------------------------------- qapi/misc.json | 4 +- qapi/qapi-schema.json | 95 +++++++++++++++++++++++++++++++++++++ qga/Makefile.objs | 2 +- qga/commands-posix.c | 2 +- qga/commands-win32.c | 2 +- qga/commands.c | 2 +- qga/main.c | 2 +- qom/object.c | 2 +- scripts/qapi/commands.py | 7 --- scripts/qapi/common.py | 5 +- scripts/qapi/events.py | 9 +--- scripts/qapi/introspect.py | 4 +- scripts/qapi/types.py | 6 +-- scripts/qapi/visit.py | 6 +-- tests/.gitignore | 6 +-- tests/Makefile.include | 14 +++--- tests/test-qmp-cmds.c | 2 +- tests/test-qmp-event.c | 2 +- tests/test-qobject-input-visitor.c | 6 +-- tpm.c | 3 +- ui/cocoa.m | 2 +- ui/vnc.c | 2 +- 36 files changed, 198 insertions(+), 213 deletions(-) delete mode 100644 qapi-schema.json create mode 100644 qapi/qapi-schema.json (limited to 'scripts/qapi/introspect.py') diff --git a/.gitignore b/.gitignore index 7f162e862f..dabfe6bea8 100644 --- a/.gitignore +++ b/.gitignore @@ -29,8 +29,8 @@ /qga/qapi-generated /qapi-generated /qapi-gen-timestamp -/qapi-builtin-types.[ch] -/qapi-builtin-visit.[ch] +/qapi/qapi-builtin-types.[ch] +/qapi/qapi-builtin-visit.[ch] /qapi/qapi-commands-block-core.[ch] /qapi/qapi-commands-block.[ch] /qapi/qapi-commands-char.[ch] @@ -47,6 +47,7 @@ /qapi/qapi-commands-trace.[ch] /qapi/qapi-commands-transaction.[ch] /qapi/qapi-commands-ui.[ch] +/qapi/qapi-commands.[ch] /qapi/qapi-events-block-core.[ch] /qapi/qapi-events-block.[ch] /qapi/qapi-events-char.[ch] @@ -63,6 +64,8 @@ /qapi/qapi-events-trace.[ch] /qapi/qapi-events-transaction.[ch] /qapi/qapi-events-ui.[ch] +/qapi/qapi-events.[ch] +/qapi/qapi-introspect.[ch] /qapi/qapi-types-block-core.[ch] /qapi/qapi-types-block.[ch] /qapi/qapi-types-char.[ch] @@ -79,7 +82,7 @@ /qapi/qapi-types-trace.[ch] /qapi/qapi-types-transaction.[ch] /qapi/qapi-types-ui.[ch] -/qapi-types.[ch] +/qapi/qapi-types.[ch] /qapi/qapi-visit-block-core.[ch] /qapi/qapi-visit-block.[ch] /qapi/qapi-visit-char.[ch] @@ -96,11 +99,8 @@ /qapi/qapi-visit-trace.[ch] /qapi/qapi-visit-transaction.[ch] /qapi/qapi-visit-ui.[ch] -/qapi-visit.[ch] -/qapi-event.[ch] -/qapi-doc.texi -/qmp-commands.[ch] -/qmp-introspect.[ch] +/qapi/qapi-visit.[ch] +/qapi/qapi-doc.texi /qemu-doc.html /qemu-doc.info /qemu-doc.txt diff --git a/Makefile b/Makefile index 26ed98e030..a470168d98 100644 --- a/Makefile +++ b/Makefile @@ -90,8 +90,8 @@ endif include $(SRC_PATH)/rules.mak GENERATED_FILES = qemu-version.h config-host.h qemu-options.def -GENERATED_FILES += qapi-builtin-types.h qapi-builtin-types.c -GENERATED_FILES += qapi-types.h qapi-types.c +GENERATED_FILES += qapi/qapi-builtin-types.h qapi/qapi-builtin-types.c +GENERATED_FILES += qapi/qapi-types.h qapi/qapi-types.c GENERATED_FILES += qapi/qapi-types-block-core.h qapi/qapi-types-block-core.c GENERATED_FILES += qapi/qapi-types-block.h qapi/qapi-types-block.c GENERATED_FILES += qapi/qapi-types-char.h qapi/qapi-types-char.c @@ -108,8 +108,8 @@ GENERATED_FILES += qapi/qapi-types-tpm.h qapi/qapi-types-tpm.c GENERATED_FILES += qapi/qapi-types-trace.h qapi/qapi-types-trace.c GENERATED_FILES += qapi/qapi-types-transaction.h qapi/qapi-types-transaction.c GENERATED_FILES += qapi/qapi-types-ui.h qapi/qapi-types-ui.c -GENERATED_FILES += qapi-builtin-visit.h qapi-builtin-visit.c -GENERATED_FILES += qapi-visit.h qapi-visit.c +GENERATED_FILES += qapi/qapi-builtin-visit.h qapi/qapi-builtin-visit.c +GENERATED_FILES += qapi/qapi-visit.h qapi/qapi-visit.c GENERATED_FILES += qapi/qapi-visit-block-core.h qapi/qapi-visit-block-core.c GENERATED_FILES += qapi/qapi-visit-block.h qapi/qapi-visit-block.c GENERATED_FILES += qapi/qapi-visit-char.h qapi/qapi-visit-char.c @@ -126,7 +126,7 @@ GENERATED_FILES += qapi/qapi-visit-tpm.h qapi/qapi-visit-tpm.c GENERATED_FILES += qapi/qapi-visit-trace.h qapi/qapi-visit-trace.c GENERATED_FILES += qapi/qapi-visit-transaction.h qapi/qapi-visit-transaction.c GENERATED_FILES += qapi/qapi-visit-ui.h qapi/qapi-visit-ui.c -GENERATED_FILES += qmp-commands.h qmp-commands.c +GENERATED_FILES += qapi/qapi-commands.h qapi/qapi-commands.c GENERATED_FILES += qapi/qapi-commands-block-core.h qapi/qapi-commands-block-core.c GENERATED_FILES += qapi/qapi-commands-block.h qapi/qapi-commands-block.c GENERATED_FILES += qapi/qapi-commands-char.h qapi/qapi-commands-char.c @@ -143,7 +143,7 @@ GENERATED_FILES += qapi/qapi-commands-tpm.h qapi/qapi-commands-tpm.c GENERATED_FILES += qapi/qapi-commands-trace.h qapi/qapi-commands-trace.c GENERATED_FILES += qapi/qapi-commands-transaction.h qapi/qapi-commands-transaction.c GENERATED_FILES += qapi/qapi-commands-ui.h qapi/qapi-commands-ui.c -GENERATED_FILES += qapi-event.h qapi-event.c +GENERATED_FILES += qapi/qapi-events.h qapi/qapi-events.c GENERATED_FILES += qapi/qapi-events-block-core.h qapi/qapi-events-block-core.c GENERATED_FILES += qapi/qapi-events-block.h qapi/qapi-events-block.c GENERATED_FILES += qapi/qapi-events-char.h qapi/qapi-events-char.c @@ -160,8 +160,8 @@ GENERATED_FILES += qapi/qapi-events-tpm.h qapi/qapi-events-tpm.c GENERATED_FILES += qapi/qapi-events-trace.h qapi/qapi-events-trace.c GENERATED_FILES += qapi/qapi-events-transaction.h qapi/qapi-events-transaction.c GENERATED_FILES += qapi/qapi-events-ui.h qapi/qapi-events-ui.c -GENERATED_FILES += qmp-introspect.c qmp-introspect.h -GENERATED_FILES += qapi-doc.texi +GENERATED_FILES += qapi/qapi-introspect.c qapi/qapi-introspect.h +GENERATED_FILES += qapi/qapi-doc.texi GENERATED_FILES += trace/generated-tcg-tracers.h @@ -562,7 +562,7 @@ $(SRC_PATH)/scripts/qapi-gen.py qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h \ qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h \ -qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-commands.c \ +qga/qapi-generated/qga-qapi-commands.h qga/qapi-generated/qga-qapi-commands.c \ qga/qapi-generated/qga-qapi-doc.texi: \ qga/qapi-generated/qapi-gen-timestamp ; qga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py) @@ -571,7 +571,7 @@ qga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json $(qapi-p "GEN","$(@:%-timestamp=%)") @>$@ -qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ +qapi-modules = $(SRC_PATH)/qapi/qapi-schema.json $(SRC_PATH)/qapi/common.json \ $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \ $(SRC_PATH)/qapi/char.json \ $(SRC_PATH)/qapi/crypto.json \ @@ -587,8 +587,8 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ $(SRC_PATH)/qapi/transaction.json \ $(SRC_PATH)/qapi/ui.json -qapi-builtin-types.c qapi-builtin-types.h \ -qapi-types.c qapi-types.h \ +qapi/qapi-builtin-types.c qapi/qapi-builtin-types.h \ +qapi/qapi-types.c qapi/qapi-types.h \ qapi/qapi-types-block-core.c qapi/qapi-types-block-core.h \ qapi/qapi-types-block.c qapi/qapi-types-block.h \ qapi/qapi-types-char.c qapi/qapi-types-char.h \ @@ -605,8 +605,8 @@ qapi/qapi-types-tpm.c qapi/qapi-types-tpm.h \ qapi/qapi-types-trace.c qapi/qapi-types-trace.h \ qapi/qapi-types-transaction.c qapi/qapi-types-transaction.h \ qapi/qapi-types-ui.c qapi/qapi-types-ui.h \ -qapi-builtin-visit.c qapi-builtin-visit.h \ -qapi-visit.c qapi-visit.h \ +qapi/qapi-builtin-visit.c qapi/qapi-builtin-visit.h \ +qapi/qapi-visit.c qapi/qapi-visit.h \ qapi/qapi-visit-block-core.c qapi/qapi-visit-block-core.h \ qapi/qapi-visit-block.c qapi/qapi-visit-block.h \ qapi/qapi-visit-char.c qapi/qapi-visit-char.h \ @@ -623,7 +623,7 @@ qapi/qapi-visit-tpm.c qapi/qapi-visit-tpm.h \ qapi/qapi-visit-trace.c qapi/qapi-visit-trace.h \ qapi/qapi-visit-transaction.c qapi/qapi-visit-transaction.h \ qapi/qapi-visit-ui.c qapi/qapi-visit-ui.h \ -qmp-commands.h qmp-commands.c \ +qapi/qapi-commands.h qapi/qapi-commands.c \ qapi/qapi-commands-block-core.c qapi/qapi-commands-block-core.h \ qapi/qapi-commands-block.c qapi/qapi-commands-block.h \ qapi/qapi-commands-char.c qapi/qapi-commands-char.h \ @@ -640,7 +640,7 @@ qapi/qapi-commands-tpm.c qapi/qapi-commands-tpm.h \ qapi/qapi-commands-trace.c qapi/qapi-commands-trace.h \ qapi/qapi-commands-transaction.c qapi/qapi-commands-transaction.h \ qapi/qapi-commands-ui.c qapi/qapi-commands-ui.h \ -qapi-event.c qapi-event.h \ +qapi/qapi-events.c qapi/qapi-events.h \ qapi/qapi-events-block-core.c qapi/qapi-events-block-core.h \ qapi/qapi-events-block.c qapi/qapi-events-block.h \ qapi/qapi-events-char.c qapi/qapi-events-char.h \ @@ -657,16 +657,16 @@ qapi/qapi-events-tpm.c qapi/qapi-events-tpm.h \ qapi/qapi-events-trace.c qapi/qapi-events-trace.h \ qapi/qapi-events-transaction.c qapi/qapi-events-transaction.h \ qapi/qapi-events-ui.c qapi/qapi-events-ui.h \ -qmp-introspect.h qmp-introspect.c \ -qapi-doc.texi: \ +qapi/qapi-introspect.h qapi/qapi-introspect.c \ +qapi/qapi-doc.texi: \ qapi-gen-timestamp ; qapi-gen-timestamp: $(qapi-modules) $(qapi-py) $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-gen.py \ - -o "." -b $<, \ + -o "qapi" -b $<, \ "GEN","$(@:%-timestamp=%)") @>$@ -QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h) +QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qapi-commands.h) $(qga-obj-y): $(QGALIB_GEN) qemu-ga$(EXESUF): $(qga-obj-y) $(COMMON_LDADDS) @@ -933,7 +933,7 @@ qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/hxt qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@") -docs/interop/qemu-qmp-qapi.texi: qapi-doc.texi +docs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi @cp -p $< $@ docs/interop/qemu-ga-qapi.texi: qga/qapi-generated/qga-qapi-doc.texi diff --git a/Makefile.objs b/Makefile.objs index 149627b589..d741134cc7 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -2,8 +2,8 @@ # Common libraries for tools and emulators stub-obj-y = stubs/ crypto/ util-obj-y = util/ qobject/ qapi/ -util-obj-y += qapi-builtin-types.o -util-obj-y += qapi-types.o +util-obj-y += qapi/qapi-builtin-types.o +util-obj-y += qapi/qapi-types.o util-obj-y += qapi/qapi-types-block-core.o util-obj-y += qapi/qapi-types-block.o util-obj-y += qapi/qapi-types-char.o @@ -20,8 +20,8 @@ util-obj-y += qapi/qapi-types-tpm.o util-obj-y += qapi/qapi-types-trace.o util-obj-y += qapi/qapi-types-transaction.o util-obj-y += qapi/qapi-types-ui.o -util-obj-y += qapi-builtin-visit.o -util-obj-y += qapi-visit.o +util-obj-y += qapi/qapi-builtin-visit.o +util-obj-y += qapi/qapi-visit.o util-obj-y += qapi/qapi-visit-block-core.o util-obj-y += qapi/qapi-visit-block.o util-obj-y += qapi/qapi-visit-char.o @@ -38,7 +38,7 @@ util-obj-y += qapi/qapi-visit-tpm.o util-obj-y += qapi/qapi-visit-trace.o util-obj-y += qapi/qapi-visit-transaction.o util-obj-y += qapi/qapi-visit-ui.o -util-obj-y += qapi-event.o +util-obj-y += qapi/qapi-events.o util-obj-y += qapi/qapi-events-block-core.o util-obj-y += qapi/qapi-events-block.o util-obj-y += qapi/qapi-events-char.o @@ -55,7 +55,7 @@ util-obj-y += qapi/qapi-events-tpm.o util-obj-y += qapi/qapi-events-trace.o util-obj-y += qapi/qapi-events-transaction.o util-obj-y += qapi/qapi-events-ui.o -util-obj-y += qmp-introspect.o +util-obj-y += qapi/qapi-introspect.o chardev-obj-y = chardev/ @@ -131,7 +131,7 @@ common-obj-$(CONFIG_FDT) += device_tree.o ###################################################################### # qapi -common-obj-y += qmp-commands.o +common-obj-y += qapi/qapi-commands.o common-obj-y += qapi/qapi-commands-block-core.o common-obj-y += qapi/qapi-commands-block.o common-obj-y += qapi/qapi-commands-char.o @@ -148,7 +148,7 @@ common-obj-y += qapi/qapi-commands-tpm.o common-obj-y += qapi/qapi-commands-trace.o common-obj-y += qapi/qapi-commands-transaction.o common-obj-y += qapi/qapi-commands-ui.o -common-obj-y += qmp-introspect.o +common-obj-y += qapi/qapi-introspect.o common-obj-y += qmp.o hmp.o endif @@ -171,8 +171,9 @@ target-obj-y += trace/ ###################################################################### # guest agent -# FIXME: a few definitions from qapi-types.o/qapi-visit.o are needed -# by libqemuutil.a. These should be moved to a separate .json schema. +# FIXME: a few definitions from qapi/qapi-types.o and +# qapi/qapi-visit.o are needed by libqemuutil.a. These should be +# extracted into a QAPI schema module, or perhaps a separate schema. qga-obj-y = qga/ qga-vss-dll-obj-y = qga/ diff --git a/backends/hostmem.c b/backends/hostmem.c index 74fc04a362..f61093654e 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -14,7 +14,7 @@ #include "sysemu/hostmem.h" #include "hw/boards.h" #include "qapi/error.h" -#include "qapi-builtin-visit.h" +#include "qapi/qapi-builtin-visit.h" #include "qapi/visitor.h" #include "qemu/config-file.h" #include "qom/object_interfaces.h" diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index c86792add2..25b7180a18 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -647,7 +647,7 @@ name an event 'MAX', since the generator also produces a C enumeration of all event names with a generated _MAX value at the end. When 'data' is also specified, additional info will be included in the event, with similar semantics to a 'struct' expression. Finally there -will be C API generated in qapi-event.h; when called by QEMU code, a +will be C API generated in qapi-events.h; when called by QEMU code, a message with timestamp will be emitted on the wire. An example event is: @@ -1147,15 +1147,15 @@ declares qmp_COMMAND() that the user must implement. The following files are generated: -$(prefix)qmp-commands.c: Command marshal/dispatch functions for each - QMP command defined in the schema +$(prefix)qapi-commands.c: Command marshal/dispatch functions for each + QMP command defined in the schema -$(prefix)qmp-commands.h: Function prototypes for the QMP commands - specified in the schema +$(prefix)qapi-commands.h: Function prototypes for the QMP commands + specified in the schema Example: - $ cat qapi-generated/example-qmp-commands.h + $ cat qapi-generated/example-qapi-commands.h [Uninteresting stuff omitted...] #ifndef EXAMPLE_QMP_COMMANDS_H @@ -1170,7 +1170,7 @@ Example: void qmp_marshal_my_command(QDict *args, QObject **ret, Error **errp); #endif - $ cat qapi-generated/example-qmp-commands.c + $ cat qapi-generated/example-qapi-commands.c [Uninteresting stuff omitted...] static void qmp_marshal_output_UserDefOne(UserDefOne *ret_in, QObject **ret_out, Error **errp) @@ -1243,14 +1243,14 @@ qapi_event_send_EVENT(). The following files are created: -$(prefix)qapi-event.h - Function prototypes for each event type, plus an +$(prefix)qapi-events.h - Function prototypes for each event type, plus an enumeration of all event names -$(prefix)qapi-event.c - Implementation of functions to send an event +$(prefix)qapi-events.c - Implementation of functions to send an event Example: - $ cat qapi-generated/example-qapi-event.h + $ cat qapi-generated/example-qapi-events.h [Uninteresting stuff omitted...] #ifndef EXAMPLE_QAPI_EVENT_H @@ -1273,7 +1273,7 @@ Example: extern const char *const example_QAPIEvent_lookup[]; #endif - $ cat qapi-generated/example-qapi-event.c + $ cat qapi-generated/example-qapi-events.c [Uninteresting stuff omitted...] void qapi_event_send_my_event(Error **errp) @@ -1306,14 +1306,14 @@ Example: The following files are created: -$(prefix)qmp-introspect.c - Defines a string holding a JSON +$(prefix)qapi-introspect.c - Defines a string holding a JSON description of the schema -$(prefix)qmp-introspect.h - Declares the above string +$(prefix)qapi-introspect.h - Declares the above string Example: - $ cat qapi-generated/example-qmp-introspect.h + $ cat qapi-generated/example-qapi-introspect.h [Uninteresting stuff omitted...] #ifndef EXAMPLE_QMP_INTROSPECT_H @@ -1322,7 +1322,7 @@ Example: extern const char example_qmp_schema_json[]; #endif - $ cat qapi-generated/example-qmp-introspect.c + $ cat qapi-generated/example-qapi-introspect.c [Uninteresting stuff omitted...] const char example_qmp_schema_json[] = "[" diff --git a/docs/devel/writing-qmp-commands.txt b/docs/devel/writing-qmp-commands.txt index 50385eff27..9dfc62bf5a 100644 --- a/docs/devel/writing-qmp-commands.txt +++ b/docs/devel/writing-qmp-commands.txt @@ -419,7 +419,7 @@ There are a number of things to be noticed: allocated by the implementation. This is so because the QAPI also generates a function to free its types and it cannot distinguish between dynamically or statically allocated strings -6. You have to include "qapi/qmp-commands-misc.h" in qemu-timer.c +6. You have to include "qapi/qapi-commands-misc.h" in qemu-timer.c Time to test the new command. Build qemu, run it as described in the "Testing" section and try this: diff --git a/docs/interop/qmp-intro.txt b/docs/interop/qmp-intro.txt index 430fe1b747..900d69d612 100644 --- a/docs/interop/qmp-intro.txt +++ b/docs/interop/qmp-intro.txt @@ -79,7 +79,7 @@ Escape character is '^]'. } Please refer to docs/interop/qemu-qmp-ref.* for a complete command -reference, generated from qapi-schema.json. +reference, generated from qapi/qapi-schema.json. QMP wiki page ------------- diff --git a/hmp.c b/hmp.c index 8ea227dac4..016cb5c4f1 100644 --- a/hmp.c +++ b/hmp.c @@ -28,7 +28,7 @@ #include "monitor/qdev.h" #include "qapi/error.h" #include "qapi/opts-visitor.h" -#include "qapi-builtin-visit.h" +#include "qapi/qapi-builtin-visit.h" #include "qapi/qapi-commands-block.h" #include "qapi/qapi-commands-char.h" #include "qapi/qapi-commands-migration.h" diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h index a2964fbf25..012439a2e3 100644 --- a/include/qapi/qmp/qobject.h +++ b/include/qapi/qmp/qobject.h @@ -32,7 +32,7 @@ #ifndef QOBJECT_H #define QOBJECT_H -#include "qapi-builtin-types.h" +#include "qapi/qapi-builtin-types.h" struct QObject { QType type; diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 9e57508446..5b2ed3f202 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -15,7 +15,7 @@ #ifndef QAPI_VISITOR_H #define QAPI_VISITOR_H -#include "qapi-builtin-types.h" +#include "qapi/qapi-builtin-types.h" /* * The QAPI schema defines both a set of C data types, and a QMP wire diff --git a/include/qom/object.h b/include/qom/object.h index 5b5c016d8f..30db296af4 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -14,7 +14,7 @@ #ifndef QEMU_OBJECT_H #define QEMU_OBJECT_H -#include "qapi-builtin-types.h" +#include "qapi/qapi-builtin-types.h" #include "qemu/queue.h" struct TypeImpl; diff --git a/monitor.c b/monitor.c index fc9df6253a..57957b3969 100644 --- a/monitor.c +++ b/monitor.c @@ -69,14 +69,14 @@ #include "exec/exec-all.h" #include "qemu/log.h" #include "qemu/option.h" -#include "qmp-commands.h" #include "hmp.h" #include "qemu/thread.h" #include "block/qapi.h" +#include "qapi/qapi-commands.h" +#include "qapi/qapi-events.h" #include "qapi/error.h" #include "qapi/qmp-event.h" -#include "qapi-event.h" -#include "qmp-introspect.h" +#include "qapi/qapi-introspect.h" #include "sysemu/qtest.h" #include "sysemu/cpus.h" #include "qemu/cutils.h" diff --git a/net/filter-buffer.c b/net/filter-buffer.c index 7c487629f9..f7265c50a8 100644 --- a/net/filter-buffer.c +++ b/net/filter-buffer.c @@ -13,7 +13,7 @@ #include "qemu-common.h" #include "qemu/timer.h" #include "qemu/iov.h" -#include "qapi-builtin-visit.h" +#include "qapi/qapi-builtin-visit.h" #include "qapi/qmp/qerror.h" #include "qom/object.h" diff --git a/qapi-schema.json b/qapi-schema.json deleted file mode 100644 index 689d06c530..0000000000 --- a/qapi-schema.json +++ /dev/null @@ -1,95 +0,0 @@ -# -*- Mode: Python -*- -## -# = Introduction -# -# This document describes all commands currently supported by QMP. -# -# Most of the time their usage is exactly the same as in the user Monitor, this -# means that any other document which also describe commands (the manpage, -# QEMU's manual, etc) can and should be consulted. -# -# QMP has two types of commands: regular and query commands. Regular commands -# usually change the Virtual Machine's state someway, while query commands just -# return information. The sections below are divided accordingly. -# -# It's important to observe that all communication examples are formatted in -# a reader-friendly way, so that they're easier to understand. However, in real -# protocol usage, they're emitted as a single line. -# -# Also, the following notation is used to denote data flow: -# -# Example: -# -# | -> data issued by the Client -# | <- Server data response -# -# Please, refer to the QMP specification (docs/interop/qmp-spec.txt) for -# detailed information on the Server command and response formats. -# -# = Stability Considerations -# -# The current QMP command set (described in this file) may be useful for a -# number of use cases, however it's limited and several commands have bad -# defined semantics, specially with regard to command completion. -# -# These problems are going to be solved incrementally in the next QEMU releases -# and we're going to establish a deprecation policy for badly defined commands. -# -# If you're planning to adopt QMP, please observe the following: -# -# 1. The deprecation policy will take effect and be documented soon, please -# check the documentation of each used command as soon as a new release of -# QEMU is available -# -# 2. DO NOT rely on anything which is not explicit documented -# -# 3. Errors, in special, are not documented. Applications should NOT check -# for specific errors classes or data (it's strongly recommended to only -# check for the "error" key) -# -## - -{ 'pragma': { 'doc-required': true } } - -# Whitelists to permit QAPI rule violations; think twice before you -# add to them! -{ 'pragma': { - # Commands allowed to return a non-dictionary: - 'returns-whitelist': [ - 'human-monitor-command', - 'qom-get', - 'query-migrate-cache-size', - 'query-tpm-models', - 'query-tpm-types', - 'ringbuf-read' ], - 'name-case-whitelist': [ - 'ACPISlotType', # DIMM, visible through query-acpi-ospm-status - 'CpuInfoMIPS', # PC, visible through query-cpu - 'CpuInfoTricore', # PC, visible through query-cpu - 'QapiErrorClass', # all members, visible through errors - 'UuidInfo', # UUID, visible through query-uuid - 'X86CPURegister32', # all members, visible indirectly through qom-get - 'q_obj_CpuInfo-base' # CPU, visible through query-cpu - ] } } - -# Documentation generated with qapi-gen.py is in source order, with -# included sub-schemas inserted at the first include directive -# (subsequent include directives have no effect). To get a sane and -# stable order, it's best to include each sub-schema just once, or -# include it first in qapi-schema.json. - -{ 'include': 'qapi/common.json' } -{ 'include': 'qapi/sockets.json' } -{ 'include': 'qapi/run-state.json' } -{ 'include': 'qapi/crypto.json' } -{ 'include': 'qapi/block.json' } -{ 'include': 'qapi/char.json' } -{ 'include': 'qapi/net.json' } -{ 'include': 'qapi/rocker.json' } -{ 'include': 'qapi/tpm.json' } -{ 'include': 'qapi/ui.json' } -{ 'include': 'qapi/migration.json' } -{ 'include': 'qapi/transaction.json' } -{ 'include': 'qapi/trace.json' } -{ 'include': 'qapi/introspect.json' } -{ 'include': 'qapi/misc.json' } diff --git a/qapi/misc.json b/qapi/misc.json index dabc987f7a..a1702c9060 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -1729,7 +1729,7 @@ # # Emitted when background dump has completed # -# @result: DumpQueryResult type described in qapi-schema.json. +# @result: final dump status # # @error: human-readable error string that provides # hint on why dump failed. Only presents on failure. The @@ -2944,7 +2944,7 @@ # # Emitted when guest executes ACPI _OST method. # -# @info: ACPIOSTInfo type as described in qapi-schema.json +# @info: OSPM Status Indication # # Since: 2.1 # diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json new file mode 100644 index 0000000000..25bce78352 --- /dev/null +++ b/qapi/qapi-schema.json @@ -0,0 +1,95 @@ +# -*- Mode: Python -*- +## +# = Introduction +# +# This document describes all commands currently supported by QMP. +# +# Most of the time their usage is exactly the same as in the user Monitor, this +# means that any other document which also describe commands (the manpage, +# QEMU's manual, etc) can and should be consulted. +# +# QMP has two types of commands: regular and query commands. Regular commands +# usually change the Virtual Machine's state someway, while query commands just +# return information. The sections below are divided accordingly. +# +# It's important to observe that all communication examples are formatted in +# a reader-friendly way, so that they're easier to understand. However, in real +# protocol usage, they're emitted as a single line. +# +# Also, the following notation is used to denote data flow: +# +# Example: +# +# | -> data issued by the Client +# | <- Server data response +# +# Please, refer to the QMP specification (docs/interop/qmp-spec.txt) for +# detailed information on the Server command and response formats. +# +# = Stability Considerations +# +# The current QMP command set (described in this file) may be useful for a +# number of use cases, however it's limited and several commands have bad +# defined semantics, specially with regard to command completion. +# +# These problems are going to be solved incrementally in the next QEMU releases +# and we're going to establish a deprecation policy for badly defined commands. +# +# If you're planning to adopt QMP, please observe the following: +# +# 1. The deprecation policy will take effect and be documented soon, please +# check the documentation of each used command as soon as a new release of +# QEMU is available +# +# 2. DO NOT rely on anything which is not explicit documented +# +# 3. Errors, in special, are not documented. Applications should NOT check +# for specific errors classes or data (it's strongly recommended to only +# check for the "error" key) +# +## + +{ 'pragma': { 'doc-required': true } } + +# Whitelists to permit QAPI rule violations; think twice before you +# add to them! +{ 'pragma': { + # Commands allowed to return a non-dictionary: + 'returns-whitelist': [ + 'human-monitor-command', + 'qom-get', + 'query-migrate-cache-size', + 'query-tpm-models', + 'query-tpm-types', + 'ringbuf-read' ], + 'name-case-whitelist': [ + 'ACPISlotType', # DIMM, visible through query-acpi-ospm-status + 'CpuInfoMIPS', # PC, visible through query-cpu + 'CpuInfoTricore', # PC, visible through query-cpu + 'QapiErrorClass', # all members, visible through errors + 'UuidInfo', # UUID, visible through query-uuid + 'X86CPURegister32', # all members, visible indirectly through qom-get + 'q_obj_CpuInfo-base' # CPU, visible through query-cpu + ] } } + +# Documentation generated with qapi-gen.py is in source order, with +# included sub-schemas inserted at the first include directive +# (subsequent include directives have no effect). To get a sane and +# stable order, it's best to include each sub-schema just once, or +# include it first right here. + +{ 'include': 'common.json' } +{ 'include': 'sockets.json' } +{ 'include': 'run-state.json' } +{ 'include': 'crypto.json' } +{ 'include': 'block.json' } +{ 'include': 'char.json' } +{ 'include': 'net.json' } +{ 'include': 'rocker.json' } +{ 'include': 'tpm.json' } +{ 'include': 'ui.json' } +{ 'include': 'migration.json' } +{ 'include': 'transaction.json' } +{ 'include': 'trace.json' } +{ 'include': 'introspect.json' } +{ 'include': 'misc.json' } diff --git a/qga/Makefile.objs b/qga/Makefile.objs index 6151378ae4..ed08c5917c 100644 --- a/qga/Makefile.objs +++ b/qga/Makefile.objs @@ -3,6 +3,6 @@ qga-obj-$(CONFIG_POSIX) += commands-posix.o channel-posix.o qga-obj-$(CONFIG_WIN32) += commands-win32.o channel-win32.o service-win32.o qga-obj-$(CONFIG_WIN32) += vss-win32.o qga-obj-y += qapi-generated/qga-qapi-types.o qapi-generated/qga-qapi-visit.o -qga-obj-y += qapi-generated/qga-qmp-commands.o +qga-obj-y += qapi-generated/qga-qapi-commands.o qga-vss-dll-obj-$(CONFIG_QGA_VSS) += vss-win32/ diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 967061444a..ac17d0d6cf 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -17,7 +17,7 @@ #include #include #include "qga/guest-agent-core.h" -#include "qga-qmp-commands.h" +#include "qga-qapi-commands.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qemu/queue.h" diff --git a/qga/commands-win32.c b/qga/commands-win32.c index bedae32957..2d48394748 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -34,7 +34,7 @@ #include "qga/guest-agent-core.h" #include "qga/vss-win32.h" -#include "qga-qmp-commands.h" +#include "qga-qapi-commands.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qemu/queue.h" diff --git a/qga/commands.c b/qga/commands.c index 6d710dbb20..a64b34ccab 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -12,7 +12,7 @@ #include "qemu/osdep.h" #include "qga/guest-agent-core.h" -#include "qga-qmp-commands.h" +#include "qga-qapi-commands.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qemu/base64.h" diff --git a/qga/main.c b/qga/main.c index cb434d8c46..f9c83050c5 100644 --- a/qga/main.c +++ b/qga/main.c @@ -25,7 +25,7 @@ #include "qapi/qmp/qstring.h" #include "qga/guest-agent-core.h" #include "qemu/module.h" -#include "qga-qmp-commands.h" +#include "qga-qapi-commands.h" #include "qapi/qmp/qerror.h" #include "qapi/error.h" #include "qga/channel.h" diff --git a/qom/object.c b/qom/object.c index 81b4f7ac48..f70a75c308 100644 --- a/qom/object.c +++ b/qom/object.c @@ -18,7 +18,7 @@ #include "qapi/visitor.h" #include "qapi/string-input-visitor.h" #include "qapi/string-output-visitor.h" -#include "qapi-builtin-visit.h" +#include "qapi/qapi-builtin-visit.h" #include "qapi/qmp/qerror.h" #include "trace.h" diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 953449171b..21a7e0dbe6 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -232,13 +232,6 @@ class QAPISchemaGenCommandVisitor(QAPISchemaModularCVisitor): self._regy = '' self._visited_ret_types = {} - # Temporary HACK: - def _module_basename(self, what, name): - basename = QAPISchemaModularCVisitor._module_basename(self, what, name) - if name == self._main_module: - return re.sub(r'qapi-commands', 'qmp-commands', basename) - return basename - def _begin_module(self, name): self._visited_ret_types[self._genc] = set() commands = self._module_basename('qapi-commands', name) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index e0b88f1896..97e9060b67 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -1775,11 +1775,10 @@ def c_enum_const(type_name, const_name, prefix=None): type_name = prefix return camel_to_upper(type_name) + '_' + c_name(const_name, False).upper() -# Temporary HACK for '/': if hasattr(str, 'maketrans'): - c_name_trans = str.maketrans('.-/', '___') + c_name_trans = str.maketrans('.-', '__') else: - c_name_trans = string.maketrans('.-/', '___') + c_name_trans = string.maketrans('.-', '__') # Map @name to a valid C identifier. diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index 5ad6708491..3dc523cf39 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -157,20 +157,13 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor): self._enum_name = c_name(prefix + 'QAPIEvent', protect=False) self._event_names = [] - # Temporary HACK: - def _module_basename(self, what, name): - basename = QAPISchemaModularCVisitor._module_basename(self, what, name) - if name == self._main_module: - return re.sub(r'qapi-events', 'qapi-event', basename) - return basename - def _begin_module(self, name): types = self._module_basename('qapi-types', name) visit = self._module_basename('qapi-visit', name) self._genc.add(mcgen(''' #include "qemu/osdep.h" #include "qemu-common.h" -#include "%(prefix)sqapi-event.h" +#include "%(prefix)sqapi-events.h" #include "%(visit)s.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index f571cc134c..f66c397fb0 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -44,7 +44,7 @@ class QAPISchemaGenIntrospectVisitor(QAPISchemaMonolithicCVisitor): def __init__(self, prefix, unmask): QAPISchemaMonolithicCVisitor.__init__( - self, prefix, 'qmp-introspect', + self, prefix, 'qapi-introspect', ' * QAPI/QMP schema introspection', __doc__) self._unmask = unmask self._schema = None @@ -53,7 +53,7 @@ class QAPISchemaGenIntrospectVisitor(QAPISchemaMonolithicCVisitor): self._name_map = {} self._genc.add(mcgen(''' #include "qemu/osdep.h" -#include "%(prefix)sqmp-introspect.h" +#include "%(prefix)sqapi-introspect.h" ''', prefix=prefix)) diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index 2a3c502cf6..64d9c0fb37 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -177,8 +177,8 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor): self._genc.preamble_add(mcgen(''' #include "qemu/osdep.h" #include "qapi/dealloc-visitor.h" -#include "qapi-builtin-types.h" -#include "qapi-builtin-visit.h" +#include "qapi/qapi-builtin-types.h" +#include "qapi/qapi-builtin-visit.h" ''')) self._genh.preamble_add(mcgen(''' #include "qapi/util.h" @@ -195,7 +195,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor): ''', types=types, visit=visit)) self._genh.preamble_add(mcgen(''' -#include "qapi-builtin-types.h" +#include "qapi/qapi-builtin-types.h" ''')) def visit_begin(self, schema): diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index de09966643..5d72d8936c 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -274,11 +274,11 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor): #include "qemu/osdep.h" #include "qemu-common.h" #include "qapi/error.h" -#include "qapi-builtin-visit.h" +#include "qapi/qapi-builtin-visit.h" ''')) self._genh.preamble_add(mcgen(''' #include "qapi/visitor.h" -#include "qapi-builtin-types.h" +#include "qapi/qapi-builtin-types.h" ''', prefix=prefix)) @@ -295,7 +295,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor): ''', visit=visit, prefix=self._prefix)) self._genh.preamble_add(mcgen(''' -#include "qapi-builtin-visit.h" +#include "qapi/qapi-builtin-visit.h" #include "%(types)s.h" ''', diff --git a/tests/.gitignore b/tests/.gitignore index 2629cfc2f9..18e58b2183 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -60,7 +60,8 @@ test-keyval test-logging test-mul64 test-opts-visitor -test-qapi-event.[ch] +test-qapi-commands.[ch] +test-qapi-events.[ch] test-qapi-types.[ch] test-qapi-util test-qapi-visit.[ch] @@ -71,11 +72,10 @@ test-qga test-qht test-qht-par test-qmp-cmds -test-qmp-commands.[ch] test-qmp-event test-qobject-input-strict test-qobject-input-visitor -test-qmp-introspect.[ch] +test-qapi-introspect.[ch] test-qobject-output-visitor test-rcu-list test-replication diff --git a/tests/Makefile.include b/tests/Makefile.include index 2de46f8acb..fdca062591 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -570,8 +570,8 @@ qapi-schema += unknown-expr-key.json check-qapi-schema-y := $(addprefix tests/qapi-schema/, $(qapi-schema)) GENERATED_FILES += tests/test-qapi-types.h tests/test-qapi-visit.h \ - tests/test-qmp-commands.h tests/test-qapi-event.h \ - tests/test-qmp-introspect.h + tests/test-qapi-commands.h tests/test-qapi-events.h \ + tests/test-qapi-introspect.h test-obj-y = tests/check-qnum.o tests/check-qstring.o tests/check-qdict.o \ tests/check-qlist.o tests/check-qnull.o tests/check-qobject.o \ @@ -596,7 +596,7 @@ QEMU_CFLAGS += -I$(SRC_PATH)/tests test-util-obj-y = libqemuutil.a test-qom-obj-y = $(qom-obj-y) $(test-util-obj-y) test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o \ - tests/test-qapi-event.o tests/test-qmp-introspect.o \ + tests/test-qapi-events.o tests/test-qapi-introspect.o \ $(test-qom-obj-y) benchmark-crypto-obj-y = $(crypto-obj-y) $(test-qom-obj-y) test-crypto-obj-y = $(crypto-obj-y) $(test-qom-obj-y) @@ -660,9 +660,9 @@ tests/test-replication$(EXESUF): tests/test-replication.o $(test-util-obj-y) \ tests/test-qapi-types.c tests/test-qapi-types.h \ tests/test-qapi-visit.c tests/test-qapi-visit.h \ -tests/test-qmp-commands.h tests/test-qmp-commands.c \ -tests/test-qapi-event.c tests/test-qapi-event.h \ -tests/test-qmp-introspect.c tests/test-qmp-introspect.h: \ +tests/test-qapi-commands.h tests/test-qapi-commands.c \ +tests/test-qapi-events.c tests/test-qapi-events.h \ +tests/test-qapi-introspect.c tests/test-qapi-introspect.h: \ tests/test-qapi-gen-timestamp ; tests/test-qapi-gen-timestamp: $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(qapi-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \ @@ -683,7 +683,7 @@ tests/test-qmp-event$(EXESUF): tests/test-qmp-event.o $(test-qapi-obj-y) tests/test-qobject-output-visitor$(EXESUF): tests/test-qobject-output-visitor.o $(test-qapi-obj-y) tests/test-clone-visitor$(EXESUF): tests/test-clone-visitor.o $(test-qapi-obj-y) tests/test-qobject-input-visitor$(EXESUF): tests/test-qobject-input-visitor.o $(test-qapi-obj-y) -tests/test-qmp-cmds$(EXESUF): tests/test-qmp-cmds.o tests/test-qmp-commands.o $(test-qapi-obj-y) +tests/test-qmp-cmds$(EXESUF): tests/test-qmp-cmds.o tests/test-qapi-commands.o $(test-qapi-obj-y) tests/test-visitor-serialization$(EXESUF): tests/test-visitor-serialization.o $(test-qapi-obj-y) tests/test-opts-visitor$(EXESUF): tests/test-opts-visitor.o $(test-qapi-obj-y) diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index 24660d0868..5b1cee6912 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -3,12 +3,12 @@ #include "qapi/qmp/qdict.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" -#include "test-qmp-commands.h" #include "qapi/error.h" #include "qemu/module.h" #include "qapi/qobject-input-visitor.h" #include "tests/test-qapi-types.h" #include "tests/test-qapi-visit.h" +#include "test-qapi-commands.h" static QmpCommandList qmp_commands; diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c index 5fbe7e551f..31f35b3e66 100644 --- a/tests/test-qmp-event.c +++ b/tests/test-qmp-event.c @@ -14,13 +14,13 @@ #include "qemu/osdep.h" #include "qemu-common.h" -#include "test-qapi-event.h" #include "qapi/error.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" #include "qapi/qmp-event.h" +#include "test-qapi-events.h" typedef struct TestEventData { QDict *expect; diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c index d3a56bd071..79b1a8cb17 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -24,8 +24,8 @@ #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" #include "qapi/qmp/qjson.h" -#include "test-qmp-introspect.h" -#include "qmp-introspect.h" +#include "test-qapi-introspect.h" +#include "qapi/qapi-introspect.h" typedef struct TestInputVisitorData { QObject *obj; @@ -1376,7 +1376,7 @@ int main(int argc, char **argv) NULL, test_visitor_in_fail_alternate); input_visitor_test_add("/visitor/input/fail/union-native-list", NULL, test_visitor_in_fail_union_native_list); - input_visitor_test_add("/visitor/input/qmp-introspect", + input_visitor_test_add("/visitor/input/qapi-introspect", NULL, test_visitor_in_qmp_introspect); g_test_run(); diff --git a/tpm.c b/tpm.c index 2db03a09b2..93031723ad 100644 --- a/tpm.c +++ b/tpm.c @@ -181,8 +181,7 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optarg) } /* - * Walk the list of active TPM backends and collect information about them - * following the schema description in qapi-schema.json. + * Walk the list of active TPM backends and collect information about them. */ TPMInfoList *qmp_query_tpm(Error **errp) { diff --git a/ui/cocoa.m b/ui/cocoa.m index 90d9aa57ea..30888ca8fd 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -32,7 +32,7 @@ #include "ui/input.h" #include "sysemu/sysemu.h" #include "qapi/error.h" -#include "qmp-commands.h" +#include "qapi/qapi-commands.h" #include "sysemu/blockdev.h" #include "qemu-version.h" #include diff --git a/ui/vnc.c b/ui/vnc.c index a25e408cf0..13c28cabb0 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -35,10 +35,10 @@ #include "qemu/timer.h" #include "qemu/acl.h" #include "qemu/config-file.h" +#include "qapi/qapi-events.h" #include "qapi/error.h" #include "qapi/qapi-commands-ui.h" #include "ui/input.h" -#include "qapi-event.h" #include "crypto/hash.h" #include "crypto/tlscredsanon.h" #include "crypto/tlscredsx509.h" -- cgit 1.4.1