On Thu, 12 Mar 2026 at 04:32, <[email protected]> wrote: > > From: Alistair Francis <[email protected]> > > Calling qdev_get_machine() in the soc_init function would result in > the following assert > > ../hw/core/qdev.c:858: qdev_get_machine: Assertion `dev' failed. > > when trying to run > > ./qemu-system-aarch64 -S -display none -M virt -device xlnx-zynqmp,help > > as the machine wasn't created yet. We call qdev_get_machine() to obtain > the number of CPUs in the machine. So instead of initialising the CPUs in > the SoC init let's instead do it in the realise where the machine > will exist.
Here I'm not sure I agree. We should init child objects in init, not in realize, unless there's a strong reason we need to not do that. Working around "we crash if the user does something pointless on the command line" isn't a strong enough reason IMHO. The problem here, though, is of the kind "what child objects we need depends on the configuration of this device", which kind of pushes "init children" into "realize". We do that in some places already. But I don't like that -- it makes us inconsistent about how we handle child init. If we're OK doing some child init in the parent's realize method, why not do all child init in realize? thanks -- PMM
