Previous postings: v1: https://lists.gnu.org/archive/html/qemu-devel/2021-09/msg02295.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 tlb info irq info lapic info cmma info skeys info ramblock info rdma info usb info numa info profile info roms info registers After doing this conversion - All except 1 usage of qemu_fprintf is eliminated - 50% of calls to qemu_printf are eliminated - 75 calls to monitor_printf are eliminated Ultimately it should be possible to entirely eliminate qemu_fprintf and qemu_printf, and confine monitor_printf calls exclusively to the top level HMP command handlers. 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 48 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 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é (53): docs/devel: rename file for writing monitor commands docs/devel: tweak headings in monitor command docs 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 hw/core: introduce 'format_state' callback to replace 'dump_state' target/alpha: convert to use format_state instead of dump_state target/arm: convert to use format_state instead of dump_state target/avr: convert to use format_state instead of dump_state target/cris: convert to use format_state instead of dump_state target/hexagon: delete unused hexagon_debug() method target/hexagon: convert to use format_state instead of dump_state target/hppa: convert to use format_state instead of dump_state target/i386: convert to use format_state instead of dump_state target/m68k: convert to use format_state instead of dump_state target/microblaze: convert to use format_state instead of dump_state target/mips: convert to use format_state instead of dump_state target/nios2: convert to use format_state instead of dump_state target/openrisc: convert to use format_state instead of dump_state target/ppc: convert to use format_state instead of dump_state target/riscv: convert to use format_state instead of dump_state target/rx: convert to use format_state instead of dump_state target/s390x: convert to use format_state instead of dump_state target/sh: convert to use format_state instead of dump_state target/sparc: convert to use format_state instead of dump_state target/tricore: convert to use format_state instead of dump_state target/xtensa: convert to use format_state instead of dump_state monitor: remove 'info ioapic' HMP command qapi: introduce x-query-registers QMP command 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 hw/core: drop "dump_state" callback from CPU targets hw/core: drop support for NULL pointer for FILE * in cpu_dump_state hw/core: introduce a 'format_tlb' callback target/i386: convert to use format_tlb callback target/m68k: convert to use format_tlb callback target/nios2: convert to use format_tlb callback target/ppc: convert to use format_tlb callback target/sh4: convert to use format_tlb callback target/sparc: convert to use format_tlb callback target/xtensa: convert to use format_tlb callback monitor: merge duplicate "info tlb" handlers qapi: introduce x-query-tlb QMP command qapi: introduce x-query-jit QMP command qapi: introduce x-query-opcount QMP command accel/tcg/cpu-exec.c | 56 +- accel/tcg/hmp.c | 24 +- accel/tcg/translate-all.c | 84 +-- docs/devel/index.rst | 2 +- ...mands.rst => writing-monitor-commands.rst} | 136 ++++- hmp-commands-info.hx | 18 - hw/core/cpu-common.c | 27 +- hw/core/loader.c | 55 +- hw/core/machine-hmp-cmds.c | 33 +- hw/core/machine-qmp-cmds.c | 94 ++++ hw/rdma/rdma_rm.c | 104 ++-- hw/rdma/rdma_rm.h | 2 +- hw/rdma/vmw/pvrdma_main.c | 31 +- hw/s390x/s390-skeys.c | 37 +- hw/s390x/s390-stattrib.c | 58 ++- hw/usb/bus.c | 38 +- include/exec/cpu-all.h | 6 +- include/exec/ramlist.h | 2 +- include/hw/core/cpu.h | 36 +- include/hw/rdma/rdma.h | 2 +- include/monitor/hmp-target.h | 2 - include/tcg/tcg.h | 4 +- monitor/hmp-cmds.c | 81 +-- monitor/misc.c | 68 ++- monitor/qmp-cmds.c | 127 +++++ qapi/common.json | 11 + qapi/machine-target.json | 58 +++ qapi/machine.json | 140 +++++ softmmu/physmem.c | 19 +- stubs/usb-dev-stub.c | 8 + target/alpha/cpu.c | 2 +- target/alpha/cpu.h | 2 +- target/alpha/helper.c | 28 +- target/arm/cpu.c | 152 +++--- target/avr/cpu.c | 57 +- target/cris/cpu.c | 2 +- target/cris/cpu.h | 2 +- target/cris/translate.c | 33 +- target/hexagon/cpu.c | 70 ++- target/hexagon/internal.h | 1 - target/hppa/cpu.c | 2 +- target/hppa/cpu.h | 2 +- target/hppa/helper.c | 25 +- target/i386/cpu-dump.c | 489 ++++++++++-------- target/i386/cpu.c | 5 +- target/i386/cpu.h | 7 +- target/i386/monitor.c | 142 ++--- target/m68k/cpu.c | 5 +- target/m68k/cpu.h | 5 +- target/m68k/helper.c | 132 ++--- target/m68k/monitor.c | 14 +- target/m68k/translate.c | 92 ++-- target/microblaze/cpu.c | 2 +- target/microblaze/cpu.h | 2 +- target/microblaze/translate.c | 45 +- target/mips/cpu.c | 85 +-- target/nios2/cpu.c | 5 +- target/nios2/cpu.h | 4 +- target/nios2/mmu.c | 37 +- target/nios2/monitor.c | 7 - target/nios2/translate.c | 20 +- target/openrisc/cpu.c | 2 +- target/openrisc/cpu.h | 2 +- target/openrisc/translate.c | 8 +- target/ppc/cpu.h | 5 +- target/ppc/cpu_init.c | 215 ++++---- target/ppc/mmu-hash64.c | 8 +- target/ppc/mmu-hash64.h | 2 +- target/ppc/mmu_common.c | 167 +++--- target/ppc/monitor.c | 11 - target/riscv/cpu.c | 105 ++-- target/rx/cpu.c | 2 +- target/rx/cpu.h | 2 +- target/rx/translate.c | 14 +- target/s390x/cpu-dump.c | 43 +- target/s390x/cpu.c | 2 +- target/s390x/s390x-internal.h | 2 +- target/sh4/cpu.c | 5 +- target/sh4/cpu.h | 3 +- target/sh4/monitor.c | 41 +- target/sh4/translate.c | 36 +- target/sparc/cpu.c | 86 +-- target/sparc/cpu.h | 3 +- target/sparc/mmu_helper.c | 43 +- target/sparc/monitor.c | 12 - target/tricore/cpu.c | 2 +- target/tricore/cpu.h | 2 +- target/tricore/translate.c | 24 +- target/xtensa/cpu.c | 2 +- target/xtensa/cpu.h | 4 +- target/xtensa/mmu_helper.c | 126 +++-- target/xtensa/monitor.c | 11 - target/xtensa/translate.c | 45 +- tcg/tcg.c | 98 ++-- tests/qtest/qmp-cmd-test.c | 8 + 95 files changed, 2429 insertions(+), 1551 deletions(-) rename docs/devel/{writing-qmp-commands.rst => writing-monitor-commands.rst} (78%) -- 2.31.1