From: Markus Armbruster <armbru@redhat.com>
To: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Cc: qemu-devel@nongnu.org, "BALATON Zoltan" <balaton@eik.bme.hu>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"David Hildenbrand" <david@kernel.org>,
"Igor Mammedov" <imammedo@redhat.com>,
"FangSheng Huang" <FangSheng.Huang@amd.com>,
"Alistair Francis" <alistair@alistair23.me>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
qemu-arm@nongnu.org, "Nicholas Piggin" <npiggin@gmail.com>,
"Aditya Gupta" <adityag@linux.ibm.com>,
"Glenn Miles" <milesg@linux.ibm.com>,
"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
qemu-ppc@nongnu.org, "Alex Williamson" <alex@shazbot.org>,
"Cédric Le Goater" <clg@redhat.com>,
"Zhao Liu" <zhao1.liu@intel.com>,
"Hendrik Brueckner" <brueckner@linux.ibm.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Ilya Leoshkevich" <iii@linux.ibm.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Eric Farman" <farman@linux.ibm.com>,
"Matthew Rosato" <mjrosato@linux.ibm.com>,
qemu-s390x@nongnu.org, "Luc Michel" <luc@lmichel.fr>,
"Fam Zheng" <fam@euphon.net>, "Eric Blake" <eblake@redhat.com>
Subject: Re: [PATCH for-11.2 v3 00/15] qdev: Clarify and enforce the device realization lifecycle
Date: Fri, 24 Jul 2026 13:44:00 +0200 [thread overview]
Message-ID: <874ihoa9z3.fsf@pond.sub.org> (raw)
In-Reply-To: <20260721-qdev-v3-0-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp> (Akihiko Odaki's message of "Tue, 21 Jul 2026 17:16:50 +0900")
Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> writes:
> qdev currently represents a device's realization state with a single
> boolean. This cannot distinguish a device that has never been realized
> from one whose realization has failed or that has been unrealized, nor
> can it represent realization in progress. Consequently, the same device
> can enter DeviceClass::realize() reentrantly or more than once.
.realized is initially false. It is only ever modified in
device_set_realized(), which is the setter of QOM property "realized" of
"device" and its subtypes. device_set_realized() is only called when
the property is set. It does nothing when the new value is the same as
the old value.
Code changes property "realized" only in qdev_realize() and
qdev_unrealize().
Implementations of .realize may call qdev_realize() for their
components. Having this loop back would be a bug.
If your claim "can enter reentrantly" is correct, we have bugs to fix.
I believe it is incorrect.
There are two kinds of devices, onboard and user-created.
User-created devices go through qdev_device_add_from_qdict(). If
qdev_realize() fails, the device is immediately destroyed.
Onboard devices get created and realized by board code. It commonly
treats qdev_realize() failure as fatal error. Trying again instead
would be a bug.
If your claim "can enter more than once" is correct, we have bugs to
fix. I believe it is incorrect.
Exception, sort of: users can manipulate properties with QMP command
qom-set. This is generally unsupported and a Very Bad Idea[*]. There
might be supported exceptions (I don't know), but "realized" is
definitely not among them. Unsurprisingly, it's a fast path to grief:
$ qemu-system-x86_64 -S -display none -monitor stdio -nodefaults
QEMU 11.0.90 monitor - type 'help' for more information
(qemu) qom-set /machine/i440fx realized false
(qemu) qom-set /machine/i440fx realized true
qemu-system-x86_64: ../system/memory.c:2585: memory_region_add_subregion_common: Assertion `!subregion->container' failed.
I figure your series rejects the second qom-set. I'm pretty sure the
first qom-set already wounds the VM fatally[**]. Same as for a
multitude of other properties that aren't prepared to be qom-set at
arbitrary times.
Mind, I'm not objecting to adding additional guards against .realize()
getting called more than exactly once. I'm only challenging your cover
letter, and probably your commit messages (which I haven't read).
[...]
[*] One could argue that having command qom-set is a Very Bad Idea.
[**] It just doesn't crash a stopped VM right away for me.
next prev parent reply other threads:[~2026-07-24 11:44 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 8:16 [PATCH for-11.2 v3 00/15] qdev: Clarify and enforce the device realization lifecycle Akihiko Odaki
2026-07-21 8:16 ` [PATCH for-11.2 v3 01/15] qdev: Clarify instantiation and realization Akihiko Odaki
2026-07-21 11:14 ` BALATON Zoltan
2026-07-21 11:38 ` Akihiko Odaki
2026-07-21 8:16 ` [PATCH for-11.2 v3 02/15] qdev: Make qdev_is_realized() take a const DeviceState * Akihiko Odaki
2026-07-21 19:49 ` Philippe Mathieu-Daudé
2026-07-21 8:16 ` [PATCH for-11.2 v3 03/15] hw/hyperv/balloon: Use qdev_is_realized() Akihiko Odaki
2026-07-21 19:56 ` Philippe Mathieu-Daudé
2026-07-21 8:16 ` [PATCH for-11.2 v3 04/15] hw/intc/apic: " Akihiko Odaki
2026-07-21 19:51 ` Philippe Mathieu-Daudé
2026-07-21 8:16 ` [PATCH for-11.2 v3 05/15] hw/mem/memory-device: " Akihiko Odaki
2026-07-21 19:56 ` Philippe Mathieu-Daudé
2026-07-21 8:16 ` [PATCH for-11.2 v3 06/15] hw/mem/pc-dimm: " Akihiko Odaki
2026-07-21 19:52 ` Philippe Mathieu-Daudé
2026-07-21 8:16 ` [PATCH for-11.2 v3 07/15] hw/nvram: " Akihiko Odaki
2026-07-21 19:53 ` Philippe Mathieu-Daudé
2026-07-21 8:16 ` [PATCH for-11.2 v3 08/15] hw/ppc/pnv_xscom: " Akihiko Odaki
2026-07-21 19:53 ` Philippe Mathieu-Daudé
2026-07-21 8:16 ` [PATCH for-11.2 v3 09/15] hw/vfio: " Akihiko Odaki
2026-07-21 19:55 ` Philippe Mathieu-Daudé
2026-07-21 8:17 ` [PATCH for-11.2 v3 10/15] hw/virtio/virtio-mem: " Akihiko Odaki
2026-07-21 19:55 ` Philippe Mathieu-Daudé
2026-07-21 8:17 ` [PATCH for-11.2 v3 11/15] hw/virtio/virtio-qmp: " Akihiko Odaki
2026-07-21 19:52 ` Philippe Mathieu-Daudé
2026-07-21 8:17 ` [PATCH for-11.2 v3 12/15] target/i386/cpu: " Akihiko Odaki
2026-07-21 19:52 ` Philippe Mathieu-Daudé
2026-07-21 8:17 ` [PATCH for-11.2 v3 13/15] target/s390x: " Akihiko Odaki
2026-07-21 19:52 ` Philippe Mathieu-Daudé
2026-07-21 8:17 ` [PATCH for-11.2 v3 14/15] hw/qdev: Parent device before setting parent bus Akihiko Odaki
2026-07-21 20:15 ` Philippe Mathieu-Daudé
2026-07-21 8:17 ` [PATCH for-11.2 v3 15/15] hw/qdev: Prevent devices from being realized more than once Akihiko Odaki
2026-07-21 20:11 ` Philippe Mathieu-Daudé
2026-07-22 5:12 ` Akihiko Odaki
2026-07-22 9:57 ` Philippe Mathieu-Daudé
2026-07-22 11:08 ` Akihiko Odaki
2026-07-22 12:05 ` Philippe Mathieu-Daudé
2026-07-24 11:44 ` Markus Armbruster [this message]
2026-07-25 8:20 ` [PATCH for-11.2 v3 00/15] qdev: Clarify and enforce the device realization lifecycle Akihiko Odaki
2026-08-15 13:59 ` Philippe Mathieu-Daudé
2026-08-16 14:33 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874ihoa9z3.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=FangSheng.Huang@amd.com \
--cc=adityag@linux.ibm.com \
--cc=alex@shazbot.org \
--cc=alistair@alistair23.me \
--cc=balaton@eik.bme.hu \
--cc=berrange@redhat.com \
--cc=brueckner@linux.ibm.com \
--cc=clg@redhat.com \
--cc=cohuck@redhat.com \
--cc=david@kernel.org \
--cc=eblake@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=eduardo@habkost.net \
--cc=fam@euphon.net \
--cc=farman@linux.ibm.com \
--cc=harshpb@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=imammedo@redhat.com \
--cc=luc@lmichel.fr \
--cc=maciej.szmigiero@oracle.com \
--cc=milesg@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=mst@redhat.com \
--cc=npiggin@gmail.com \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=zhao1.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.