* [PULL 00/56] Misc HW patches for 2026-08-16
@ 2026-08-16 14:44 Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 01/56] hw/qdev: Remove DEFINE_PROP_DMAADDR() and 'hw/qdev-dma.h' Philippe Mathieu-Daudé
` (56 more replies)
0 siblings, 57 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:44 UTC (permalink / raw)
To: qemu-devel
The following changes since commit af06b5df2610fe5de6c02d17c17bced9e9f0d47d:
Merge tag 'qom-qdev-20260814' of https://gitlab.com/mcayland-ntx/qemu into staging (2026-08-14 08:44:51 -0700)
are available in the Git repository at:
https://github.com/philmd/qemu.git tags/hw-misc-20260816
for you to fetch changes up to b409523587c49a08b1ddadd51212a320092347b1:
hw/core/machine: Move EHCI migration compat properties to 11.1 (2026-08-16 16:35:27 +0200)
----------------------------------------------------------------
Misc HW and Monitor patch queue
- Bug fixes
. Reinstate x86/pc 'xenfv' machine alias
. Defend against malformed ELF headers to prevent underflows
. Restore ROMD mode after migration for Intel PFlash (CFI01)
. Fix VLAN tag handling on incoming packets on RTL8139 model
- Refactoring (Monitor, common CPU, NMI)
. Add missing inclusions and remove unnecessary ones
. Use qdev_is_realized() consistently (no direct field access)
. Remove deprecated DEFINE_PROP_DMAADDR() macro
. Renaming churn around cpu_{exec,common}* helpers
. Simplify NMI API hanlding
. Move QMP handlers (physmem, nmi) to appropriate subsystems
. Replace container_of() casts with HMP typed accessors
. Rename @mon to @hmp in MonitorHMP for clarity
----------------------------------------------------------------
Akihiko Odaki (13):
qdev: Make qdev_is_realized() take a const DeviceState *
hw/hyperv/balloon: Use qdev_is_realized()
hw/intc/apic: Use qdev_is_realized()
hw/mem/memory-device: Use qdev_is_realized()
hw/mem/pc-dimm: Use qdev_is_realized()
hw/nvram: Use qdev_is_realized()
hw/ppc/pnv_xscom: Use qdev_is_realized()
hw/vfio: Use qdev_is_realized()
hw/virtio/virtio-mem: Use qdev_is_realized()
hw/virtio/virtio-qmp: Use qdev_is_realized()
target/i386/cpu: Use qdev_is_realized()
target/s390x: Use qdev_is_realized()
hw/qdev: Parent device before setting parent bus
Alex Bennée (1):
hw/elf_ops: defend against weird elf headers
Bin Guo (1):
hw/block/pflash_cfi01: Restore ROMD mode after migration
Dario Faggioli (1):
hw/i386/pc: xen: reinstate the "xenfv" machine alias
Jamin Lin (1):
hw/core/machine: Move EHCI migration compat properties to 11.1
Marc-André Lureau (1):
hw/mem/nvdimm: fix "size" property typename
Peter Maydell (2):
hw/net/rtl8139: Fix handling of VLAN tags on incoming short packets
hw/net/rtl8139: Send whole of vlan-tagged packet when doing loopback
Philippe Mathieu-Daudé (35):
hw/qdev: Remove DEFINE_PROP_DMAADDR() and 'hw/qdev-dma.h'
hw/cpu: Correct CPU_GET_CLASS() comment
hw/cpu: Include missing 'qemu/accel.h' header
hw/cpu: Move internal declarations to new 'cpu-internal.h' header
hw/cpu: Rename cpu_common_realizefn() -> cpu_exec_realize()
hw/cpu: Rename cpu_exec_realizefn() -> cpu_common_realize()
hw/cpu: Rename cpu_exec_unrealizefn() -> cpu_common_unrealize()
hw/cpu: Extract cpu_exec_realize() out of cpu_common_realizefn()
hw/cpu: Move system-specific cpu_exec_realize() to cpu-system.c
hw/nmi: Use object_child_foreach_recursive() in nmi_children()
hw/s390x/virtio-ccw: Always inject NMI to first CPU
hw/nmi: Remove @cpu_index argument from
NMIClass::nmi_monitor_handler()
hw/nmi: Remove @cpu_index argument from nmi_inject()
hw/nmi: Rename nmi_monitor_handler() -> raise_nmi()
hw/nmi: Remove unused @errp argument from raise_nmi()
hw/nmi: Raise NMI line only once
hexagon: Remove unnecessary 'monitor/monitor.h' header
net/vhost-vdpa: Include missing 'qemu/iov.h' header
tests/unit: Include 'qemu/main-loop.h' header in test-util-sockets.c
qapi/qmp-dispatch: Include 'qemu/aio-wait.h' and 'monitor/monitor.h'
qapi/qmp-registry: Remove unnecessary 'monitor/monitor.h' header
migration/hmp-cmds: Include 'block/block-global-state.h' header
monitor: Include missing 'qemu/aio-wait.h' header
monitor: Include missing 'qemu/lockable.h' header
monitor: Include missing 'qemu/coroutine-core.h' header
monitor: Reduce inclusion of 'qapi/qapi-emit-events.h' header
monitor: Remove unnecessary 'block/block.h' header
system: Remove unnecessary 'monitor/monitor.h' header
system/dirtylimit: Extract HMP code to dirtylimit-hmp-cmds.c
system: Move qmp_inject_nmi() to hw/core/machine-qmp-cmds.c
system: Extract QMP memsave/pmemsave commands to physmem-qmp-cmds.c
system: Move runstate-related code from cpus.c to runstate.c
monitor: Rename MonitorHMP @mon -> @hmp
monitor: Better express monitor_read()'s opaque arg is of Monitor type
monitor: Replace container_of(MonitorHMP, parent_obj) -> MONITOR_HMP()
Stefan Hajnoczi (1):
hw/nvme: add SPDM_SOCKET Kconfig dependency
MAINTAINERS | 3 +
qapi/machine.json | 7 +-
qapi/run-state.json | 6 +-
hw/core/cpu-internal.h | 23 +++
include/hw/core/cpu.h | 15 +-
include/hw/core/nmi.h | 33 +++-
include/hw/core/qdev-dma.h | 16 --
include/hw/core/qdev.h | 2 +-
include/hw/hexagon/hexagon_tlb.h | 2 +-
include/monitor/monitor.h | 7 +-
include/qapi/qmp-registry.h | 1 -
monitor/monitor-internal.h | 3 +-
target/hexagon/hex_mmu.h | 3 +-
include/hw/elf_ops.h.inc | 5 +
hw/block/pflash_cfi01.c | 10 ++
hw/core/cpu-common.c | 32 +---
hw/core/cpu-system.c | 30 +++-
hw/core/cpu-user.c | 8 +-
hw/core/machine-qmp-cmds.c | 6 +
hw/core/machine.c | 7 +-
hw/core/nmi.c | 48 ++----
hw/core/qdev.c | 51 ++++---
hw/hppa/machine.c | 4 +-
hw/hyperv/hv-balloon.c | 2 +-
hw/i386/pc_piix.c | 1 +
hw/i386/x86.c | 4 +-
hw/intc/apic_common.c | 2 +-
hw/intc/m68k_irqc.c | 4 +-
hw/ipmi/ipmi.c | 3 +-
hw/m68k/q800-glue.c | 4 +-
hw/mem/memory-device.c | 4 +-
hw/mem/nvdimm.c | 2 +-
hw/mem/pc-dimm.c | 2 +-
hw/misc/macio/gpio.c | 4 +-
hw/net/rtl8139.c | 6 +-
hw/nvram/xlnx-bbram.c | 2 +-
hw/nvram/xlnx-efuse.c | 2 +-
hw/ppc/pnv.c | 4 +-
hw/ppc/pnv_xscom.c | 2 +-
hw/ppc/spapr.c | 4 +-
hw/s390x/s390-virtio-ccw.c | 8 +-
hw/usb/hcd-ohci-pci.c | 1 -
hw/usb/hcd-ohci-sysbus.c | 3 +-
hw/usb/hcd-ohci.c | 1 -
hw/vfio/container-legacy.c | 4 +-
hw/vfio/device.c | 4 +-
hw/vfio/iommufd.c | 2 +-
hw/virtio/virtio-mem.c | 4 +-
hw/virtio/virtio-qmp.c | 4 +-
hw/watchdog/watchdog.c | 2 +-
migration/migration-hmp-cmds.c | 1 +
monitor/fds.c | 1 +
monitor/hmp-cmds.c | 6 +-
monitor/hmp.c | 136 ++++++++---------
monitor/monitor.c | 2 +
monitor/qmp.c | 3 +-
net/vhost-vdpa.c | 1 +
qapi/qmp-dispatch.c | 2 +
system/cpus.c | 248 -------------------------------
system/device_tree.c | 1 -
system/dirtylimit-hmp-cmds.c | 74 +++++++++
system/dirtylimit.c | 60 --------
system/physmem-qmp-cmds.c | 107 +++++++++++++
system/physmem.c | 2 -
system/runstate.c | 154 +++++++++++++++++++
target/alpha/cpu.c | 2 +-
target/arm/cpu.c | 2 +-
target/avr/cpu.c | 2 +-
target/hexagon/cpu.c | 2 +-
target/hppa/cpu.c | 2 +-
target/i386/cpu.c | 12 +-
target/i386/kvm/kvm-cpu.c | 4 +-
target/loongarch/cpu.c | 2 +-
target/m68k/cpu.c | 2 +-
target/microblaze/cpu.c | 2 +-
target/mips/cpu.c | 2 +-
target/or1k/cpu.c | 2 +-
target/ppc/cpu_init.c | 4 +-
target/riscv/cpu.c | 2 +-
target/riscv/kvm/kvm-cpu.c | 2 +-
target/riscv/tcg/tcg-cpu.c | 2 +-
target/rx/cpu.c | 2 +-
target/s390x/cpu.c | 2 +-
target/s390x/cpu_models.c | 4 +-
target/sh4/cpu.c | 2 +-
target/sparc/cpu.c | 2 +-
target/tricore/cpu.c | 2 +-
target/xtensa/cpu.c | 2 +-
tests/unit/test-qdev.c | 13 ++
tests/unit/test-util-sockets.c | 1 +
ui/ui-hmp-cmds.c | 6 +-
hmp-commands.hx | 7 +-
hw/nvme/Kconfig | 1 +
system/meson.build | 2 +
94 files changed, 702 insertions(+), 595 deletions(-)
create mode 100644 hw/core/cpu-internal.h
delete mode 100644 include/hw/core/qdev-dma.h
create mode 100644 system/dirtylimit-hmp-cmds.c
create mode 100644 system/physmem-qmp-cmds.c
--
2.53.0
^ permalink raw reply [flat|nested] 58+ messages in thread
* [PULL 01/56] hw/qdev: Remove DEFINE_PROP_DMAADDR() and 'hw/qdev-dma.h'
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 02/56] hw/mem/nvdimm: fix "size" property typename Philippe Mathieu-Daudé
` (55 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Philippe Mathieu-Daudé <philmd@linaro.org>
DEFINE_PROP_DMAADDR() is only used once. Since it doesn't
add much value, simply remove it, along with the header
defining it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20230203145536.17585-14-philmd@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
include/hw/core/qdev-dma.h | 16 ----------------
hw/usb/hcd-ohci-pci.c | 1 -
hw/usb/hcd-ohci-sysbus.c | 3 +--
hw/usb/hcd-ohci.c | 1 -
4 files changed, 1 insertion(+), 20 deletions(-)
delete mode 100644 include/hw/core/qdev-dma.h
diff --git a/include/hw/core/qdev-dma.h b/include/hw/core/qdev-dma.h
deleted file mode 100644
index b00391aa0c3..00000000000
--- a/include/hw/core/qdev-dma.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Support for dma_addr_t typed properties
- *
- * Copyright (C) 2012 David Gibson, IBM Corporation.
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#ifndef HW_QDEV_DMA_H
-#define HW_QDEV_DMA_H
-
-#define DEFINE_PROP_DMAADDR(_n, _s, _f, _d) \
- DEFINE_PROP_UINT64(_n, _s, _f, _d)
-
-#endif
diff --git a/hw/usb/hcd-ohci-pci.c b/hw/usb/hcd-ohci-pci.c
index 18b58f5fcbc..70c9e9ac4f5 100644
--- a/hw/usb/hcd-ohci-pci.c
+++ b/hw/usb/hcd-ohci-pci.c
@@ -25,7 +25,6 @@
#include "migration/vmstate.h"
#include "hw/pci/pci_device.h"
#include "hw/core/sysbus.h"
-#include "hw/core/qdev-dma.h"
#include "hw/core/qdev-properties.h"
#include "trace.h"
#include "hcd-ohci.h"
diff --git a/hw/usb/hcd-ohci-sysbus.c b/hw/usb/hcd-ohci-sysbus.c
index 1a2cf29bed8..4f51eebccb2 100644
--- a/hw/usb/hcd-ohci-sysbus.c
+++ b/hw/usb/hcd-ohci-sysbus.c
@@ -26,7 +26,6 @@
#include "hw/usb/usb.h"
#include "migration/vmstate.h"
#include "hw/core/sysbus.h"
-#include "hw/core/qdev-dma.h"
#include "hw/core/qdev-properties.h"
#include "trace.h"
#include "hcd-ohci.h"
@@ -61,7 +60,7 @@ static const Property ohci_sysbus_properties[] = {
DEFINE_PROP_STRING("masterbus", OHCISysBusState, masterbus),
DEFINE_PROP_UINT32("num-ports", OHCISysBusState, num_ports, 3),
DEFINE_PROP_UINT32("firstport", OHCISysBusState, firstport, 0),
- DEFINE_PROP_DMAADDR("dma-offset", OHCISysBusState, dma_offset, 0),
+ DEFINE_PROP_UINT64("dma-offset", OHCISysBusState, dma_offset, 0),
};
static void ohci_sysbus_class_init(ObjectClass *klass, const void *data)
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index c4a9741bd42..23990115abe 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -34,7 +34,6 @@
#include "hw/usb/usb.h"
#include "migration/vmstate.h"
#include "hw/core/sysbus.h"
-#include "hw/core/qdev-dma.h"
#include "hw/core/qdev-properties.h"
#include "trace.h"
#include "hcd-ohci.h"
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 02/56] hw/mem/nvdimm: fix "size" property typename
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 01/56] hw/qdev: Remove DEFINE_PROP_DMAADDR() and 'hw/qdev-dma.h' Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 03/56] qdev: Make qdev_is_realized() take a const DeviceState * Philippe Mathieu-Daudé
` (54 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Marc-André Lureau <marcandre.lureau@redhat.com>
The getter/setter use visit_type_size().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260616-qom-qapi-v2-30-cc9396b9c18c@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/mem/nvdimm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c
index b7032525271..cf8a4d8c5f2 100644
--- a/hw/mem/nvdimm.c
+++ b/hw/mem/nvdimm.c
@@ -99,7 +99,7 @@ static void nvdimm_set_uuid(Object *obj, Visitor *v, const char *name,
static void nvdimm_init(Object *obj)
{
- object_property_add(obj, NVDIMM_LABEL_SIZE_PROP, "int",
+ object_property_add(obj, NVDIMM_LABEL_SIZE_PROP, "size",
nvdimm_get_label_size, nvdimm_set_label_size, NULL,
NULL);
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 03/56] qdev: Make qdev_is_realized() take a const DeviceState *
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 01/56] hw/qdev: Remove DEFINE_PROP_DMAADDR() and 'hw/qdev-dma.h' Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 02/56] hw/mem/nvdimm: fix "size" property typename Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 04/56] hw/hyperv/balloon: Use qdev_is_realized() Philippe Mathieu-Daudé
` (53 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
qdev_is_realized() only reads DeviceState. Make its parameter const so a
later caller with a const DeviceState * can use it.
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260721-qdev-v3-2-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp>
---
include/hw/core/qdev.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/hw/core/qdev.h b/include/hw/core/qdev.h
index e1476223411..37f7d335519 100644
--- a/include/hw/core/qdev.h
+++ b/include/hw/core/qdev.h
@@ -437,7 +437,7 @@ DeviceState *qdev_try_new(const char *name);
* Context: May be called outside big qemu lock.
* Return: true if the device has been fully constructed, false otherwise.
*/
-static inline bool qdev_is_realized(DeviceState *dev)
+static inline bool qdev_is_realized(const DeviceState *dev)
{
return qatomic_load_acquire(&dev->realized);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 04/56] hw/hyperv/balloon: Use qdev_is_realized()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2026-08-16 14:45 ` [PULL 03/56] qdev: Make qdev_is_realized() take a const DeviceState * Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 05/56] hw/intc/apic: " Philippe Mathieu-Daudé
` (52 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
DeviceState fields should be accessed through qdev helpers rather than
directly. Use qdev_is_realized() instead of reading
DeviceState::realized directly.
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260721-qdev-v3-3-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp>
---
hw/hyperv/hv-balloon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/hyperv/hv-balloon.c b/hw/hyperv/hv-balloon.c
index 9dd759f11e8..b8664a246b4 100644
--- a/hw/hyperv/hv-balloon.c
+++ b/hw/hyperv/hv-balloon.c
@@ -197,7 +197,7 @@ static int build_dimm_list(Object *obj, void *opaque)
if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
DeviceState *dev = DEVICE(obj);
- if (dev->realized) { /* only realized DIMMs matter */
+ if (qdev_is_realized(dev)) { /* only realized DIMMs matter */
*list = g_slist_prepend(*list, dev);
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 05/56] hw/intc/apic: Use qdev_is_realized()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2026-08-16 14:45 ` [PULL 04/56] hw/hyperv/balloon: Use qdev_is_realized() Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 06/56] hw/mem/memory-device: " Philippe Mathieu-Daudé
` (51 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
DeviceState fields should be accessed through qdev helpers rather than
directly. Use qdev_is_realized() instead of reading
DeviceState::realized directly.
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260721-qdev-v3-4-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp>
---
hw/intc/apic_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
index 49c03a5bcee..0f0f37d4573 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -424,7 +424,7 @@ static void apic_common_set_id(Object *obj, Visitor *v, const char *name,
DeviceState *dev = DEVICE(obj);
uint32_t value;
- if (dev->realized) {
+ if (qdev_is_realized(dev)) {
qdev_prop_set_after_realize(dev, name, errp);
return;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 06/56] hw/mem/memory-device: Use qdev_is_realized()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2026-08-16 14:45 ` [PULL 05/56] hw/intc/apic: " Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 07/56] hw/mem/pc-dimm: " Philippe Mathieu-Daudé
` (50 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
DeviceState fields should be accessed through qdev helpers rather than
directly. Use qdev_is_realized() instead of reading
DeviceState::realized directly.
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260721-qdev-v3-5-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp>
---
hw/mem/memory-device.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
index 9cf82b84cf4..24bebfb6b31 100644
--- a/hw/mem/memory-device.c
+++ b/hw/mem/memory-device.c
@@ -59,7 +59,7 @@ static int memory_device_build_list(Object *obj, void *opaque)
if (object_dynamic_cast(obj, TYPE_MEMORY_DEVICE)) {
DeviceState *dev = DEVICE(obj);
- if (dev->realized) { /* only realized memory devices matter */
+ if (qdev_is_realized(dev)) {
*list = g_slist_insert_sorted(*list, dev, memory_device_addr_sort);
}
}
@@ -326,7 +326,7 @@ static int memory_device_plugged_size(Object *obj, void *opaque)
const MemoryDeviceState *md = MEMORY_DEVICE(obj);
const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(obj);
- if (dev->realized && !memory_device_is_empty(md)) {
+ if (qdev_is_realized(dev) && !memory_device_is_empty(md)) {
*size += mdc->get_plugged_size(md, &error_abort);
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 07/56] hw/mem/pc-dimm: Use qdev_is_realized()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2026-08-16 14:45 ` [PULL 06/56] hw/mem/memory-device: " Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 08/56] hw/nvram: " Philippe Mathieu-Daudé
` (49 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
DeviceState fields should be accessed through qdev helpers rather than
directly. Use qdev_is_realized() instead of reading
DeviceState::realized directly.
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260721-qdev-v3-6-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp>
---
hw/mem/pc-dimm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 3efe47f499a..68862926ee2 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -103,7 +103,7 @@ static int pc_dimm_slot2bitmap(Object *obj, void *opaque)
if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
DeviceState *dev = DEVICE(obj);
- if (dev->realized) { /* count only realized DIMMs */
+ if (qdev_is_realized(dev)) { /* count only realized DIMMs */
PCDIMMDevice *d = PC_DIMM(obj);
set_bit(d->slot, bitmap);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 08/56] hw/nvram: Use qdev_is_realized()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2026-08-16 14:45 ` [PULL 07/56] hw/mem/pc-dimm: " Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 09/56] hw/ppc/pnv_xscom: " Philippe Mathieu-Daudé
` (48 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
DeviceState fields should be accessed through qdev helpers rather than
directly. Use qdev_is_realized() instead of reading
DeviceState::realized directly.
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260721-qdev-v3-7-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp>
---
hw/nvram/xlnx-bbram.c | 2 +-
hw/nvram/xlnx-efuse.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/nvram/xlnx-bbram.c b/hw/nvram/xlnx-bbram.c
index edfb592a5ec..e336874bdef 100644
--- a/hw/nvram/xlnx-bbram.c
+++ b/hw/nvram/xlnx-bbram.c
@@ -468,7 +468,7 @@ static void bbram_prop_set_drive(Object *obj, Visitor *v, const char *name,
qdev_prop_drive.set(obj, v, name, opaque, errp);
/* Fill initial data if backend is attached after realized */
- if (dev->realized) {
+ if (qdev_is_realized(dev)) {
bbram_bdrv_read(XLNX_BBRAM(obj), errp);
}
}
diff --git a/hw/nvram/xlnx-efuse.c b/hw/nvram/xlnx-efuse.c
index 1a9650ba128..03c9fbc0d07 100644
--- a/hw/nvram/xlnx-efuse.c
+++ b/hw/nvram/xlnx-efuse.c
@@ -233,7 +233,7 @@ static void efuse_prop_set_drive(Object *obj, Visitor *v, const char *name,
qdev_prop_drive.set(obj, v, name, opaque, errp);
/* Fill initial data if backend is attached after realized */
- if (dev->realized) {
+ if (qdev_is_realized(dev)) {
efuse_bdrv_read(XLNX_EFUSE(obj), errp);
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 09/56] hw/ppc/pnv_xscom: Use qdev_is_realized()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2026-08-16 14:45 ` [PULL 08/56] hw/nvram: " Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 10/56] hw/vfio: " Philippe Mathieu-Daudé
` (47 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
DeviceState fields should be accessed through qdev helpers rather than
directly. Use qdev_is_realized() instead of reading
DeviceState::realized directly.
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260721-qdev-v3-8-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp>
---
hw/ppc/pnv_xscom.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/ppc/pnv_xscom.c b/hw/ppc/pnv_xscom.c
index dc1ffc6c014..7af722584e2 100644
--- a/hw/ppc/pnv_xscom.c
+++ b/hw/ppc/pnv_xscom.c
@@ -253,7 +253,7 @@ static int xscom_dt_child(Object *child, void *opaque)
/*
* Only "realized" devices should be configured in the DT
*/
- if (xc->dt_xscom && DEVICE(child)->realized) {
+ if (xc->dt_xscom && qdev_is_realized(DEVICE(child))) {
_FDT((xc->dt_xscom(xd, args->fdt, args->xscom_offset)));
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 10/56] hw/vfio: Use qdev_is_realized()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2026-08-16 14:45 ` [PULL 09/56] hw/ppc/pnv_xscom: " Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 11/56] hw/virtio/virtio-mem: " Philippe Mathieu-Daudé
` (46 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
DeviceState fields should be accessed through qdev helpers rather than
directly. Use qdev_is_realized() instead of reading
DeviceState::realized directly.
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260721-qdev-v3-9-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp>
---
hw/vfio/container-legacy.c | 4 ++--
hw/vfio/device.c | 4 ++--
hw/vfio/iommufd.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/hw/vfio/container-legacy.c b/hw/vfio/container-legacy.c
index d301b27aa65..7ac7b372145 100644
--- a/hw/vfio/container-legacy.c
+++ b/hw/vfio/container-legacy.c
@@ -1075,7 +1075,7 @@ static int vfio_legacy_pci_hot_reset(VFIODevice *vbasedev, bool single)
/* Prep dependent devices for reset and clear our marker. */
QLIST_FOREACH(vbasedev_iter, &group->device_list, next) {
- if (!vbasedev_iter->dev->realized ||
+ if (!qdev_is_realized(vbasedev_iter->dev) ||
!vfio_pci_from_vfio_device(vbasedev_iter)) {
continue;
}
@@ -1160,7 +1160,7 @@ out:
}
QLIST_FOREACH(vbasedev_iter, &group->device_list, next) {
- if (!vbasedev_iter->dev->realized ||
+ if (!qdev_is_realized(vbasedev_iter->dev) ||
!vfio_pci_from_vfio_device(vbasedev_iter)) {
continue;
}
diff --git a/hw/vfio/device.c b/hw/vfio/device.c
index 1a7f8088aad..4f119596336 100644
--- a/hw/vfio/device.c
+++ b/hw/vfio/device.c
@@ -59,13 +59,13 @@ void vfio_device_reset_handler(void *opaque)
trace_vfio_device_reset_handler();
QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) {
- if (vbasedev->dev->realized) {
+ if (qdev_is_realized(vbasedev->dev)) {
vbasedev->ops->vfio_compute_needs_reset(vbasedev);
}
}
QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) {
- if (vbasedev->dev->realized && vbasedev->needs_reset) {
+ if (qdev_is_realized(vbasedev->dev) && vbasedev->needs_reset) {
vbasedev->ops->vfio_hot_reset_multi(vbasedev);
}
}
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
index 6ff668d2597..242644aa001 100644
--- a/hw/vfio/iommufd.c
+++ b/hw/vfio/iommufd.c
@@ -829,7 +829,7 @@ iommufd_cdev_dep_get_realized_vpdev(struct vfio_pci_dependent_device *dep_dev,
vbasedev_tmp = iommufd_cdev_pci_find_by_devid(dep_dev->devid);
if (!vfio_pci_from_vfio_device(vbasedev_tmp) ||
- !vbasedev_tmp->dev->realized) {
+ !qdev_is_realized(vbasedev_tmp->dev)) {
return NULL;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 11/56] hw/virtio/virtio-mem: Use qdev_is_realized()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2026-08-16 14:45 ` [PULL 10/56] hw/vfio: " Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 12/56] hw/virtio/virtio-qmp: " Philippe Mathieu-Daudé
` (45 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
DeviceState fields should be accessed through qdev helpers rather than
directly. Use qdev_is_realized() instead of reading
DeviceState::realized directly.
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260721-qdev-v3-10-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp>
---
hw/virtio/virtio-mem.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index 35e03ed7599..7130ed852d9 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -1453,7 +1453,7 @@ static void virtio_mem_set_requested_size(Object *obj, Visitor *v,
* The block size and memory backend are not fixed until the device was
* realized. realize() will verify these properties then.
*/
- if (DEVICE(obj)->realized) {
+ if (qdev_is_realized(DEVICE(obj))) {
if (!QEMU_IS_ALIGNED(value, vmem->block_size)) {
error_setg(errp, "'%s' has to be multiples of '%s' (0x%" PRIx64
")", name, VIRTIO_MEM_BLOCK_SIZE_PROP,
@@ -1507,7 +1507,7 @@ static void virtio_mem_set_block_size(Object *obj, Visitor *v, const char *name,
VirtIOMEM *vmem = VIRTIO_MEM(obj);
uint64_t value;
- if (DEVICE(obj)->realized) {
+ if (qdev_is_realized(DEVICE(obj))) {
error_setg(errp, "'%s' cannot be changed", name);
return;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 12/56] hw/virtio/virtio-qmp: Use qdev_is_realized()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2026-08-16 14:45 ` [PULL 11/56] hw/virtio/virtio-mem: " Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 13/56] target/i386/cpu: " Philippe Mathieu-Daudé
` (44 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
DeviceState fields should be accessed through qdev helpers rather than
directly. Use qdev_is_realized() instead of reading
DeviceState::realized directly.
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260721-qdev-v3-11-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp>
---
hw/virtio/virtio-qmp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c
index 57cc03828c2..5aaeebdd96a 100644
--- a/hw/virtio/virtio-qmp.c
+++ b/hw/virtio/virtio-qmp.c
@@ -659,7 +659,7 @@ static int query_dev_child(Object *child, void *opaque)
{
VirtioInfoList **vdevs = opaque;
Object *dev = object_dynamic_cast(child, TYPE_VIRTIO_DEVICE);
- if (dev != NULL && DEVICE(dev)->realized) {
+ if (dev != NULL && qdev_is_realized(DEVICE(dev))) {
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtioInfo *info = g_new(VirtioInfo, 1);
@@ -688,7 +688,7 @@ VirtIODevice *qmp_find_virtio_device(const char *path)
/* Verify the canonical path is a realized virtio device */
Object *dev = object_dynamic_cast(object_resolve_path(path, NULL),
TYPE_VIRTIO_DEVICE);
- if (!dev || !DEVICE(dev)->realized) {
+ if (!dev || !qdev_is_realized(DEVICE(dev))) {
return NULL;
}
return VIRTIO_DEVICE(dev);
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 13/56] target/i386/cpu: Use qdev_is_realized()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2026-08-16 14:45 ` [PULL 12/56] hw/virtio/virtio-qmp: " Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 14/56] target/s390x: " Philippe Mathieu-Daudé
` (43 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
DeviceState fields should be accessed through qdev helpers rather than
directly. Use qdev_is_realized() instead of reading
DeviceState::realized directly.
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260721-qdev-v3-12-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp>
---
target/i386/cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 5805d33ab92..7a2c3cf358d 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -10387,7 +10387,7 @@ static void x86_cpu_set_bit_prop(Object *obj, Visitor *v, const char *name,
BitProperty *fp = opaque;
bool value;
- if (dev->realized) {
+ if (qdev_is_realized(dev)) {
qdev_prop_set_after_realize(dev, name, errp);
return;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 14/56] target/s390x: Use qdev_is_realized()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2026-08-16 14:45 ` [PULL 13/56] target/i386/cpu: " Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 15/56] hw/qdev: Parent device before setting parent bus Philippe Mathieu-Daudé
` (42 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
DeviceState fields should be accessed through qdev helpers rather than
directly. Use qdev_is_realized() instead of reading
DeviceState::realized directly.
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260721-qdev-v3-13-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp>
---
target/s390x/cpu_models.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index 2dd9aac8078..f292af7ad01 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -714,7 +714,7 @@ static void set_feature(Object *obj, Visitor *v, const char *name,
S390CPU *cpu = S390_CPU(obj);
bool value;
- if (dev->realized) {
+ if (qdev_is_realized(dev)) {
error_setg(errp, "Attempt to set property '%s' on '%s' after "
"it was realized", name, object_get_typename(obj));
return;
@@ -770,7 +770,7 @@ static void set_feature_group(Object *obj, Visitor *v, const char *name,
S390CPU *cpu = S390_CPU(obj);
bool value;
- if (dev->realized) {
+ if (qdev_is_realized(dev)) {
error_setg(errp, "Attempt to set property '%s' on '%s' after "
"it was realized", name, object_get_typename(obj));
return;
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 15/56] hw/qdev: Parent device before setting parent bus
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2026-08-16 14:45 ` [PULL 14/56] target/s390x: " Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 16/56] hw/i386/pc: xen: reinstate the "xenfv" machine alias Philippe Mathieu-Daudé
` (41 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Commit 9940b2cfbc05 ("qdev: New qdev_new(), qdev_realize(), etc.") says
"device state 'no QOM parent, but plugged into bus' is dangerous". In
such a case, unrealizing the bus will hang in bus_unparent():
while ((kid = QTAILQ_FIRST(&bus->children)) != NULL) {
DeviceState *dev = kid->child;
object_unparent(OBJECT(dev));
}
object_unparent() does nothing when its argument has no QOM parent,
and the loop spins forever.
However, that commit did not completely eliminate such a situation.
When the device is not parented, device_set_realized() lets
/machine/unattached parent it, but it happens after setting parent bus.
Therefore, any failure between the two operations can leave the device
in a dangerous state.
qdev_realize() at least asserts that the device is not already realized
and prevents one realization failure pattern, but it is not
comprehensive. Besides, it will trip with a command line like the
following:
qemu-system-x86_64 -M none -nodefaults -nographic \
-device ipmi-bmc-sim,realized=on
Eliminate the dangerous state by ensuring that the device is parented
before calling qdev_set_parent_bus(). Also, stop asserting that the
device is not already realized in qdev_realize(); it is broken and
no longer serves any purpose.
Fixes: 9940b2cfbc05 ("qdev: New qdev_new(), qdev_realize(), etc.")
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260721-qdev-v3-14-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp>
---
hw/core/qdev.c | 51 ++++++++++++++++++++++++------------------
tests/unit/test-qdev.c | 13 +++++++++++
2 files changed, 42 insertions(+), 22 deletions(-)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index e2aab3d1fc6..0b0f2f47fa7 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -264,17 +264,43 @@ static void device_reset_child_foreach(Object *obj, ResettableChildCallback cb,
bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp)
{
- assert(!dev->realized && !dev->parent_bus);
+ static int unattached_count;
+ bool unattached_parent = false;
+
+ assert(!dev->parent_bus);
+
+ if (!OBJECT(dev)->parent) {
+ gchar *name = g_strdup_printf("device[%d]", unattached_count++);
+
+ object_property_add_child(machine_get_container("unattached"),
+ name, OBJECT(dev));
+ unattached_parent = true;
+ g_free(name);
+ }
if (bus) {
if (!qdev_set_parent_bus(dev, bus, errp)) {
- return false;
+ goto fail;
}
} else {
assert(!DEVICE_GET_CLASS(dev)->bus_type);
}
- return object_property_set_bool(OBJECT(dev), "realized", true, errp);
+ if (object_property_set_bool(OBJECT(dev), "realized", true, errp)) {
+ return true;
+ }
+
+fail:
+ if (unattached_parent) {
+ /*
+ * Beware, this doesn't just revert
+ * object_property_add_child(), it also runs bus_remove()!
+ */
+ object_unparent(OBJECT(dev));
+ unattached_count--;
+ }
+
+ return false;
}
bool qdev_realize_and_unref(DeviceState *dev, BusState *bus, Error **errp)
@@ -479,8 +505,6 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
BusState *bus;
NamedClockList *ncl;
Error *local_err = NULL;
- bool unattached_parent = false;
- static int unattached_count;
if (dev->hotplugged && !dc->hotpluggable) {
error_setg(errp, "Device '%s' does not support hotplugging",
@@ -493,15 +517,6 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
goto fail;
}
- if (!obj->parent) {
- gchar *name = g_strdup_printf("device[%d]", unattached_count++);
-
- object_property_add_child(machine_get_container("unattached"),
- name, obj);
- unattached_parent = true;
- g_free(name);
- }
-
hotplug_ctrl = qdev_get_hotplug_handler(dev);
if (hotplug_ctrl) {
hotplug_handler_pre_plug(hotplug_ctrl, dev, &local_err);
@@ -627,14 +642,6 @@ post_realize_fail:
fail:
error_propagate(errp, local_err);
- if (unattached_parent) {
- /*
- * Beware, this doesn't just revert
- * object_property_add_child(), it also runs bus_remove()!
- */
- object_unparent(OBJECT(dev));
- unattached_count--;
- }
}
static bool device_get_hotpluggable(Object *obj, Error **errp)
diff --git a/tests/unit/test-qdev.c b/tests/unit/test-qdev.c
index 20eae38e03f..77c3eee7171 100644
--- a/tests/unit/test-qdev.c
+++ b/tests/unit/test-qdev.c
@@ -78,6 +78,16 @@ static void test_qdev_free_properties(void)
object_unref(mt);
}
+static void test_qdev_double_realization(void)
+{
+ MyDev *mt = STATIC_TYPE(object_new(TYPE_MY_DEV));
+
+ qdev_realize(DEVICE(mt), NULL, &error_fatal);
+ qdev_realize(DEVICE(mt), NULL, &error_fatal);
+ object_unparent(OBJECT(mt));
+ object_unref(OBJECT(mt));
+}
+
int main(int argc, char **argv)
{
@@ -90,6 +100,9 @@ int main(int argc, char **argv)
g_test_add_func("/qdev/free-properties",
test_qdev_free_properties);
+ g_test_add_func("/qdev/double-realization",
+ test_qdev_double_realization);
+
g_test_run();
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 16/56] hw/i386/pc: xen: reinstate the "xenfv" machine alias
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (14 preceding siblings ...)
2026-08-16 14:45 ` [PULL 15/56] hw/qdev: Parent device before setting parent bus Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 17/56] hw/net/rtl8139: Fix handling of VLAN tags on incoming short packets Philippe Mathieu-Daudé
` (40 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Dario Faggioli <dfaggioli@suse.com>
Commit 7d2778dea32a4924a469f1cc5767042c8f5b4eea ("hw/i386/pc:
Remove deprecated pc-q35/pc-i440fx/xenfv 3.1 machines") removed
the Xen machine type that was providing the "xenfv" alias. As a
consequence, since the tools are apparently relying on such alias,
we're getting this, as soon as one tries to start a Xen (HVM) VM:
qemu-system-i386: unsupported machine type: "xenfv"
Use -machine help to list supported machines
Reinstate the alias and let it point to the only Xen machine we
still have.
Cc: qemu-stable@nongnu.org
Fixes: 7d2778dea3 Remove deprecated pc-q35/pc-i440fx/xenfv 3.1 machines
Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260730162238.3308286-1-dfaggioli@suse.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/i386/pc_piix.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 223a19cc4bb..a929cc4decd 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -667,6 +667,7 @@ static void xenfv_machine_4_2_options(MachineClass *m)
{
pc_i440fx_machine_4_2_options(m);
m->desc = "Xen Fully-virtualized PC";
+ m->alias = "xenfv";
m->max_cpus = HVM_MAX_VCPUS;
m->default_machine_opts = "accel=xen,suppress-vmdesc=on";
}
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 17/56] hw/net/rtl8139: Fix handling of VLAN tags on incoming short packets
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (15 preceding siblings ...)
2026-08-16 14:45 ` [PULL 16/56] hw/i386/pc: xen: reinstate the "xenfv" machine alias Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 18/56] hw/net/rtl8139: Send whole of vlan-tagged packet when doing loopback Philippe Mathieu-Daudé
` (39 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Peter Maydell <peter.maydell@linaro.org>
The rtl8139 receive code handles VLAN tags in incoming packets by
copying the VLAN tag to a special field in the receive descriptor,
and copying only the actual payload data to the receive buffer. This
code tries to ensure that it pads out the payload to at least
MIN_BUF_SIZE bytes.
In commit 63b901bfd30 we removed the main "pad short frames" code
from this device because we switched to requiring net backends to do
the padding. However we didn't notice that this broke the VLAN tag
handling, which relied on the old code making the buffer at least
MIN_BUF_SIZE + VLAN_HLEN bytes so that it could copy MIN_BUF_SIZE
bytes into the receive buffer even after removing the VLAN tag. The
result is that the guest can make us read 4 bytes off the end of a
buffer by feeding itself a suitable short packet in loopback mode.
The old behaviour is actually not correct, because the IEEE802.1Q
standard says that the minimum ethernet frame size remains 64 bytes
including the 4 checksum bytes, and so when a tag is present the
payload data only needs to be 56 bytes. (A bridge implementation can
choose to pad tagged frames out to 68 bytes, but it doesn't have to,
and so all devices have to correctly handle incoming tagged frames
that are 64 bytes long.)
The RTL8139 datasheet isn't very communicative on this topic, but
there's nothing that suggests it adds extra padding on receive that
didn't exist in the incoming packet.
Drop the last remnants of the padding handling from this device;
this avoids overcopying into the guest when we receive a short
VLAN tagged packet.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3518
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Bin Meng <bin.meng@processmission.com>
Message-ID: <20260731093618.2961031-2-peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/net/rtl8139.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 424af73a18f..2b61c171f2a 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -778,7 +778,6 @@ static void rtl8139_write_buffer(RTL8139State *s, const void *buf, int size)
s->RxBufAddr += size;
}
-#define MIN_BUF_SIZE 60
static inline dma_addr_t rtl8139_addr64(uint32_t low, uint32_t high)
{
return low | ((uint64_t)high << 32);
@@ -1007,10 +1006,6 @@ static ssize_t rtl8139_receive(NetClientState *nc,
lduw_be_p(&buf[ETH_ALEN * 2]) == ETH_P_VLAN) {
dot1q_buf = &buf[ETH_ALEN * 2];
size -= VLAN_HLEN;
- /* if too small buffer, use the tailroom added duing expansion */
- if (size < MIN_BUF_SIZE) {
- size = MIN_BUF_SIZE;
- }
rxdw1 &= ~CP_RX_VLAN_TAG_MASK;
/* BE + ~le_to_cpu()~ + cpu_to_le() = BE */
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 18/56] hw/net/rtl8139: Send whole of vlan-tagged packet when doing loopback
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (16 preceding siblings ...)
2026-08-16 14:45 ` [PULL 17/56] hw/net/rtl8139: Fix handling of VLAN tags on incoming short packets Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 19/56] hw/block/pflash_cfi01: Restore ROMD mode after migration Philippe Mathieu-Daudé
` (38 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Peter Maydell <peter.maydell@linaro.org>
In rtl8139_transfer_frame(), if we are transmitting a frame over
loopback then we do this by calling qemu_receive_packet(). If we
have an iovec rather than a simple buffer (which happens only when
we're sending a packet where we are inserting a vlan tag), we have to
convert this into a simple buffer first using iov_to_buf(). However,
when we do this we forget to also update the 'size' local variable to
the size of the new simple buffer, so we will truncate the packet by
4 bytes (the size of the vlan tag).
Correct the logic so we don't truncate vlan-tagged packets when
sending them over loopback.
Cc: qemu-stable@nongnu.org
Reported-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Bin Meng <bin.meng@processmission.com>
Message-ID: <20260731093618.2961031-3-peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/net/rtl8139.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 2b61c171f2a..16479284eea 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -1765,6 +1765,7 @@ static void rtl8139_transfer_frame(RTL8139State *s, uint8_t *buf, int size,
buf2 = g_malloc(buf2_size);
iov_to_buf(iov, 3, 0, buf2, buf2_size);
buf = buf2;
+ size = buf2_size;
}
DPRINTF("+++ transmit loopback mode\n");
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 19/56] hw/block/pflash_cfi01: Restore ROMD mode after migration
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (17 preceding siblings ...)
2026-08-16 14:45 ` [PULL 18/56] hw/net/rtl8139: Send whole of vlan-tagged packet when doing loopback Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 20/56] hw/nvme: add SPDM_SOCKET Kconfig dependency Philippe Mathieu-Daudé
` (37 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Bin Guo <guobin@linux.alibaba.com>
pflash_post_load() did not restore the ROMD mode of the memory region.
Although cmd and wcycle are migrated, the destination retains the
default ROMD = true from realize. When the source was in a non-array
mode (e.g. ID read, cmd = 0x90), reads on the destination bypass
pflash_read() via the ROM fast path and return raw storage bytes
instead of the command-specific response.
Derive ROMD from the migrated cmd/wcycle in pflash_post_load.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4042
Cc: qemu-stable@nongnu.org
Signed-off-by: Bin Guo <guobin@linux.alibaba.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
[PMD: Including review comments from
https://lore.kernel.org/qemu-devel/CAFEAcA-P6RH7nJK0KQ1H8576ULFA7nocB0EkhhZf6Rw3g0WCag@mail.gmail.com/
Confirming that this is correct is a bit tricky. It relies on:
* when we set romd mode to true we also set wcycle = 0, cmd = 0
(which we do, in reset and in the mode_read_array code)
* when we set romd mode to false at the top of pflash_write(),
all paths out of that function either go through the
mode_read_array path, or else update pfl->cmd to something
non-zero
* nowhere outside pflash_write() udpates cmd or wcycle except
for the "clear them to 0 and set romd mode" places
This is almost but not quite true. In pflash_read(), the default
case for the pfl->cmd switch sets wcycle = 0 cmd = 0 but doesn't
change the romd state. Luckily the "this should never happen"
comment is true -- there's no way to get a pfl->cmd that falls
into the default (except for being deliberately fed a bogus value
via inbound migration).
]
Message-ID: <20260803041808.58174-1-guobin@linux.alibaba.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/block/pflash_cfi01.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index 5b9ddb20b18..a13b91967ed 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -1030,6 +1030,16 @@ static int pflash_post_load(void *opaque, int version_id)
{
PFlashCFI01 *pfl = opaque;
+ /*
+ * ROMD mode is not in the VMState; derive it from the migrated
+ * cmd and wcycle. Only (wcycle == 0, cmd == 0x00) is read-array.
+ */
+ if (pfl->wcycle == 0 && pfl->cmd == 0x00) {
+ memory_region_rom_device_set_romd(&pfl->mem, true);
+ } else {
+ memory_region_rom_device_set_romd(&pfl->mem, false);
+ }
+
if (!pfl->ro) {
pfl->vmstate = qemu_add_vm_change_state_handler(postload_update_cb,
pfl);
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 20/56] hw/nvme: add SPDM_SOCKET Kconfig dependency
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (18 preceding siblings ...)
2026-08-16 14:45 ` [PULL 19/56] hw/block/pflash_cfi01: Restore ROMD mode after migration Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 21/56] hw/cpu: Correct CPU_GET_CLASS() comment Philippe Mathieu-Daudé
` (36 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Stefan Hajnoczi <stefanha@redhat.com>
The NVMe emulation code unconditionally calls spdm_socket_*() APIs. Add
a Kconfig dependency to avoid build errors when NVME_PCI is enabled
without SPDM_SOCKET.
Fixes: 4f947b10d52 ("hw/nvme: Add SPDM over DOE support")
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260810214846.76805-1-stefanha@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/nvme/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/nvme/Kconfig b/hw/nvme/Kconfig
index cfa2ab0f9d5..cfeeed64cd7 100644
--- a/hw/nvme/Kconfig
+++ b/hw/nvme/Kconfig
@@ -2,3 +2,4 @@ config NVME_PCI
bool
default y if PCI_DEVICES || PCIE_DEVICES
depends on PCI
+ select SPDM_SOCKET
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 21/56] hw/cpu: Correct CPU_GET_CLASS() comment
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (19 preceding siblings ...)
2026-08-16 14:45 ` [PULL 20/56] hw/nvme: add SPDM_SOCKET Kconfig dependency Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 22/56] hw/cpu: Include missing 'qemu/accel.h' header Philippe Mathieu-Daudé
` (35 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
commit 0e86d7a71e8 ("cpus: Cache CPUClass early in instance_init()
handler") renamed cpu_exec_realizefn() -> cpu_common_initfn();
update the comment.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260811183410.22428-2-philmd@oss.qualcomm.com>
---
include/hw/core/cpu.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index b54035fb13b..c5064a5449b 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -60,7 +60,7 @@ typedef int (*WriteCoreDumpFunction)(const void *buf, size_t size,
* expensive given the eventual call to
* object_class_dynamic_cast_assert(). Because of this the CPUState
* has a cached value for the class in cs->cc which is set up in
- * cpu_exec_realizefn() for use in hot code paths.
+ * cpu_common_initfn() for use in hot code paths.
*/
typedef struct CPUClass CPUClass;
DECLARE_CLASS_CHECKERS(CPUClass, CPU,
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 22/56] hw/cpu: Include missing 'qemu/accel.h' header
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (20 preceding siblings ...)
2026-08-16 14:45 ` [PULL 21/56] hw/cpu: Correct CPU_GET_CLASS() comment Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 23/56] hw/cpu: Move internal declarations to new 'cpu-internal.h' header Philippe Mathieu-Daudé
` (34 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Philippe Mathieu-Daudé <philmd@linaro.org>
cpu_common_realize() calls accel_cpu_common_realize(),
itself declared in "qemu/accel.h". Include the latter,
otherwise we get when refactoring unrelated headers:
hw/core/cpu-common.c:233:10: error: implicit declaration of function ‘accel_cpu_common_realize’
233 | if (!accel_cpu_common_realize(cpu, errp)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260811183410.22428-3-philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/core/cpu-common.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index e314f916f84..8c9ff25e04a 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -23,6 +23,7 @@
#include "qapi/error.h"
#include "hw/core/cpu.h"
#include "system/hw_accel.h"
+#include "qemu/accel.h"
#include "qemu/log.h"
#include "qemu/main-loop.h"
#include "qemu/lockcnt.h"
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 23/56] hw/cpu: Move internal declarations to new 'cpu-internal.h' header
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (21 preceding siblings ...)
2026-08-16 14:45 ` [PULL 22/56] hw/cpu: Include missing 'qemu/accel.h' header Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 24/56] hw/cpu: Rename cpu_common_realizefn() -> cpu_exec_realize() Philippe Mathieu-Daudé
` (33 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
Some declarations are only used within hw/core/, in particular
by the 3 cpu-{common,user,system}.c. Restrict the declarations
scope by moving them to a new "cpu-internal.h" local header.
Rename cpu_exec_initfn() -> cpu_exec_init() because we usually
have the 'fn' suffix for handler, not API entry point methods.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260811183410.22428-4-philmd@oss.qualcomm.com>
---
MAINTAINERS | 1 +
hw/core/cpu-internal.h | 22 ++++++++++++++++++++++
include/hw/core/cpu.h | 6 ------
hw/core/cpu-common.c | 3 ++-
hw/core/cpu-system.c | 3 ++-
hw/core/cpu-user.c | 3 ++-
6 files changed, 29 insertions(+), 9 deletions(-)
create mode 100644 hw/core/cpu-internal.h
diff --git a/MAINTAINERS b/MAINTAINERS
index f249be744e9..c296dd5abfd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2093,6 +2093,7 @@ Machine core
M: Philippe Mathieu-Daudé <philmd@mailo.com>
R: Zhao Liu <zhao1.liu@intel.com>
S: Maintained
+F: hw/core/cpu-internal.h
F: hw/core/cpu-common.c
F: hw/core/cpu-system.c
F: hw/core/machine-qmp-cmds.c
diff --git a/hw/core/cpu-internal.h b/hw/core/cpu-internal.h
new file mode 100644
index 00000000000..ae6a31bca2d
--- /dev/null
+++ b/hw/core/cpu-internal.h
@@ -0,0 +1,22 @@
+/*
+ * QEMU private CPU interface between user / system modes)
+ *
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef HW_CORE_CPU_INTERNAL_H
+#define HW_CORE_CPU_INTERNAL_H
+
+#include "hw/core/qdev.h"
+#include "hw/core/cpu.h"
+
+void cpu_class_init_props(DeviceClass *dc);
+void cpu_exec_class_post_init(CPUClass *cc);
+
+void cpu_exec_init(CPUState *cpu);
+
+void cpu_vmstate_register(CPUState *cpu);
+void cpu_vmstate_unregister(CPUState *cpu);
+
+#endif
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index c5064a5449b..6490fb070f2 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -1178,12 +1178,6 @@ G_NORETURN void cpu_abort(CPUState *cpu, const char *fmt, ...)
*/
void qemu_process_cpu_events(CPUState *cpu);
-/* $(top_srcdir)/cpu.c */
-void cpu_class_init_props(DeviceClass *dc);
-void cpu_exec_class_post_init(CPUClass *cc);
-void cpu_exec_initfn(CPUState *cpu);
-void cpu_vmstate_register(CPUState *cpu);
-void cpu_vmstate_unregister(CPUState *cpu);
bool cpu_exec_realizefn(CPUState *cpu, Error **errp);
void cpu_exec_unrealizefn(CPUState *cpu);
void cpu_exec_reset_hold(CPUState *cpu);
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index 8c9ff25e04a..17d76580930 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -39,6 +39,7 @@
#ifdef CONFIG_PLUGIN
#include "qemu/plugin.h"
#endif
+#include "cpu-internal.h"
CPUState *cpu_by_arch_id(int64_t id)
{
@@ -326,7 +327,7 @@ static void cpu_common_initfn(Object *obj)
QTAILQ_INIT(&cpu->breakpoints);
QTAILQ_INIT(&cpu->watchpoints);
- cpu_exec_initfn(cpu);
+ cpu_exec_init(cpu);
/*
* Plugin initialization must wait until the cpu start executing
diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c
index 14eb4ed87f8..8a9f2fcea84 100644
--- a/hw/core/cpu-system.c
+++ b/hw/core/cpu-system.c
@@ -30,6 +30,7 @@
#include "hw/core/sysemu-cpu-ops.h"
#include "migration/vmstate.h"
#include "system/tcg.h"
+#include "cpu-internal.h"
bool cpu_has_work(CPUState *cpu)
{
@@ -188,7 +189,7 @@ void cpu_exec_class_post_init(CPUClass *cc)
g_assert(cc->sysemu_ops->has_work);
}
-void cpu_exec_initfn(CPUState *cpu)
+void cpu_exec_init(CPUState *cpu)
{
cpu->memory = get_system_memory();
object_ref(OBJECT(cpu->memory));
diff --git a/hw/core/cpu-user.c b/hw/core/cpu-user.c
index 25aa25ad240..c2cb00a85d3 100644
--- a/hw/core/cpu-user.c
+++ b/hw/core/cpu-user.c
@@ -11,6 +11,7 @@
#include "hw/core/qdev-properties.h"
#include "hw/core/cpu.h"
#include "migration/vmstate.h"
+#include "cpu-internal.h"
static const Property cpu_user_props[] = {
/*
@@ -32,7 +33,7 @@ void cpu_exec_class_post_init(CPUClass *cc)
/* nothing to do */
}
-void cpu_exec_initfn(CPUState *cpu)
+void cpu_exec_init(CPUState *cpu)
{
/* nothing to do */
}
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 24/56] hw/cpu: Rename cpu_common_realizefn() -> cpu_exec_realize()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (22 preceding siblings ...)
2026-08-16 14:45 ` [PULL 23/56] hw/cpu: Move internal declarations to new 'cpu-internal.h' header Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 25/56] hw/cpu: Rename cpu_exec_realizefn() -> cpu_common_realize() Philippe Mathieu-Daudé
` (32 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
Keep cpu_common_*() pattern for publicly exposed common methods
used by target code. Use cpu_exec_*() pattern for internal ones,
mostly to distinct between system / user mode.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260811183410.22428-5-philmd@oss.qualcomm.com>
---
hw/core/cpu-common.c | 4 ++--
target/i386/kvm/kvm-cpu.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index 17d76580930..33e349d4402 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -246,7 +246,7 @@ bool cpu_exec_realizefn(CPUState *cpu, Error **errp)
return true;
}
-static void cpu_common_realizefn(DeviceState *dev, Error **errp)
+static void cpu_exec_realize(DeviceState *dev, Error **errp)
{
CPUState *cpu = CPU(dev);
Object *machine = qdev_get_machine();
@@ -379,7 +379,7 @@ static void cpu_common_class_init(ObjectClass *klass, const void *data)
k->gdb_read_register = cpu_common_gdb_read_register;
k->gdb_write_register = cpu_common_gdb_write_register;
set_bit(DEVICE_CATEGORY_CPU, dc->categories);
- dc->realize = cpu_common_realizefn;
+ dc->realize = cpu_exec_realize;
dc->unrealize = cpu_common_unrealizefn;
rc->phases.hold = cpu_common_reset_hold;
rc->phases.exit = cpu_common_reset_exit;
diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c
index c34d9f15c7e..e164cef2036 100644
--- a/target/i386/kvm/kvm-cpu.c
+++ b/target/i386/kvm/kvm-cpu.c
@@ -63,7 +63,7 @@ static bool kvm_cpu_realizefn(CPUState *cs, Error **errp)
* host_cpu_realizefn()
* kvm_set_guest_phys_bits()
* check/update ucode_rev, phys_bits, guest_phys_bits, mwait
- * cpu_common_realizefn() (via xcc->parent_realize)
+ * cpu_exec_realize() (via xcc->parent_realize)
*/
if (xcc->max_features) {
if (enable_cpu_pm) {
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 25/56] hw/cpu: Rename cpu_exec_realizefn() -> cpu_common_realize()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (23 preceding siblings ...)
2026-08-16 14:45 ` [PULL 24/56] hw/cpu: Rename cpu_common_realizefn() -> cpu_exec_realize() Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 26/56] hw/cpu: Rename cpu_exec_unrealizefn() -> cpu_common_unrealize() Philippe Mathieu-Daudé
` (31 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Keep cpu_common_*() pattern for publicly exposed common methods
used by target code. Use cpu_exec_*() pattern for internal ones,
mostly to distinct between system / user mode.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260811183410.22428-6-philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
include/hw/core/cpu.h | 3 ++-
hw/core/cpu-common.c | 2 +-
target/alpha/cpu.c | 2 +-
target/arm/cpu.c | 2 +-
target/avr/cpu.c | 2 +-
target/hexagon/cpu.c | 2 +-
target/hppa/cpu.c | 2 +-
target/i386/cpu.c | 10 +++++-----
target/i386/kvm/kvm-cpu.c | 2 +-
target/loongarch/cpu.c | 2 +-
target/m68k/cpu.c | 2 +-
target/microblaze/cpu.c | 2 +-
target/mips/cpu.c | 2 +-
target/or1k/cpu.c | 2 +-
target/ppc/cpu_init.c | 2 +-
target/riscv/cpu.c | 2 +-
target/riscv/kvm/kvm-cpu.c | 2 +-
target/riscv/tcg/tcg-cpu.c | 2 +-
target/rx/cpu.c | 2 +-
target/s390x/cpu.c | 2 +-
target/sh4/cpu.c | 2 +-
target/sparc/cpu.c | 2 +-
target/tricore/cpu.c | 2 +-
target/xtensa/cpu.c | 2 +-
24 files changed, 29 insertions(+), 28 deletions(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 6490fb070f2..7b7cf330cde 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -1178,7 +1178,8 @@ G_NORETURN void cpu_abort(CPUState *cpu, const char *fmt, ...)
*/
void qemu_process_cpu_events(CPUState *cpu);
-bool cpu_exec_realizefn(CPUState *cpu, Error **errp);
+/** cpu_common_realize: CPU DeviceRealize common handler */
+bool cpu_common_realize(CPUState *cpu, Error **errp);
void cpu_exec_unrealizefn(CPUState *cpu);
void cpu_exec_reset_hold(CPUState *cpu);
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index 33e349d4402..732e32fade2 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -230,7 +230,7 @@ const char *parse_cpu_option(const char *cpu_option)
return cpu_type;
}
-bool cpu_exec_realizefn(CPUState *cpu, Error **errp)
+bool cpu_common_realize(CPUState *cpu, Error **errp)
{
if (!accel_cpu_common_realize(cpu, errp)) {
return false;
diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c
index 0c35067b202..12e86021663 100644
--- a/target/alpha/cpu.c
+++ b/target/alpha/cpu.c
@@ -117,7 +117,7 @@ static void alpha_cpu_realizefn(DeviceState *dev, Error **errp)
cs->tcg_cflags |= CF_PCREL;
#endif
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 787e4dc7ab2..77aa78f00e2 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -1891,7 +1891,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
}
#endif
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/target/avr/cpu.c b/target/avr/cpu.c
index 35912192126..f8409f32ab9 100644
--- a/target/avr/cpu.c
+++ b/target/avr/cpu.c
@@ -131,7 +131,7 @@ static void avr_cpu_realizefn(DeviceState *dev, Error **errp)
AVRCPUClass *mcc = AVR_CPU_GET_CLASS(dev);
Error *local_err = NULL;
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c
index 0ddd898e6e9..7067e5b70f7 100644
--- a/target/hexagon/cpu.c
+++ b/target/hexagon/cpu.c
@@ -457,7 +457,7 @@ static void hexagon_cpu_realize(DeviceState *dev, Error **errp)
HexagonCPUClass *mcc = HEXAGON_CPU_GET_CLASS(dev);
Error *local_err = NULL;
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c
index a68152f9682..07b49e51326 100644
--- a/target/hppa/cpu.c
+++ b/target/hppa/cpu.c
@@ -181,7 +181,7 @@ static void hppa_cpu_realizefn(DeviceState *dev, Error **errp)
HPPACPUClass *acc = HPPA_CPU_GET_CLASS(dev);
Error *local_err = NULL;
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 7a2c3cf358d..e5ffb10d156 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -10164,7 +10164,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
* These may be set by the accel-specific code,
* and the results are subsequently checked / assumed in this function.
*/
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
@@ -10179,7 +10179,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
if (cpu->guest_phys_bits == -1) {
/*
* If it was not set by the user, or by the accelerator via
- * cpu_exec_realizefn, clear.
+ * cpu_common_realize, clear.
*/
cpu->guest_phys_bits = 0;
}
@@ -10188,7 +10188,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
/*
* The default is the same as KVM's. Note that this check
* needs to happen after the evenual setting of ucode_rev in
- * accel-specific code in cpu_exec_realizefn.
+ * accel-specific code in cpu_common_realize.
*/
if (IS_AMD_CPU(env)) {
cpu->ucode_rev = 0x01000065;
@@ -10201,7 +10201,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
* mwait extended info: needed for Core compatibility
* We always wake on interrupt even if host does not have the capability.
*
- * requires the accel-specific code in cpu_exec_realizefn to
+ * requires the accel-specific code in cpu_common_realize to
* have already acquired the CPUID data into cpu->mwait.
*/
cpu->mwait.ecx |= CPUID_MWAIT_EMX | CPUID_MWAIT_IBE;
@@ -10230,7 +10230,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
* Note that this code assumes features expansion has already been done
* (as it checks for CPUID_EXT2_LM), and also assumes that potential
* phys_bits adjustments to match the host have been already done in
- * accel-specific code in cpu_exec_realizefn.
+ * accel-specific code in cpu_common_realize.
*/
if (env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM) {
if (cpu->phys_bits && cpu->phys_bits < 32) {
diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c
index e164cef2036..da8d77ade06 100644
--- a/target/i386/kvm/kvm-cpu.c
+++ b/target/i386/kvm/kvm-cpu.c
@@ -57,7 +57,7 @@ static bool kvm_cpu_realizefn(CPUState *cs, Error **errp)
*
* x86_cpu_realizefn():
* x86_cpu_expand_features()
- * cpu_exec_realizefn():
+ * cpu_common_realize():
* accel_cpu_common_realize()
* kvm_cpu_realizefn()
* host_cpu_realizefn()
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index fb03424ffa8..cb07f15110f 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -704,7 +704,7 @@ static void loongarch_cpu_realizefn(DeviceState *dev, Error **errp)
LoongArchCPUClass *lacc = LOONGARCH_CPU_GET_CLASS(dev);
Error *local_err = NULL;
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
index 9ad3057d91c..ce2707dee5a 100644
--- a/target/m68k/cpu.c
+++ b/target/m68k/cpu.c
@@ -389,7 +389,7 @@ static void m68k_cpu_realizefn(DeviceState *dev, Error **errp)
register_m68k_insns(&cpu->env);
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
index a97c92a7b68..389a5124b12 100644
--- a/target/microblaze/cpu.c
+++ b/target/microblaze/cpu.c
@@ -251,7 +251,7 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp)
int i = 0;
Error *local_err = NULL;
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/target/mips/cpu.c b/target/mips/cpu.c
index d72044aef61..669c7d99bb7 100644
--- a/target/mips/cpu.c
+++ b/target/mips/cpu.c
@@ -544,7 +544,7 @@ static void mips_cpu_realizefn(DeviceState *dev, Error **errp)
}
mips_cp0_period_set(cpu);
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/target/or1k/cpu.c b/target/or1k/cpu.c
index ea29b2e01fa..66c00c0930c 100644
--- a/target/or1k/cpu.c
+++ b/target/or1k/cpu.c
@@ -170,7 +170,7 @@ static void openrisc_cpu_realizefn(DeviceState *dev, Error **errp)
OpenRISCCPUClass *occ = OPENRISC_CPU_GET_CLASS(dev);
Error *local_err = NULL;
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index f404c7e549d..b07e9c3ff9c 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -6921,7 +6921,7 @@ static void ppc_cpu_realize(DeviceState *dev, Error **errp)
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
Error *local_err = NULL;
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 5a82e6563bf..23b5023dd37 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -1226,7 +1226,7 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(dev);
Error *local_err = NULL;
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c
index 495cb42dc89..97069bf597a 100644
--- a/target/riscv/kvm/kvm-cpu.c
+++ b/target/riscv/kvm/kvm-cpu.c
@@ -2006,7 +2006,7 @@ static void kvm_cpu_instance_init(CPUState *cs)
* We'll get here via the following path:
*
* riscv_cpu_realize()
- * -> cpu_exec_realizefn()
+ * -> cpu_common_realize()
* -> kvm_cpu_realize() (via accel_cpu_common_realize())
*/
static bool kvm_cpu_realize(CPUState *cs, Error **errp)
diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c
index 4af5cd9c731..9e3cc87f8a3 100644
--- a/target/riscv/tcg/tcg-cpu.c
+++ b/target/riscv/tcg/tcg-cpu.c
@@ -1304,7 +1304,7 @@ static void riscv_cpu_set_profile(RISCVCPU *cpu,
* We'll get here via the following path:
*
* riscv_cpu_realize()
- * -> cpu_exec_realizefn()
+ * -> cpu_common_realize()
* -> tcg_cpu_realize() (via accel_cpu_common_realize())
*/
static bool riscv_tcg_cpu_realize(CPUState *cs, Error **errp)
diff --git a/target/rx/cpu.c b/target/rx/cpu.c
index 20b188c24cd..9b8473d71cf 100644
--- a/target/rx/cpu.c
+++ b/target/rx/cpu.c
@@ -147,7 +147,7 @@ static void rx_cpu_realize(DeviceState *dev, Error **errp)
RXCPUClass *rcc = RX_CPU_GET_CLASS(dev);
Error *local_err = NULL;
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index c074e12ba2d..641ea96c8ea 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -249,7 +249,7 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp)
}
#endif
- cpu_exec_realizefn(cs, &err);
+ cpu_common_realize(cs, &err);
if (err != NULL) {
goto out;
}
diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
index 763424695c6..ad2ec28c1b7 100644
--- a/target/sh4/cpu.c
+++ b/target/sh4/cpu.c
@@ -250,7 +250,7 @@ static void superh_cpu_realizefn(DeviceState *dev, Error **errp)
SuperHCPUClass *scc = SUPERH_CPU_GET_CLASS(dev);
Error *local_err = NULL;
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index 13ebb122a38..1bc14b586bb 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -892,7 +892,7 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
/* Default NaN value: sign bit clear, all frac bits set */
set_float_default_nan_pattern(0b01111111, &env->fp_status);
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c
index 472c24ae32d..96e2817dee7 100644
--- a/target/tricore/cpu.c
+++ b/target/tricore/cpu.c
@@ -99,7 +99,7 @@ static void tricore_cpu_realizefn(DeviceState *dev, Error **errp)
CPUTriCoreState *env = &cpu->env;
Error *local_err = NULL;
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
index 2015a4e3d0d..7c25b9ab707 100644
--- a/target/xtensa/cpu.c
+++ b/target/xtensa/cpu.c
@@ -257,7 +257,7 @@ static void xtensa_cpu_realizefn(DeviceState *dev, Error **errp)
xtensa_irq_init(&XTENSA_CPU(dev)->env);
#endif
- cpu_exec_realizefn(cs, &local_err);
+ cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 26/56] hw/cpu: Rename cpu_exec_unrealizefn() -> cpu_common_unrealize()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (24 preceding siblings ...)
2026-08-16 14:45 ` [PULL 25/56] hw/cpu: Rename cpu_exec_realizefn() -> cpu_common_realize() Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 27/56] hw/cpu: Extract cpu_exec_realize() out of cpu_common_realizefn() Philippe Mathieu-Daudé
` (30 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
Keep cpu_common_*() pattern for publicly exposed common methods
used by target code. Use cpu_exec_*() pattern for internal ones,
mostly to distinct between system / user mode.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260811183410.22428-7-philmd@oss.qualcomm.com>
---
include/hw/core/cpu.h | 4 +++-
hw/core/cpu-common.c | 4 ++--
target/ppc/cpu_init.c | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 7b7cf330cde..81af7b9ee1a 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -1180,7 +1180,9 @@ void qemu_process_cpu_events(CPUState *cpu);
/** cpu_common_realize: CPU DeviceRealize common handler */
bool cpu_common_realize(CPUState *cpu, Error **errp);
-void cpu_exec_unrealizefn(CPUState *cpu);
+/** cpu_common_realize: CPU DeviceUnrealize common handler */
+void cpu_common_unrealize(CPUState *cpu);
+
void cpu_exec_reset_hold(CPUState *cpu);
extern const VMStateDescription vmstate_cpu_common;
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index 732e32fade2..59cd489b713 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -284,10 +284,10 @@ static void cpu_common_unrealizefn(DeviceState *dev)
#endif
/* NOTE: latest generic point before the cpu is fully unrealized */
- cpu_exec_unrealizefn(cpu);
+ cpu_common_unrealize(cpu);
}
-void cpu_exec_unrealizefn(CPUState *cpu)
+void cpu_common_unrealize(CPUState *cpu)
{
cpu_vmstate_unregister(cpu);
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index b07e9c3ff9c..e3a1075aad3 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -6956,7 +6956,7 @@ static void ppc_cpu_realize(DeviceState *dev, Error **errp)
return;
unrealize:
- cpu_exec_unrealizefn(cs);
+ cpu_common_unrealize(cs);
}
static void ppc_cpu_unrealize(DeviceState *dev)
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 27/56] hw/cpu: Extract cpu_exec_realize() out of cpu_common_realizefn()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (25 preceding siblings ...)
2026-08-16 14:45 ` [PULL 26/56] hw/cpu: Rename cpu_exec_unrealizefn() -> cpu_common_unrealize() Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 28/56] hw/cpu: Move system-specific cpu_exec_realize() to cpu-system.c Philippe Mathieu-Daudé
` (29 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
cpu_common_realizefn() contains code only used by system mode
emulation. Extract it to a new cpu_exec_realize() helper. In
the next commit this helper will be moved to cpu-system.c where
it belongs.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260811183410.22428-8-philmd@oss.qualcomm.com>
---
hw/core/cpu-common.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index 59cd489b713..cd7c8763cf5 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -246,9 +246,8 @@ bool cpu_common_realize(CPUState *cpu, Error **errp)
return true;
}
-static void cpu_exec_realize(DeviceState *dev, Error **errp)
+static void cpu_exec_realize(CPUState *cpu, Error **errp)
{
- CPUState *cpu = CPU(dev);
Object *machine = qdev_get_machine();
/* qdev_get_machine() can return something that's not TYPE_MACHINE
@@ -264,10 +263,15 @@ static void cpu_exec_realize(DeviceState *dev, Error **errp)
}
}
- if (dev->hotplugged) {
+ if (DEVICE(cpu)->hotplugged) {
cpu_synchronize_post_init(cpu);
cpu_resume(cpu);
}
+}
+
+static void cpu_common_realizefn(DeviceState *dev, Error **errp)
+{
+ cpu_exec_realize(CPU(dev), errp);
/* NOTE: latest generic point where the cpu is fully realized */
}
@@ -379,7 +383,7 @@ static void cpu_common_class_init(ObjectClass *klass, const void *data)
k->gdb_read_register = cpu_common_gdb_read_register;
k->gdb_write_register = cpu_common_gdb_write_register;
set_bit(DEVICE_CATEGORY_CPU, dc->categories);
- dc->realize = cpu_exec_realize;
+ dc->realize = cpu_common_realizefn;
dc->unrealize = cpu_common_unrealizefn;
rc->phases.hold = cpu_common_reset_hold;
rc->phases.exit = cpu_common_reset_exit;
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 28/56] hw/cpu: Move system-specific cpu_exec_realize() to cpu-system.c
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (26 preceding siblings ...)
2026-08-16 14:45 ` [PULL 27/56] hw/cpu: Extract cpu_exec_realize() out of cpu_common_realizefn() Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 29/56] hw/nmi: Use object_child_foreach_recursive() in nmi_children() Philippe Mathieu-Daudé
` (28 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
Current cpu_exec_realize() body only contains system-mode
related code. Move that method out of cpu-common.c to
cpu-system.c, removing the system / machine mentions in
this common file. Add an empty stub for user-mode.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260811183410.22428-9-philmd@oss.qualcomm.com>
---
hw/core/cpu-internal.h | 1 +
hw/core/cpu-common.c | 24 ------------------------
hw/core/cpu-system.c | 27 +++++++++++++++++++++++++++
hw/core/cpu-user.c | 5 +++++
4 files changed, 33 insertions(+), 24 deletions(-)
diff --git a/hw/core/cpu-internal.h b/hw/core/cpu-internal.h
index ae6a31bca2d..44715b44329 100644
--- a/hw/core/cpu-internal.h
+++ b/hw/core/cpu-internal.h
@@ -15,6 +15,7 @@ void cpu_class_init_props(DeviceClass *dc);
void cpu_exec_class_post_init(CPUClass *cc);
void cpu_exec_init(CPUState *cpu);
+void cpu_exec_realize(CPUState *cpu, Error **errp);
void cpu_vmstate_register(CPUState *cpu);
void cpu_vmstate_unregister(CPUState *cpu);
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index cd7c8763cf5..4f4c87f33a0 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -33,7 +33,6 @@
#include "exec/log.h"
#include "exec/gdbstub.h"
#include "system/tcg.h"
-#include "hw/core/boards.h"
#include "hw/core/qdev-properties.h"
#include "trace.h"
#ifdef CONFIG_PLUGIN
@@ -246,29 +245,6 @@ bool cpu_common_realize(CPUState *cpu, Error **errp)
return true;
}
-static void cpu_exec_realize(CPUState *cpu, Error **errp)
-{
- Object *machine = qdev_get_machine();
-
- /* qdev_get_machine() can return something that's not TYPE_MACHINE
- * if this is one of the user-only emulators; in that case there's
- * no need to check the ignore_memory_transaction_failures board flag.
- */
- if (object_dynamic_cast(machine, TYPE_MACHINE)) {
- MachineClass *mc = MACHINE_GET_CLASS(machine);
-
- if (mc) {
- cpu->ignore_memory_transaction_failures =
- mc->ignore_memory_transaction_failures;
- }
- }
-
- if (DEVICE(cpu)->hotplugged) {
- cpu_synchronize_post_init(cpu);
- cpu_resume(cpu);
- }
-}
-
static void cpu_common_realizefn(DeviceState *dev, Error **errp)
{
cpu_exec_realize(CPU(dev), errp);
diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c
index 8a9f2fcea84..a64e8c2b687 100644
--- a/hw/core/cpu-system.c
+++ b/hw/core/cpu-system.c
@@ -25,10 +25,12 @@
#include "exec/target_page.h"
#include "system/memory.h"
#include "qemu/target-info.h"
+#include "hw/core/boards.h"
#include "hw/core/qdev.h"
#include "hw/core/qdev-properties.h"
#include "hw/core/sysemu-cpu-ops.h"
#include "migration/vmstate.h"
+#include "system/hw_accel.h"
#include "system/tcg.h"
#include "cpu-internal.h"
@@ -221,6 +223,31 @@ static int cpu_common_pre_load(void *opaque)
return 0;
}
+void cpu_exec_realize(CPUState *cpu, Error **errp)
+{
+ Object *machine = qdev_get_machine();
+
+ /*
+ * qdev_get_machine() can return something that's not TYPE_MACHINE
+ * if this is one of the user-only emulators; in that case there's
+ * no need to check the ignore_memory_transaction_failures board flag.
+ */
+ if (object_dynamic_cast(machine, TYPE_MACHINE)) {
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
+
+ if (mc) {
+ cpu->ignore_memory_transaction_failures =
+ mc->ignore_memory_transaction_failures;
+ }
+ }
+
+ if (DEVICE(cpu)->hotplugged) {
+ cpu_synchronize_post_init(cpu);
+ cpu_resume(cpu);
+ }
+
+}
+
static bool cpu_common_exception_index_needed(void *opaque)
{
CPUState *cpu = opaque;
diff --git a/hw/core/cpu-user.c b/hw/core/cpu-user.c
index c2cb00a85d3..1e38c88f9bd 100644
--- a/hw/core/cpu-user.c
+++ b/hw/core/cpu-user.c
@@ -38,6 +38,11 @@ void cpu_exec_init(CPUState *cpu)
/* nothing to do */
}
+void cpu_exec_realize(CPUState *cpu, Error **errp)
+{
+ /* nothing to do */
+}
+
void cpu_vmstate_register(CPUState *cpu)
{
assert(qdev_get_vmsd(DEVICE(cpu)) == NULL ||
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 29/56] hw/nmi: Use object_child_foreach_recursive() in nmi_children()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (27 preceding siblings ...)
2026-08-16 14:45 ` [PULL 28/56] hw/cpu: Move system-specific cpu_exec_realize() to cpu-system.c Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 30/56] hw/s390x/virtio-ccw: Always inject NMI to first CPU Philippe Mathieu-Daudé
` (27 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Replace object_child_foreach() and recursion by a single
object_child_foreach_recursive() call.
Propagate the returned value so callers can check it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812121232.71958-2-philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/core/nmi.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/hw/core/nmi.c b/hw/core/nmi.c
index 4b447e126ba..22724046575 100644
--- a/hw/core/nmi.c
+++ b/hw/core/nmi.c
@@ -31,8 +31,6 @@ struct do_nmi_s {
bool handled;
};
-static void nmi_children(Object *o, struct do_nmi_s *ns);
-
static int do_nmi(Object *o, void *opaque)
{
struct do_nmi_s *ns = opaque;
@@ -47,14 +45,13 @@ static int do_nmi(Object *o, void *opaque)
return -1;
}
}
- nmi_children(o, ns);
return 0;
}
-static void nmi_children(Object *o, struct do_nmi_s *ns)
+static int nmi_children(Object *o, struct do_nmi_s *ns)
{
- object_child_foreach(o, do_nmi, ns);
+ return object_child_foreach_recursive(o, do_nmi, ns);
}
void nmi_monitor_handle(int cpu_index, Error **errp)
@@ -65,10 +62,9 @@ void nmi_monitor_handle(int cpu_index, Error **errp)
.handled = false
};
- nmi_children(object_get_root(), &ns);
- if (ns.handled) {
+ if (nmi_children(object_get_root(), &ns)) {
error_propagate(errp, ns.err);
- } else {
+ } else if (!ns.handled) {
error_setg(errp, "machine does not provide NMIs");
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 30/56] hw/s390x/virtio-ccw: Always inject NMI to first CPU
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (28 preceding siblings ...)
2026-08-16 14:45 ` [PULL 29/56] hw/nmi: Use object_child_foreach_recursive() in nmi_children() Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 31/56] hw/nmi: Remove @cpu_index argument from NMIClass::nmi_monitor_handler() Philippe Mathieu-Daudé
` (26 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Philippe Mathieu-Daudé <philmd@linaro.org>
We can trigger NMI from HMP or QMP.
QEMU maps the NMI to the s390x per-CPU 'RESTART' interrupt.
Linux guests usually setup this interrupt to trigger kdump
or crash. Such crashdump can be triggered in QEMU by HMP
"nmi" or QMP "inject-nmi" commands.
Using QMP, since we can not select a particular CPU, the first
CPU is used (CPU#0). See the documentation from commit 795dc6e4
("watchdog: Add new Virtual Watchdog action INJECT-NMI"):
@inject-nmi: a non-maskable interrupt is injected into the
first VCPU (all VCPUS on x86) (since 2.4)
While we can select a particular CPU on HMP, the guest behavior
is expected to be the same if using CPU #N or CPU #0. Since
always using CPU#0 simplifies API maintenance , update s390_nmi()
to inject NMI to the first CPU.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812121232.71958-3-philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
qapi/machine.json | 7 ++++---
qapi/run-state.json | 6 ++++--
hw/s390x/s390-virtio-ccw.c | 4 +---
hmp-commands.hx | 5 +++--
4 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/qapi/machine.json b/qapi/machine.json
index 9b2248038fc..2d63c1bac3b 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -432,9 +432,10 @@
##
# @inject-nmi:
#
-# Injects a Non-Maskable Interrupt into the default CPU (x86/s390) or
-# all CPUs (ppc64). The command fails when the guest doesn't support
-# injecting.
+# Injects a Non-Maskable Interrupt (machine specific: for example on
+# s390x CCW only the first vCPU receives the NMI, but on x86 machines
+# all vCPUs receive it). The command fails when the guest doesn't
+# support injecting.
#
# Since: 0.14
#
diff --git a/qapi/run-state.json b/qapi/run-state.json
index a5771ad4681..e4fdead1e0b 100644
--- a/qapi/run-state.json
+++ b/qapi/run-state.json
@@ -317,8 +317,10 @@
#
# @none: nothing is done
#
-# @inject-nmi: a non-maskable interrupt is injected into the first
-# VCPU (all VCPUS on x86) (since 2.4)
+# @inject-nmi: a non-maskable interrupt is injected (machine
+# specific: for example on s390x CCW only the first vCPU
+# receives the NMI, but on x86 machines all vCPUs receive
+# it). (since 2.4)
#
# Since: 2.1
##
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 55131c1a444..a2f373b1190 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -727,9 +727,7 @@ static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
static void s390_nmi(NMIState *n, int cpu_index, Error **errp)
{
- CPUState *cs = qemu_get_cpu(cpu_index);
-
- s390_cpu_restart(S390_CPU(cs));
+ s390_cpu_restart(S390_CPU(first_cpu));
}
static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 7f43cf537fc..a29f02b623e 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -865,12 +865,13 @@ ERST
.name = "nmi",
.args_type = "",
.params = "",
- .help = "inject an NMI",
+ .help = "Inject an NMI, in a machine-specific way",
.cmd = hmp_nmi,
},
SRST
``nmi`` *cpu*
- Inject an NMI on the default CPU (x86/s390) or all CPUs (ppc64).
+ Inject an NMI, in a machine-specific way.
+ Not all machines implement NMI handling.
ERST
{
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 31/56] hw/nmi: Remove @cpu_index argument from NMIClass::nmi_monitor_handler()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (29 preceding siblings ...)
2026-08-16 14:45 ` [PULL 30/56] hw/s390x/virtio-ccw: Always inject NMI to first CPU Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 32/56] hw/nmi: Remove @cpu_index argument from nmi_inject() Philippe Mathieu-Daudé
` (25 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Only s390x was using the 'cpu_index' argument, but since the
previous commit it isn't anymore (it use the first cpu).
Since this argument is now completely unused, remove it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812121232.71958-4-philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
include/hw/core/nmi.h | 8 +++++++-
hw/core/nmi.c | 2 +-
hw/hppa/machine.c | 2 +-
hw/i386/x86.c | 2 +-
hw/intc/m68k_irqc.c | 2 +-
hw/m68k/q800-glue.c | 2 +-
hw/misc/macio/gpio.c | 2 +-
hw/ppc/pnv.c | 2 +-
hw/ppc/spapr.c | 2 +-
hw/s390x/s390-virtio-ccw.c | 2 +-
10 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/include/hw/core/nmi.h b/include/hw/core/nmi.h
index fff41bebc69..4c4ce79071d 100644
--- a/include/hw/core/nmi.h
+++ b/include/hw/core/nmi.h
@@ -37,7 +37,13 @@ typedef struct NMIState NMIState;
struct NMIClass {
InterfaceClass parent_class;
- void (*nmi_monitor_handler)(NMIState *n, int cpu_index, Error **errp);
+ /**
+ * nmi_monitor_handler: Callback to handle NMI notifications.
+ *
+ * @ns: Class #NMIState state
+ * @errp: pointer to error object
+ */
+ void (*nmi_monitor_handler)(NMIState *ns, Error **errp);
};
void nmi_monitor_handle(int cpu_index, Error **errp);
diff --git a/hw/core/nmi.c b/hw/core/nmi.c
index 22724046575..ff6454437c1 100644
--- a/hw/core/nmi.c
+++ b/hw/core/nmi.c
@@ -40,7 +40,7 @@ static int do_nmi(Object *o, void *opaque)
NMIClass *nc = NMI_GET_CLASS(n);
ns->handled = true;
- nc->nmi_monitor_handler(n, ns->cpu_index, &ns->err);
+ nc->nmi_monitor_handler(n, &ns->err);
if (ns->err) {
return -1;
}
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index d762163ddf5..2b44debc388 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -829,7 +829,7 @@ static void hppa_machine_reset(MachineState *ms, ResetType type)
cpu[0]->env.cmdline_or_bootorder = 'c';
}
-static void hppa_nmi(NMIState *n, int cpu_index, Error **errp)
+static void hppa_nmi(NMIState *ns, Error **errp)
{
CPUState *cs;
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index dc7f0d56b01..0ea5453403d 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -147,7 +147,7 @@ static const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms)
return ms->possible_cpus;
}
-static void x86_nmi(NMIState *n, int cpu_index, Error **errp)
+static void x86_nmi(NMIState *ns, Error **errp)
{
/* cpu index isn't used */
CPUState *cs;
diff --git a/hw/intc/m68k_irqc.c b/hw/intc/m68k_irqc.c
index 68ddb5351be..bc41b44d455 100644
--- a/hw/intc/m68k_irqc.c
+++ b/hw/intc/m68k_irqc.c
@@ -70,7 +70,7 @@ static void m68k_irqc_instance_init(Object *obj)
qdev_init_gpio_in(DEVICE(obj), m68k_set_irq, M68K_IRQC_LEVEL_NUM);
}
-static void m68k_nmi(NMIState *n, int cpu_index, Error **errp)
+static void m68k_nmi(NMIState *n, Error **errp)
{
m68k_set_irq(n, M68K_IRQC_LEVEL_7, 1);
}
diff --git a/hw/m68k/q800-glue.c b/hw/m68k/q800-glue.c
index ac9062c6488..b13e5ef95f1 100644
--- a/hw/m68k/q800-glue.c
+++ b/hw/m68k/q800-glue.c
@@ -159,7 +159,7 @@ static void glue_auxmode_set_irq(void *opaque, int irq, int level)
s->auxmode = level;
}
-static void glue_nmi(NMIState *n, int cpu_index, Error **errp)
+static void glue_nmi(NMIState *n, Error **errp)
{
GLUEState *s = GLUE(n);
diff --git a/hw/misc/macio/gpio.c b/hw/misc/macio/gpio.c
index 1a7c534d652..1bdca728f97 100644
--- a/hw/misc/macio/gpio.c
+++ b/hw/misc/macio/gpio.c
@@ -188,7 +188,7 @@ static void macio_gpio_reset(DeviceState *dev)
macio_set_gpio(s, 1, true);
}
-static void macio_gpio_nmi(NMIState *n, int cpu_index, Error **errp)
+static void macio_gpio_nmi(NMIState *n, Error **errp)
{
macio_set_gpio(MACIO_GPIO(n), 9, true);
macio_set_gpio(MACIO_GPIO(n), 9, false);
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index c0cb45dbfbc..8676be7bbb1 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -3552,7 +3552,7 @@ static void pnv_cpu_do_nmi(PnvChip *chip, PowerPCCPU *cpu, void *opaque)
async_run_on_cpu(CPU(cpu), pnv_cpu_do_nmi_on_cpu, RUN_ON_CPU_HOST_INT(0));
}
-static void pnv_nmi(NMIState *n, int cpu_index, Error **errp)
+static void pnv_nmi(NMIState *ns, Error **errp)
{
PnvMachineState *pnv = PNV_MACHINE(qdev_get_machine());
int i;
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 7e284edd7d0..c376a588720 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3550,7 +3550,7 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg)
}
}
-static void spapr_nmi(NMIState *n, int cpu_index, Error **errp)
+static void spapr_nmi(NMIState *ns, Error **errp)
{
CPUState *cs;
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index a2f373b1190..ac04245d65b 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -725,7 +725,7 @@ static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
return NULL;
}
-static void s390_nmi(NMIState *n, int cpu_index, Error **errp)
+static void s390_nmi(NMIState *ns, Error **errp)
{
s390_cpu_restart(S390_CPU(first_cpu));
}
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 32/56] hw/nmi: Remove @cpu_index argument from nmi_inject()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (30 preceding siblings ...)
2026-08-16 14:45 ` [PULL 31/56] hw/nmi: Remove @cpu_index argument from NMIClass::nmi_monitor_handler() Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 33/56] hw/nmi: Rename nmi_monitor_handler() -> raise_nmi() Philippe Mathieu-Daudé
` (24 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Philippe Mathieu-Daudé <philmd@linaro.org>
nmi_monitor_handle() is not related to the monitor, rename
it as nmi_inject().
Return a boolean value indicating success / failure as
recommended by the Error API since commit e3fe3988d7
("error: Document Error API usage rules").
The 'cpu_index' argument is not used, remove it.
This officially drops the current CPU for HMP command.
Document nmi_inject() as suggested by Peter Maydell in
https://lore.kernel.org/qemu-devel/CAFEAcA-yALySmCJLbitCmYpiZKUXJNOavGJG9RYeo8fKqz7gcw@mail.gmail.com/.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-Id: <20260812121232.71958-5-philmd@oss.qualcomm.com>
---
include/hw/core/nmi.h | 24 +++++++++++++++++++++++-
hw/core/nmi.c | 9 ++++-----
hw/ipmi/ipmi.c | 3 +--
hw/watchdog/watchdog.c | 2 +-
system/cpus.c | 3 +--
hmp-commands.hx | 2 +-
6 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/include/hw/core/nmi.h b/include/hw/core/nmi.h
index 4c4ce79071d..851be28257e 100644
--- a/include/hw/core/nmi.h
+++ b/include/hw/core/nmi.h
@@ -46,6 +46,28 @@ struct NMIClass {
void (*nmi_monitor_handler)(NMIState *ns, Error **errp);
};
-void nmi_monitor_handle(int cpu_index, Error **errp);
+/**
+ * nmi_inject: Inject an NMI, in a machine-specific way
+ * @errp: pointer to error object
+ *
+ * This function injects an NMI, in a machine-specific way. The
+ * intention is that this should typically trigger a guest kernel
+ * dump or reboot, and might happen as a result of user request
+ * from the monitor, watchdog timeouts, and similar events.
+ * (For example on the x86 PC it triggers an NMI on all CPUs,
+ * and on s390 it triggers the RESTART interrupt on the first CPU.)
+ *
+ * The NMI is injected by looking for a QOM object which implements
+ * the TYPE_NMI interface, and calling its nmi_monitor_handler method. Usually
+ * it is the machine model class that implements this interface.
+ *
+ * Not all machines implement NMI handling; this function
+ * will return an error if used on a machine which does not
+ * implement NMIs.
+ *
+ * On success, return %true.
+ * On failure, store an error through @errp and return %false.
+ */
+bool nmi_inject(Error **errp);
#endif /* NMI_H */
diff --git a/hw/core/nmi.c b/hw/core/nmi.c
index ff6454437c1..2d890f2995d 100644
--- a/hw/core/nmi.c
+++ b/hw/core/nmi.c
@@ -22,11 +22,8 @@
#include "qemu/osdep.h"
#include "hw/core/nmi.h"
#include "qapi/error.h"
-#include "qemu/module.h"
-#include "monitor/monitor.h"
struct do_nmi_s {
- int cpu_index;
Error *err;
bool handled;
};
@@ -54,19 +51,21 @@ static int nmi_children(Object *o, struct do_nmi_s *ns)
return object_child_foreach_recursive(o, do_nmi, ns);
}
-void nmi_monitor_handle(int cpu_index, Error **errp)
+bool nmi_inject(Error **errp)
{
struct do_nmi_s ns = {
- .cpu_index = cpu_index,
.err = NULL,
.handled = false
};
if (nmi_children(object_get_root(), &ns)) {
error_propagate(errp, ns.err);
+ return false;
} else if (!ns.handled) {
error_setg(errp, "machine does not provide NMIs");
+ return false;
}
+ return true;
}
static const TypeInfo nmi_info = {
diff --git a/hw/ipmi/ipmi.c b/hw/ipmi/ipmi.c
index 74818ff3cea..dedf23cb997 100644
--- a/hw/ipmi/ipmi.c
+++ b/hw/ipmi/ipmi.c
@@ -59,8 +59,7 @@ static int ipmi_do_hw_op(IPMIInterface *s, enum ipmi_op op, int checkonly)
if (checkonly) {
return 0;
}
- /* We don't care what CPU we use. */
- nmi_monitor_handle(0, NULL);
+ nmi_inject(NULL);
return 0;
case IPMI_SHUTDOWN_VIA_ACPI_OVERTEMP:
diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c
index 0842fe373ae..5f764a0c1b8 100644
--- a/hw/watchdog/watchdog.c
+++ b/hw/watchdog/watchdog.c
@@ -81,7 +81,7 @@ void watchdog_perform_action(void)
case WATCHDOG_ACTION_INJECT_NMI:
qapi_event_send_watchdog(WATCHDOG_ACTION_INJECT_NMI);
- nmi_monitor_handle(0, NULL);
+ nmi_inject(NULL);
break;
default:
diff --git a/system/cpus.c b/system/cpus.c
index 97e5a5edee2..9758cda4636 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -23,7 +23,6 @@
*/
#include "qemu/osdep.h"
-#include "monitor/monitor.h"
#include "qemu/coroutine-tls.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-machine.h"
@@ -926,6 +925,6 @@ exit:
void qmp_inject_nmi(Error **errp)
{
- nmi_monitor_handle(monitor_get_cpu_index(monitor_cur()), errp);
+ nmi_inject(errp);
}
diff --git a/hmp-commands.hx b/hmp-commands.hx
index a29f02b623e..43ff220b5fe 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -869,7 +869,7 @@ ERST
.cmd = hmp_nmi,
},
SRST
-``nmi`` *cpu*
+``nmi``
Inject an NMI, in a machine-specific way.
Not all machines implement NMI handling.
ERST
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 33/56] hw/nmi: Rename nmi_monitor_handler() -> raise_nmi()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (31 preceding siblings ...)
2026-08-16 14:45 ` [PULL 32/56] hw/nmi: Remove @cpu_index argument from nmi_inject() Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 34/56] hw/nmi: Remove unused @errp argument from raise_nmi() Philippe Mathieu-Daudé
` (23 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
nmi_monitor_handler() is not related to the monitor,
rename it as raise_nmi().
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812121232.71958-6-philmd@oss.qualcomm.com>
---
include/hw/core/nmi.h | 10 ++++++----
hw/core/nmi.c | 2 +-
hw/hppa/machine.c | 2 +-
hw/i386/x86.c | 2 +-
hw/intc/m68k_irqc.c | 2 +-
hw/m68k/q800-glue.c | 2 +-
hw/misc/macio/gpio.c | 2 +-
hw/ppc/pnv.c | 2 +-
hw/ppc/spapr.c | 2 +-
hw/s390x/s390-virtio-ccw.c | 2 +-
10 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/include/hw/core/nmi.h b/include/hw/core/nmi.h
index 851be28257e..a8feac3b67e 100644
--- a/include/hw/core/nmi.h
+++ b/include/hw/core/nmi.h
@@ -38,12 +38,14 @@ struct NMIClass {
InterfaceClass parent_class;
/**
- * nmi_monitor_handler: Callback to handle NMI notifications.
- *
+ * raise_nmi: Callback to handle NMI notifications.
* @ns: Class #NMIState state
* @errp: pointer to error object
+ *
+ * Called by nmi_inject() to perform the machine-specific
+ * action when a NMI is requested.
*/
- void (*nmi_monitor_handler)(NMIState *ns, Error **errp);
+ void (*raise_nmi)(NMIState *ns, Error **errp);
};
/**
@@ -58,7 +60,7 @@ struct NMIClass {
* and on s390 it triggers the RESTART interrupt on the first CPU.)
*
* The NMI is injected by looking for a QOM object which implements
- * the TYPE_NMI interface, and calling its nmi_monitor_handler method. Usually
+ * the TYPE_NMI interface, and calling its raise_nmi method. Usually
* it is the machine model class that implements this interface.
*
* Not all machines implement NMI handling; this function
diff --git a/hw/core/nmi.c b/hw/core/nmi.c
index 2d890f2995d..a6edf4fbf01 100644
--- a/hw/core/nmi.c
+++ b/hw/core/nmi.c
@@ -37,7 +37,7 @@ static int do_nmi(Object *o, void *opaque)
NMIClass *nc = NMI_GET_CLASS(n);
ns->handled = true;
- nc->nmi_monitor_handler(n, &ns->err);
+ nc->raise_nmi(n, &ns->err);
if (ns->err) {
return -1;
}
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 2b44debc388..717cfde61da 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -851,7 +851,7 @@ static void hppa_machine_common_class_init(ObjectClass *oc, const void *data)
mc->default_ram_id = "hppa.ram";
mc->default_nic = "tulip";
- nc->nmi_monitor_handler = hppa_nmi;
+ nc->raise_nmi = hppa_nmi;
}
static void HP_B160L_machine_init_class_init(ObjectClass *oc, const void *data)
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 0ea5453403d..d1414ff63db 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -389,7 +389,7 @@ static void x86_machine_class_init(ObjectClass *oc, const void *data)
mc->get_default_cpu_node_id = x86_get_default_cpu_node_id;
mc->possible_cpu_arch_ids = x86_possible_cpu_arch_ids;
mc->kvm_type = x86_kvm_type;
- nc->nmi_monitor_handler = x86_nmi;
+ nc->raise_nmi = x86_nmi;
object_class_property_add(oc, X86_MACHINE_SMM, "OnOffAuto",
x86_machine_get_smm, x86_machine_set_smm,
diff --git a/hw/intc/m68k_irqc.c b/hw/intc/m68k_irqc.c
index bc41b44d455..29f758dafd1 100644
--- a/hw/intc/m68k_irqc.c
+++ b/hw/intc/m68k_irqc.c
@@ -97,7 +97,7 @@ static void m68k_irqc_class_init(ObjectClass *oc, const void *data)
InterruptStatsProviderClass *ic = INTERRUPT_STATS_PROVIDER_CLASS(oc);
device_class_set_props(dc, m68k_irqc_properties);
- nc->nmi_monitor_handler = m68k_nmi;
+ nc->raise_nmi = m68k_nmi;
device_class_set_legacy_reset(dc, m68k_irqc_reset);
dc->vmsd = &vmstate_m68k_irqc;
ic->get_statistics = m68k_irqc_get_statistics;
diff --git a/hw/m68k/q800-glue.c b/hw/m68k/q800-glue.c
index b13e5ef95f1..265af90a8e6 100644
--- a/hw/m68k/q800-glue.c
+++ b/hw/m68k/q800-glue.c
@@ -237,7 +237,7 @@ static void glue_class_init(ObjectClass *klass, const void *data)
dc->vmsd = &vmstate_glue;
device_class_set_props(dc, glue_properties);
rc->phases.hold = glue_reset_hold;
- nc->nmi_monitor_handler = glue_nmi;
+ nc->raise_nmi = glue_nmi;
}
static const TypeInfo glue_info_types[] = {
diff --git a/hw/misc/macio/gpio.c b/hw/misc/macio/gpio.c
index 1bdca728f97..db0c4ecb3cf 100644
--- a/hw/misc/macio/gpio.c
+++ b/hw/misc/macio/gpio.c
@@ -201,7 +201,7 @@ static void macio_gpio_class_init(ObjectClass *oc, const void *data)
device_class_set_legacy_reset(dc, macio_gpio_reset);
dc->vmsd = &vmstate_macio_gpio;
- nc->nmi_monitor_handler = macio_gpio_nmi;
+ nc->raise_nmi = macio_gpio_nmi;
}
static const TypeInfo macio_gpio_init_info = {
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 8676be7bbb1..a9f74245866 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -3583,7 +3583,7 @@ static void pnv_machine_class_init(ObjectClass *oc, const void *data)
mc->default_ram_size = 1 * GiB;
mc->default_ram_id = "pnv.ram";
ispc->print_info = pnv_pic_print_info;
- nc->nmi_monitor_handler = pnv_nmi;
+ nc->raise_nmi = pnv_nmi;
object_class_property_add_bool(oc, "hb-mode",
pnv_machine_get_hb, pnv_machine_set_hb);
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index c376a588720..1bc90ceed35 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -4652,7 +4652,7 @@ static void spapr_machine_class_init(ObjectClass *oc, const void *data)
mc->nvdimm_supported = true;
smc->resize_hpt_default = SPAPR_RESIZE_HPT_ENABLED;
fwc->get_dev_path = spapr_get_fw_dev_path;
- nc->nmi_monitor_handler = spapr_nmi;
+ nc->raise_nmi = spapr_nmi;
vhc->cpu_in_nested = spapr_cpu_in_nested;
vhc->deliver_hv_excp = spapr_exit_nested;
vhc->hypercall = emulate_spapr_hypercall;
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index ac04245d65b..21d9f51ddcc 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -830,7 +830,7 @@ static void ccw_machine_class_init(ObjectClass *oc, const void *data)
hc->plug = s390_machine_device_plug;
hc->unplug_request = s390_machine_device_unplug_request;
hc->unplug = s390_machine_device_unplug;
- nc->nmi_monitor_handler = s390_nmi;
+ nc->raise_nmi = s390_nmi;
mc->default_ram_id = "s390.ram";
mc->default_nic = "virtio-net-ccw";
dsi->qmp_dump_skeys = s390_qmp_dump_skeys;
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 34/56] hw/nmi: Remove unused @errp argument from raise_nmi()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (32 preceding siblings ...)
2026-08-16 14:45 ` [PULL 33/56] hw/nmi: Rename nmi_monitor_handler() -> raise_nmi() Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 35/56] hw/nmi: Raise NMI line only once Philippe Mathieu-Daudé
` (22 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
Not a single handler update @errp. The single user is
nmi_inject() filling with "machine does not provide NMIs".
Remove the unused argument from the raise_nmi() callback,
simplifying the methods in hw/core/nmi.c.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812121232.71958-7-philmd@oss.qualcomm.com>
---
include/hw/core/nmi.h | 3 +--
hw/core/nmi.c | 32 ++++++--------------------------
hw/hppa/machine.c | 2 +-
hw/i386/x86.c | 2 +-
hw/intc/m68k_irqc.c | 2 +-
hw/m68k/q800-glue.c | 2 +-
hw/misc/macio/gpio.c | 2 +-
hw/ppc/pnv.c | 2 +-
hw/ppc/spapr.c | 2 +-
hw/s390x/s390-virtio-ccw.c | 2 +-
10 files changed, 15 insertions(+), 36 deletions(-)
diff --git a/include/hw/core/nmi.h b/include/hw/core/nmi.h
index a8feac3b67e..d71d92dfbb9 100644
--- a/include/hw/core/nmi.h
+++ b/include/hw/core/nmi.h
@@ -40,12 +40,11 @@ struct NMIClass {
/**
* raise_nmi: Callback to handle NMI notifications.
* @ns: Class #NMIState state
- * @errp: pointer to error object
*
* Called by nmi_inject() to perform the machine-specific
* action when a NMI is requested.
*/
- void (*raise_nmi)(NMIState *ns, Error **errp);
+ void (*raise_nmi)(NMIState *ns);
};
/**
diff --git a/hw/core/nmi.c b/hw/core/nmi.c
index a6edf4fbf01..c44b0cf892d 100644
--- a/hw/core/nmi.c
+++ b/hw/core/nmi.c
@@ -23,45 +23,25 @@
#include "hw/core/nmi.h"
#include "qapi/error.h"
-struct do_nmi_s {
- Error *err;
- bool handled;
-};
-
static int do_nmi(Object *o, void *opaque)
{
- struct do_nmi_s *ns = opaque;
+ bool *handled = opaque;
NMIState *n = (NMIState *) object_dynamic_cast(o, TYPE_NMI);
if (n) {
- NMIClass *nc = NMI_GET_CLASS(n);
-
- ns->handled = true;
- nc->raise_nmi(n, &ns->err);
- if (ns->err) {
- return -1;
- }
+ *handled = true;
+ NMI_GET_CLASS(n)->raise_nmi(n);
}
return 0;
}
-static int nmi_children(Object *o, struct do_nmi_s *ns)
-{
- return object_child_foreach_recursive(o, do_nmi, ns);
-}
-
bool nmi_inject(Error **errp)
{
- struct do_nmi_s ns = {
- .err = NULL,
- .handled = false
- };
+ bool handled = false;
- if (nmi_children(object_get_root(), &ns)) {
- error_propagate(errp, ns.err);
- return false;
- } else if (!ns.handled) {
+ object_child_foreach_recursive(object_get_root(), do_nmi, &handled);
+ if (!handled) {
error_setg(errp, "machine does not provide NMIs");
return false;
}
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 717cfde61da..98931481b20 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -829,7 +829,7 @@ static void hppa_machine_reset(MachineState *ms, ResetType type)
cpu[0]->env.cmdline_or_bootorder = 'c';
}
-static void hppa_nmi(NMIState *ns, Error **errp)
+static void hppa_nmi(NMIState *ns)
{
CPUState *cs;
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index d1414ff63db..f8ba3244e22 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -147,7 +147,7 @@ static const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms)
return ms->possible_cpus;
}
-static void x86_nmi(NMIState *ns, Error **errp)
+static void x86_nmi(NMIState *ns)
{
/* cpu index isn't used */
CPUState *cs;
diff --git a/hw/intc/m68k_irqc.c b/hw/intc/m68k_irqc.c
index 29f758dafd1..47f626c0fa0 100644
--- a/hw/intc/m68k_irqc.c
+++ b/hw/intc/m68k_irqc.c
@@ -70,7 +70,7 @@ static void m68k_irqc_instance_init(Object *obj)
qdev_init_gpio_in(DEVICE(obj), m68k_set_irq, M68K_IRQC_LEVEL_NUM);
}
-static void m68k_nmi(NMIState *n, Error **errp)
+static void m68k_nmi(NMIState *n)
{
m68k_set_irq(n, M68K_IRQC_LEVEL_7, 1);
}
diff --git a/hw/m68k/q800-glue.c b/hw/m68k/q800-glue.c
index 265af90a8e6..223e7d9019c 100644
--- a/hw/m68k/q800-glue.c
+++ b/hw/m68k/q800-glue.c
@@ -159,7 +159,7 @@ static void glue_auxmode_set_irq(void *opaque, int irq, int level)
s->auxmode = level;
}
-static void glue_nmi(NMIState *n, Error **errp)
+static void glue_nmi(NMIState *n)
{
GLUEState *s = GLUE(n);
diff --git a/hw/misc/macio/gpio.c b/hw/misc/macio/gpio.c
index db0c4ecb3cf..ba001f7b206 100644
--- a/hw/misc/macio/gpio.c
+++ b/hw/misc/macio/gpio.c
@@ -188,7 +188,7 @@ static void macio_gpio_reset(DeviceState *dev)
macio_set_gpio(s, 1, true);
}
-static void macio_gpio_nmi(NMIState *n, Error **errp)
+static void macio_gpio_nmi(NMIState *n)
{
macio_set_gpio(MACIO_GPIO(n), 9, true);
macio_set_gpio(MACIO_GPIO(n), 9, false);
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index a9f74245866..f0413639f98 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -3552,7 +3552,7 @@ static void pnv_cpu_do_nmi(PnvChip *chip, PowerPCCPU *cpu, void *opaque)
async_run_on_cpu(CPU(cpu), pnv_cpu_do_nmi_on_cpu, RUN_ON_CPU_HOST_INT(0));
}
-static void pnv_nmi(NMIState *ns, Error **errp)
+static void pnv_nmi(NMIState *ns)
{
PnvMachineState *pnv = PNV_MACHINE(qdev_get_machine());
int i;
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 1bc90ceed35..20e024907b1 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3550,7 +3550,7 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg)
}
}
-static void spapr_nmi(NMIState *ns, Error **errp)
+static void spapr_nmi(NMIState *ns)
{
CPUState *cs;
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 21d9f51ddcc..06e5def9092 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -725,7 +725,7 @@ static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
return NULL;
}
-static void s390_nmi(NMIState *ns, Error **errp)
+static void s390_nmi(NMIState *ns)
{
s390_cpu_restart(S390_CPU(first_cpu));
}
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 35/56] hw/nmi: Raise NMI line only once
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (33 preceding siblings ...)
2026-08-16 14:45 ` [PULL 34/56] hw/nmi: Remove unused @errp argument from raise_nmi() Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 36/56] hexagon: Remove unnecessary 'monitor/monitor.h' header Philippe Mathieu-Daudé
` (21 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
We only expect one device in the system to implement the
TYPE_NMI interface (typically the machine, but in a few cases
for e.g. m68k and ppc this is an interrupt controller or
similar device); so we don't need to keep walking the whole
QOM tree once we've found it. As no machine type creates more
than one object implementing TYPE_NMI, this is not a behaviour
change.
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812121232.71958-8-philmd@oss.qualcomm.com>
---
hw/core/nmi.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/core/nmi.c b/hw/core/nmi.c
index c44b0cf892d..84f21665987 100644
--- a/hw/core/nmi.c
+++ b/hw/core/nmi.c
@@ -31,6 +31,11 @@ static int do_nmi(Object *o, void *opaque)
if (n) {
*handled = true;
NMI_GET_CLASS(n)->raise_nmi(n);
+ /*
+ * We expect only one object to implement TYPE_NMI, so once
+ * we've asked it to deliver the NMI we can stop looking.
+ */
+ return 1;
}
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 36/56] hexagon: Remove unnecessary 'monitor/monitor.h' header
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (34 preceding siblings ...)
2026-08-16 14:45 ` [PULL 35/56] hw/nmi: Raise NMI line only once Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 37/56] net/vhost-vdpa: Include missing 'qemu/iov.h' header Philippe Mathieu-Daudé
` (20 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
The Monitor type is used in these 2 files, as a pointer.
Since the type is forward-declared in "qemu/typedefs.h",
which all source files include via "qemu/osdep.h", we do
not need to include it.
Do however include "exec/hwaddr.h" and "exec/mmu-access-type.h"
which declare the types used by hex_tlb_find_match prototype:
extern bool hex_tlb_find_match(CPUHexagonState *env, uint32_t VA,
MMUAccessType access_type, hwaddr *PA, int *prot,
^^^^^^^^^^^^^ ^^^^^^
uint64_t *size, int32_t *excp, int mmu_idx);
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-2-philmd@oss.qualcomm.com>
---
include/hw/hexagon/hexagon_tlb.h | 2 +-
target/hexagon/hex_mmu.h | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/hw/hexagon/hexagon_tlb.h b/include/hw/hexagon/hexagon_tlb.h
index 90d9ed84043..760dc1ea811 100644
--- a/include/hw/hexagon/hexagon_tlb.h
+++ b/include/hw/hexagon/hexagon_tlb.h
@@ -12,7 +12,7 @@
#include "qom/object.h"
#include "exec/hwaddr.h"
#include "exec/mmu-access-type.h"
-#include "monitor/monitor.h"
+
#define TYPE_HEXAGON_TLB "hexagon-tlb"
OBJECT_DECLARE_SIMPLE_TYPE(HexagonTLBState, HEXAGON_TLB)
diff --git a/target/hexagon/hex_mmu.h b/target/hexagon/hex_mmu.h
index 4f556c715a9..6aa450b9413 100644
--- a/target/hexagon/hex_mmu.h
+++ b/target/hexagon/hex_mmu.h
@@ -7,8 +7,9 @@
#ifndef HEXAGON_MMU_H
#define HEXAGON_MMU_H
+#include "exec/hwaddr.h"
+#include "exec/mmu-access-type.h"
#include "cpu.h"
-#include "monitor/monitor.h"
extern void hex_tlbw(CPUHexagonState *env, uint32_t index, uint64_t value);
extern uint32_t hex_tlb_lookup(CPUHexagonState *env, uint32_t ssr, uint32_t VA);
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 37/56] net/vhost-vdpa: Include missing 'qemu/iov.h' header
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (35 preceding siblings ...)
2026-08-16 14:45 ` [PULL 36/56] hexagon: Remove unnecessary 'monitor/monitor.h' header Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 38/56] tests/unit: Include 'qemu/main-loop.h' header in test-util-sockets.c Philippe Mathieu-Daudé
` (19 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
vhost-vdpa.c uses methods declared in the "qemu/iov." header.
Include it otherwise we get when refactoring unrelated headers:
../net/vhost-vdpa.c: In function ‘vhost_vdpa_net_load_cmd’:
../net/vhost-vdpa.c:714:24: error: implicit declaration of function ‘iov_size’
714 | size_t data_size = iov_size(data_sg, data_num), cmd_size;
| ^~~~~~~~
../net/vhost-vdpa.c:714:24: error: nested extern declaration of ‘iov_size’
../net/vhost-vdpa.c:742:5: error: implicit declaration of function ‘iov_from_buf’
742 | iov_from_buf(out_cursor, 1, 0, &ctrl, sizeof(ctrl));
| ^~~~~~~~~~~~
../net/vhost-vdpa.c:742:5: error: nested extern declaration of ‘iov_from_buf’
../net/vhost-vdpa.c:744:5: error: implicit declaration of function ‘iov_to_buf’
744 | iov_to_buf(data_sg, data_num, 0,
| ^~~~~~~~~~
../net/vhost-vdpa.c:744:5: error: nested extern declaration of ‘iov_to_buf’
../net/vhost-vdpa.c:748:5: error: implicit declaration of function ‘iov_copy’
748 | iov_copy(&out, 1, out_cursor, 1, 0, cmd_size);
| ^~~~~~~~
Fixes: bd907ae4b00 ("vdpa: manual forward CVQ buffers")
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-3-philmd@oss.qualcomm.com>
---
net/vhost-vdpa.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index c526c2b2dc0..1052361a4ab 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -17,6 +17,7 @@
#include "hw/virtio/vhost-vdpa.h"
#include "qemu/config-file.h"
#include "qemu/error-report.h"
+#include "qemu/iov.h"
#include "qemu/log.h"
#include "qemu/memalign.h"
#include "qemu/option.h"
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 38/56] tests/unit: Include 'qemu/main-loop.h' header in test-util-sockets.c
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (36 preceding siblings ...)
2026-08-16 14:45 ` [PULL 37/56] net/vhost-vdpa: Include missing 'qemu/iov.h' header Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 39/56] qapi/qmp-dispatch: Include 'qemu/aio-wait.h' and 'monitor/monitor.h' Philippe Mathieu-Daudé
` (18 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
test-util-sockets.c calls qemu_init_main_loop(), itself declared in
the "qemu/main-loop.h" header. Include the latter to avoid when
refactoring unrelated headers:
../tests/unit/test-util-sockets.c:553:5: error: call to undeclared function 'qemu_init_main_loop'
553 | qemu_init_main_loop(&error_abort);
| ^
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-4-philmd@oss.qualcomm.com>
---
tests/unit/test-util-sockets.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/unit/test-util-sockets.c b/tests/unit/test-util-sockets.c
index ee66d727c38..ab3f39c3efb 100644
--- a/tests/unit/test-util-sockets.c
+++ b/tests/unit/test-util-sockets.c
@@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/main-loop.h"
#include "qemu/sockets.h"
#include "qapi/error.h"
#include "socket-helpers.h"
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 39/56] qapi/qmp-dispatch: Include 'qemu/aio-wait.h' and 'monitor/monitor.h'
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (37 preceding siblings ...)
2026-08-16 14:45 ` [PULL 38/56] tests/unit: Include 'qemu/main-loop.h' header in test-util-sockets.c Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 40/56] qapi/qmp-registry: Remove unnecessary 'monitor/monitor.h' header Philippe Mathieu-Daudé
` (17 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
qmp-dispatch.c calls aio_wait_kick() and monitor_cur(). Include the
header declaring them in order to avoid the following build failure
when refactoring unrelated headers:
../qapi/qmp-dispatch.c:126:12: error: call to undeclared function 'monitor_cur'
126 | assert(monitor_cur() == NULL);
| ^
../qapi/qmp-dispatch.c:141:5: error: call to undeclared function 'aio_wait_kick'
141 | aio_wait_kick();
| ^
Fixes: 41725fa7eda ("qmp: Call monitor_set_cur() only in qmp_dispatch()")
Fixes: fc1a2ec7da5 ("monitor: Fix deadlock in monitor_cleanup")
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-5-philmd@oss.qualcomm.com>
---
qapi/qmp-dispatch.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
index e3897d51977..965cad64998 100644
--- a/qapi/qmp-dispatch.c
+++ b/qapi/qmp-dispatch.c
@@ -14,6 +14,7 @@
#include "qemu/osdep.h"
#include "qemu/aio.h"
+#include "qemu/aio-wait.h"
#include "qapi/compat-policy.h"
#include "qapi/error.h"
#include "qapi/qmp-registry.h"
@@ -24,6 +25,7 @@
#include "qobject/qbool.h"
#include "qemu/coroutine.h"
#include "qemu/main-loop.h"
+#include "monitor/monitor.h"
Visitor *qobject_input_visitor_new_qmp(QObject *obj)
{
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 40/56] qapi/qmp-registry: Remove unnecessary 'monitor/monitor.h' header
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (38 preceding siblings ...)
2026-08-16 14:45 ` [PULL 39/56] qapi/qmp-dispatch: Include 'qemu/aio-wait.h' and 'monitor/monitor.h' Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 41/56] migration/hmp-cmds: Include 'block/block-global-state.h' header Philippe Mathieu-Daudé
` (16 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-6-philmd@oss.qualcomm.com>
---
include/qapi/qmp-registry.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/include/qapi/qmp-registry.h b/include/qapi/qmp-registry.h
index e0ee1ad3ac6..6146306a3a1 100644
--- a/include/qapi/qmp-registry.h
+++ b/include/qapi/qmp-registry.h
@@ -14,7 +14,6 @@
#ifndef QAPI_QMP_DISPATCH_H
#define QAPI_QMP_DISPATCH_H
-#include "monitor/monitor.h"
#include "qemu/queue.h"
typedef void (QmpCommandFunc)(QDict *, QObject **, Error **);
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 41/56] migration/hmp-cmds: Include 'block/block-global-state.h' header
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (39 preceding siblings ...)
2026-08-16 14:45 ` [PULL 40/56] qapi/qmp-registry: Remove unnecessary 'monitor/monitor.h' header Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 42/56] monitor: Include missing 'qemu/aio-wait.h' header Philippe Mathieu-Daudé
` (15 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
migration-hmp-cmds.c uses types / methods declared in
"block/block-global-state.h". Include the latter otherwise
we get when refactoring unrelated headers:
../migration/migration-hmp-cmds.c:911:5: error: use of undeclared identifier 'BdrvNextIterator'
911 | BdrvNextIterator it;
| ^
../migration/migration-hmp-cmds.c:918:15: error: call to undeclared function 'bdrv_first'
918 | for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
| ^
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org>
Message-Id: <20260812211708.92824-7-philmd@oss.qualcomm.com>
---
migration/migration-hmp-cmds.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index b5eb27467cd..ad68fa23aa4 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -15,6 +15,7 @@
#include "qemu/osdep.h"
#include "block/qapi.h"
+#include "block/block-global-state.h"
#include "migration/snapshot.h"
#include "monitor/hmp.h"
#include "monitor/hmp-completion.h"
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 42/56] monitor: Include missing 'qemu/aio-wait.h' header
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (40 preceding siblings ...)
2026-08-16 14:45 ` [PULL 41/56] migration/hmp-cmds: Include 'block/block-global-state.h' header Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 43/56] monitor: Include missing 'qemu/lockable.h' header Philippe Mathieu-Daudé
` (14 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
Both monitor.c and qmp.c use types / methods declared in
"qemu/aio-wait.h". Include the latter to avoid the following
errors when refactoring unrelated headers:
../monitor/monitor.c:648:5: error: call to undeclared function 'AIO_WAIT_WHILE_UNLOCKED'
648 | AIO_WAIT_WHILE_UNLOCKED(NULL,
| ^
../monitor/qmp.c:792:9: error: call to undeclared function 'aio_wait_bh_oneshot'
792 | aio_wait_bh_oneshot(iothread_get_aio_context(mon_iothread),
| ^
Fixes: 9ce44e2ce26 ("qmp: Move dispatcher to a coroutine")
Fixes: a5df506e129 ("monitor: implement support for deleting QMP objects")
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-8-philmd@oss.qualcomm.com>
---
monitor/monitor.c | 1 +
monitor/qmp.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/monitor/monitor.c b/monitor/monitor.c
index ed195fd97bb..c75ae815343 100644
--- a/monitor/monitor.c
+++ b/monitor/monitor.c
@@ -30,6 +30,7 @@
#include "qapi/qapi-visit-control.h"
#include "qobject/qdict.h"
#include "qom/object_interfaces.h"
+#include "qemu/aio-wait.h"
#include "qemu/error-report.h"
#include "qemu/option.h"
#include "system/qtest.h"
diff --git a/monitor/qmp.c b/monitor/qmp.c
index 338d37cb7e5..6ae1098d39f 100644
--- a/monitor/qmp.c
+++ b/monitor/qmp.c
@@ -23,7 +23,7 @@
*/
#include "qemu/osdep.h"
-
+#include "qemu/aio-wait.h"
#include "chardev/char-io.h"
#include "monitor-internal.h"
#include "qapi/error.h"
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 43/56] monitor: Include missing 'qemu/lockable.h' header
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (41 preceding siblings ...)
2026-08-16 14:45 ` [PULL 42/56] monitor: Include missing 'qemu/aio-wait.h' header Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 44/56] monitor: Include missing 'qemu/coroutine-core.h' header Philippe Mathieu-Daudé
` (13 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
Files in monitor/ use the QEMU_LOCK_GUARD() macros, which
are declared in "qemu/lockable.h". Include the latter to
avoid when refactoring unrelated headers:
../monitor/fds.c:146:5: error: call to undeclared function 'QEMU_LOCK_GUARD'
146 | QEMU_LOCK_GUARD(&mon->mon_lock);
| ^
../monitor/monitor.c:176:5: error: call to undeclared function 'QEMU_LOCK_GUARD'
176 | QEMU_LOCK_GUARD(&mon->mon_lock);
| ^
../monitor/qmp.c:164:5: error: call to undeclared function 'WITH_QEMU_LOCK_GUARD'
164 | WITH_QEMU_LOCK_GUARD(&mon->mon_lock) {
| ^
Fixes: 0210c3b39be ("monitor: Use LOCK_GUARD macros")
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-9-philmd@oss.qualcomm.com>
---
monitor/fds.c | 1 +
monitor/monitor.c | 1 +
monitor/qmp.c | 1 +
3 files changed, 3 insertions(+)
diff --git a/monitor/fds.c b/monitor/fds.c
index cc35d2ec334..abe5f13487d 100644
--- a/monitor/fds.c
+++ b/monitor/fds.c
@@ -29,6 +29,7 @@
#include "qapi/qmp/qerror.h"
#include "qemu/ctype.h"
#include "qemu/cutils.h"
+#include "qemu/lockable.h"
#include "system/runstate.h"
/* file descriptors passed via SCM_RIGHTS */
diff --git a/monitor/monitor.c b/monitor/monitor.c
index c75ae815343..6af09f2f6ea 100644
--- a/monitor/monitor.c
+++ b/monitor/monitor.c
@@ -32,6 +32,7 @@
#include "qom/object_interfaces.h"
#include "qemu/aio-wait.h"
#include "qemu/error-report.h"
+#include "qemu/lockable.h"
#include "qemu/option.h"
#include "system/qtest.h"
#include "trace.h"
diff --git a/monitor/qmp.c b/monitor/qmp.c
index 6ae1098d39f..aec03157750 100644
--- a/monitor/qmp.c
+++ b/monitor/qmp.c
@@ -24,6 +24,7 @@
#include "qemu/osdep.h"
#include "qemu/aio-wait.h"
+#include "qemu/lockable.h"
#include "chardev/char-io.h"
#include "monitor-internal.h"
#include "qapi/error.h"
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 44/56] monitor: Include missing 'qemu/coroutine-core.h' header
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (42 preceding siblings ...)
2026-08-16 14:45 ` [PULL 43/56] monitor: Include missing 'qemu/lockable.h' header Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 45/56] monitor: Reduce inclusion of 'qapi/qapi-emit-events.h' header Philippe Mathieu-Daudé
` (12 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
"monitor/monitor.h" declares monitor_set_cur() which use the
'Coroutine' type, itself declared in "qemu/coroutine-core.h".
Include the latter to avoid when refactoring unrelated headers:
In file included from ../../target/sh4/monitor.c:26:
qemu/include/monitor/monitor.h:32:26: error: unknown type name 'Coroutine'
32 | Monitor *monitor_set_cur(Coroutine *co, Monitor *mon);
| ^
Fixes: e69ee454b5f ("monitor: Make current monitor a per-coroutine property")
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-10-philmd@oss.qualcomm.com>
---
include/monitor/monitor.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 890497b0d22..efdd2165aa9 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -4,6 +4,7 @@
#include "block/block.h"
#include "qapi/qapi-types-misc.h"
#include "qapi/qapi-emit-events.h"
+#include "qemu/coroutine-core.h"
#include "qemu/readline.h"
#include "exec/hwaddr.h"
#include "qom/object.h"
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 45/56] monitor: Reduce inclusion of 'qapi/qapi-emit-events.h' header
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (43 preceding siblings ...)
2026-08-16 14:45 ` [PULL 44/56] monitor: Include missing 'qemu/coroutine-core.h' header Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 46/56] monitor: Remove unnecessary 'block/block.h' header Philippe Mathieu-Daudé
` (11 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
"monitor/monitor.h" don't use anything declared in the generated
"qapi/qapi-emit-events.h" header.
However the "monitor/monitor-internal.h" do:
107 struct MonitorClass {
...
116 /*
117 * If non-NULL, the monitor is able to send event
118 * notifications back to the client
119 */
120 void (*emit_event)(Monitor *mon, QAPIEvent event, QDict *qdict);
^^^^^^^^^
Move the header inclusion to "monitor/monitor-internal.h" to
avoid including / re-exposing unnecessary declarations in the
global "monitor/monitor.h" header.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-11-philmd@oss.qualcomm.com>
---
include/monitor/monitor.h | 1 -
monitor/monitor-internal.h | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index efdd2165aa9..fa9f4a8a75a 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -3,7 +3,6 @@
#include "block/block.h"
#include "qapi/qapi-types-misc.h"
-#include "qapi/qapi-emit-events.h"
#include "qemu/coroutine-core.h"
#include "qemu/readline.h"
#include "exec/hwaddr.h"
diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
index 23829f32f9a..bc0932c425a 100644
--- a/monitor/monitor-internal.h
+++ b/monitor/monitor-internal.h
@@ -27,6 +27,7 @@
#include "chardev/char-fe.h"
#include "monitor/monitor.h"
+#include "qapi/qapi-emit-events.h"
#include "qapi/qapi-types-control.h"
#include "qapi/qapi-types-qom.h"
#include "qapi/qmp-registry.h"
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 46/56] monitor: Remove unnecessary 'block/block.h' header
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (44 preceding siblings ...)
2026-08-16 14:45 ` [PULL 45/56] monitor: Reduce inclusion of 'qapi/qapi-emit-events.h' header Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 47/56] system: Remove unnecessary 'monitor/monitor.h' header Philippe Mathieu-Daudé
` (10 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
Nothing here requires declarations from "block/block.h" anymore.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-12-philmd@oss.qualcomm.com>
---
include/monitor/monitor.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index fa9f4a8a75a..fd98ee2c71d 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -1,7 +1,6 @@
#ifndef MONITOR_H
#define MONITOR_H
-#include "block/block.h"
#include "qapi/qapi-types-misc.h"
#include "qemu/coroutine-core.h"
#include "qemu/readline.h"
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 47/56] system: Remove unnecessary 'monitor/monitor.h' header
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (45 preceding siblings ...)
2026-08-16 14:45 ` [PULL 46/56] monitor: Remove unnecessary 'block/block.h' header Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 48/56] system/dirtylimit: Extract HMP code to dirtylimit-hmp-cmds.c Philippe Mathieu-Daudé
` (9 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
No code in device_tree.c or physmem.c require declarations
from "monitor/monitor.h".
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-13-philmd@oss.qualcomm.com>
---
system/device_tree.c | 1 -
system/physmem.c | 2 --
2 files changed, 3 deletions(-)
diff --git a/system/device_tree.c b/system/device_tree.c
index 1ea19629841..48365435ea0 100644
--- a/system/device_tree.c
+++ b/system/device_tree.c
@@ -29,7 +29,6 @@
#include "qemu/config-file.h"
#include "qapi/qapi-commands-machine.h"
#include "qobject/qdict.h"
-#include "monitor/hmp.h"
#include <libfdt.h>
diff --git a/system/physmem.c b/system/physmem.c
index 2f37cbeb071..362a00f76c0 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -84,8 +84,6 @@
#include "qemu/mmap-alloc.h"
#endif
-#include "monitor/monitor.h"
-
#ifdef CONFIG_LIBDAXCTL
#include <daxctl/libdaxctl.h>
#endif
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 48/56] system/dirtylimit: Extract HMP code to dirtylimit-hmp-cmds.c
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (46 preceding siblings ...)
2026-08-16 14:45 ` [PULL 47/56] system: Remove unnecessary 'monitor/monitor.h' header Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 49/56] system: Move qmp_inject_nmi() to hw/core/machine-qmp-cmds.c Philippe Mathieu-Daudé
` (8 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Hyman Huang <yong.huang@bitdeer.com>
Message-Id: <20260812211708.92824-14-philmd@oss.qualcomm.com>
---
MAINTAINERS | 1 +
system/dirtylimit-hmp-cmds.c | 74 ++++++++++++++++++++++++++++++++++++
system/dirtylimit.c | 60 -----------------------------
system/meson.build | 1 +
4 files changed, 76 insertions(+), 60 deletions(-)
create mode 100644 system/dirtylimit-hmp-cmds.c
diff --git a/MAINTAINERS b/MAINTAINERS
index c296dd5abfd..bad65aeda50 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3875,6 +3875,7 @@ Migration dirty limit and dirty page rate
M: Hyman Huang <infra.ai.cloud@bitdeer.com>
S: Maintained
F: system/dirtylimit.c
+F: system/dirtylimit-hmp-cmds.c
F: include/system/dirtylimit.h
F: migration/dirtyrate.c
F: migration/dirtyrate.h
diff --git a/system/dirtylimit-hmp-cmds.c b/system/dirtylimit-hmp-cmds.c
new file mode 100644
index 00000000000..4928d57cc8e
--- /dev/null
+++ b/system/dirtylimit-hmp-cmds.c
@@ -0,0 +1,74 @@
+/*
+ * HMP commands related to migration dirty page rate limit
+ *
+ * Copyright (c) 2022 CHINA TELECOM CO.,LTD.
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "qapi/qapi-commands-migration.h"
+#include "qobject/qdict.h"
+#include "monitor/hmp.h"
+#include "monitor/monitor.h"
+#include "system/dirtylimit.h"
+
+void hmp_cancel_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
+{
+ int64_t cpu_index = qdict_get_try_int(qdict, "cpu_index", -1);
+ Error *err = NULL;
+
+ qmp_cancel_vcpu_dirty_limit(!!(cpu_index != -1), cpu_index, &err);
+ if (err) {
+ hmp_handle_error(mon, err);
+ return;
+ }
+
+ monitor_printf(mon, "[Please use 'info vcpu_dirty_limit' to query "
+ "dirty limit for virtual CPU]\n");
+}
+
+void hmp_set_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
+{
+ int64_t dirty_rate = qdict_get_int(qdict, "dirty_rate");
+ int64_t cpu_index = qdict_get_try_int(qdict, "cpu_index", -1);
+ Error *err = NULL;
+
+ if (dirty_rate < 0) {
+ error_setg(&err, "invalid dirty page limit %" PRId64, dirty_rate);
+ goto out;
+ }
+
+ qmp_set_vcpu_dirty_limit(!!(cpu_index != -1), cpu_index, dirty_rate, &err);
+
+out:
+ hmp_handle_error(mon, err);
+}
+
+void hmp_info_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
+{
+ DirtyLimitInfoList *info;
+ g_autoptr(DirtyLimitInfoList) head = NULL;
+ Error *err = NULL;
+
+ if (!dirtylimit_in_service()) {
+ monitor_printf(mon, "Dirty page limit not enabled!\n");
+ return;
+ }
+
+ head = qmp_query_vcpu_dirty_limit(&err);
+ if (err) {
+ hmp_handle_error(mon, err);
+ return;
+ }
+
+ for (info = head; info != NULL; info = info->next) {
+ monitor_printf(mon, "vcpu[%"PRIi64"], limit rate %"PRIi64 " (MB/s),"
+ " current rate %"PRIi64 " (MB/s)\n",
+ info->value->cpu_index,
+ info->value->limit_rate,
+ info->value->current_rate);
+ }
+}
diff --git a/system/dirtylimit.c b/system/dirtylimit.c
index 50fa67f3d6a..70bb7bac2d0 100644
--- a/system/dirtylimit.c
+++ b/system/dirtylimit.c
@@ -17,8 +17,6 @@
#include "qapi/error.h"
#include "system/dirtyrate.h"
#include "system/dirtylimit.h"
-#include "monitor/hmp.h"
-#include "monitor/monitor.h"
#include "system/memory.h"
#include "exec/target_page.h"
#include "hw/core/boards.h"
@@ -491,21 +489,6 @@ void qmp_cancel_vcpu_dirty_limit(bool has_cpu_index,
dirtylimit_state_unlock();
}
-void hmp_cancel_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
-{
- int64_t cpu_index = qdict_get_try_int(qdict, "cpu_index", -1);
- Error *err = NULL;
-
- qmp_cancel_vcpu_dirty_limit(!!(cpu_index != -1), cpu_index, &err);
- if (err) {
- hmp_handle_error(mon, err);
- return;
- }
-
- monitor_printf(mon, "[Please use 'info vcpu_dirty_limit' to query "
- "dirty limit for virtual CPU]\n");
-}
-
void qmp_set_vcpu_dirty_limit(bool has_cpu_index,
int64_t cpu_index,
uint64_t dirty_rate,
@@ -548,23 +531,6 @@ void qmp_set_vcpu_dirty_limit(bool has_cpu_index,
dirtylimit_state_unlock();
}
-void hmp_set_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
-{
- int64_t dirty_rate = qdict_get_int(qdict, "dirty_rate");
- int64_t cpu_index = qdict_get_try_int(qdict, "cpu_index", -1);
- Error *err = NULL;
-
- if (dirty_rate < 0) {
- error_setg(&err, "invalid dirty page limit %" PRId64, dirty_rate);
- goto out;
- }
-
- qmp_set_vcpu_dirty_limit(!!(cpu_index != -1), cpu_index, dirty_rate, &err);
-
-out:
- hmp_handle_error(mon, err);
-}
-
/* Return the max throttle time of each virtual CPU */
uint64_t dirtylimit_throttle_time_per_round(void)
{
@@ -646,29 +612,3 @@ struct DirtyLimitInfoList *qmp_query_vcpu_dirty_limit(Error **errp)
{
return dirtylimit_query_all();
}
-
-void hmp_info_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
-{
- DirtyLimitInfoList *info;
- g_autoptr(DirtyLimitInfoList) head = NULL;
- Error *err = NULL;
-
- if (!dirtylimit_in_service()) {
- monitor_printf(mon, "Dirty page limit not enabled!\n");
- return;
- }
-
- head = qmp_query_vcpu_dirty_limit(&err);
- if (err) {
- hmp_handle_error(mon, err);
- return;
- }
-
- for (info = head; info != NULL; info = info->next) {
- monitor_printf(mon, "vcpu[%"PRIi64"], limit rate %"PRIi64 " (MB/s),"
- " current rate %"PRIi64 " (MB/s)\n",
- info->value->cpu_index,
- info->value->limit_rate,
- info->value->current_rate);
- }
-}
diff --git a/system/meson.build b/system/meson.build
index cd3193d170b..377adce8035 100644
--- a/system/meson.build
+++ b/system/meson.build
@@ -9,6 +9,7 @@ system_ss.add(files(
'cpus.c',
'cpu-timers.c',
'dirtylimit.c',
+ 'dirtylimit-hmp-cmds.c',
'dma-helpers.c',
'exit-with-parent.c',
'globals.c',
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 49/56] system: Move qmp_inject_nmi() to hw/core/machine-qmp-cmds.c
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (47 preceding siblings ...)
2026-08-16 14:45 ` [PULL 48/56] system/dirtylimit: Extract HMP code to dirtylimit-hmp-cmds.c Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 50/56] system: Extract QMP memsave/pmemsave commands to physmem-qmp-cmds.c Philippe Mathieu-Daudé
` (7 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
We figured NMI relates to machines (for their machine-specific
handling), so move the 'inject-nmi' QMP handler with the rest
of machine ones, in hw/core/machine-qmp-cmds.c.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-15-philmd@oss.qualcomm.com>
---
hw/core/machine-qmp-cmds.c | 6 ++++++
system/cpus.c | 8 --------
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index e62cb4ec888..1aa5f262298 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -10,6 +10,7 @@
#include "qemu/osdep.h"
#include "hw/acpi/vmgenid.h"
#include "hw/core/boards.h"
+#include "hw/core/nmi.h"
#include "hw/intc/intc.h"
#include "hw/mem/memory-device.h"
#include "qapi/error.h"
@@ -448,3 +449,8 @@ void qmp_dump_skeys(const char *filename, Error **errp)
}
DUMP_SKEYS_INTERFACE_CLASS(oc)->qmp_dump_skeys(filename, errp);
}
+
+void qmp_inject_nmi(Error **errp)
+{
+ nmi_inject(errp);
+}
diff --git a/system/cpus.c b/system/cpus.c
index 9758cda4636..aa2510bf8fc 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -26,7 +26,6 @@
#include "qemu/coroutine-tls.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-machine.h"
-#include "qapi/qapi-commands-misc.h"
#include "qapi/qapi-events-run-state.h"
#include "qapi/qmp/qerror.h"
#include "exec/gdbstub.h"
@@ -38,7 +37,6 @@
#include "qemu/plugin.h"
#include "system/cpus.h"
#include "qemu/guest-random.h"
-#include "hw/core/nmi.h"
#include "system/physmem.h"
#include "system/replay.h"
#include "system/runstate.h"
@@ -922,9 +920,3 @@ void qmp_pmemsave(uint64_t addr, uint64_t size, const char *filename,
exit:
fclose(f);
}
-
-void qmp_inject_nmi(Error **errp)
-{
- nmi_inject(errp);
-}
-
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 50/56] system: Extract QMP memsave/pmemsave commands to physmem-qmp-cmds.c
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (48 preceding siblings ...)
2026-08-16 14:45 ` [PULL 49/56] system: Move qmp_inject_nmi() to hw/core/machine-qmp-cmds.c Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 51/56] system: Move runstate-related code from cpus.c to runstate.c Philippe Mathieu-Daudé
` (6 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
Keep cpus.c related to vCPU scheduling, move the QMP handlers
related to dumping physical memory to file to their own unit.
Fix a pair of checkpatch.pl errors doing so:
ERROR: braces {} are necessary for all arms of this statement
#185: FILE: system/physmem-qmp-cmds.c:51:
+ if (l > size)
[...]
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-16-philmd@oss.qualcomm.com>
---
MAINTAINERS | 1 +
system/cpus.c | 92 --------------------------------
system/physmem-qmp-cmds.c | 107 ++++++++++++++++++++++++++++++++++++++
system/meson.build | 1 +
4 files changed, 109 insertions(+), 92 deletions(-)
create mode 100644 system/physmem-qmp-cmds.c
diff --git a/MAINTAINERS b/MAINTAINERS
index bad65aeda50..b51f5c3e602 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3436,6 +3436,7 @@ F: system/ioport.c
F: system/memory.c
F: system/memory_mapping.c
F: system/physmem.c
+F: system/physmem-qmp-cmds.c
F: system/memory_ldst*
F: system/memory-internal.h
F: system/ram-block-attributes.c
diff --git a/system/cpus.c b/system/cpus.c
index aa2510bf8fc..43ff10cf008 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -25,9 +25,7 @@
#include "qemu/osdep.h"
#include "qemu/coroutine-tls.h"
#include "qapi/error.h"
-#include "qapi/qapi-commands-machine.h"
#include "qapi/qapi-events-run-state.h"
-#include "qapi/qmp/qerror.h"
#include "exec/gdbstub.h"
#include "accel/accel-cpu-ops.h"
#include "system/hw_accel.h"
@@ -40,7 +38,6 @@
#include "system/physmem.h"
#include "system/replay.h"
#include "system/runstate.h"
-#include "migration/misc.h"
#include "system/cpu-timers.h"
#include "system/whpx.h"
#include "hw/core/boards.h"
@@ -831,92 +828,3 @@ int vm_stop_force_state(RunState state)
return ret;
}
}
-
-void qmp_memsave(uint64_t addr, uint64_t size, const char *filename,
- bool has_cpu, int64_t cpu_index, Error **errp)
-{
- FILE *f;
- uint64_t l;
- CPUState *cpu;
- uint8_t buf[1024];
- uint64_t orig_addr = addr, orig_size = size;
-
- if (migration_guest_ram_loading()) {
- error_setg(errp, "Guest memory access not allowed during migration");
- return;
- }
-
- if (!has_cpu) {
- cpu_index = 0;
- }
-
- cpu = qemu_get_cpu(cpu_index);
- if (cpu == NULL) {
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
- "a CPU number");
- return;
- }
-
- f = fopen(filename, "wb");
- if (!f) {
- error_setg_file_open(errp, errno, filename);
- return;
- }
-
- while (size != 0) {
- l = sizeof(buf);
- if (l > size)
- l = size;
- if (cpu_memory_rw_debug(cpu, addr, buf, l, 0) != 0) {
- error_setg(errp, "Invalid addr 0x%016" PRIx64 "/size %" PRIu64
- " specified", orig_addr, orig_size);
- goto exit;
- }
- if (fwrite(buf, 1, l, f) != l) {
- error_setg(errp, "writing memory to '%s' failed",
- filename);
- goto exit;
- }
- addr += l;
- size -= l;
- }
-
-exit:
- fclose(f);
-}
-
-void qmp_pmemsave(uint64_t addr, uint64_t size, const char *filename,
- Error **errp)
-{
- FILE *f;
- uint64_t l;
- uint8_t buf[1024];
-
- if (migration_guest_ram_loading()) {
- error_setg(errp, "Guest memory access not allowed during migration");
- return;
- }
-
- f = fopen(filename, "wb");
- if (!f) {
- error_setg_file_open(errp, errno, filename);
- return;
- }
-
- while (size != 0) {
- l = sizeof(buf);
- if (l > size)
- l = size;
- physical_memory_read(addr, buf, l);
- if (fwrite(buf, 1, l, f) != l) {
- error_setg(errp, "writing memory to '%s' failed",
- filename);
- goto exit;
- }
- addr += l;
- size -= l;
- }
-
-exit:
- fclose(f);
-}
diff --git a/system/physmem-qmp-cmds.c b/system/physmem-qmp-cmds.c
new file mode 100644
index 00000000000..d85430357d5
--- /dev/null
+++ b/system/physmem-qmp-cmds.c
@@ -0,0 +1,107 @@
+/*
+ * QMP commands to dump physical memory
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "qapi/qapi-commands-machine.h"
+#include "qapi/qmp/qerror.h"
+#include "hw/core/cpu.h"
+#include "system/physmem.h"
+#include "migration/misc.h"
+
+void qmp_memsave(uint64_t addr, uint64_t size, const char *filename,
+ bool has_cpu, int64_t cpu_index, Error **errp)
+{
+ FILE *f;
+ uint64_t l;
+ CPUState *cpu;
+ uint8_t buf[1024];
+ uint64_t orig_addr = addr, orig_size = size;
+
+ if (migration_guest_ram_loading()) {
+ error_setg(errp, "Guest memory access not allowed during migration");
+ return;
+ }
+
+ if (!has_cpu) {
+ cpu_index = 0;
+ }
+
+ cpu = qemu_get_cpu(cpu_index);
+ if (cpu == NULL) {
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
+ "a CPU number");
+ return;
+ }
+
+ f = fopen(filename, "wb");
+ if (!f) {
+ error_setg_file_open(errp, errno, filename);
+ return;
+ }
+
+ while (size != 0) {
+ l = sizeof(buf);
+ if (l > size) {
+ l = size;
+ }
+ if (cpu_memory_rw_debug(cpu, addr, buf, l, 0) != 0) {
+ error_setg(errp, "Invalid addr 0x%016" PRIx64 "/size %" PRIu64
+ " specified", orig_addr, orig_size);
+ goto exit;
+ }
+ if (fwrite(buf, 1, l, f) != l) {
+ error_setg(errp, "writing memory to '%s' failed",
+ filename);
+ goto exit;
+ }
+ addr += l;
+ size -= l;
+ }
+
+exit:
+ fclose(f);
+}
+
+void qmp_pmemsave(uint64_t addr, uint64_t size, const char *filename,
+ Error **errp)
+{
+ FILE *f;
+ uint64_t l;
+ uint8_t buf[1024];
+
+ if (migration_guest_ram_loading()) {
+ error_setg(errp, "Guest memory access not allowed during migration");
+ return;
+ }
+
+ f = fopen(filename, "wb");
+ if (!f) {
+ error_setg_file_open(errp, errno, filename);
+ return;
+ }
+
+ while (size != 0) {
+ l = sizeof(buf);
+ if (l > size) {
+ l = size;
+ }
+ physical_memory_read(addr, buf, l);
+ if (fwrite(buf, 1, l, f) != l) {
+ error_setg(errp, "writing memory to '%s' failed",
+ filename);
+ goto exit;
+ }
+ addr += l;
+ size -= l;
+ }
+
+exit:
+ fclose(f);
+}
diff --git a/system/meson.build b/system/meson.build
index 377adce8035..64e06e7abcc 100644
--- a/system/meson.build
+++ b/system/meson.build
@@ -19,6 +19,7 @@ system_ss.add(files(
'memory_mapping.c',
'memory.c',
'physmem.c',
+ 'physmem-qmp-cmds.c',
'qdev-monitor.c',
'qtest.c',
'rtc.c',
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 51/56] system: Move runstate-related code from cpus.c to runstate.c
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (49 preceding siblings ...)
2026-08-16 14:45 ` [PULL 50/56] system: Extract QMP memsave/pmemsave commands to physmem-qmp-cmds.c Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 52/56] monitor: Rename MonitorHMP @mon -> @hmp Philippe Mathieu-Daudé
` (5 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
Keep cpus.c focused on vCPUs handling, move code related to
VM state to runstate.c where similar code lives.
Fix few checkpatch.pl warnings:
WARNING: Block comments use a leading /* on a separate line
WARNING: Block comments use * on subsequent lines
#327: FILE: system/runstate.c:541:
+/* does a state transition even if the VM is already stopped,
+ current state is forgotten forever */
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-17-philmd@oss.qualcomm.com>
---
system/cpus.c | 147 -------------------------------------------
system/runstate.c | 154 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 154 insertions(+), 147 deletions(-)
diff --git a/system/cpus.c b/system/cpus.c
index 43ff10cf008..f37e215c586 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -25,7 +25,6 @@
#include "qemu/osdep.h"
#include "qemu/coroutine-tls.h"
#include "qapi/error.h"
-#include "qapi/qapi-events-run-state.h"
#include "exec/gdbstub.h"
#include "accel/accel-cpu-ops.h"
#include "system/hw_accel.h"
@@ -272,58 +271,6 @@ void cpu_interrupt(CPUState *cpu, int mask)
cpus_accel->handle_interrupt(cpu, mask);
}
-/*
- * True if the vm was previously suspended, and has not been woken or reset.
- */
-static int vm_was_suspended;
-
-void vm_set_suspended(bool suspended)
-{
- vm_was_suspended = suspended;
-}
-
-bool vm_get_suspended(void)
-{
- return vm_was_suspended;
-}
-
-static int do_vm_stop(RunState state, bool send_stop)
-{
- int ret = 0;
- RunState oldstate = runstate_get();
-
- if (runstate_is_live(oldstate)) {
- vm_was_suspended = (oldstate == RUN_STATE_SUSPENDED);
- runstate_set(state);
- cpu_disable_ticks();
- if (oldstate == RUN_STATE_RUNNING) {
- pause_all_vcpus();
- }
- ret = vm_state_notify(0, state);
- if (send_stop) {
- qapi_event_send_stop();
- }
- }
-
- bdrv_drain_all();
- /*
- * Even if vm_state_notify() return failure,
- * it would be better to flush as before.
- */
- ret |= bdrv_flush_all();
- trace_vm_stop_flush_all(ret);
-
- return ret;
-}
-
-/* Special vm_stop() variant for terminating the process. Historically clients
- * did not expect a QMP STOP event and so we need to retain compatibility.
- */
-int vm_shutdown(void)
-{
- return do_vm_stop(RUN_STATE_SHUTDOWN, false);
-}
-
bool cpu_can_run(CPUState *cpu)
{
if (cpu->stop) {
@@ -734,97 +681,3 @@ void cpu_stop_current(void)
cpu_exit(current_cpu);
}
}
-
-int vm_stop(RunState state)
-{
- if (qemu_in_vcpu_thread()) {
- qemu_system_vmstop_request_prepare();
- qemu_system_vmstop_request(state);
- /*
- * FIXME: should not return to device code in case
- * vm_stop() has been requested.
- */
- cpu_stop_current();
- return 0;
- }
-
- return do_vm_stop(state, true);
-}
-
-/**
- * Prepare for (re)starting the VM.
- * Returns 0 if the vCPUs should be restarted, -1 on an error condition,
- * and 1 otherwise.
- */
-int vm_prepare_start(bool step_pending)
-{
- int ret = vm_was_suspended ? 1 : 0;
- RunState state = vm_was_suspended ? RUN_STATE_SUSPENDED : RUN_STATE_RUNNING;
- RunState requested;
-
- qemu_vmstop_requested(&requested);
- if (runstate_is_running() && requested == RUN_STATE__MAX) {
- return -1;
- }
-
- /* Ensure that a STOP/RESUME pair of events is emitted if a
- * vmstop request was pending. The BLOCK_IO_ERROR event, for
- * example, according to documentation is always followed by
- * the STOP event.
- */
- if (runstate_is_running()) {
- qapi_event_send_stop();
- qapi_event_send_resume();
- return -1;
- }
-
- /*
- * WHPX accelerator needs to know whether we are going to step
- * any CPUs, before starting the first one.
- */
- accel_pre_resume(MACHINE(qdev_get_machine()), step_pending);
-
- /* We are sending this now, but the CPUs will be resumed shortly later */
- qapi_event_send_resume();
-
- cpu_enable_ticks();
- runstate_set(state);
- vm_state_notify(1, state);
- vm_was_suspended = false;
- return ret;
-}
-
-void vm_start(void)
-{
- if (!vm_prepare_start(false)) {
- resume_all_vcpus();
- }
-}
-
-void vm_resume(RunState state)
-{
- if (runstate_is_live(state)) {
- vm_start();
- } else {
- runstate_set(state);
- }
-}
-
-/* does a state transition even if the VM is already stopped,
- current state is forgotten forever */
-int vm_stop_force_state(RunState state)
-{
- if (runstate_is_live(runstate_get())) {
- return vm_stop(state);
- } else {
- int ret;
- runstate_set(state);
-
- bdrv_drain_all();
- /* Make sure to return an error if the flush in a previous vm_stop()
- * failed. */
- ret = bdrv_flush_all();
- trace_vm_stop_flush_all(ret);
- return ret;
- }
-}
diff --git a/system/runstate.c b/system/runstate.c
index 08acf801b0e..d3e64d2b625 100644
--- a/system/runstate.c
+++ b/system/runstate.c
@@ -52,6 +52,7 @@
#include "qemu/thread.h"
#include "qom/object.h"
#include "qom/object_interfaces.h"
+#include "system/cpu-timers.h"
#include "system/cpus.h"
#include "system/qtest.h"
#include "system/replay.h"
@@ -408,6 +409,159 @@ int vm_state_notify(bool running, RunState state)
return ret;
}
+/*
+ * True if the vm was previously suspended, and has not been woken or reset.
+ */
+static int vm_was_suspended;
+
+void vm_set_suspended(bool suspended)
+{
+ vm_was_suspended = suspended;
+}
+
+bool vm_get_suspended(void)
+{
+ return vm_was_suspended;
+}
+
+static int do_vm_stop(RunState state, bool send_stop)
+{
+ int ret = 0;
+ RunState oldstate = runstate_get();
+
+ if (runstate_is_live(oldstate)) {
+ vm_was_suspended = (oldstate == RUN_STATE_SUSPENDED);
+ runstate_set(state);
+ cpu_disable_ticks();
+ if (oldstate == RUN_STATE_RUNNING) {
+ pause_all_vcpus();
+ }
+ ret = vm_state_notify(0, state);
+ if (send_stop) {
+ qapi_event_send_stop();
+ }
+ }
+
+ bdrv_drain_all();
+ /*
+ * Even if vm_state_notify() return failure,
+ * it would be better to flush as before.
+ */
+ ret |= bdrv_flush_all();
+ trace_vm_stop_flush_all(ret);
+
+ return ret;
+}
+
+/*
+ * Special vm_stop() variant for terminating the process. Historically clients
+ * did not expect a QMP STOP event and so we need to retain compatibility.
+ */
+int vm_shutdown(void)
+{
+ return do_vm_stop(RUN_STATE_SHUTDOWN, false);
+}
+
+
+int vm_stop(RunState state)
+{
+ if (qemu_in_vcpu_thread()) {
+ qemu_system_vmstop_request_prepare();
+ qemu_system_vmstop_request(state);
+ /*
+ * FIXME: should not return to device code in case
+ * vm_stop() has been requested.
+ */
+ cpu_stop_current();
+ return 0;
+ }
+
+ return do_vm_stop(state, true);
+}
+
+/**
+ * Prepare for (re)starting the VM.
+ * Returns 0 if the vCPUs should be restarted, -1 on an error condition,
+ * and 1 otherwise.
+ */
+int vm_prepare_start(bool step_pending)
+{
+ int ret = vm_was_suspended ? 1 : 0;
+ RunState state = vm_was_suspended ? RUN_STATE_SUSPENDED : RUN_STATE_RUNNING;
+ RunState requested;
+
+ qemu_vmstop_requested(&requested);
+ if (runstate_is_running() && requested == RUN_STATE__MAX) {
+ return -1;
+ }
+
+ /*
+ * Ensure that a STOP/RESUME pair of events is emitted if a
+ * vmstop request was pending. The BLOCK_IO_ERROR event, for
+ * example, according to documentation is always followed by
+ * the STOP event.
+ */
+ if (runstate_is_running()) {
+ qapi_event_send_stop();
+ qapi_event_send_resume();
+ return -1;
+ }
+
+ /*
+ * WHPX accelerator needs to know whether we are going to step
+ * any CPUs, before starting the first one.
+ */
+ accel_pre_resume(MACHINE(qdev_get_machine()), step_pending);
+
+ /* We are sending this now, but the CPUs will be resumed shortly later */
+ qapi_event_send_resume();
+
+ cpu_enable_ticks();
+ runstate_set(state);
+ vm_state_notify(1, state);
+ vm_was_suspended = false;
+ return ret;
+}
+
+void vm_start(void)
+{
+ if (!vm_prepare_start(false)) {
+ resume_all_vcpus();
+ }
+}
+
+void vm_resume(RunState state)
+{
+ if (runstate_is_live(state)) {
+ vm_start();
+ } else {
+ runstate_set(state);
+ }
+}
+
+/*
+ * does a state transition even if the VM is already stopped,
+ * current state is forgotten forever
+ */
+int vm_stop_force_state(RunState state)
+{
+ if (runstate_is_live(runstate_get())) {
+ return vm_stop(state);
+ } else {
+ int ret;
+ runstate_set(state);
+
+ bdrv_drain_all();
+ /*
+ * Make sure to return an error if the flush in a previous vm_stop()
+ * failed.
+ */
+ ret = bdrv_flush_all();
+ trace_vm_stop_flush_all(ret);
+ return ret;
+ }
+}
+
static ShutdownCause reset_requested;
static ShutdownCause shutdown_requested;
static int shutdown_exit_code = EXIT_SUCCESS;
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 52/56] monitor: Rename MonitorHMP @mon -> @hmp
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (50 preceding siblings ...)
2026-08-16 14:45 ` [PULL 51/56] system: Move runstate-related code from cpus.c to runstate.c Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 53/56] monitor: Better express monitor_read()'s opaque arg is of Monitor type Philippe Mathieu-Daudé
` (4 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
Mechanical change to sanitize using the following patterns:
MonitorQMP *qmp
MonitorHMP *hmp
Monitor *mon
Rename @mon (and @hmp_mon) as @hmp when the type is MonitorHMP.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-Id: <20260812211708.92824-19-philmd@oss.qualcomm.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/monitor/monitor.h | 4 +-
monitor/monitor-internal.h | 2 +-
monitor/hmp-cmds.c | 6 +-
monitor/hmp.c | 135 +++++++++++++++++++------------------
ui/ui-hmp-cmds.c | 4 +-
5 files changed, 76 insertions(+), 75 deletions(-)
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index fd98ee2c71d..54134f2aa4f 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -55,8 +55,8 @@ void monitor_flush_locked(Monitor *mon);
void *gpa2hva(MemoryRegion **p_mr, hwaddr addr, uint64_t size, Error **errp);
-void monitor_read_command(MonitorHMP *mon, int show_prompt);
-int monitor_read_password(MonitorHMP *mon, ReadLineFunc *readline_func,
+void monitor_read_command(MonitorHMP *hmp, int show_prompt);
+int monitor_read_password(MonitorHMP *hmp, ReadLineFunc *readline_func,
void *opaque);
AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id,
diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
index bc0932c425a..e0a124a317a 100644
--- a/monitor/monitor-internal.h
+++ b/monitor/monitor-internal.h
@@ -221,7 +221,7 @@ void monitor_data_destroy_qmp(MonitorQMP *mon);
void coroutine_fn monitor_qmp_dispatcher_co(void *data);
void qmp_dispatcher_co_wake(void);
-void handle_hmp_command(MonitorHMP *mon, const char *cmdline);
+void handle_hmp_command(MonitorHMP *hmp, const char *cmdline);
int hmp_compare_cmd(const char *name, const char *list);
/*
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index e9fb8d827a0..bcd0a1fc878 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -290,16 +290,16 @@ void hmp_info_sync_profile(Monitor *mon, const QDict *qdict)
void hmp_info_history(Monitor *mon, const QDict *qdict)
{
- MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, parent_obj);
+ MonitorHMP *hmp = container_of(mon, MonitorHMP, parent_obj);
int i;
const char *str;
- if (!hmp_mon->rs) {
+ if (!hmp->rs) {
return;
}
i = 0;
for(;;) {
- str = readline_get_history(hmp_mon->rs, i);
+ str = readline_get_history(hmp->rs, i);
if (!str) {
break;
}
diff --git a/monitor/hmp.c b/monitor/hmp.c
index 71a18882491..cbf7a114c0c 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -49,24 +49,24 @@ OBJECT_DEFINE_TYPE(MonitorHMP, monitor_hmp, MONITOR_HMP, MONITOR);
static void monitor_hmp_finalize(Object *obj)
{
- MonitorHMP *mon = MONITOR_HMP(obj);
- if (mon->rs) {
- readline_free(mon->rs);
+ MonitorHMP *hmp = MONITOR_HMP(obj);
+ if (hmp->rs) {
+ readline_free(hmp->rs);
}
}
static bool monitor_hmp_get_readline(Object *obj, Error **errp)
{
- MonitorHMP *mon = MONITOR_HMP(obj);
+ MonitorHMP *hmp = MONITOR_HMP(obj);
- return mon->use_readline;
+ return hmp->use_readline;
}
static void monitor_hmp_set_readline(Object *obj, bool val, Error **errp)
{
- MonitorHMP *mon = MONITOR_HMP(obj);
+ MonitorHMP *hmp = MONITOR_HMP(obj);
- mon->use_readline = val;
+ hmp->use_readline = val;
}
int monitor_hmp_vprintf(Monitor *mon, const char *fmt, va_list ap)
@@ -128,34 +128,34 @@ static void monitor_hmp_accept_input(Monitor *mon)
static void monitor_command_cb(void *opaque, const char *cmdline,
void *readline_opaque)
{
- MonitorHMP *mon = opaque;
+ MonitorHMP *hmp = opaque;
- monitor_suspend(&mon->parent_obj);
- handle_hmp_command(mon, cmdline);
- monitor_resume(&mon->parent_obj);
+ monitor_suspend(&hmp->parent_obj);
+ handle_hmp_command(hmp, cmdline);
+ monitor_resume(&hmp->parent_obj);
}
-void monitor_read_command(MonitorHMP *mon, int show_prompt)
+void monitor_read_command(MonitorHMP *hmp, int show_prompt)
{
- if (!mon->rs) {
+ if (!hmp->rs) {
return;
}
- readline_start(mon->rs, "(qemu) ", 0, monitor_command_cb, NULL);
+ readline_start(hmp->rs, "(qemu) ", 0, monitor_command_cb, NULL);
if (show_prompt) {
- readline_show_prompt(mon->rs);
+ readline_show_prompt(hmp->rs);
}
}
-int monitor_read_password(MonitorHMP *mon, ReadLineFunc *readline_func,
+int monitor_read_password(MonitorHMP *hmp, ReadLineFunc *readline_func,
void *opaque)
{
- if (mon->rs) {
- readline_start(mon->rs, "Password: ", 1, readline_func, opaque);
+ if (hmp->rs) {
+ readline_start(hmp->rs, "Password: ", 1, readline_func, opaque);
/* prompt is printed on return from the command handler */
return 0;
} else {
- monitor_printf(&mon->parent_obj,
+ monitor_printf(&hmp->parent_obj,
"terminal does not support password prompting\n");
return -ENOTTY;
}
@@ -772,12 +772,12 @@ static const HMPCommand *search_dispatch_table(const HMPCommand *disp_table,
* Do not assume the return value points into @table! It doesn't when
* the command is found in a sub-command table.
*/
-static const HMPCommand *monitor_parse_command(MonitorHMP *hmp_mon,
+static const HMPCommand *monitor_parse_command(MonitorHMP *hmp,
const char *cmdp_start,
const char **cmdp,
HMPCommand *table)
{
- Monitor *mon = &hmp_mon->parent_obj;
+ Monitor *mon = &hmp->parent_obj;
const char *p;
const HMPCommand *cmd;
char cmdname[256];
@@ -809,7 +809,7 @@ static const HMPCommand *monitor_parse_command(MonitorHMP *hmp_mon,
*cmdp = p;
/* search sub command */
if (cmd->sub_table != NULL && *p != '\0') {
- return monitor_parse_command(hmp_mon, cmdp_start, cmdp, cmd->sub_table);
+ return monitor_parse_command(hmp, cmdp_start, cmdp, cmd->sub_table);
}
return cmd;
@@ -1254,15 +1254,15 @@ static void handle_hmp_command_co(void *opaque)
data->done = true;
}
-void handle_hmp_command(MonitorHMP *mon, const char *cmdline)
+void handle_hmp_command(MonitorHMP *hmp, const char *cmdline)
{
QDict *qdict;
const HMPCommand *cmd;
const char *cmd_start = cmdline;
- trace_handle_hmp_command(mon, cmdline);
+ trace_handle_hmp_command(hmp, cmdline);
- cmd = monitor_parse_command(mon, cmdline, &cmdline,
+ cmd = monitor_parse_command(hmp, cmdline, &cmdline,
hmp_cmds_for_target(false));
if (!cmd) {
return;
@@ -1270,17 +1270,17 @@ void handle_hmp_command(MonitorHMP *mon, const char *cmdline)
if (!cmd->cmd && !cmd->cmd_info_hrt) {
/* FIXME: is it useful to try autoload modules here ??? */
- monitor_printf(&mon->parent_obj, "Command \"%.*s\" is not available.\n",
+ monitor_printf(&hmp->parent_obj, "Command \"%.*s\" is not available.\n",
(int)(cmdline - cmd_start), cmd_start);
return;
}
- qdict = monitor_parse_arguments(&mon->parent_obj, &cmdline, cmd);
+ qdict = monitor_parse_arguments(&hmp->parent_obj, &cmdline, cmd);
if (!qdict) {
while (cmdline > cmd_start && qemu_isspace(cmdline[-1])) {
cmdline--;
}
- monitor_printf(&mon->parent_obj,
+ monitor_printf(&hmp->parent_obj,
"Try \"help %.*s\" for more information\n",
(int)(cmdline - cmd_start), cmd_start);
return;
@@ -1289,18 +1289,18 @@ void handle_hmp_command(MonitorHMP *mon, const char *cmdline)
if (!cmd->coroutine) {
/* old_mon is non-NULL when called from qmp_human_monitor_command() */
Monitor *old_mon = monitor_set_cur(qemu_coroutine_self(),
- &mon->parent_obj);
- handle_hmp_command_exec(&mon->parent_obj, cmd, qdict);
+ &hmp->parent_obj);
+ handle_hmp_command_exec(&hmp->parent_obj, cmd, qdict);
monitor_set_cur(qemu_coroutine_self(), old_mon);
} else {
HandleHmpCommandCo data = {
- .mon = &mon->parent_obj,
+ .mon = &hmp->parent_obj,
.cmd = cmd,
.qdict = qdict,
.done = false,
};
Coroutine *co = qemu_coroutine_create(handle_hmp_command_co, &data);
- monitor_set_cur(co, &mon->parent_obj);
+ monitor_set_cur(co, &hmp->parent_obj);
aio_co_enter(qemu_get_aio_context(), co);
AIO_WAIT_WHILE_UNLOCKED(NULL, !data.done);
}
@@ -1308,7 +1308,8 @@ void handle_hmp_command(MonitorHMP *mon, const char *cmdline)
qobject_unref(qdict);
}
-static void cmd_completion(MonitorHMP *mon, const char *name, const char *list)
+static void cmd_completion(MonitorHMP *hmp,
+ const char *name, const char *list)
{
const char *p, *pstart;
char cmd[128];
@@ -1324,7 +1325,7 @@ static void cmd_completion(MonitorHMP *mon, const char *name, const char *list)
}
memcpy(cmd, pstart, len);
cmd[len] = '\0';
- readline_add_completion_of(mon->rs, name, cmd);
+ readline_add_completion_of(hmp->rs, name, cmd);
if (*p == '\0') {
break;
}
@@ -1332,7 +1333,7 @@ static void cmd_completion(MonitorHMP *mon, const char *name, const char *list)
}
}
-static void file_completion(MonitorHMP *mon, const char *input)
+static void file_completion(MonitorHMP *hmp, const char *input)
{
DIR *ffs;
struct dirent *d;
@@ -1384,7 +1385,7 @@ static void file_completion(MonitorHMP *mon, const char *input)
if (stat(file, &sb) == 0 && S_ISDIR(sb.st_mode)) {
pstrcat(file, sizeof(file), "/");
}
- readline_add_completion(mon->rs, file);
+ readline_add_completion(hmp->rs, file);
}
}
closedir(ffs);
@@ -1396,7 +1397,7 @@ static const char *next_arg_type(const char *typestr)
return (p != NULL ? ++p : typestr);
}
-static void monitor_find_completion_by_table(MonitorHMP *mon,
+static void monitor_find_completion_by_table(MonitorHMP *hmp,
const HMPCommand *cmd_table,
char **args,
int nb_args)
@@ -1414,10 +1415,10 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
} else {
cmdname = args[0];
}
- readline_set_completion_index(mon->rs, strlen(cmdname));
+ readline_set_completion_index(hmp->rs, strlen(cmdname));
for (cmd = cmd_table; cmd->name != NULL; cmd++) {
if (cmd_available(cmd)) {
- cmd_completion(mon, cmdname, cmd->name);
+ cmd_completion(hmp, cmdname, cmd->name);
}
}
} else {
@@ -1434,12 +1435,12 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
if (cmd->sub_table) {
/* do the job again */
- monitor_find_completion_by_table(mon, cmd->sub_table,
+ monitor_find_completion_by_table(hmp, cmd->sub_table,
&args[1], nb_args - 1);
return;
}
if (cmd->command_completion) {
- cmd->command_completion(mon->rs, nb_args, args[nb_args - 1]);
+ cmd->command_completion(hmp->rs, nb_args, args[nb_args - 1]);
return;
}
@@ -1461,20 +1462,20 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
switch (*ptype) {
case 'F':
/* file completion */
- readline_set_completion_index(mon->rs, strlen(str));
- file_completion(mon, str);
+ readline_set_completion_index(hmp->rs, strlen(str));
+ file_completion(hmp, str);
break;
case 'B':
/* block device name completion */
- readline_set_completion_index(mon->rs, strlen(str));
+ readline_set_completion_index(hmp->rs, strlen(str));
while ((blk = blk_next(blk)) != NULL) {
- readline_add_completion_of(mon->rs, str, blk_name(blk));
+ readline_add_completion_of(hmp->rs, str, blk_name(blk));
}
break;
case 's':
case 'S':
if (!strcmp(cmd->name, "help|?")) {
- monitor_find_completion_by_table(mon, cmd_table,
+ monitor_find_completion_by_table(hmp, cmd_table,
&args[1], nb_args - 1);
}
break;
@@ -1487,7 +1488,7 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
static void monitor_find_completion(void *opaque,
const char *cmdline)
{
- MonitorHMP *mon = opaque;
+ MonitorHMP *hmp = opaque;
char *args[MAX_ARGS];
int nb_args, len;
@@ -1509,7 +1510,7 @@ static void monitor_find_completion(void *opaque,
}
/* 2. auto complete according to args */
- monitor_find_completion_by_table(mon, hmp_cmds_for_target(false),
+ monitor_find_completion_by_table(hmp, hmp_cmds_for_target(false),
args, nb_args);
cleanup:
@@ -1518,18 +1519,18 @@ cleanup:
static void monitor_read(void *opaque, const uint8_t *buf, int size)
{
- MonitorHMP *mon = container_of(opaque, MonitorHMP, parent_obj);
+ MonitorHMP *hmp = container_of(opaque, MonitorHMP, parent_obj);
int i;
- if (mon->rs) {
+ if (hmp->rs) {
for (i = 0; i < size; i++) {
- readline_handle_byte(mon->rs, buf[i]);
+ readline_handle_byte(hmp->rs, buf[i]);
}
} else {
if (size == 0 || buf[size - 1] != 0) {
- monitor_printf(&mon->parent_obj, "corrupted command\n");
+ monitor_printf(&hmp->parent_obj, "corrupted command\n");
} else {
- handle_hmp_command(mon, (char *)buf);
+ handle_hmp_command(hmp, (char *)buf);
}
}
}
@@ -1598,17 +1599,17 @@ static void monitor_event(void *opaque, QEMUChrEvent event)
static void G_GNUC_PRINTF(2, 3) monitor_readline_printf(void *opaque,
const char *fmt, ...)
{
- MonitorHMP *mon = opaque;
+ MonitorHMP *hmp = opaque;
va_list ap;
va_start(ap, fmt);
- monitor_vprintf(&mon->parent_obj, fmt, ap);
+ monitor_vprintf(&hmp->parent_obj, fmt, ap);
va_end(ap);
}
static void monitor_readline_flush(void *opaque)
{
- MonitorHMP *mon = opaque;
- monitor_flush(&mon->parent_obj);
+ MonitorHMP *hmp = opaque;
+ monitor_flush(&hmp->parent_obj);
}
void monitor_new_hmp(const char *id, const char *chardev_id,
@@ -1626,11 +1627,11 @@ void monitor_new_hmp(const char *id, const char *chardev_id,
static void monitor_hmp_complete(UserCreatable *uc, Error **errp)
{
- MonitorHMP *mon = MONITOR_HMP(uc);
+ MonitorHMP *hmp = MONITOR_HMP(uc);
UserCreatableClass *ucc_parent =
USER_CREATABLE_CLASS(
object_class_get_parent(
- OBJECT_CLASS(MONITOR_HMP_GET_CLASS(mon))));
+ OBJECT_CLASS(MONITOR_HMP_GET_CLASS(hmp))));
ERRP_GUARD();
ucc_parent->complete(uc, errp);
@@ -1638,21 +1639,21 @@ static void monitor_hmp_complete(UserCreatable *uc, Error **errp)
return;
}
- if (mon->parent_obj.chardev_id) {
- if (mon->use_readline) {
- mon->rs = readline_init(monitor_readline_printf,
+ if (hmp->parent_obj.chardev_id) {
+ if (hmp->use_readline) {
+ hmp->rs = readline_init(monitor_readline_printf,
monitor_readline_flush,
- mon,
+ hmp,
monitor_find_completion);
- monitor_read_command(mon, 0);
+ monitor_read_command(hmp, 0);
}
- qemu_chr_fe_set_handlers(&mon->parent_obj.chr,
+ qemu_chr_fe_set_handlers(&hmp->parent_obj.chr,
monitor_can_read,
monitor_read,
monitor_event, NULL,
- &mon->parent_obj, NULL, true);
- monitor_list_append(&mon->parent_obj);
+ &hmp->parent_obj, NULL, true);
+ monitor_list_append(&hmp->parent_obj);
}
}
diff --git a/ui/ui-hmp-cmds.c b/ui/ui-hmp-cmds.c
index 06f4030ce4f..24cf3a67104 100644
--- a/ui/ui-hmp-cmds.c
+++ b/ui/ui-hmp-cmds.c
@@ -343,8 +343,8 @@ void hmp_change_vnc(Monitor *mon, const char *device, const char *target,
return;
}
if (!arg) {
- MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, parent_obj);
- monitor_read_password(hmp_mon, hmp_change_read_arg, NULL);
+ MonitorHMP *hmp = container_of(mon, MonitorHMP, parent_obj);
+ monitor_read_password(hmp, hmp_change_read_arg, NULL);
} else {
qmp_change_vnc_password(arg, errp);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 53/56] monitor: Better express monitor_read()'s opaque arg is of Monitor type
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (51 preceding siblings ...)
2026-08-16 14:45 ` [PULL 52/56] monitor: Rename MonitorHMP @mon -> @hmp Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 54/56] monitor: Replace container_of(MonitorHMP, parent_obj) -> MONITOR_HMP() Philippe Mathieu-Daudé
` (3 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
monitor_read() is a IOReadHandler handler, called by
qemu_chr_fe_set_handlers() with a Monitor* opaque argument.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-20-philmd@oss.qualcomm.com>
---
monitor/hmp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/monitor/hmp.c b/monitor/hmp.c
index cbf7a114c0c..46f8d4a6ede 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -1519,7 +1519,8 @@ cleanup:
static void monitor_read(void *opaque, const uint8_t *buf, int size)
{
- MonitorHMP *hmp = container_of(opaque, MonitorHMP, parent_obj);
+ Monitor *mon = opaque;
+ MonitorHMP *hmp = container_of(mon, MonitorHMP, parent_obj);
int i;
if (hmp->rs) {
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 54/56] monitor: Replace container_of(MonitorHMP, parent_obj) -> MONITOR_HMP()
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (52 preceding siblings ...)
2026-08-16 14:45 ` [PULL 53/56] monitor: Better express monitor_read()'s opaque arg is of Monitor type Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 55/56] hw/elf_ops: defend against weird elf headers Philippe Mathieu-Daudé
` (2 subsequent siblings)
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
By replacing the container_of(MonitorHMP) use in ui/ui-hmp-cmds.c
we can remove its incorrect inclusion of "monitor/monitor-internal.h"
header, using the public "monitor/monitor.h" instead.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20260812211708.92824-23-philmd@oss.qualcomm.com>
---
monitor/hmp-cmds.c | 2 +-
monitor/hmp.c | 2 +-
ui/ui-hmp-cmds.c | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index bcd0a1fc878..4e8d996dbb5 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -290,7 +290,7 @@ void hmp_info_sync_profile(Monitor *mon, const QDict *qdict)
void hmp_info_history(Monitor *mon, const QDict *qdict)
{
- MonitorHMP *hmp = container_of(mon, MonitorHMP, parent_obj);
+ MonitorHMP *hmp = MONITOR_HMP(mon);
int i;
const char *str;
diff --git a/monitor/hmp.c b/monitor/hmp.c
index 46f8d4a6ede..22b1972d346 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -1520,7 +1520,7 @@ cleanup:
static void monitor_read(void *opaque, const uint8_t *buf, int size)
{
Monitor *mon = opaque;
- MonitorHMP *hmp = container_of(mon, MonitorHMP, parent_obj);
+ MonitorHMP *hmp = MONITOR_HMP(mon);
int i;
if (hmp->rs) {
diff --git a/ui/ui-hmp-cmds.c b/ui/ui-hmp-cmds.c
index 24cf3a67104..806a7bece7c 100644
--- a/ui/ui-hmp-cmds.c
+++ b/ui/ui-hmp-cmds.c
@@ -19,7 +19,7 @@
#endif
#include "monitor/hmp.h"
#include "monitor/hmp-completion.h"
-#include "monitor/monitor-internal.h"
+#include "monitor/monitor.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-ui.h"
#include "qobject/qdict.h"
@@ -343,7 +343,7 @@ void hmp_change_vnc(Monitor *mon, const char *device, const char *target,
return;
}
if (!arg) {
- MonitorHMP *hmp = container_of(mon, MonitorHMP, parent_obj);
+ MonitorHMP *hmp = MONITOR_HMP(mon);
monitor_read_password(hmp, hmp_change_read_arg, NULL);
} else {
qmp_change_vnc_password(arg, errp);
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 55/56] hw/elf_ops: defend against weird elf headers
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (53 preceding siblings ...)
2026-08-16 14:45 ` [PULL 54/56] monitor: Replace container_of(MonitorHMP, parent_obj) -> MONITOR_HMP() Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 56/56] hw/core/machine: Move EHCI migration compat properties to 11.1 Philippe Mathieu-Daudé
2026-08-16 17:26 ` [PULL 00/56] Misc HW patches for 2026-08-16 Richard Henderson
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Alex Bennée <alex.bennee@linaro.org>
According to the ELF spec:
PT_LOAD
The array element specifies a loadable segment, described by
p_filesz and p_memsz. The bytes from the file are mapped to the
beginning of the memory segment. If the segment's memory
size (p_memsz) is larger than the file size (p_filesz), the
``extra'' bytes are defined to hold the value 0 and to follow the
segment's initialized area. The file size may not be larger than the
memory size. Loadable segment entries in the program header table
appear in ascending order, sorted on the p_vaddr member.
which implies while both p_filesz and p_memsz can be zero we should
never see a case where p_filesz is greater than the in memory size.
Indeed it has been reported such a hand crafted ELF can blow up, for
example during rom_reset():
address_space_set(rom->as, rom->addr + rom->datasize, 0,
rom->romsize - rom->datasize,
MEMTXATTRS_UNSPECIFIED);
which could trigger and underflow leaving QEMU slowly filling a very
large buffer.
Cc: qemu-stable@nongnu.org
Fixes: https://gitlab.com/qemu-project/qemu/-/work_items/4056
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260812081405.3811787-1-alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
include/hw/elf_ops.h.inc | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/hw/elf_ops.h.inc b/include/hw/elf_ops.h.inc
index 9c35d1b9da6..044e72de2a2 100644
--- a/include/hw/elf_ops.h.inc
+++ b/include/hw/elf_ops.h.inc
@@ -427,6 +427,11 @@ static ssize_t glue(load_elf, SZ)(const char *name, int fd,
file_size = ph->p_filesz; /* Size of the allocated data */
data_offset = ph->p_offset; /* Offset where the data is located */
+ if (file_size > mem_size) {
+ ret = ELF_LOAD_TOO_BIG;
+ goto fail;
+ }
+
if (file_size > 0) {
if (g_mapped_file_get_length(mapped_file) <
file_size + data_offset) {
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [PULL 56/56] hw/core/machine: Move EHCI migration compat properties to 11.1
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (54 preceding siblings ...)
2026-08-16 14:45 ` [PULL 55/56] hw/elf_ops: defend against weird elf headers Philippe Mathieu-Daudé
@ 2026-08-16 14:45 ` Philippe Mathieu-Daudé
2026-08-16 17:26 ` [PULL 00/56] Misc HW patches for 2026-08-16 Richard Henderson
56 siblings, 0 replies; 58+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-16 14:45 UTC (permalink / raw)
To: qemu-devel
From: Jamin Lin <jamin_lin@aspeedtech.com>
The x-migrate-fetch-addr-64bit compatibility properties for
sysbus-ehci-usb and pci-ehci-usb were reviewed before the QEMU 11.1
release and were therefore initially added to hw_compat_11_0.
However, the EHCI migration change was merged after the QEMU 11.1
release. As a result, these compatibility properties belong in
hw_compat_11_1 rather than hw_compat_11_0.
Move both properties to hw_compat_11_1 so that migration compatibility
is associated with the correct machine version.
Fixes: 38ed803aebb2 ("usb/hcd-ehci: Change descriptor addresses to 64-bit")
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260814032559.3381363-1-jamin_lin@aspeedtech.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/core/machine.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 4e551194465..e617f7804d4 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -40,7 +40,10 @@
#include "qemu/audio.h"
#include "hw/arm/smmuv3.h"
-GlobalProperty hw_compat_11_1[] = {};
+GlobalProperty hw_compat_11_1[] = {
+ { "sysbus-ehci-usb", "x-migrate-fetch-addr-64bit", "off" },
+ { "pci-ehci-usb", "x-migrate-fetch-addr-64bit", "off" },
+};
const size_t hw_compat_11_1_len = G_N_ELEMENTS(hw_compat_11_1);
GlobalProperty hw_compat_11_0[] = {
@@ -54,8 +57,6 @@ GlobalProperty hw_compat_11_0[] = {
{ TYPE_ARM_SMMUV3, "ssidsize", "0" },
{ TYPE_ARM_SMMUV3, "oas", "44" },
{ "migration", "switchover-ack-legacy", "on" },
- { "sysbus-ehci-usb", "x-migrate-fetch-addr-64bit", "off" },
- { "pci-ehci-usb", "x-migrate-fetch-addr-64bit", "off" },
};
const size_t hw_compat_11_0_len = G_N_ELEMENTS(hw_compat_11_0);
--
2.53.0
^ permalink raw reply related [flat|nested] 58+ messages in thread
* Re: [PULL 00/56] Misc HW patches for 2026-08-16
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
` (55 preceding siblings ...)
2026-08-16 14:45 ` [PULL 56/56] hw/core/machine: Move EHCI migration compat properties to 11.1 Philippe Mathieu-Daudé
@ 2026-08-16 17:26 ` Richard Henderson
56 siblings, 0 replies; 58+ messages in thread
From: Richard Henderson @ 2026-08-16 17:26 UTC (permalink / raw)
To: qemu-devel
On 8/16/26 07:44, Philippe Mathieu-Daudé wrote:
> The following changes since commit af06b5df2610fe5de6c02d17c17bced9e9f0d47d:
>
> Merge tag 'qom-qdev-20260814' ofhttps://gitlab.com/mcayland-ntx/qemu into staging (2026-08-14 08:44:51 -0700)
>
> are available in the Git repository at:
>
> https://github.com/philmd/qemu.git tags/hw-misc-20260816
>
> for you to fetch changes up to b409523587c49a08b1ddadd51212a320092347b1:
>
> hw/core/machine: Move EHCI migration compat properties to 11.1 (2026-08-16 16:35:27 +0200)
>
> ----------------------------------------------------------------
> Misc HW and Monitor patch queue
>
> - Bug fixes
>
> . Reinstate x86/pc 'xenfv' machine alias
> . Defend against malformed ELF headers to prevent underflows
> . Restore ROMD mode after migration for Intel PFlash (CFI01)
> . Fix VLAN tag handling on incoming packets on RTL8139 model
>
> - Refactoring (Monitor, common CPU, NMI)
>
> . Add missing inclusions and remove unnecessary ones
> . Use qdev_is_realized() consistently (no direct field access)
> . Remove deprecated DEFINE_PROP_DMAADDR() macro
> . Renaming churn around cpu_{exec,common}* helpers
> . Simplify NMI API hanlding
> . Move QMP handlers (physmem, nmi) to appropriate subsystems
> . Replace container_of() casts with HMP typed accessors
> . Rename @mon to @hmp in MonitorHMP for clarity
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/11.2 as appropriate.
r~
^ permalink raw reply [flat|nested] 58+ messages in thread
end of thread, other threads:[~2026-08-16 17:27 UTC | newest]
Thread overview: 58+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-16 14:44 [PULL 00/56] Misc HW patches for 2026-08-16 Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 01/56] hw/qdev: Remove DEFINE_PROP_DMAADDR() and 'hw/qdev-dma.h' Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 02/56] hw/mem/nvdimm: fix "size" property typename Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 03/56] qdev: Make qdev_is_realized() take a const DeviceState * Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 04/56] hw/hyperv/balloon: Use qdev_is_realized() Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 05/56] hw/intc/apic: " Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 06/56] hw/mem/memory-device: " Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 07/56] hw/mem/pc-dimm: " Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 08/56] hw/nvram: " Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 09/56] hw/ppc/pnv_xscom: " Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 10/56] hw/vfio: " Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 11/56] hw/virtio/virtio-mem: " Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 12/56] hw/virtio/virtio-qmp: " Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 13/56] target/i386/cpu: " Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 14/56] target/s390x: " Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 15/56] hw/qdev: Parent device before setting parent bus Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 16/56] hw/i386/pc: xen: reinstate the "xenfv" machine alias Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 17/56] hw/net/rtl8139: Fix handling of VLAN tags on incoming short packets Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 18/56] hw/net/rtl8139: Send whole of vlan-tagged packet when doing loopback Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 19/56] hw/block/pflash_cfi01: Restore ROMD mode after migration Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 20/56] hw/nvme: add SPDM_SOCKET Kconfig dependency Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 21/56] hw/cpu: Correct CPU_GET_CLASS() comment Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 22/56] hw/cpu: Include missing 'qemu/accel.h' header Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 23/56] hw/cpu: Move internal declarations to new 'cpu-internal.h' header Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 24/56] hw/cpu: Rename cpu_common_realizefn() -> cpu_exec_realize() Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 25/56] hw/cpu: Rename cpu_exec_realizefn() -> cpu_common_realize() Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 26/56] hw/cpu: Rename cpu_exec_unrealizefn() -> cpu_common_unrealize() Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 27/56] hw/cpu: Extract cpu_exec_realize() out of cpu_common_realizefn() Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 28/56] hw/cpu: Move system-specific cpu_exec_realize() to cpu-system.c Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 29/56] hw/nmi: Use object_child_foreach_recursive() in nmi_children() Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 30/56] hw/s390x/virtio-ccw: Always inject NMI to first CPU Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 31/56] hw/nmi: Remove @cpu_index argument from NMIClass::nmi_monitor_handler() Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 32/56] hw/nmi: Remove @cpu_index argument from nmi_inject() Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 33/56] hw/nmi: Rename nmi_monitor_handler() -> raise_nmi() Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 34/56] hw/nmi: Remove unused @errp argument from raise_nmi() Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 35/56] hw/nmi: Raise NMI line only once Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 36/56] hexagon: Remove unnecessary 'monitor/monitor.h' header Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 37/56] net/vhost-vdpa: Include missing 'qemu/iov.h' header Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 38/56] tests/unit: Include 'qemu/main-loop.h' header in test-util-sockets.c Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 39/56] qapi/qmp-dispatch: Include 'qemu/aio-wait.h' and 'monitor/monitor.h' Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 40/56] qapi/qmp-registry: Remove unnecessary 'monitor/monitor.h' header Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 41/56] migration/hmp-cmds: Include 'block/block-global-state.h' header Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 42/56] monitor: Include missing 'qemu/aio-wait.h' header Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 43/56] monitor: Include missing 'qemu/lockable.h' header Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 44/56] monitor: Include missing 'qemu/coroutine-core.h' header Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 45/56] monitor: Reduce inclusion of 'qapi/qapi-emit-events.h' header Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 46/56] monitor: Remove unnecessary 'block/block.h' header Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 47/56] system: Remove unnecessary 'monitor/monitor.h' header Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 48/56] system/dirtylimit: Extract HMP code to dirtylimit-hmp-cmds.c Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 49/56] system: Move qmp_inject_nmi() to hw/core/machine-qmp-cmds.c Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 50/56] system: Extract QMP memsave/pmemsave commands to physmem-qmp-cmds.c Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 51/56] system: Move runstate-related code from cpus.c to runstate.c Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 52/56] monitor: Rename MonitorHMP @mon -> @hmp Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 53/56] monitor: Better express monitor_read()'s opaque arg is of Monitor type Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 54/56] monitor: Replace container_of(MonitorHMP, parent_obj) -> MONITOR_HMP() Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 55/56] hw/elf_ops: defend against weird elf headers Philippe Mathieu-Daudé
2026-08-16 14:45 ` [PULL 56/56] hw/core/machine: Move EHCI migration compat properties to 11.1 Philippe Mathieu-Daudé
2026-08-16 17:26 ` [PULL 00/56] Misc HW patches for 2026-08-16 Richard Henderson
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.