Philippe Mathieu-Daudé <f4...@amsat.org> writes: > Since commit 510ef98dca5, qdev_realize() aborts if bus-less > device is realized on a bus. While commits 514db7710b..007d1dbf72 > took care of converting all mainstream uses, QEMU forks weren't > converted. > > These forks are usually maintained by hobbyist with interest in > following mainstream development, but with limited time, so usually > rebase from time to time. To avoid them to spend time on debugging > and reading git-log history, display a kind hint about what is wrong. > > Before: > > qemu-system-mipsel: hw/core/qdev.c:376: qdev_realize: Assertion > `!DEVICE_GET_CLASS(dev)->bus_type' failed. > Aborted (core dumped) > > After: > > Unexpected error in qdev_realize() at hw/core/qdev.c:376: > qemu-system-mipsel: Unexpected bus 'System' for bus-less device > 'unimplemented-device' > Aborted (core dumped) > > Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> > --- > hw/core/qdev.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/hw/core/qdev.c b/hw/core/qdev.c > index 2131c7f951..a16f1270f1 100644 > --- a/hw/core/qdev.c > +++ b/hw/core/qdev.c > @@ -392,8 +392,11 @@ bool qdev_realize(DeviceState *dev, BusState *bus, Error > **errp) > > if (bus) { > qdev_set_parent_bus(dev, bus); > - } else { > - assert(!DEVICE_GET_CLASS(dev)->bus_type); > + } else if (DEVICE_GET_CLASS(dev)->bus_type) { > + error_setg(errp, "Unexpected bus '%s' for bus-less device '%s'", > + DEVICE_GET_CLASS(dev)->bus_type, > + object_get_typename(OBJECT(dev))); > + return false; > } > > object_property_set_bool(OBJECT(dev), true, "realized", &err);
Objection. This turns an abort into something else unless the caller passes &error_abort. The caller in your commit message's example does, others don't. Keep the unconditional abort, please. Feel free to print something kind right before. I doubt it's all that useful, as I believe whoever gets to fix the bug will have to figure out the code anyway, but I could be wrong.