[Qemu-devel] [PATCH 00/13] qapi: add #if pre-processor conditions to generated code (part 3)

Marc-André Lureau posted 13 patches 5 years, 4 months ago
Test checkpatch passed
Test asan passed
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
Test docker-clang@ubuntu failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20181216140902.23986-1-marcandre.lureau@redhat.com
There is a newer version of this series
qapi/misc.json                          | 478 ----------------------
qapi/qapi-schema.json                   |   1 +
qapi/target.json                        | 516 ++++++++++++++++++++++++
scripts/qapi/commands.py                |  28 +-
scripts/qapi/common.py                  | 105 ++++-
scripts/qapi/events.py                  |  37 +-
scripts/qapi/types.py                   |   8 +-
scripts/qapi/visit.py                   |   8 +-
include/qapi/qmp-event.h                |   4 +
include/qapi/qmp/dispatch.h             |   1 -
include/sysemu/arch_init.h              |  11 -
target/i386/sev_i386.h                  |   2 +-
hw/ppc/spapr_rtc.c                      |   2 +-
hw/s390x/s390-skeys.c                   |   2 +-
hw/timer/mc146818rtc.c                  |   4 +-
monitor.c                               | 306 +++++++-------
qapi/qmp-event.c                        |  11 +
qapi/qmp-registry.c                     |   8 -
qga/main.c                              |   3 +-
qmp.c                                   |  26 --
stubs/arch-query-cpu-def.c              |  11 -
stubs/arch-query-cpu-model-baseline.c   |  13 -
stubs/arch-query-cpu-model-comparison.c |  13 -
stubs/arch-query-cpu-model-expansion.c  |  13 -
target/arm/helper.c                     |   3 +-
target/arm/monitor.c                    |   2 +-
target/i386/cpu.c                       |   6 +-
target/ppc/translate_init.inc.c         |   3 +-
target/s390x/cpu_models.c               |   9 +-
tests/test-qmp-cmds.c                   |   3 +-
tests/test-qobject-input-visitor.c      |   1 -
Makefile                                |   7 +-
Makefile.objs                           |   2 -
Makefile.target                         |   4 +
docs/devel/qapi-code-gen.txt            |   6 +-
stubs/Makefile.objs                     |   4 -
36 files changed, 851 insertions(+), 810 deletions(-)
create mode 100644 qapi/target.json
delete mode 100644 stubs/arch-query-cpu-def.c
delete mode 100644 stubs/arch-query-cpu-model-baseline.c
delete mode 100644 stubs/arch-query-cpu-model-comparison.c
delete mode 100644 stubs/arch-query-cpu-model-expansion.c
[Qemu-devel] [PATCH 00/13] qapi: add #if pre-processor conditions to generated code (part 3)
Posted by Marc-André Lureau 5 years, 4 months ago
Hi,

The thrid and last part (of "[PATCH v2 00/54] qapi: add #if
pre-processor conditions to generated code") is about adding schema
conditions based on the target.

For now, the qapi code is compiled in common objects (common to all
targets). This makes it impossible to add #if TARGET_ARM for example.

The patch "RFC: qapi: learn to split the schema by 'top-unit'"
proposes to split the schema by "top-unit", so that generated code can
be built either in common objects or per-target. That patch is a bit
rough, I would like to get some feedback about the approach before
trying to improve it. The following patches demonstrate usage of
target-based #if conditions, and getting rid of the
qmp_unregister_command() hack.

Marc-André Lureau (13):
  build-sys: move qmp-introspect per target
  qapi-commands: don't initialize command list in qmp_init_marshall()
  qapi-commands: rename init_marshal() to register_commands()
  RFC: qapi: learn to split the schema by 'top-unit'
  qapi: add a top-unit 'target' schema
  qapi: make rtc-reset-reinjection and SEV depend on TARGET_I386
  qapi: make s390 commands depend on TARGET_S390X
  target.json: add a note about query-cpu* not being s390x-specific
  qapi: make query-gic-capabilities depend on TARGET_ARM
  qapi: make query-cpu-model-expansion depend on s390 or x86
  qapi: make query-cpu-definitions depend on specific targets
  qapi: remove qmp_unregister_command()
  qapi: move RTC_CHANGE to the target schema

 qapi/misc.json                          | 478 ----------------------
 qapi/qapi-schema.json                   |   1 +
 qapi/target.json                        | 516 ++++++++++++++++++++++++
 scripts/qapi/commands.py                |  28 +-
 scripts/qapi/common.py                  | 105 ++++-
 scripts/qapi/events.py                  |  37 +-
 scripts/qapi/types.py                   |   8 +-
 scripts/qapi/visit.py                   |   8 +-
 include/qapi/qmp-event.h                |   4 +
 include/qapi/qmp/dispatch.h             |   1 -
 include/sysemu/arch_init.h              |  11 -
 target/i386/sev_i386.h                  |   2 +-
 hw/ppc/spapr_rtc.c                      |   2 +-
 hw/s390x/s390-skeys.c                   |   2 +-
 hw/timer/mc146818rtc.c                  |   4 +-
 monitor.c                               | 306 +++++++-------
 qapi/qmp-event.c                        |  11 +
 qapi/qmp-registry.c                     |   8 -
 qga/main.c                              |   3 +-
 qmp.c                                   |  26 --
 stubs/arch-query-cpu-def.c              |  11 -
 stubs/arch-query-cpu-model-baseline.c   |  13 -
 stubs/arch-query-cpu-model-comparison.c |  13 -
 stubs/arch-query-cpu-model-expansion.c  |  13 -
 target/arm/helper.c                     |   3 +-
 target/arm/monitor.c                    |   2 +-
 target/i386/cpu.c                       |   6 +-
 target/ppc/translate_init.inc.c         |   3 +-
 target/s390x/cpu_models.c               |   9 +-
 tests/test-qmp-cmds.c                   |   3 +-
 tests/test-qobject-input-visitor.c      |   1 -
 Makefile                                |   7 +-
 Makefile.objs                           |   2 -
 Makefile.target                         |   4 +
 docs/devel/qapi-code-gen.txt            |   6 +-
 stubs/Makefile.objs                     |   4 -
 36 files changed, 851 insertions(+), 810 deletions(-)
 create mode 100644 qapi/target.json
 delete mode 100644 stubs/arch-query-cpu-def.c
 delete mode 100644 stubs/arch-query-cpu-model-baseline.c
 delete mode 100644 stubs/arch-query-cpu-model-comparison.c
 delete mode 100644 stubs/arch-query-cpu-model-expansion.c

-- 
2.20.0


Re: [Qemu-devel] [PATCH 00/13] qapi: add #if pre-processor conditions to generated code (part 3)
Posted by Markus Armbruster 5 years, 4 months ago
Marc-André Lureau <marcandre.lureau@redhat.com> writes:

> Hi,
>
> The thrid and last part (of "[PATCH v2 00/54] qapi: add #if
> pre-processor conditions to generated code") is about adding schema
> conditions based on the target.
>
> For now, the qapi code is compiled in common objects (common to all
> targets). This makes it impossible to add #if TARGET_ARM for example.
>
> The patch "RFC: qapi: learn to split the schema by 'top-unit'"
> proposes to split the schema by "top-unit", so that generated code can
> be built either in common objects or per-target. That patch is a bit
> rough, I would like to get some feedback about the approach before
> trying to improve it. The following patches demonstrate usage of
> target-based #if conditions, and getting rid of the
> qmp_unregister_command() hack.

Lovely except for the 'top-unit' feature.  I believe the existing
modules can do the job.  Quoting my "[PATCH v2 00/29] Modularize
generated QAPI code":

    Related: Marc-André's 'unit' pragma proposal.  That's a different
    way to split off parts of the generated code, motivated by the
    desire to use poisoned identifiers such as TARGET_I386.  I noted in
    my review of v3 that I "can either accept it, or come up with a
    better solution."  This is my attempt at a better solution.  It's a
    bit more ambitious, and thus more useful (I hope).  The pragma has
    one theoretical advantage, though: you can modularize the generated
    output in different ways than the input.  The patches using don't do
    that, however.

I'm going to post RFC patches that show how to do a target-dependent
module.  Then we can discuss the two approaches.