@@ -915,10 +915,6 @@ static void fw_cfg_init1(DeviceState *dev)
MachineState *machine = MACHINE(qdev_get_machine());
uint32_t version = FW_CFG_VERSION;
- assert(!object_resolve_path(FW_CFG_PATH, NULL));
-
- object_property_add_child(OBJECT(machine), FW_CFG_NAME, OBJECT(s), NULL);
-
qdev_init_nofail(dev);
fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (char *)"QEMU", 4);
@@ -1020,6 +1016,15 @@ FWCfgState *fw_cfg_find(void)
return FW_CFG(object_resolve_path(FW_CFG_PATH, NULL));
}
+static void fw_cfg_init(Object *obj)
+{
+ MachineState *machine = MACHINE(qdev_get_machine());
+
+ assert(!object_resolve_path(FW_CFG_PATH, NULL));
+
+ object_property_add_child(OBJECT(machine), FW_CFG_NAME, obj, NULL);
+}
+
static void fw_cfg_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -1033,6 +1038,7 @@ static const TypeInfo fw_cfg_info = {
.parent = TYPE_SYS_BUS_DEVICE,
.abstract = true,
.instance_size = sizeof(FWCfgState),
+ .instance_init = fw_cfg_init,
.class_init = fw_cfg_class_init,
};