On 14 January 2018 at 02:52, Philippe Mathieu-Daudé <f4...@amsat.org> wrote: > Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> > --- > hw/core/sysbus.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c > index 5d0887f499..0531eb60ce 100644 > --- a/hw/core/sysbus.c > +++ b/hw/core/sysbus.c > @@ -18,6 +18,7 @@ > */ > > #include "qemu/osdep.h" > +#include "qapi/error.h" > #include "hw/sysbus.h" > #include "monitor/monitor.h" > #include "exec/address-spaces.h" > @@ -200,15 +201,15 @@ void sysbus_init_ioports(SysBusDevice *dev, uint32_t > ioport, uint32_t size) > } > } > > -static int sysbus_device_init(DeviceState *dev) > +static void sysbus_device_realize(DeviceState *dev, Error **errp) > { > SysBusDevice *sd = SYS_BUS_DEVICE(dev); > SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd); > > - if (!sbc->init) { > - return 0; > + if (sbc->init && sbc->init(sd)) { > + error_setg(errp, "sysbus device initialization failed"); > + return; > } > - return sbc->init(sd); > } > > DeviceState *sysbus_create_varargs(const char *name, > @@ -324,7 +325,7 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev) > static void sysbus_device_class_init(ObjectClass *klass, void *data) > { > DeviceClass *k = DEVICE_CLASS(klass); > - k->init = sysbus_device_init; > + k->realize = sysbus_device_realize; > k->bus_type = TYPE_SYSTEM_BUS; > /* > * device_add plugs devices into a suitable bus. For "real" buses,
This doesn't look right. SysBus::init is something we're trying to deprecate, I think, so we should be looking to complete that process, not changing its semantics so it isn't called until Device::realize. thanks -- PMM