Skip to content

monitor: explicitly permit QMP commands to be added for all use cases

Daniel P. Berrangé qemu-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest22 patches 25 repliesIn review
  2. v319 patches 21 repliesSuperseded
  3. v253 patches 54 repliesSuperseded

Changes in v4 from the cover letter

- Introduce a 'cmd_info_hrt' callback for HMP commands, to handle common case of an info command with no parameters that returns humand readable text. This simply needs the QMP callback and will print the resulting text
- Make hmp_handle_error return bool
- Improve HMP error handling docs

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/22monitor: remove 'info ioapic' HMP commandhmp-commands-info.hx include/monitor/hmp-target.h target/i386/monitor.c+0 -221 reply
2/22monitor: make hmp_handle_error return a booleanhw/core/machine-hmp-cmds.c include/monitor/hmp.h monitor/hmp-cmds.c+13 -203 replies
3/22docs/devel: rename file for writing monitor commandsdocs/devel/index.rst docs/devel/writing-monitor-commands.rst+4 -41 reply
4/22docs/devel: tweak headings in monitor command docsdocs/devel/writing-monitor-commands.rst+4 -40 replies
5/22docs/devel: update error handling guidance for HMP commandsdocs/devel/writing-monitor-commands.rst+7 -121 reply
6/22monitor: introduce HumanReadableText and HMP supportinclude/monitor/hmp.h include/monitor/monitor.h include/qapi/type-helpers.h +6 more+108 -42 replies
7/22docs/devel: document expectations for QAPI data modelling for QMPdocs/devel/writing-monitor-commands.rst+27 -01 reply
8/22docs/devel: add example of command returning unstructured textdocs/devel/writing-monitor-commands.rst+100 -10 replies
9/22docs/devel: document expectations for HMP commands in the futuredocs/devel/writing-monitor-commands.rst+8 -00 replies
10/22qapi: introduce x-query-roms QMP commandhmp-commands-info.hx hw/core/loader.c monitor/misc.c +1 more+36 -181 reply
11/22qapi: introduce x-query-profile QMP commandhmp-commands-info.hx monitor/misc.c monitor/qmp-cmds.c +2 more+48 -281 reply
12/22qapi: introduce x-query-numa QMP commandhmp-commands-info.hx hw/core/machine-hmp-cmds.c hw/core/machine-qmp-cmds.c +1 more+53 -361 reply
13/22qapi: introduce x-query-usb QMP commandhmp-commands-info.hx hw/usb/bus.c qapi/machine.json +2 more+38 -101 reply
14/22qapi: introduce x-query-rdma QMP commandhmp-commands-info.hx hw/rdma/rdma_rm.c hw/rdma/rdma_rm.h +5 more+115 -971 reply
15/22qapi: introduce x-query-ramblock QMP commandhmp-commands-info.hx include/exec/ramlist.h monitor/hmp-cmds.c +3 more+33 -161 reply
16/22qapi: introduce x-query-skeys QMP commandhw/s390x/s390-skeys.c qapi/machine-target.json scripts/qapi/commands.py+45 -82 replies
17/22qapi: introduce x-query-cmma QMP commandhw/s390x/s390-stattrib.c qapi/machine-target.json+52 -182 replies
18/22hmp: synchronize cpu state for lapic infotarget/i386/monitor.c+5 -01 reply
19/22qapi: introduce x-query-lapic QMP commandhw/core/cpu-common.c include/hw/core/cpu.h qapi/machine-target.json +3 more+157 -900 replies
20/22qapi: introduce x-query-irq QMP commandhmp-commands-info.hx monitor/hmp-cmds.c monitor/qmp-cmds.c +1 more+57 -392 replies
21/22qapi: introduce x-query-jit QMP commandaccel/tcg/cpu-exec.c accel/tcg/hmp.c accel/tcg/translate-all.c +5 more+140 -1011 reply
22/22qapi: introduce x-query-opcount QMP commandaccel/tcg/cpu-exec.c accel/tcg/hmp.c accel/tcg/translate-all.c +5 more+38 -152 replies

Reviews trailers per patch

20 of 22 patches have a Reviewed-by or Acked-by.

PatchPhilippe Mathieu-DaudéEric BlakeMarkus ArmbrusterDaniel P. BerrangéDr. David Alan GilbertPeter XuDavid Woodhouse
1/22R-b R-b
2/22R-b R-b
3/22R-b R-b
4/22R-b
5/22R-b
6/22R-b T-b
7/22R-b
8/22R-b
9/22R-b R-b
10/22R-b
11/22R-b
12/22R-b
13/22R-b
14/22R-b
15/22R-b
16/22
17/22R-b
18/22R-b R-b
19/22
20/22R-b
21/22R-b
22/22R-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 7 reviewers.

Read the v4 thread

Cover letter [PATCH v4 00/22] monitor: explicitly permit QMP commands to be added for all use cases

Previous postings:

v1: https://lists.gnu.org/archive/html/qemu-devel/2021-09/msg02295.html
v2: https://lists.gnu.org/archive/html/qemu-devel/2021-09/msg03703.html
v3: https://lists.gnu.org/archive/html/qemu-devel/2021-09/msg07710.html

We are still adding HMP commands without any QMP counterparts. This is done because there are a reasonable number of scenarios where the cost of designing a QAPI data type for the command is not justified.

This has the downside, however, that we will never be able to fully isolate the monitor code from the remainder of QEMU internals. It is desirable to be able to get to a point where subsystems in QEMU are exclusively implemented using QAPI types and never need to have any knowledge of the monitor.

The way to get there is to stop adding commands to HMP only. All commands must be implemented using QMP and any HMP equivalent be a shim around the QMP implemetation. We don't want to compromise our supportability of QMP long term though.

This series proposes that we relax our requirements around fine grained QAPI data design, but with the caveat that any command taking this design approach is mandated to use the 'x-' name prefix. This tradeoff should be suitable for any commands we have been adding exclusively to HMP in recent times, and thus mean we have mandate QMP support for all new commands going forward.

The series then converts the following HMP commands to be QMP shims.

info opcount
info jit
info irq
info lapic
info cmma
info skeys
info ramblock
info rdma
info usb
info numa
info profile
info roms

A full conversion would also enable HMP to be emulated entirely outside QEMU. This could be interesting if we introduce a new QEMU system emulator binary which is legacy free and 100% controlled via QMP, as it would let us provide HMP backcompat around it without the burden of HMP being integrated directly.

There are still many HMP commands with no QMP counterpart after this series.

- A few are not relevant to port as they directly reflect HMP functionality (help, info history).
- A few are sort of available in QMP but look quite different (drive_add vs blockdev_add)
- A few are complicated. "info usbhost" is a dynamically loaded HMP command inside a loadable module and we don't have a way to dynamically register QMP handlers at runtime.
- Most are just tedious gruntwork.

Changed in v4:

- Introduce a 'cmd_info_hrt' callback for HMP commands, to handle common case of an info command with no parameters that returns humand readable text. This simply needs the QMP callback and will print the resulting text
- Make hmp_handle_error return bool
- Improve HMP error handling docs

Changed in v3:

- Temporarily spun off the 'info registers' and 'info tlb' conversions. These required 30+ patches across all the targets and was making this series too large and conflict prone and spanning too many subsystems.

I'll re-submit those two later

- Pull in a fix for the 'info lapic' command

- Misc improvements to the documentation after reviews

- Add helper for GString -> HumanReadableText conversion

Changed in v2:

- Improved documentation in response to feedback
- Finished "info registers" conversion on all targets
- Got a bit carried away and converted many many more commands

Daniel P. Berrangé (21):
monitor: remove 'info ioapic' HMP command
monitor: make hmp_handle_error return a boolean docs/devel: rename file for writing monitor commands docs/devel: tweak headings in monitor command docs docs/devel: update error handling guidance for HMP commands
monitor: introduce HumanReadableText and HMP support docs/devel: document expectations for QAPI data modelling for QMP docs/devel: add example of command returning unstructured text docs/devel: document expectations for HMP commands in the future
qapi: introduce x-query-roms QMP command
qapi: introduce x-query-profile QMP command
qapi: introduce x-query-numa QMP command
qapi: introduce x-query-usb QMP command
qapi: introduce x-query-rdma QMP command
qapi: introduce x-query-ramblock QMP command
qapi: introduce x-query-skeys QMP command
qapi: introduce x-query-cmma QMP command
qapi: introduce x-query-lapic QMP command
qapi: introduce x-query-irq QMP command
qapi: introduce x-query-jit QMP command
qapi: introduce x-query-opcount QMP command

Dongli Zhang (1):
hmp: synchronize cpu state for lapic info

 accel/tcg/cpu-exec.c                          |  51 +++++-
 accel/tcg/hmp.c                               |  22 +--
 accel/tcg/translate-all.c                     |  84 +++++----
 docs/devel/index.rst                          |   2 +-
 ...mands.rst => writing-monitor-commands.rst} | 167 ++++++++++++++++--
 hmp-commands-info.hx                          |  29 +--
 hw/core/cpu-common.c                          |   7 +
 hw/core/loader.c                              |  39 ++--
 hw/core/machine-hmp-cmds.c                    |  38 +---
 hw/core/machine-qmp-cmds.c                    |  40 +++++
 hw/rdma/rdma_rm.c                             | 104 +++++------
 hw/rdma/rdma_rm.h                             |   2 +-
 hw/rdma/vmw/pvrdma_main.c                     |  31 ++--
 hw/s390x/s390-skeys.c                         |  35 +++-
 hw/s390x/s390-stattrib.c                      |  56 ++++--
 hw/usb/bus.c                                  |  24 ++-
 include/exec/cpu-all.h                        |   6 +-
 include/exec/ramlist.h                        |   2 +-
 include/hw/core/cpu.h                         |  10 ++
 include/hw/rdma/rdma.h                        |   2 +-
 include/monitor/hmp-target.h                  |   1 -
 include/monitor/hmp.h                         |   5 +-
 include/monitor/monitor.h                     |   2 +
 include/qapi/type-helpers.h                   |  14 ++
 include/tcg/tcg.h                             |   4 +-
 monitor/hmp-cmds.c                            |  99 ++---------
 monitor/hmp.c                                 |  31 +++-
 monitor/misc.c                                |  46 ++---
 monitor/monitor-internal.h                    |   7 +
 monitor/qmp-cmds.c                            | 116 ++++++++++++
 qapi/common.json                              |  11 ++
 qapi/machine-target.json                      |  47 +++++
 qapi/machine.json                             | 110 ++++++++++++
 qapi/meson.build                              |   3 +
 qapi/qapi-type-helpers.c                      |  23 +++
 scripts/qapi/commands.py                      |   1 +
 softmmu/physmem.c                             |  19 +-
 stubs/usb-dev-stub.c                          |   8 +
 target/i386/cpu-dump.c                        | 161 +++++++++--------
 target/i386/cpu.h                             |   4 +-
 target/i386/monitor.c                         |  50 ++++--
 tcg/tcg.c                                     |  98 +++++-----
 tests/qtest/qmp-cmd-test.c                    |   8 +
 43 files changed, 1082 insertions(+), 537 deletions(-)
 rename docs/devel/{writing-qmp-commands.rst => writing-monitor-commands.rst} (75%)
 create mode 100644 include/qapi/type-helpers.h
 create mode 100644 qapi/qapi-type-helpers.c
Signature · 1 line
2.31.1