Skip to content

qapi: Elide redundant has_FOO in generated C

Markus Armbruster qemu-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest30 patches 10 repliesIn review
  2. v228 patches 19 repliesSuperseded
  3. v127 patches 28 repliesSuperseded

Changes in v3 from the cover letter

* Rebased
- Straighforward conflict with commit 58684155e4 "qcow: switch to *_co_* functions" resolved in PATCH 10
- Straighforward conflict with commit 53b85d9574 "net: introduce qemu_set_info_str() function" in PATCH 18
- Semantic conflict with commit 8801ccd050 "vhost-vdpa: allow passing opened vhostfd to vhost-vdpa" in PATCH 18
- Straighforward conflict with commit a124109422 "qga: Move HW address getting to a separate function" in PATCH 29
* PATCH 07: Fix sndio backend [Stefan]
* PATCH 08+09: New; PATCH 10 adjusted for them
* PATCH 10: Fix for #ifndef LIBRBD_SUPPORTS_ENCRYPTION [Stefan]
* PATCH 10+26: Back out incorrect cleanup of qmp_transaction() in PATCH 10, adjust PATCH 26, and explain it in its commit message
* PATCH 11: Commit message tweaked [Philippe]
* PATCH 17: Drop superfluous conditional around g_strdup() [David]
* PATCH 20: Update stubs/qdev.c, too [Stefan]
* PATCH 23: Commit message tweaked [Philippe]

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/30docs/devel/qapi-code-gen: Update example to match current codedocs/devel/qapi-code-gen.rst+1 -10 replies
2/30qapi: Tidy up whitespace in generated codedocs/devel/qapi-code-gen.rst scripts/qapi/commands.py scripts/qapi/events.py+3 -60 replies
3/30docs/devel/qapi-code-gen: Extend example for next commit's changedocs/devel/qapi-code-gen.rst+20 -10 replies
4/30qapi: Start to elide redundant has_FOO in generated Cdocs/devel/qapi-code-gen.rst docs/devel/writing-monitor-commands.rst scripts/qapi/commands.py +5 more+77 -150 replies
5/30qapi tests: Elide redundant has_FOO in generated Cscripts/qapi/schema.py tests/qtest/qmp-cmd-test.c tests/unit/test-qmp-cmds.c +4 more+18 -250 replies
6/30qapi acpi: Elide redundant has_FOO in generated Chw/acpi/core.c hw/acpi/cpu.c hw/acpi/memory_hotplug.c +1 more+7 -100 replies
7/30qapi audio: Elide redundant has_FOO in generated Caudio/alsaaudio.c audio/audio.c audio/audio_legacy.c +5 more+21 -290 replies
8/30blockdev: Clean up abuse of DriveBackup member formatblockdev.c+9 -81 reply
9/30nbd/server: Clean up abuse of BlockExportOptionsNbd member @argnbd/server.c+6 -92 replies
10/30qapi block: Elide redundant has_FOO in generated Cblock/block-backend.c block/copy-before-write.c block/dirty-bitmap.c +19 more+167 -2740 replies
11/30qapi chardev: Elide redundant has_FOO in generated Cchardev/char-file.c chardev/char-socket.c chardev/char-udp.c +3 more+7 -160 replies
12/30qapi crypto: Elide redundant has_FOO in generated Ccrypto/block-luks.c scripts/qapi/schema.py tests/unit/test-crypto-block.c+8 -150 replies
13/30qapi dump: Elide redundant has_FOO in generated Cdump/dump.c scripts/qapi/schema.py+2 -31 reply
14/30qapi job: Elide redundant has_FOO in generated Cjob-qmp.c scripts/qapi/schema.py+1 -30 replies
15/30qapi machine: Elide redundant has_FOO in generated Chw/core/machine-hmp-cmds.c hw/core/machine-qmp-cmds.c hw/core/machine.c +10 more+15 -340 replies
16/30qapi migration: Elide redundant has_FOO in generated Cmigration/block-dirty-bitmap.c migration/colo.c migration/migration.c +3 more+22 -390 replies
17/30qapi misc: Elide redundant has_FOO in generated Cinclude/monitor/monitor.h monitor/hmp-cmds.c monitor/misc.c +4 more+14 -360 replies
18/30qapi net: Elide redundant has_FOO in generated Chw/net/virtio-net.c monitor/hmp-cmds.c net/announce.c +9 more+59 -641 reply
19/30qapi pci: Elide redundant has_FOO in generated Chw/pci/pci.c monitor/hmp-cmds.c scripts/qapi/schema.py+3 -60 replies
20/30qapi qdev qom: Elide redundant has_FOO in generated Chw/acpi/memory_hotplug.c hw/core/qdev.c hw/ppc/spapr.c +5 more+8 -191 reply
21/30qapi replay: Elide redundant has_FOO in generated Creplay/replay-debugging.c scripts/qapi/schema.py+0 -20 replies
22/30qapi rocker: Elide redundant has_FOO in generated Chw/net/rocker/rocker_of_dpa.c monitor/hmp-cmds.c scripts/qapi/schema.py+13 -231 reply
23/30qapi run-state: Elide redundant has_FOO in generated Cscripts/qapi/schema.py softmmu/runstate.c+5 -140 replies
24/30qapi stats: Elide redundant has_FOO in generated Cmonitor/qmp-cmds.c scripts/qapi/schema.py+1 -50 replies
25/30qapi tpm: Elide redundant has_FOO in generated Cbackends/tpm/tpm_passthrough.c monitor/hmp-cmds.c scripts/qapi/schema.py+4 -70 replies
26/30qapi transaction: Elide redundant has_FOO in generated Cblockdev.c scripts/qapi/schema.py+2 -31 reply
27/30qapi ui: Elide redundant has_FOO in generated Cmonitor/hmp-cmds.c scripts/qapi/schema.py ui/console.c +3 more+8 -280 replies
28/30qapi virtio: Elide redundant has_FOO in generated Chw/virtio/virtio.c monitor/hmp-cmds.c scripts/qapi/schema.py+2 -40 replies
29/30qapi qga: Elide redundant has_FOO in generated Cqga/commands-posix.c qga/commands-win32.c qga/commands.c +1 more+20 -661 reply
30/30qapi: Drop temporary logic to support conversion step by stepscripts/qapi/schema.py+0 -60 replies

Reviews trailers per patch

28 of 30 patches have a Reviewed-by or Acked-by.

PatchDaniel P. BerrangéDr. David Alan GilbertStefan BergerPhilippe Mathieu-DaudéIgor MammedovVladimir Sementsov-OgievskiyMark KandaEric Blake
1/30R-b
2/30R-b
3/30R-b
4/30R-b
5/30R-b
6/30R-b R-b
7/30R-b R-b
8/30R-b
9/30R-b R-b
10/30
11/30R-b R-b
12/30R-b R-b
13/30R-b
14/30R-b
15/30
16/30R-b R-b
17/30R-b
18/30R-b
19/30R-b
20/30R-b
21/30R-b
22/30R-b
23/30R-b
24/30R-b R-b
25/30R-b
26/30R-b
27/30R-b
28/30R-b
29/30R-b
30/30R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 8 reviewers.

Read the v3 thread

Cover letter [PATCH v3 00/30] qapi: Elide redundant has_FOO in generated C

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-07,10-29 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 08+09 clean up in preparation for PATCH 10.

PATCH 28 drops the nerfing code.

v3:
* Rebased
- Straighforward conflict with commit 58684155e4 "qcow: switch to *_co_* functions" resolved in PATCH 10
- Straighforward conflict with commit 53b85d9574 "net: introduce qemu_set_info_str() function" in PATCH 18
- Semantic conflict with commit 8801ccd050 "vhost-vdpa: allow passing opened vhostfd to vhost-vdpa" in PATCH 18
- Straighforward conflict with commit a124109422 "qga: Move HW address getting to a separate function" in PATCH 29
* PATCH 07: Fix sndio backend [Stefan]
* PATCH 08+09: New; PATCH 10 adjusted for them
* PATCH 10: Fix for #ifndef LIBRBD_SUPPORTS_ENCRYPTION [Stefan]
* PATCH 10+26: Back out incorrect cleanup of qmp_transaction() in PATCH 10, adjust PATCH 26, and explain it in its commit message
* PATCH 11: Commit message tweaked [Philippe]
* PATCH 17: Drop superfluous conditional around g_strdup() [David]
* PATCH 20: Update stubs/qdev.c, too [Stefan]
* PATCH 23: Commit message tweaked [Philippe]

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 (30):
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
blockdev: Clean up abuse of DriveBackup member format nbd/server: Clean up abuse of BlockExportOptionsNbd member @arg qapi block: Elide redundant has_FOO in generated C qapi chardev: 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/sndioaudio.c                       |   2 +-
 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                               | 185 ++++++++++-------------
 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                       |  11 +-
 nbd/server.c                             |  15 +-
 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 +++----
 net/vhost-vdpa.c                         |   6 +-
 qemu-img.c                               |  13 +-
 qemu-nbd.c                               |   2 -
 qga/commands-posix.c                     |  32 +---
 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 +-
 stubs/qdev.c                             |   6 +-
 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 ++-
 104 files changed, 487 insertions(+), 735 deletions(-)
Signature · 1 line
2.37.3