qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com
Subject: [PATCH v2 00/28] qapi: Elide redundant has_FOO in generated C
Date: Tue, 18 Oct 2022 08:28:21 +0200	[thread overview]
Message-ID: <20221018062849.3420573-1-armbru@redhat.com> (raw)

In QAPI, absent optional members are distinct from any present value.
We thus represent an optional schema member FOO as two C members: a
FOO with the member's type, and a bool has_FOO.  Likewise for function
arguments.

However, the has_FOO is actually redundant for a pointer-valued FOO,
which can be null only when has_FOO is false, i.e. has_FOO == !!FOO.
Except for arrays, where we a null FOO can also be a present empty
array.

The redundant has_FOO are a nuisance to work with.  Improve the
generator to elide them.

PATCH 01+02 are trivial documentation cleanups.

PATCH 03 tweaks an example in documentation so it'll show the change.

PATCH 04 improves the code generator, but nerfs the change for the
schema modules where handwritten code needs to be updated.

PATCH 05-27 un-nerf in reviewable chunks.  Their commit messages
refer back to PATCH 04 for an explanation of the transformation.
Please read that first.  Note that these patches combine the
mechanical transformation with obvious, local follow-up
simplifications.  If you want them separate for easier review, let me
know.

PATCH 28 drops the nerfing code.

v2:
* Rebased
  - Straighforward conflicts with commit bf0c50d4aa "monitor: expose
    monitor_puts to rest of code" resolved in PATCH 08+17
  - Commit 90c066cd68 "qmp: add QMP command x-query-virtio-status"
    necessitates nerfing qapi/virtio.json in PATCH 04, un-nerfing in
    new PATCH 26
* PATCH 14: Redundant check of params-tls_creds dropped [Philippe]
* PATCH 09+16+27: Fix for Windows

Markus Armbruster (28):
  docs/devel/qapi-code-gen: Update example to match current code
  qapi: Tidy up whitespace in generated code
  docs/devel/qapi-code-gen: Extend example for next commit's change
  qapi: Start to elide redundant has_FOO in generated C
  qapi tests: Elide redundant has_FOO in generated C
  qapi acpi: Elide redundant has_FOO in generated C
  qapi audio: Elide redundant has_FOO in generated C
  qapi block: Elide redundant has_FOO in generated C
  qapi char: Elide redundant has_FOO in generated C
  qapi crypto: Elide redundant has_FOO in generated C
  qapi dump: Elide redundant has_FOO in generated C
  qapi job: Elide redundant has_FOO in generated C
  qapi machine: Elide redundant has_FOO in generated C
  qapi migration: Elide redundant has_FOO in generated C
  qapi misc: Elide redundant has_FOO in generated C
  qapi net: Elide redundant has_FOO in generated C
  qapi pci: Elide redundant has_FOO in generated C
  qapi qdev qom: Elide redundant has_FOO in generated C
  qapi replay: Elide redundant has_FOO in generated C
  qapi rocker: Elide redundant has_FOO in generated C
  qapi run-state: Elide redundant has_FOO in generated C
  qapi stats: Elide redundant has_FOO in generated C
  qapi tpm: Elide redundant has_FOO in generated C
  qapi transaction: Elide redundant has_FOO in generated C
  qapi ui: Elide redundant has_FOO in generated C
  qapi virtio: Elide redundant has_FOO in generated C
  qapi qga: Elide redundant has_FOO in generated C
  qapi: Drop temporary logic to support conversion step by step

 docs/devel/qapi-code-gen.rst             |  29 +++-
 docs/devel/writing-monitor-commands.rst  |  14 +-
 include/monitor/monitor.h                |   3 +-
 audio/alsaaudio.c                        |   2 +-
 audio/audio.c                            |   6 +-
 audio/audio_legacy.c                     |  17 +--
 audio/ossaudio.c                         |   8 +-
 audio/paaudio.c                          |  12 +-
 audio/wavaudio.c                         |   2 +-
 backends/tpm/tpm_passthrough.c           |   2 -
 block/block-backend.c                    |   2 +-
 block/copy-before-write.c                |   2 +-
 block/dirty-bitmap.c                     |   1 -
 block/export/export.c                    |   2 +-
 block/export/vduse-blk.c                 |   3 +-
 block/gluster.c                          |   3 -
 block/monitor/block-hmp-cmds.c           |  48 +++----
 block/qapi-sysemu.c                      |  73 ++++------
 block/qapi.c                             |  62 +++-----
 block/qcow.c                             |  10 +-
 block/qcow2.c                            |  18 ++-
 block/qed.c                              |   2 +-
 block/quorum.c                           |   2 +-
 block/rbd.c                              |  15 +-
 block/ssh.c                              |   2 +-
 blockdev-nbd.c                           |   9 +-
 blockdev.c                               | 173 +++++++++--------------
 blockjob.c                               |   2 -
 chardev/char-file.c                      |   4 +-
 chardev/char-socket.c                    |  10 +-
 chardev/char-udp.c                       |   1 -
 chardev/char.c                           |   6 +-
 crypto/block-luks.c                      |  16 +--
 dump/dump.c                              |   4 +-
 hw/acpi/core.c                           |  14 +-
 hw/acpi/cpu.c                            |   1 -
 hw/acpi/memory_hotplug.c                 |   3 +-
 hw/core/machine-hmp-cmds.c               |   2 +-
 hw/core/machine-qmp-cmds.c               |   9 +-
 hw/core/machine.c                        |  10 +-
 hw/core/numa.c                           |   8 +-
 hw/core/qdev.c                           |   2 +-
 hw/mem/pc-dimm.c                         |   1 -
 hw/net/rocker/rocker_of_dpa.c            |  13 +-
 hw/net/virtio-net.c                      |   3 +-
 hw/nvram/fw_cfg.c                        |   2 +-
 hw/pci/pci.c                             |   2 -
 hw/ppc/spapr.c                           |   2 +-
 hw/ppc/spapr_drc.c                       |   3 +-
 hw/virtio/virtio-mem-pci.c               |   4 +-
 hw/virtio/virtio-pmem-pci.c              |   1 -
 hw/virtio/virtio.c                       |   1 -
 job-qmp.c                                |   3 +-
 migration/block-dirty-bitmap.c           |   4 +-
 migration/colo.c                         |   1 -
 migration/migration.c                    |  27 ++--
 monitor/hmp-cmds.c                       |  84 +++++------
 monitor/misc.c                           |  21 +--
 monitor/qmp-cmds.c                       |   6 +-
 nbd/server.c                             |   2 +-
 net/announce.c                           |   8 +-
 net/hub.c                                |   2 +-
 net/l2tpv3.c                             |   2 +-
 net/net.c                                |  25 ++--
 net/slirp.c                              |   4 +-
 net/socket.c                             |  18 +--
 net/tap-win32.c                          |   2 +-
 net/tap.c                                |  51 ++++---
 qemu-img.c                               |  13 +-
 qemu-nbd.c                               |   2 -
 qga/commands-posix.c                     |  33 ++---
 qga/commands-win32.c                     |  40 +-----
 qga/commands.c                           |  11 +-
 qom/qom-qmp-cmds.c                       |   7 +-
 replay/replay-debugging.c                |   1 -
 softmmu/runstate.c                       |  18 +--
 softmmu/vl.c                             |   2 +-
 target/arm/monitor.c                     |   1 -
 target/i386/cpu-sysemu.c                 |   7 +-
 target/i386/cpu.c                        |   1 -
 target/s390x/cpu_models_sysemu.c         |   1 -
 tests/qtest/fuzz/qos_fuzz.c              |   3 +-
 tests/qtest/qmp-cmd-test.c               |   2 +-
 tests/unit/test-char.c                   |   1 -
 tests/unit/test-crypto-block.c           |   6 -
 tests/unit/test-qmp-cmds.c               |  26 ++--
 tests/unit/test-qmp-event.c              |   4 +-
 tests/unit/test-qobject-input-visitor.c  |   2 +-
 tests/unit/test-qobject-output-visitor.c |   2 -
 tests/unit/test-visitor-serialization.c  |   3 +-
 ui/console.c                             |   4 +-
 ui/input.c                               |   4 +-
 ui/spice-core.c                          |   5 -
 ui/vnc.c                                 |  10 --
 util/qemu-config.c                       |  17 +--
 scripts/qapi/commands.py                 |   9 +-
 scripts/qapi/events.py                   |   3 +-
 scripts/qapi/gen.py                      |   2 +-
 scripts/qapi/schema.py                   |  14 ++
 scripts/qapi/types.py                    |   2 +-
 scripts/qapi/visit.py                    |  17 ++-
 101 files changed, 467 insertions(+), 712 deletions(-)

-- 
2.37.2



             reply	other threads:[~2022-10-18  6:48 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18  6:28 Markus Armbruster [this message]
2022-10-18  6:28 ` [PATCH v2 01/28] docs/devel/qapi-code-gen: Update example to match current code Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 02/28] qapi: Tidy up whitespace in generated code Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 03/28] docs/devel/qapi-code-gen: Extend example for next commit's change Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 04/28] qapi: Start to elide redundant has_FOO in generated C Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 05/28] qapi tests: Elide " Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 06/28] qapi acpi: " Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 07/28] qapi audio: " Markus Armbruster
2022-10-18 12:15   ` Philippe Mathieu-Daudé
2022-10-18  6:28 ` [PATCH v2 08/28] qapi block: " Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 09/28] qapi char: " Markus Armbruster
2022-10-18 12:14   ` Philippe Mathieu-Daudé
2022-10-18 12:55     ` Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 10/28] qapi crypto: " Markus Armbruster
2022-10-18 11:57   ` Philippe Mathieu-Daudé
2022-10-18  6:28 ` [PATCH v2 11/28] qapi dump: " Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 12/28] qapi job: " Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 13/28] qapi machine: " Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 14/28] qapi migration: " Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 15/28] qapi misc: " Markus Armbruster
2022-10-18 10:32   ` Dr. David Alan Gilbert
2022-10-18 11:10     ` Markus Armbruster
2022-10-18 11:17       ` Dr. David Alan Gilbert
2022-10-18 13:01         ` Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 16/28] qapi net: " Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 17/28] qapi pci: " Markus Armbruster
2022-10-18 12:12   ` Philippe Mathieu-Daudé
2022-10-18  6:28 ` [PATCH v2 18/28] qapi qdev qom: " Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 19/28] qapi replay: " Markus Armbruster
2022-10-18 12:11   ` Philippe Mathieu-Daudé
2022-10-18  6:28 ` [PATCH v2 20/28] qapi rocker: " Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 21/28] qapi run-state: " Markus Armbruster
2022-10-18 12:11   ` Philippe Mathieu-Daudé
2022-10-18 13:04     ` Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 22/28] qapi stats: " Markus Armbruster
2022-10-18 12:02   ` Philippe Mathieu-Daudé
2022-10-18  6:28 ` [PATCH v2 23/28] qapi tpm: " Markus Armbruster
2022-10-18 12:01   ` Philippe Mathieu-Daudé
2022-10-18 12:12     ` Stefan Berger
2022-10-18 12:23       ` Philippe Mathieu-Daudé
2022-10-18 13:06         ` Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 24/28] qapi transaction: " Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 25/28] qapi ui: " Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 26/28] qapi virtio: " Markus Armbruster
2022-10-18 12:04   ` Philippe Mathieu-Daudé
2022-10-18  6:28 ` [PATCH v2 27/28] qapi qga: " Markus Armbruster
2022-10-18  6:28 ` [PATCH v2 28/28] qapi: Drop temporary logic to support conversion step by step Markus Armbruster
2022-10-18 12:03   ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221018062849.3420573-1-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).