spapr_drc: fix realize and unrealize
If object_property_add_alias() returns an error in realize(), we should propagate it to the caller and certainly not unref the DRC. Same thing goes for unrealize(). Since object_property_del() is the last call, we can even get rid of the intermediate Error *. And finally, unrealize() should undo all registrations performed by realize(). Signed-off-by: Greg Kurz <groug@kaod.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
a588c4985e
commit
bf26ae32a9
@ -506,11 +506,11 @@ static void realize(DeviceState *d, Error **errp)
|
|||||||
trace_spapr_drc_realize_child(spapr_drc_index(drc), child_name);
|
trace_spapr_drc_realize_child(spapr_drc_index(drc), child_name);
|
||||||
object_property_add_alias(root_container, link_name,
|
object_property_add_alias(root_container, link_name,
|
||||||
drc->owner, child_name, &err);
|
drc->owner, child_name, &err);
|
||||||
if (err) {
|
|
||||||
error_report_err(err);
|
|
||||||
object_unref(OBJECT(drc));
|
|
||||||
}
|
|
||||||
g_free(child_name);
|
g_free(child_name);
|
||||||
|
if (err) {
|
||||||
|
error_propagate(errp, err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
vmstate_register(DEVICE(drc), spapr_drc_index(drc), &vmstate_spapr_drc,
|
vmstate_register(DEVICE(drc), spapr_drc_index(drc), &vmstate_spapr_drc,
|
||||||
drc);
|
drc);
|
||||||
qemu_register_reset(drc_reset, drc);
|
qemu_register_reset(drc_reset, drc);
|
||||||
@ -522,16 +522,13 @@ static void unrealize(DeviceState *d, Error **errp)
|
|||||||
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(d);
|
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(d);
|
||||||
Object *root_container;
|
Object *root_container;
|
||||||
char name[256];
|
char name[256];
|
||||||
Error *err = NULL;
|
|
||||||
|
|
||||||
trace_spapr_drc_unrealize(spapr_drc_index(drc));
|
trace_spapr_drc_unrealize(spapr_drc_index(drc));
|
||||||
|
qemu_unregister_reset(drc_reset, drc);
|
||||||
|
vmstate_unregister(DEVICE(drc), &vmstate_spapr_drc, drc);
|
||||||
root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
|
root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
|
||||||
snprintf(name, sizeof(name), "%x", spapr_drc_index(drc));
|
snprintf(name, sizeof(name), "%x", spapr_drc_index(drc));
|
||||||
object_property_del(root_container, name, &err);
|
object_property_del(root_container, name, errp);
|
||||||
if (err) {
|
|
||||||
error_report_err(err);
|
|
||||||
object_unref(OBJECT(drc));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sPAPRDRConnector *spapr_dr_connector_new(Object *owner, const char *type,
|
sPAPRDRConnector *spapr_dr_connector_new(Object *owner, const char *type,
|
||||||
|
Loading…
Reference in New Issue
Block a user