All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/sparc64/sun4u: Fix introspection by converting prom instance_init to realize
@ 2018-04-05  9:32 Thomas Huth
  2018-04-05 16:22 ` Philippe Mathieu-Daudé
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Thomas Huth @ 2018-04-05  9:32 UTC (permalink / raw)
  To: qemu-devel, Mark Cave-Ayland; +Cc: Artyom Tarasenko

The instance_init function of devices should always succeed to be able
to introspect the device. However, the instance_init function of the
"openprom" device can currently fail, for example like this:

$ echo "{'execute':'qmp_capabilities'}"\
       "{'execute':'device-list-properties',"\
       " 'arguments':{'typename':'openprom'}}" \
       | sparc64-softmmu/qemu-system-sparc64 -M sun4v,accel=qtest -qmp stdio
{"QMP": {"version": {"qemu": {"micro": 91, "minor": 11, "major": 2},
 "package": "build-all"}, "capabilities": []}}
{"return": {}}
RAMBlock "sun4u.prom" already registered, abort!
Aborted (core dumped)

This should not happen. Fix this problem by moving the affected code from
instance_init into a realize function instead.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/sparc64/sun4u.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 2044a52..d62f5a2 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -425,13 +425,19 @@ static void prom_init(hwaddr addr, const char *bios_name)
     }
 }
 
-static void prom_init1(Object *obj)
+static void prom_realize(DeviceState *ds, Error **errp)
 {
-    PROMState *s = OPENPROM(obj);
-    SysBusDevice *dev = SYS_BUS_DEVICE(obj);
+    PROMState *s = OPENPROM(ds);
+    SysBusDevice *dev = SYS_BUS_DEVICE(ds);
+    Error *local_err = NULL;
+
+    memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4u.prom",
+                                     PROM_SIZE_MAX, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
 
-    memory_region_init_ram_nomigrate(&s->prom, obj, "sun4u.prom", PROM_SIZE_MAX,
-                           &error_fatal);
     vmstate_register_ram_global(&s->prom);
     memory_region_set_readonly(&s->prom, true);
     sysbus_init_mmio(dev, &s->prom);
@@ -446,6 +452,7 @@ static void prom_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->props = prom_properties;
+    dc->realize = prom_realize;
 }
 
 static const TypeInfo prom_info = {
@@ -453,7 +460,6 @@ static const TypeInfo prom_info = {
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(PROMState),
     .class_init    = prom_class_init,
-    .instance_init = prom_init1,
 };
 
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/sparc64/sun4u: Fix introspection by converting prom instance_init to realize
  2018-04-05  9:32 [Qemu-devel] [PATCH] hw/sparc64/sun4u: Fix introspection by converting prom instance_init to realize Thomas Huth
@ 2018-04-05 16:22 ` Philippe Mathieu-Daudé
  2018-04-05 16:27   ` Philippe Mathieu-Daudé
  2018-04-06 14:41 ` Mark Cave-Ayland
  2018-06-15  5:16 ` Thomas Huth
  2 siblings, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-05 16:22 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel, Mark Cave-Ayland; +Cc: Artyom Tarasenko

On 04/05/2018 06:32 AM, Thomas Huth wrote:
> The instance_init function of devices should always succeed to be able
> to introspect the device. However, the instance_init function of the
> "openprom" device can currently fail, for example like this:
> 
> $ echo "{'execute':'qmp_capabilities'}"\
>        "{'execute':'device-list-properties',"\
>        " 'arguments':{'typename':'openprom'}}" \
>        | sparc64-softmmu/qemu-system-sparc64 -M sun4v,accel=qtest -qmp stdio
> {"QMP": {"version": {"qemu": {"micro": 91, "minor": 11, "major": 2},
>  "package": "build-all"}, "capabilities": []}}
> {"return": {}}
> RAMBlock "sun4u.prom" already registered, abort!
> Aborted (core dumped)
> 
> This should not happen. Fix this problem by moving the affected code from
> instance_init into a realize function instead.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  hw/sparc64/sun4u.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
> index 2044a52..d62f5a2 100644
> --- a/hw/sparc64/sun4u.c
> +++ b/hw/sparc64/sun4u.c
> @@ -425,13 +425,19 @@ static void prom_init(hwaddr addr, const char *bios_name)
>      }
>  }
>  
> -static void prom_init1(Object *obj)
> +static void prom_realize(DeviceState *ds, Error **errp)
>  {
> -    PROMState *s = OPENPROM(obj);
> -    SysBusDevice *dev = SYS_BUS_DEVICE(obj);
> +    PROMState *s = OPENPROM(ds);
> +    SysBusDevice *dev = SYS_BUS_DEVICE(ds);
> +    Error *local_err = NULL;
> +
> +    memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4u.prom",
> +                                     PROM_SIZE_MAX, &local_err);

This looks the memory_region_init_ram() pattern...

> +    if (local_err) {
> +        error_propagate(errp, local_err);
> +        return;
> +    }
>  
> -    memory_region_init_ram_nomigrate(&s->prom, obj, "sun4u.prom", PROM_SIZE_MAX,
> -                           &error_fatal);
>      vmstate_register_ram_global(&s->prom);

...    ^

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

>      memory_region_set_readonly(&s->prom, true);
>      sysbus_init_mmio(dev, &s->prom);
> @@ -446,6 +452,7 @@ static void prom_class_init(ObjectClass *klass, void *data)
>      DeviceClass *dc = DEVICE_CLASS(klass);
>  
>      dc->props = prom_properties;
> +    dc->realize = prom_realize;
>  }
>  
>  static const TypeInfo prom_info = {
> @@ -453,7 +460,6 @@ static const TypeInfo prom_info = {
>      .parent        = TYPE_SYS_BUS_DEVICE,
>      .instance_size = sizeof(PROMState),
>      .class_init    = prom_class_init,
> -    .instance_init = prom_init1,
>  };
>  
>  
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/sparc64/sun4u: Fix introspection by converting prom instance_init to realize
  2018-04-05 16:22 ` Philippe Mathieu-Daudé
@ 2018-04-05 16:27   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-05 16:27 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel, Mark Cave-Ayland; +Cc: Artyom Tarasenko

On 04/05/2018 01:22 PM, Philippe Mathieu-Daudé wrote:
> On 04/05/2018 06:32 AM, Thomas Huth wrote:
>> The instance_init function of devices should always succeed to be able
>> to introspect the device. However, the instance_init function of the
>> "openprom" device can currently fail, for example like this:
>>
>> $ echo "{'execute':'qmp_capabilities'}"\
>>        "{'execute':'device-list-properties',"\
>>        " 'arguments':{'typename':'openprom'}}" \
>>        | sparc64-softmmu/qemu-system-sparc64 -M sun4v,accel=qtest -qmp stdio
>> {"QMP": {"version": {"qemu": {"micro": 91, "minor": 11, "major": 2},
>>  "package": "build-all"}, "capabilities": []}}
>> {"return": {}}
>> RAMBlock "sun4u.prom" already registered, abort!
>> Aborted (core dumped)
>>
>> This should not happen. Fix this problem by moving the affected code from
>> instance_init into a realize function instead.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>  hw/sparc64/sun4u.c | 18 ++++++++++++------
>>  1 file changed, 12 insertions(+), 6 deletions(-)
>>
>> diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
>> index 2044a52..d62f5a2 100644
>> --- a/hw/sparc64/sun4u.c
>> +++ b/hw/sparc64/sun4u.c
>> @@ -425,13 +425,19 @@ static void prom_init(hwaddr addr, const char *bios_name)
>>      }
>>  }
>>  
>> -static void prom_init1(Object *obj)
>> +static void prom_realize(DeviceState *ds, Error **errp)
>>  {
>> -    PROMState *s = OPENPROM(obj);
>> -    SysBusDevice *dev = SYS_BUS_DEVICE(obj);
>> +    PROMState *s = OPENPROM(ds);
>> +    SysBusDevice *dev = SYS_BUS_DEVICE(ds);
>> +    Error *local_err = NULL;
>> +
>> +    memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4u.prom",
>> +                                     PROM_SIZE_MAX, &local_err);
> 
> This looks the memory_region_init_ram() pattern...
> 
>> +    if (local_err) {
>> +        error_propagate(errp, local_err);
>> +        return;
>> +    }
>>  
>> -    memory_region_init_ram_nomigrate(&s->prom, obj, "sun4u.prom", PROM_SIZE_MAX,
>> -                           &error_fatal);
>>      vmstate_register_ram_global(&s->prom);
> 
> ...    ^
> 
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> 
>>      memory_region_set_readonly(&s->prom, true);

Maybe memory_region_init_rom_nomigrate() even?

>>      sysbus_init_mmio(dev, &s->prom);
>> @@ -446,6 +452,7 @@ static void prom_class_init(ObjectClass *klass, void *data)
>>      DeviceClass *dc = DEVICE_CLASS(klass);
>>  
>>      dc->props = prom_properties;
>> +    dc->realize = prom_realize;
>>  }
>>  
>>  static const TypeInfo prom_info = {
>> @@ -453,7 +460,6 @@ static const TypeInfo prom_info = {
>>      .parent        = TYPE_SYS_BUS_DEVICE,
>>      .instance_size = sizeof(PROMState),
>>      .class_init    = prom_class_init,
>> -    .instance_init = prom_init1,
>>  };
>>  
>>  
>>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/sparc64/sun4u: Fix introspection by converting prom instance_init to realize
  2018-04-05  9:32 [Qemu-devel] [PATCH] hw/sparc64/sun4u: Fix introspection by converting prom instance_init to realize Thomas Huth
  2018-04-05 16:22 ` Philippe Mathieu-Daudé
@ 2018-04-06 14:41 ` Mark Cave-Ayland
  2018-04-06 14:47   ` Thomas Huth
  2018-06-15  5:16 ` Thomas Huth
  2 siblings, 1 reply; 7+ messages in thread
From: Mark Cave-Ayland @ 2018-04-06 14:41 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel; +Cc: Artyom Tarasenko

On 05/04/18 10:32, Thomas Huth wrote:

> The instance_init function of devices should always succeed to be able
> to introspect the device. However, the instance_init function of the
> "openprom" device can currently fail, for example like this:
> 
> $ echo "{'execute':'qmp_capabilities'}"\
>         "{'execute':'device-list-properties',"\
>         " 'arguments':{'typename':'openprom'}}" \
>         | sparc64-softmmu/qemu-system-sparc64 -M sun4v,accel=qtest -qmp stdio
> {"QMP": {"version": {"qemu": {"micro": 91, "minor": 11, "major": 2},
>   "package": "build-all"}, "capabilities": []}}
> {"return": {}}
> RAMBlock "sun4u.prom" already registered, abort!
> Aborted (core dumped)
> 
> This should not happen. Fix this problem by moving the affected code from
> instance_init into a realize function instead.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   hw/sparc64/sun4u.c | 18 ++++++++++++------
>   1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
> index 2044a52..d62f5a2 100644
> --- a/hw/sparc64/sun4u.c
> +++ b/hw/sparc64/sun4u.c
> @@ -425,13 +425,19 @@ static void prom_init(hwaddr addr, const char *bios_name)
>       }
>   }
>   
> -static void prom_init1(Object *obj)
> +static void prom_realize(DeviceState *ds, Error **errp)
>   {
> -    PROMState *s = OPENPROM(obj);
> -    SysBusDevice *dev = SYS_BUS_DEVICE(obj);
> +    PROMState *s = OPENPROM(ds);
> +    SysBusDevice *dev = SYS_BUS_DEVICE(ds);
> +    Error *local_err = NULL;
> +
> +    memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4u.prom",
> +                                     PROM_SIZE_MAX, &local_err);
> +    if (local_err) {
> +        error_propagate(errp, local_err);
> +        return;
> +    }
>   
> -    memory_region_init_ram_nomigrate(&s->prom, obj, "sun4u.prom", PROM_SIZE_MAX,
> -                           &error_fatal);
>       vmstate_register_ram_global(&s->prom);
>       memory_region_set_readonly(&s->prom, true);
>       sysbus_init_mmio(dev, &s->prom);
> @@ -446,6 +452,7 @@ static void prom_class_init(ObjectClass *klass, void *data)
>       DeviceClass *dc = DEVICE_CLASS(klass);
>   
>       dc->props = prom_properties;
> +    dc->realize = prom_realize;
>   }
>   
>   static const TypeInfo prom_info = {
> @@ -453,7 +460,6 @@ static const TypeInfo prom_info = {
>       .parent        = TYPE_SYS_BUS_DEVICE,
>       .instance_size = sizeof(PROMState),
>       .class_init    = prom_class_init,
> -    .instance_init = prom_init1,
>   };

Looks good to me:

Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>

I thought this would have been caught by the device introspect test, or 
is this something you've found whilst trying to add sun4v to the list of 
machines to include in the test?


ATB,

Mark.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/sparc64/sun4u: Fix introspection by converting prom instance_init to realize
  2018-04-06 14:41 ` Mark Cave-Ayland
@ 2018-04-06 14:47   ` Thomas Huth
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Huth @ 2018-04-06 14:47 UTC (permalink / raw)
  To: Mark Cave-Ayland, qemu-devel; +Cc: Artyom Tarasenko

On 06.04.2018 16:41, Mark Cave-Ayland wrote:
> On 05/04/18 10:32, Thomas Huth wrote:
> 
>> The instance_init function of devices should always succeed to be able
>> to introspect the device. However, the instance_init function of the
>> "openprom" device can currently fail, for example like this:
>>
>> $ echo "{'execute':'qmp_capabilities'}"\
>>         "{'execute':'device-list-properties',"\
>>         " 'arguments':{'typename':'openprom'}}" \
>>         | sparc64-softmmu/qemu-system-sparc64 -M sun4v,accel=qtest
>> -qmp stdio
>> {"QMP": {"version": {"qemu": {"micro": 91, "minor": 11, "major": 2},
>>   "package": "build-all"}, "capabilities": []}}
>> {"return": {}}
>> RAMBlock "sun4u.prom" already registered, abort!
>> Aborted (core dumped)
>>
>> This should not happen. Fix this problem by moving the affected code from
>> instance_init into a realize function instead.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>   hw/sparc64/sun4u.c | 18 ++++++++++++------
>>   1 file changed, 12 insertions(+), 6 deletions(-)
>>
>> diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
>> index 2044a52..d62f5a2 100644
>> --- a/hw/sparc64/sun4u.c
>> +++ b/hw/sparc64/sun4u.c
>> @@ -425,13 +425,19 @@ static void prom_init(hwaddr addr, const char
>> *bios_name)
>>       }
>>   }
>>   -static void prom_init1(Object *obj)
>> +static void prom_realize(DeviceState *ds, Error **errp)
>>   {
>> -    PROMState *s = OPENPROM(obj);
>> -    SysBusDevice *dev = SYS_BUS_DEVICE(obj);
>> +    PROMState *s = OPENPROM(ds);
>> +    SysBusDevice *dev = SYS_BUS_DEVICE(ds);
>> +    Error *local_err = NULL;
>> +
>> +    memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4u.prom",
>> +                                     PROM_SIZE_MAX, &local_err);
>> +    if (local_err) {
>> +        error_propagate(errp, local_err);
>> +        return;
>> +    }
>>   -    memory_region_init_ram_nomigrate(&s->prom, obj, "sun4u.prom",
>> PROM_SIZE_MAX,
>> -                           &error_fatal);
>>       vmstate_register_ram_global(&s->prom);
>>       memory_region_set_readonly(&s->prom, true);
>>       sysbus_init_mmio(dev, &s->prom);
>> @@ -446,6 +452,7 @@ static void prom_class_init(ObjectClass *klass,
>> void *data)
>>       DeviceClass *dc = DEVICE_CLASS(klass);
>>         dc->props = prom_properties;
>> +    dc->realize = prom_realize;
>>   }
>>     static const TypeInfo prom_info = {
>> @@ -453,7 +460,6 @@ static const TypeInfo prom_info = {
>>       .parent        = TYPE_SYS_BUS_DEVICE,
>>       .instance_size = sizeof(PROMState),
>>       .class_init    = prom_class_init,
>> -    .instance_init = prom_init1,
>>   };
> 
> Looks good to me:
> 
> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> 
> I thought this would have been caught by the device introspect test, or
> is this something you've found whilst trying to add sun4v to the list of
> machines to include in the test?

I've found it with this patch here:

https://lists.gnu.org/archive/html/qemu-devel/2018-03/msg05033.html

The current device-introspect-test only checks with the "none" machine,
so it did not detect this problem yet since this only happens when you
use the sun4v machine.

 Thomas

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/sparc64/sun4u: Fix introspection by converting prom instance_init to realize
  2018-04-05  9:32 [Qemu-devel] [PATCH] hw/sparc64/sun4u: Fix introspection by converting prom instance_init to realize Thomas Huth
  2018-04-05 16:22 ` Philippe Mathieu-Daudé
  2018-04-06 14:41 ` Mark Cave-Ayland
@ 2018-06-15  5:16 ` Thomas Huth
  2018-06-15  7:46   ` Artyom Tarasenko
  2 siblings, 1 reply; 7+ messages in thread
From: Thomas Huth @ 2018-06-15  5:16 UTC (permalink / raw)
  To: qemu-devel, Mark Cave-Ayland; +Cc: Artyom Tarasenko

On 05.04.2018 11:32, Thomas Huth wrote:
> The instance_init function of devices should always succeed to be able
> to introspect the device. However, the instance_init function of the
> "openprom" device can currently fail, for example like this:
> 
> $ echo "{'execute':'qmp_capabilities'}"\
>        "{'execute':'device-list-properties',"\
>        " 'arguments':{'typename':'openprom'}}" \
>        | sparc64-softmmu/qemu-system-sparc64 -M sun4v,accel=qtest -qmp stdio
> {"QMP": {"version": {"qemu": {"micro": 91, "minor": 11, "major": 2},
>  "package": "build-all"}, "capabilities": []}}
> {"return": {}}
> RAMBlock "sun4u.prom" already registered, abort!
> Aborted (core dumped)
> 
> This should not happen. Fix this problem by moving the affected code from
> instance_init into a realize function instead.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  hw/sparc64/sun4u.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
> index 2044a52..d62f5a2 100644
> --- a/hw/sparc64/sun4u.c
> +++ b/hw/sparc64/sun4u.c
> @@ -425,13 +425,19 @@ static void prom_init(hwaddr addr, const char *bios_name)
>      }
>  }
>  
> -static void prom_init1(Object *obj)
> +static void prom_realize(DeviceState *ds, Error **errp)
>  {
> -    PROMState *s = OPENPROM(obj);
> -    SysBusDevice *dev = SYS_BUS_DEVICE(obj);
> +    PROMState *s = OPENPROM(ds);
> +    SysBusDevice *dev = SYS_BUS_DEVICE(ds);
> +    Error *local_err = NULL;
> +
> +    memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4u.prom",
> +                                     PROM_SIZE_MAX, &local_err);
> +    if (local_err) {
> +        error_propagate(errp, local_err);
> +        return;
> +    }
>  
> -    memory_region_init_ram_nomigrate(&s->prom, obj, "sun4u.prom", PROM_SIZE_MAX,
> -                           &error_fatal);
>      vmstate_register_ram_global(&s->prom);
>      memory_region_set_readonly(&s->prom, true);
>      sysbus_init_mmio(dev, &s->prom);
> @@ -446,6 +452,7 @@ static void prom_class_init(ObjectClass *klass, void *data)
>      DeviceClass *dc = DEVICE_CLASS(klass);
>  
>      dc->props = prom_properties;
> +    dc->realize = prom_realize;
>  }
>  
>  static const TypeInfo prom_info = {
> @@ -453,7 +460,6 @@ static const TypeInfo prom_info = {
>      .parent        = TYPE_SYS_BUS_DEVICE,
>      .instance_size = sizeof(PROMState),
>      .class_init    = prom_class_init,
> -    .instance_init = prom_init1,
>  };

Ping!

 Thomas

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/sparc64/sun4u: Fix introspection by converting prom instance_init to realize
  2018-06-15  5:16 ` Thomas Huth
@ 2018-06-15  7:46   ` Artyom Tarasenko
  0 siblings, 0 replies; 7+ messages in thread
From: Artyom Tarasenko @ 2018-06-15  7:46 UTC (permalink / raw)
  To: Thomas Huth; +Cc: qemu-devel, Mark Cave-Ayland

On Fri, Jun 15, 2018 at 7:16 AM, Thomas Huth <thuth@redhat.com> wrote:
> On 05.04.2018 11:32, Thomas Huth wrote:
>> The instance_init function of devices should always succeed to be able
>> to introspect the device. However, the instance_init function of the
>> "openprom" device can currently fail, for example like this:
>>
>> $ echo "{'execute':'qmp_capabilities'}"\
>>        "{'execute':'device-list-properties',"\
>>        " 'arguments':{'typename':'openprom'}}" \
>>        | sparc64-softmmu/qemu-system-sparc64 -M sun4v,accel=qtest -qmp stdio
>> {"QMP": {"version": {"qemu": {"micro": 91, "minor": 11, "major": 2},
>>  "package": "build-all"}, "capabilities": []}}
>> {"return": {}}
>> RAMBlock "sun4u.prom" already registered, abort!
>> Aborted (core dumped)
>>
>> This should not happen. Fix this problem by moving the affected code from
>> instance_init into a realize function instead.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>  hw/sparc64/sun4u.c | 18 ++++++++++++------
>>  1 file changed, 12 insertions(+), 6 deletions(-)
>>
>> diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
>> index 2044a52..d62f5a2 100644
>> --- a/hw/sparc64/sun4u.c
>> +++ b/hw/sparc64/sun4u.c
>> @@ -425,13 +425,19 @@ static void prom_init(hwaddr addr, const char *bios_name)
>>      }
>>  }
>>
>> -static void prom_init1(Object *obj)
>> +static void prom_realize(DeviceState *ds, Error **errp)
>>  {
>> -    PROMState *s = OPENPROM(obj);
>> -    SysBusDevice *dev = SYS_BUS_DEVICE(obj);
>> +    PROMState *s = OPENPROM(ds);
>> +    SysBusDevice *dev = SYS_BUS_DEVICE(ds);
>> +    Error *local_err = NULL;
>> +
>> +    memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4u.prom",
>> +                                     PROM_SIZE_MAX, &local_err);
>> +    if (local_err) {
>> +        error_propagate(errp, local_err);
>> +        return;
>> +    }
>>
>> -    memory_region_init_ram_nomigrate(&s->prom, obj, "sun4u.prom", PROM_SIZE_MAX,
>> -                           &error_fatal);
>>      vmstate_register_ram_global(&s->prom);
>>      memory_region_set_readonly(&s->prom, true);
>>      sysbus_init_mmio(dev, &s->prom);
>> @@ -446,6 +452,7 @@ static void prom_class_init(ObjectClass *klass, void *data)
>>      DeviceClass *dc = DEVICE_CLASS(klass);
>>
>>      dc->props = prom_properties;
>> +    dc->realize = prom_realize;
>>  }
>>
>>  static const TypeInfo prom_info = {
>> @@ -453,7 +460,6 @@ static const TypeInfo prom_info = {
>>      .parent        = TYPE_SYS_BUS_DEVICE,
>>      .instance_size = sizeof(PROMState),
>>      .class_init    = prom_class_init,
>> -    .instance_init = prom_init1,
>>  };
>
> Ping!

Acked-by: Artyom Tarasenko <atar4qemu@gmail.com>

Mark, can you please take this one too?

Artyom



-- 
Regards,
Artyom Tarasenko

SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-06-15  7:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-05  9:32 [Qemu-devel] [PATCH] hw/sparc64/sun4u: Fix introspection by converting prom instance_init to realize Thomas Huth
2018-04-05 16:22 ` Philippe Mathieu-Daudé
2018-04-05 16:27   ` Philippe Mathieu-Daudé
2018-04-06 14:41 ` Mark Cave-Ayland
2018-04-06 14:47   ` Thomas Huth
2018-06-15  5:16 ` Thomas Huth
2018-06-15  7:46   ` Artyom Tarasenko

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.