QOM has two rather unusual / surprising features historicall
* The ability to embed a QOM instance's memory inside another
struct
* The ability to register properties against the instnce
instead of struct
While they both look convenient on the surface, they also
have significant undesirable side effects (see the commit
message for each patch for details).
The premise of this series is that their convenience does
not outweigh their downsides, and we would be better off
long term by eliminating their usage, rather than trying
to add more hacks on top to mitigate their downsides.
This comes out of two separate conversations this week
* Migration series where Peter proposed changes that
make use of instance properties. When I commented,
Peter rightly pointed out that our docs do not
discourage use of instance properties:
https://lists.gnu.org/archive/html/qemu-devel/2026-06/msg02368.html
* QOM series where Akihiko proposed some funky hacks
to reference counting to better track object lifecycle
when embedding structs. We had a short discussion about
discouraging QOM embedding, so this is a real world
proposal:
https://lists.gnu.org/archive/html/qemu-devel/2026-06/msg03459.html
This is not likely to be a quick task, so this series
starts small
* Adds a "QEMU_DEPRECATIONS" annotation for internal APIs
* Deprecate the QOM instance embedding
* Deprecate the QOM instance properties
* Deprecate the memory region embedding APIs
* Deprecate the IRQ embedding APIs
* Convert PIIX to eliminate embedding as a
demonstration.
The QEMU_DEPRECATIONS idea is an effect to improve our our
historic practice where we introduce a new preferred API
and never really tell anyone the old APIs is bad to use.
If --enable-deprecations is given to configure, every use
of a deprecated API emits a compiler warning. This is not
enabled by default in this series, since we have -Werror
by default.
Note that the proposal to stop embedding memory regions has
been made by Zoltan earlier this year and was rejected by Paolo:
https://lists.nongnu.org/archive/html/qemu-devel/2026-01/msg05435.html
https://lists.nongnu.org/archive/html/qemu-devel/2026-05/msg06665.html
I don't really agree with the analysis there. IMHO, the
concept of embedding objects is to horrendous to allow to
live any longer. Yes, that's a big job, but long term it
is worth it.
Daniel P. Berrangé (7):
meson: add --enable-deprecations configure flag
qom: deprecated embedding object structs within other objects
qom: deprecate use of instance properties
system: add memory_region_new / memory_region_new_io
system: add qemu_irq_new / qemu_irq_new_child / qemu_irq_new_array
hw/isa: convert PIIX embedded QOM objects to heap allocated
qom: improve error message for invalid ID values
hw/core/irq.c | 35 +++++++++++++
hw/isa/piix.c | 65 ++++++++++++++---------
include/hw/core/irq.h | 75 +++++++++++++++++++++++++--
include/hw/southbridge/piix.h | 12 ++---
include/qemu/osdep.h | 19 +++++++
include/qom/object.h | 98 ++++++++++++++++++++++++++++++-----
include/system/memory.h | 76 +++++++++++++++++++++++----
meson.build | 1 +
meson_options.txt | 2 +
qom/object.c | 36 ++++++++++++-
scripts/meson-buildoptions.sh | 3 ++
system/memory.c | 85 +++++++++++++++++++++++++-----
12 files changed, 433 insertions(+), 74 deletions(-)
--
2.54.0