On Tue, Jan 16, 2018 at 10:15:50AM -0300, Philippe Mathieu-Daudé wrote: [...] > +static void sysbus_realize(DeviceState *dev, Error **errp) > +{ > + SysBusDevice *sd = SYS_BUS_DEVICE(dev); > + SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd); > + > + if (sbc->realize) { > + sbc->realize(sd, errp); > + } > +} > + > +static void sysbus_unrealize(DeviceState *dev, Error **errp) > +{ > + SysBusDevice *sd = SYS_BUS_DEVICE(dev); > + SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd); > + > + if (sbc->unrealize) { > + sbc->unrealize(sd, errp); > + } > +}
Why not just let the subclasses set DeviceClass::realize and DeviceClass::unrealize directly? > + > DeviceState *sysbus_create_varargs(const char *name, > hwaddr addr, ...) > { > @@ -325,6 +346,8 @@ static void sysbus_device_class_init(ObjectClass *klass, > void *data) > { > DeviceClass *k = DEVICE_CLASS(klass); > k->init = sysbus_device_init; > + k->realize = sysbus_realize; > + k->unrealize = sysbus_unrealize; > k->bus_type = TYPE_SYSTEM_BUS; > /* > * device_add plugs devices into a suitable bus. For "real" buses, > -- > 2.15.1 > > -- Eduardo