* [Qemu-arm] [PATCH] hw/intc/exynos4210_gic: Turn instance_init into realize function
@ 2018-07-23 9:23 ` Thomas Huth
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Huth @ 2018-07-23 9:23 UTC (permalink / raw)
To: qemu-devel, Peter Maydell, Igor Mitsyanko; +Cc: qemu-arm
The instance_init function of the "exynos4210.gic" device creates a
new "arm_gic" device and immediately realizes it with qdev_init_nofail().
This will leave a lot of object in the QOM tree during introspection of
the "exynos4210.gic" device, e.g. reproducible by starting QEMU like this:
qemu-system-aarch64 -M none -nodefaults -nographic -monitor stdio
And then by running "info qom-tree" at the HMP monitor, followed by
"device_add exynos4210.gic,help" and finally checking "info qom-tree"
again.
Also note that qdev_init_nofail() can exit QEMU in case of errors - and
this must never happen during an instance_init function, otherwise QEMU
could terminate unexpectedly during introspection of a device.
Since most of the code that follows the qdev_init_nofail() depends on
the realized "gicbusdev", the easiest solution to the problem is to
turn the whole instance_init function into a realize function instead.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
hw/intc/exynos4210_gic.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c
index b6b00a4..69f9c18 100644
--- a/hw/intc/exynos4210_gic.c
+++ b/hw/intc/exynos4210_gic.c
@@ -281,9 +281,9 @@ static void exynos4210_gic_set_irq(void *opaque, int irq, int level)
qemu_set_irq(qdev_get_gpio_in(s->gic, irq), level);
}
-static void exynos4210_gic_init(Object *obj)
+static void exynos4210_gic_realize(DeviceState *dev, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
+ Object *obj = OBJECT(dev);
Exynos4210GicState *s = EXYNOS4210_GIC(obj);
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
const char cpu_prefix[] = "exynos4210-gic-alias_cpu";
@@ -347,13 +347,13 @@ static void exynos4210_gic_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
dc->props = exynos4210_gic_properties;
+ dc->realize = exynos4210_gic_realize;
}
static const TypeInfo exynos4210_gic_info = {
.name = TYPE_EXYNOS4210_GIC,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(Exynos4210GicState),
- .instance_init = exynos4210_gic_init,
.class_init = exynos4210_gic_class_init,
};
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [Qemu-devel] [PATCH] hw/intc/exynos4210_gic: Turn instance_init into realize function
@ 2018-07-23 9:23 ` Thomas Huth
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Huth @ 2018-07-23 9:23 UTC (permalink / raw)
To: qemu-devel, Peter Maydell, Igor Mitsyanko; +Cc: qemu-arm
The instance_init function of the "exynos4210.gic" device creates a
new "arm_gic" device and immediately realizes it with qdev_init_nofail().
This will leave a lot of object in the QOM tree during introspection of
the "exynos4210.gic" device, e.g. reproducible by starting QEMU like this:
qemu-system-aarch64 -M none -nodefaults -nographic -monitor stdio
And then by running "info qom-tree" at the HMP monitor, followed by
"device_add exynos4210.gic,help" and finally checking "info qom-tree"
again.
Also note that qdev_init_nofail() can exit QEMU in case of errors - and
this must never happen during an instance_init function, otherwise QEMU
could terminate unexpectedly during introspection of a device.
Since most of the code that follows the qdev_init_nofail() depends on
the realized "gicbusdev", the easiest solution to the problem is to
turn the whole instance_init function into a realize function instead.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
hw/intc/exynos4210_gic.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c
index b6b00a4..69f9c18 100644
--- a/hw/intc/exynos4210_gic.c
+++ b/hw/intc/exynos4210_gic.c
@@ -281,9 +281,9 @@ static void exynos4210_gic_set_irq(void *opaque, int irq, int level)
qemu_set_irq(qdev_get_gpio_in(s->gic, irq), level);
}
-static void exynos4210_gic_init(Object *obj)
+static void exynos4210_gic_realize(DeviceState *dev, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
+ Object *obj = OBJECT(dev);
Exynos4210GicState *s = EXYNOS4210_GIC(obj);
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
const char cpu_prefix[] = "exynos4210-gic-alias_cpu";
@@ -347,13 +347,13 @@ static void exynos4210_gic_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
dc->props = exynos4210_gic_properties;
+ dc->realize = exynos4210_gic_realize;
}
static const TypeInfo exynos4210_gic_info = {
.name = TYPE_EXYNOS4210_GIC,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(Exynos4210GicState),
- .instance_init = exynos4210_gic_init,
.class_init = exynos4210_gic_class_init,
};
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [Qemu-devel] [PATCH] hw/intc/exynos4210_gic: Turn instance_init into realize function
2018-07-23 9:23 ` [Qemu-devel] " Thomas Huth
@ 2018-07-23 14:04 ` Peter Maydell
-1 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2018-07-23 14:04 UTC (permalink / raw)
To: Thomas Huth; +Cc: Igor Mitsyanko, qemu-arm, QEMU Developers
On 23 July 2018 at 10:23, Thomas Huth <thuth@redhat.com> wrote:
> The instance_init function of the "exynos4210.gic" device creates a
> new "arm_gic" device and immediately realizes it with qdev_init_nofail().
> This will leave a lot of object in the QOM tree during introspection of
> the "exynos4210.gic" device, e.g. reproducible by starting QEMU like this:
>
> qemu-system-aarch64 -M none -nodefaults -nographic -monitor stdio
>
> And then by running "info qom-tree" at the HMP monitor, followed by
> "device_add exynos4210.gic,help" and finally checking "info qom-tree"
> again.
>
> Also note that qdev_init_nofail() can exit QEMU in case of errors - and
> this must never happen during an instance_init function, otherwise QEMU
> could terminate unexpectedly during introspection of a device.
>
> Since most of the code that follows the qdev_init_nofail() depends on
> the realized "gicbusdev", the easiest solution to the problem is to
> turn the whole instance_init function into a realize function instead.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
Applied to target-arm.next, thanks.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/intc/exynos4210_gic: Turn instance_init into realize function
@ 2018-07-23 14:04 ` Peter Maydell
0 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2018-07-23 14:04 UTC (permalink / raw)
To: Thomas Huth; +Cc: QEMU Developers, Igor Mitsyanko, qemu-arm
On 23 July 2018 at 10:23, Thomas Huth <thuth@redhat.com> wrote:
> The instance_init function of the "exynos4210.gic" device creates a
> new "arm_gic" device and immediately realizes it with qdev_init_nofail().
> This will leave a lot of object in the QOM tree during introspection of
> the "exynos4210.gic" device, e.g. reproducible by starting QEMU like this:
>
> qemu-system-aarch64 -M none -nodefaults -nographic -monitor stdio
>
> And then by running "info qom-tree" at the HMP monitor, followed by
> "device_add exynos4210.gic,help" and finally checking "info qom-tree"
> again.
>
> Also note that qdev_init_nofail() can exit QEMU in case of errors - and
> this must never happen during an instance_init function, otherwise QEMU
> could terminate unexpectedly during introspection of a device.
>
> Since most of the code that follows the qdev_init_nofail() depends on
> the realized "gicbusdev", the easiest solution to the problem is to
> turn the whole instance_init function into a realize function instead.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
Applied to target-arm.next, thanks.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-23 14:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-23 9:23 [Qemu-arm] [PATCH] hw/intc/exynos4210_gic: Turn instance_init into realize function Thomas Huth
2018-07-23 9:23 ` [Qemu-devel] " Thomas Huth
2018-07-23 14:04 ` Peter Maydell
2018-07-23 14:04 ` Peter Maydell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.