Message ID | 1455020010-17532-2-git-send-email-clg@fr.ibm.com |
---|---|
State | New |
Headers | show |
On 02/09/2016 02:13 PM, Cédric Le Goater wrote: > This will be useful to define and use properties when the object is > instanciated. Hi, /s/instanciated/instantiated > > Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> > --- > hw/ipmi/ipmi_bmc_sim.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c > index e1ad19b8db6e..13171336f7f1 100644 > --- a/hw/ipmi/ipmi_bmc_sim.c > +++ b/hw/ipmi/ipmi_bmc_sim.c > @@ -1731,9 +1731,9 @@ static const VMStateDescription vmstate_ipmi_sim = { > } > }; > > -static void ipmi_sim_init(Object *obj) > +static void ipmi_sim_realize(DeviceState *dev, Error **errp) > { > - IPMIBmc *b = IPMI_BMC(obj); > + IPMIBmc *b = IPMI_BMC(dev); > unsigned int i; > unsigned int recid; > IPMIBmcSim *ibs = IPMI_BMC_SIMULATOR(b); > @@ -1790,10 +1790,17 @@ static void ipmi_sim_init(Object *obj) > vmstate_register(NULL, 0, &vmstate_ipmi_sim, ibs); > } > > +static Property ipmi_sim_properties[] = { > + DEFINE_PROP_END_OF_LIST(), > +}; There is no need to add an empty property list. You should add it in patch 5 together with the first property. Besides that, Reviewed-by: Marcel Apfelbaum <marcel@redhat.com> Thanks, Marcel > + > static void ipmi_sim_class_init(ObjectClass *oc, void *data) > { > + DeviceClass *dc = DEVICE_CLASS(oc); > IPMIBmcClass *bk = IPMI_BMC_CLASS(oc); > > + dc->realize = ipmi_sim_realize; > + dc->props = ipmi_sim_properties; > bk->handle_command = ipmi_sim_handle_command; > } > > @@ -1801,7 +1808,6 @@ static const TypeInfo ipmi_sim_type = { > .name = TYPE_IPMI_BMC_SIMULATOR, > .parent = TYPE_IPMI_BMC, > .instance_size = sizeof(IPMIBmcSim), > - .instance_init = ipmi_sim_init, > .class_init = ipmi_sim_class_init, > }; > >
diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c index e1ad19b8db6e..13171336f7f1 100644 --- a/hw/ipmi/ipmi_bmc_sim.c +++ b/hw/ipmi/ipmi_bmc_sim.c @@ -1731,9 +1731,9 @@ static const VMStateDescription vmstate_ipmi_sim = { } }; -static void ipmi_sim_init(Object *obj) +static void ipmi_sim_realize(DeviceState *dev, Error **errp) { - IPMIBmc *b = IPMI_BMC(obj); + IPMIBmc *b = IPMI_BMC(dev); unsigned int i; unsigned int recid; IPMIBmcSim *ibs = IPMI_BMC_SIMULATOR(b); @@ -1790,10 +1790,17 @@ static void ipmi_sim_init(Object *obj) vmstate_register(NULL, 0, &vmstate_ipmi_sim, ibs); } +static Property ipmi_sim_properties[] = { + DEFINE_PROP_END_OF_LIST(), +}; + static void ipmi_sim_class_init(ObjectClass *oc, void *data) { + DeviceClass *dc = DEVICE_CLASS(oc); IPMIBmcClass *bk = IPMI_BMC_CLASS(oc); + dc->realize = ipmi_sim_realize; + dc->props = ipmi_sim_properties; bk->handle_command = ipmi_sim_handle_command; } @@ -1801,7 +1808,6 @@ static const TypeInfo ipmi_sim_type = { .name = TYPE_IPMI_BMC_SIMULATOR, .parent = TYPE_IPMI_BMC, .instance_size = sizeof(IPMIBmcSim), - .instance_init = ipmi_sim_init, .class_init = ipmi_sim_class_init, };
This will be useful to define and use properties when the object is instanciated. Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> --- hw/ipmi/ipmi_bmc_sim.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)