From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A25B4C61DC2 for ; Wed, 26 Aug 2026 08:55:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wz9Pa-0002Kw-G9; Wed, 26 Aug 2026 04:55:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wz9PZ-0002KG-Cd for qemu-riscv@nongnu.org; Wed, 26 Aug 2026 04:55:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wz9PX-0002dd-1p for qemu-riscv@nongnu.org; Wed, 26 Aug 2026 04:55:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1787734506; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QcEyEJ2C65GQ7/5bh8oNJgVP3iQUPaFAtGbhQuIC7mw=; b=UFIwzdLRYcokiFpZ9mKGHOs6Pkie12EFtRsqr7GZl25hVbONo2Q4hr0NQUbCt6fSX9f4KA 27Mk0bVCUNLMj1a0CTastTRCKIOpkIcxpQw9OSj5nMKmxww95hTyTnxOL9gRfcIkBPgd0v ehuLeXUUAtGNRV0QMz7Iwfg/rLEao1s= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-473-t03T1JrFMG6NkCjYtxZrkg-1; Wed, 26 Aug 2026 04:55:01 -0400 X-MC-Unique: t03T1JrFMG6NkCjYtxZrkg-1 X-Mimecast-MFC-AGG-ID: t03T1JrFMG6NkCjYtxZrkg_1787734496 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 088181954ADD; Wed, 26 Aug 2026 08:54:53 +0000 (UTC) Received: from redhat.com (headnet05.pony-001.prod.iad2.dc.redhat.com [10.2.32.117]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 25B3B1803A44; Wed, 26 Aug 2026 08:54:36 +0000 (UTC) Date: Wed, 26 Aug 2026 09:54:34 +0100 From: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= To: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Cc: qemu-devel@nongnu.org, dave@treblig.org, Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Markus Armbruster , Gerd Hoffmann , "Gonglei (Arei)" , zhenwei pi , Kevin Wolf , Hanna Reitz , Paolo Bonzini , Alex =?utf-8?Q?Benn=C3=A9e?= , Pierrick Bouvier , Ani Sinha , "Michael S. Tsirkin" , Laurent Vivier , Amit Shah , Brian Cain , David Woodhouse , Paul Durrant , Richard Henderson , Marcelo Tosatti , Mark Cave-Ayland , Jiri Pirko , Jason Wang , Halil Pasic , Christian Borntraeger , Jason Herne , Eric Farman , Matthew Rosato , Ilya Leoshkevich , David Hildenbrand , Cornelia Huck , Stefano Stabellini , Anthony PERARD , "Edgar E. Iglesias" , Hyman Huang , Peter Xu , Fabiano Rosas , Samuel Thibault , Stefan Berger , Zhao Liu , Nicholas Piggin , Chinmay Rath , Glenn Miles , Harsh Prateek Bora , Palmer Dabbelt , Alistair Francis , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Chao Liu , Yoshinori Sato , Artyom Tarasenko , Max Filippov , Stefan Hajnoczi , 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*() Message-ID: References: <20260825-qemu-no-hmp-v4-0-af60857c2fbe@redhat.com> <20260825-qemu-no-hmp-v4-36-af60857c2fbe@redhat.com> MIME-Version: 1.0 In-Reply-To: <20260825-qemu-no-hmp-v4-36-af60857c2fbe@redhat.com> User-Agent: Mutt/2.4.0 (2026-06-19) X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-MFC-PROC-ID: 9dvgUX6Bi9hJO52By_-Y1aXMGgp29bbQEv4zlrOMabQ_1787734496 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-riscv@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= Errors-To: qemu-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org Sender: qemu-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org 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 > --- > 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 :|