From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, dave@treblig.org,
"Philippe Mathieu-Daudé" <philmd@mailo.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Gonglei (Arei)" <arei.gonglei@huawei.com>,
"zhenwei pi" <zhenwei.pi@linux.dev>,
"Kevin Wolf" <kwolf@redhat.com>,
"Hanna Reitz" <hreitz@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
"Ani Sinha" <anisinha@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>,
"Amit Shah" <amit@kernel.org>,
"Brian Cain" <brian.cain@oss.qualcomm.com>,
"David Woodhouse" <dwmw2@infradead.org>,
"Paul Durrant" <paul@xen.org>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Marcelo Tosatti" <mtosatti@redhat.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Jiri Pirko" <jiri@resnulli.us>,
"Jason Wang" <jasowangio@gmail.com>,
"Halil Pasic" <pasic@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Jason Herne" <jjherne@linux.ibm.com>,
"Eric Farman" <farman@linux.ibm.com>,
"Matthew Rosato" <mjrosato@linux.ibm.com>,
"Ilya Leoshkevich" <iii@linux.ibm.com>,
"David Hildenbrand" <david@kernel.org>,
"Cornelia Huck" <cohuck@redhat.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Anthony PERARD" <anthony@xenproject.org>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Hyman Huang" <infra.ai.cloud@bitdeer.com>,
"Peter Xu" <peterx@redhat.com>, "Fabiano Rosas" <farosas@suse.de>,
"Samuel Thibault" <samuel.thibault@ens-lyon.org>,
"Stefan Berger" <stefanb@linux.vnet.ibm.com>,
"Zhao Liu" <zhao1.liu@intel.com>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Chinmay Rath" <rathc@linux.ibm.com>,
"Glenn Miles" <milesg@linux.ibm.com>,
"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Weiwei Li" <liwei1518@gmail.com>,
"Daniel Henrique Barboza" <daniel.barboza@oss.qualcomm.com>,
"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
"Chao Liu" <chao.liu@processmission.com>,
"Yoshinori Sato" <yoshinori.sato@nifty.com>,
"Artyom Tarasenko" <atar4qemu@gmail.com>,
"Max Filippov" <jcmvbkbc@gmail.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
qemu-block@nongnu.org, kvm@vger.kernel.org, qemu-ppc@nongnu.org,
qemu-s390x@nongnu.org, xen-devel@lists.xenproject.org,
qemu-riscv@nongnu.org
Subject: Re: [PATCH v4 36/49] monitor: tighten monitor_printf*()
Date: Wed, 26 Aug 2026 09:54:34 +0100 [thread overview]
Message-ID: <ao6pyiBkHZJz_9JR@redhat.com> (raw)
In-Reply-To: <20260825-qemu-no-hmp-v4-36-af60857c2fbe@redhat.com>
On Tue, Aug 25, 2026 at 11:09:43PM +0400, Marc-André Lureau wrote:
> Rename monitor_printf->monitor_hmp_printf, monitor_vprintf->
> monitor_hmp_vprintf, and monitor_printc->monitor_hmp_printc, changing
> the first parameter from Monitor * to MonitorHMP * to enforce type
> safety. The implementation is also simplified: monitor_hmp_vprintf now
> directly calls g_strdup_vprintf + monitor_puts, removing the virtual
> dispatch via moncls->vprintf.
>
> The dev_print() callbacks are temporarily using the MONITOR_HMP(mon)
> cast, they are fixed in the following commits.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> audio/audio-hmp-cmds.c | 6 +-
> backends/cryptodev-hmp-cmds.c | 9 +-
> block/monitor/block-hmp-cmds.c | 170 +++++++++---------
> chardev/char-hmp-cmds.c | 12 +-
> disas/disas-mon.c | 10 +-
> docs/devel/style.rst | 2 +-
> docs/devel/writing-monitor-commands.rst | 8 +-
> dump/dump-hmp-cmds.c | 5 +-
> hw/char/virtio-serial-bus.c | 10 +-
> hw/core/machine-hmp-cmds.c | 213 +++++++++++-----------
> hw/core/sysbus.c | 5 +-
> hw/hexagon/hexagon_tlb.c | 44 ++---
> hw/i386/kvm/xen-stubs.c | 6 +-
> hw/i386/kvm/xen_evtchn.c | 21 +--
> hw/i386/sgx-hmp-stub.c | 3 +-
> hw/i386/sgx.c | 29 ++-
> hw/misc/auxbus.c | 9 +-
> hw/misc/mos6522-stub.c | 3 +-
> hw/net/rocker/rocker-hmp-cmds.c | 146 ++++++++--------
> hw/pci/pci-hmp-cmds.c | 114 ++++++------
> hw/pci/pci-stub.c | 3 +-
> hw/s390x/s390-skeys.c | 9 +-
> hw/s390x/s390-stattrib.c | 20 +--
> hw/uefi/ovmf-log.c | 5 +-
> hw/usb/bus.c | 11 +-
> hw/usb/host-libusb.c | 21 ++-
> hw/virtio/virtio-hmp-cmds.c | 297 ++++++++++++++++---------------
> hw/xen/xen-bus.c | 5 +-
> include/disas/disas.h | 4 +-
> include/monitor/hmp.h | 12 +-
> migration/dirtyrate.c | 46 +++--
> migration/migration-hmp-cmds.c | 301 ++++++++++++++++----------------
> monitor/hmp-cmds.c | 141 +++++++--------
> monitor/hmp.c | 143 +++++++--------
> monitor/monitor-internal.h | 6 -
> monitor/monitor.c | 33 ++--
> net/net-hmp-cmds.c | 31 ++--
> net/slirp.c | 31 ++--
> qom/qom-hmp-cmds.c | 27 ++-
> replay/replay-debugging.c | 5 +-
> stats/stats-hmp-cmds.c | 57 +++---
> stubs/hmp-cmd-info_sev.c | 3 +-
> stubs/monitor-core.c | 2 +-
> system/dirtylimit-hmp-cmds.c | 10 +-
> system/qdev-monitor.c | 19 +-
> system/runstate-hmp-cmds.c | 16 +-
> system/tpm-hmp-cmds.c | 29 ++-
> target/i386/cpu-apic.c | 3 +-
> target/i386/monitor.c | 152 ++++++++--------
> target/i386/sev.c | 35 ++--
> target/m68k/monitor.c | 3 +-
> target/ppc/monitor.c | 3 +-
> target/riscv/monitor.c | 55 +++---
> target/sh4/monitor.c | 29 ++-
> target/sparc/monitor.c | 3 +-
> target/xtensa/monitor.c | 3 +-
> tests/unit/test-util-sockets.c | 2 +-
> tools/qemu-vnc/clipboard.c | 4 +-
> tools/qemu-vnc/stubs.c | 2 +-
> trace/trace-hmp-cmds.c | 12 +-
> ui/ui-hmp-cmds.c | 115 ++++++------
> util/error-report.c | 2 +-
> util/qemu-print.c | 11 +-
> 63 files changed, 1219 insertions(+), 1327 deletions(-)
> diff --git a/util/qemu-print.c b/util/qemu-print.c
> index 5d4143d425a1..5938f2b6c338 100644
> --- a/util/qemu-print.c
> +++ b/util/qemu-print.c
> @@ -13,6 +13,7 @@
> #include "qemu/osdep.h"
> #include "monitor/monitor.h"
> #include "monitor/hmp.h"
> +#include "qom/object.h"
> #include "qemu/qemu-print.h"
>
> /*
> @@ -23,8 +24,13 @@
> int qemu_vprintf(const char *fmt, va_list ap)
> {
> Monitor *cur_mon = monitor_cur();
> +
> + /* for all monitors: QMP & HMP */
> if (cur_mon) {
> - return monitor_vprintf(cur_mon, fmt, ap);
> + /* don't use monitor_cur_hmp(), to avoid a second lookup */
> + MonitorHMP *hmp = (MonitorHMP *)
> + object_dynamic_cast(OBJECT(cur_mon), TYPE_MONITOR_HMP);
> + return monitor_hmp_vprintf(hmp, fmt, ap);
This isn't the same semantics AFAICT.
Original code, if monitor_cur() == QMP, we call monitor_vprintf()
which will return -1.
New code, if monitor_cur() == QMP, we will get a NULL back from
object_dynamic_cast which we then pass into monitor_hmp_vprintf
which will then crash on monitor_puts() IIUC.
> }
> return vprintf(fmt, ap);
> }
> @@ -55,7 +61,8 @@ int qemu_printf(const char *fmt, ...)
> int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
> {
> if (!stream) {
> - return monitor_vprintf(monitor_cur(), fmt, ap);
> + MonitorHMP *hmp = monitor_cur_hmp();
> + return monitor_hmp_vprintf(hmp, fmt, ap);
Same, this should crash on QMP now IIUC.
> }
> return vfprintf(stream, fmt, ap);
> }
>
> --
> 2.55.0.543.g5ebe2ebe4ea8
>
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
next prev parent reply other threads:[~2026-08-26 8:55 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 19:09 [PATCH v4 00/49] Make HMP optional (and later standalone) Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 01/49] build-sys: introduce CONFIG_HMP Marc-André Lureau
2026-08-26 8:38 ` Daniel P. Berrangé
2026-08-26 12:38 ` Philippe Mathieu-Daudé
2026-08-25 19:09 ` [PATCH v4 02/49] vl: fix -monitor none prefix matching Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 03/49] hmp: remove 'vcpu' argument from trace-event help Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 04/49] hmp: fix snapshot_blkdev argument type Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 05/49] target/i386: decouple cpu_x86_inject_mce() from Monitor Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 06/49] target/i386: return an error for invalid CPU in hmp_mce() Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 07/49] system: move gpa2hva() to system memory unit Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 08/49] monitor: move HMP-only fields from Monitor to MonitorHMP Marc-André Lureau
2026-08-26 8:40 ` Daniel P. Berrangé
2026-08-26 12:39 ` Philippe Mathieu-Daudé
2026-08-26 13:06 ` Marc-André Lureau
2026-08-26 17:48 ` Philippe Mathieu-Daudé
2026-08-26 19:15 ` Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 09/49] tests/functional: use query-version QMP command instead of HMP Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 10/49] net/qapi: add x-query-usernet command Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 11/49] python, tests: switch usernet queries from HMP to QMP Marc-André Lureau
2026-08-25 19:47 ` Thomas Huth
2026-08-25 19:09 ` [PATCH v4 12/49] tests/qtest/pnv: drop unnecessary -serial mon:stdio Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 13/49] tests/qtest/qmp-test: don't depend on human-monitor-command Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 14/49] tests/qtest/numa-test: replace HMP "info numa" with QMP query-cpus-fast Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 15/49] tests/qtest/cdrom-test: replace HMP "info block" with QMP query-block Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 16/49] tests/qtest/device-introspect-test: fix test without HMP Marc-André Lureau
2026-08-28 10:09 ` Philippe Mathieu-Daudé
2026-08-25 19:09 ` [PATCH v4 17/49] tests/qemu-iotests/205: fix race in assertExportNotFound Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 18/49] net: add x-query-network QMP command Marc-André Lureau
2026-08-28 10:12 ` Philippe Mathieu-Daudé
2026-08-25 19:09 ` [PATCH v4 19/49] tests/qtest/netdev-socket: replace HMP with x-query-network QMP Marc-André Lureau
2026-08-28 10:13 ` Philippe Mathieu-Daudé
2026-08-25 19:09 ` [PATCH v4 20/49] qemu-io: propagate errors through Error API instead of printf Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 21/49] block: add x-qemu-io QMP command Marc-André Lureau
2026-08-26 12:43 ` Philippe Mathieu-Daudé
2026-08-26 13:08 ` Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 22/49] qtest: add qemu-io command to the qtest protocol Marc-André Lureau
2026-08-26 12:48 ` Philippe Mathieu-Daudé
2026-08-25 19:09 ` [PATCH v4 23/49] qtest/ide-test: convert to use qtest qemu-io command Marc-André Lureau
2026-08-26 12:49 ` Philippe Mathieu-Daudé
2026-08-25 19:09 ` [PATCH v4 24/49] tests/qemu-iotests: add qmp_qemu_io() Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 25/49] tests/qemu-iotests: convert pause/resume_drive() to QMP Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 26/49] monitor: reject readline monitor when HMP is disabled Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 27/49] system: guard HMP initialization paths with CONFIG_HMP Marc-André Lureau
2026-08-26 17:56 ` Philippe Mathieu-Daudé
2026-08-25 19:09 ` [PATCH v4 28/49] tests: skip HMP-dependent tests when HMP is disabled Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 29/49] monitor: isolate HMP declarations in hmp.h Marc-André Lureau
2026-08-26 17:55 ` Philippe Mathieu-Daudé
2026-08-25 19:09 ` [PATCH v4 30/49] monitor: change HMPCommand cmd to take MonitorHMP Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 31/49] monitor: make hmp_handle_error() " Marc-André Lureau
2026-08-26 17:54 ` Philippe Mathieu-Daudé
2026-08-25 19:09 ` [PATCH v4 32/49] monitor: add monitor_cur_hmp() helper Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 33/49] qemu-print: document HMP/QMP behaviour better Marc-André Lureau
2026-08-26 8:45 ` Daniel P. Berrangé
2026-08-25 19:09 ` [PATCH v4 34/49] error-report: switch to use monitor_cur_hmp() Marc-André Lureau
2026-08-25 21:46 ` Philippe Mathieu-Daudé
2026-08-26 17:49 ` Philippe Mathieu-Daudé
2026-08-26 8:46 ` Daniel P. Berrangé
2026-08-25 19:09 ` [PATCH v4 35/49] monitor: tighten monitor_set_cpu()/get_cpu() Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 36/49] monitor: tighten monitor_printf*() Marc-André Lureau
2026-08-26 8:54 ` Daniel P. Berrangé [this message]
2026-08-26 9:41 ` Marc-André Lureau
2026-08-26 10:03 ` Daniel P. Berrangé
2026-08-26 13:04 ` Marc-André Lureau
2026-08-28 10:19 ` Philippe Mathieu-Daudé
2026-08-25 19:09 ` [PATCH v4 37/49] hexagon: make dump_mmu() take MonitorHMP Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 38/49] qdev-monitor: make print_dev() callback " Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 39/49] qapi: make HMP-specific schema entries conditional on CONFIG_HMP Marc-André Lureau
2026-08-26 9:02 ` Daniel P. Berrangé
2026-08-26 9:45 ` Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 40/49] Guard HMP command implementations with CONFIG_HMP Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 41/49] target: guard MonitorDef tables " Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 42/49] hw: guard BusClass::print_dev " Marc-André Lureau
2026-08-26 9:03 ` Daniel P. Berrangé
2026-08-25 19:09 ` [PATCH v4 43/49] hexagon: condition HMP-specific code Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 44/49] build-sys: make HMP source files conditional on have_hmp Marc-André Lureau
2026-08-26 17:43 ` Philippe Mathieu-Daudé
2026-08-26 19:09 ` Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 45/49] stubs: split monitor-core stubs into separate compilation units Marc-André Lureau
2026-08-25 21:44 ` Philippe Mathieu-Daudé
2026-08-25 19:09 ` [PATCH v4 46/49] monitor: move monitor_hmp_print*() functions to hmp.c Marc-André Lureau
2026-08-26 17:45 ` Philippe Mathieu-Daudé
2026-08-26 19:17 ` Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 47/49] monitor: move HMP-specific to monitor-hmp-internal.h Marc-André Lureau
2026-08-26 17:52 ` Philippe Mathieu-Daudé
2026-08-25 19:09 ` [PATCH v4 48/49] build-sys: add 'hmp' option Marc-André Lureau
2026-08-25 19:09 ` [PATCH v4 49/49] gitlab: --disable-hmp in build-without-defaults Marc-André Lureau
2026-08-25 21:43 ` 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=ao6pyiBkHZJz_9JR@redhat.com \
--to=berrange@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=amit@kernel.org \
--cc=anisinha@redhat.com \
--cc=anthony@xenproject.org \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=atar4qemu@gmail.com \
--cc=borntraeger@linux.ibm.com \
--cc=brian.cain@oss.qualcomm.com \
--cc=chao.liu@processmission.com \
--cc=cohuck@redhat.com \
--cc=daniel.barboza@oss.qualcomm.com \
--cc=dave@treblig.org \
--cc=david@kernel.org \
--cc=dwmw2@infradead.org \
--cc=edgar.iglesias@gmail.com \
--cc=farman@linux.ibm.com \
--cc=farosas@suse.de \
--cc=harshpb@linux.ibm.com \
--cc=hreitz@redhat.com \
--cc=iii@linux.ibm.com \
--cc=infra.ai.cloud@bitdeer.com \
--cc=jasowangio@gmail.com \
--cc=jcmvbkbc@gmail.com \
--cc=jiri@resnulli.us \
--cc=jjherne@linux.ibm.com \
--cc=kraxel@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kwolf@redhat.com \
--cc=liwei1518@gmail.com \
--cc=lvivier@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=milesg@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
--cc=npiggin@gmail.com \
--cc=palmer@dabbelt.com \
--cc=pasic@linux.ibm.com \
--cc=paul@xen.org \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@mailo.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=rathc@linux.ibm.com \
--cc=richard.henderson@linaro.org \
--cc=samuel.thibault@ens-lyon.org \
--cc=sstabellini@kernel.org \
--cc=stefanb@linux.vnet.ibm.com \
--cc=stefanha@redhat.com \
--cc=xen-devel@lists.xenproject.org \
--cc=yoshinori.sato@nifty.com \
--cc=zhao1.liu@intel.com \
--cc=zhenwei.pi@linux.dev \
--cc=zhiwei_liu@linux.alibaba.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.