From: Alistair Francis Date: Tue, 17 Jul 2018 18:03:05 +0000 (-0700) Subject: riscv_hart: Fix crash when introspecting the device X-Git-Tag: qemu-xen-4.12.0-rc1~44^2~1 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5657c3f53ca408a0b8150ecbe70d0cdb3a264d9c;p=qemu-xen.git riscv_hart: Fix crash when introspecting the device Use the new object_initialize_child() and sysbus_init_child_obj() to fix the issue. Signed-off-by: Alistair Francis Suggested-by: Thomas Huth Reviewed-by: Michael Clark Reviewed-by: Thomas Huth --- diff --git a/hw/riscv/riscv_hart.c b/hw/riscv/riscv_hart.c index 75ba7ed579..e34a26a0ef 100644 --- a/hw/riscv/riscv_hart.c +++ b/hw/riscv/riscv_hart.c @@ -45,11 +45,10 @@ static void riscv_harts_realize(DeviceState *dev, Error **errp) s->harts = g_new0(RISCVCPU, s->num_harts); for (n = 0; n < s->num_harts; n++) { - - object_initialize(&s->harts[n], sizeof(RISCVCPU), s->cpu_type); + object_initialize_child(OBJECT(s), "harts[*]", &s->harts[n], + sizeof(RISCVCPU), s->cpu_type, + &error_abort, NULL); s->harts[n].env.mhartid = n; - object_property_add_child(OBJECT(s), "harts[*]", OBJECT(&s->harts[n]), - &error_abort); qemu_register_reset(riscv_harts_cpu_reset, &s->harts[n]); object_property_set_bool(OBJECT(&s->harts[n]), true, "realized", &err);