* [Qemu-devel] [PATCH] sysbus: convert init() to realize()
@ 2018-01-14 2:52 Philippe Mathieu-Daudé
2018-01-14 15:32 ` Peter Maydell
0 siblings, 1 reply; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-01-14 2:52 UTC (permalink / raw)
To: Andreas Färber, Eduardo Habkost, Marcel Apfelbaum
Cc: Philippe Mathieu-Daudé, qemu-devel, Markus Armbruster
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/core/sysbus.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index 5d0887f499..0531eb60ce 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
+#include "qapi/error.h"
#include "hw/sysbus.h"
#include "monitor/monitor.h"
#include "exec/address-spaces.h"
@@ -200,15 +201,15 @@ void sysbus_init_ioports(SysBusDevice *dev, uint32_t ioport, uint32_t size)
}
}
-static int sysbus_device_init(DeviceState *dev)
+static void sysbus_device_realize(DeviceState *dev, Error **errp)
{
SysBusDevice *sd = SYS_BUS_DEVICE(dev);
SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
- if (!sbc->init) {
- return 0;
+ if (sbc->init && sbc->init(sd)) {
+ error_setg(errp, "sysbus device initialization failed");
+ return;
}
- return sbc->init(sd);
}
DeviceState *sysbus_create_varargs(const char *name,
@@ -324,7 +325,7 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
static void sysbus_device_class_init(ObjectClass *klass, void *data)
{
DeviceClass *k = DEVICE_CLASS(klass);
- k->init = sysbus_device_init;
+ k->realize = sysbus_device_realize;
k->bus_type = TYPE_SYSTEM_BUS;
/*
* device_add plugs devices into a suitable bus. For "real" buses,
--
2.15.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] sysbus: convert init() to realize()
2018-01-14 2:52 [Qemu-devel] [PATCH] sysbus: convert init() to realize() Philippe Mathieu-Daudé
@ 2018-01-14 15:32 ` Peter Maydell
2018-01-14 18:12 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2018-01-14 15:32 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Andreas Färber, Eduardo Habkost, Marcel Apfelbaum,
Markus Armbruster, QEMU Developers
On 14 January 2018 at 02:52, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/core/sysbus.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
> index 5d0887f499..0531eb60ce 100644
> --- a/hw/core/sysbus.c
> +++ b/hw/core/sysbus.c
> @@ -18,6 +18,7 @@
> */
>
> #include "qemu/osdep.h"
> +#include "qapi/error.h"
> #include "hw/sysbus.h"
> #include "monitor/monitor.h"
> #include "exec/address-spaces.h"
> @@ -200,15 +201,15 @@ void sysbus_init_ioports(SysBusDevice *dev, uint32_t ioport, uint32_t size)
> }
> }
>
> -static int sysbus_device_init(DeviceState *dev)
> +static void sysbus_device_realize(DeviceState *dev, Error **errp)
> {
> SysBusDevice *sd = SYS_BUS_DEVICE(dev);
> SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
>
> - if (!sbc->init) {
> - return 0;
> + if (sbc->init && sbc->init(sd)) {
> + error_setg(errp, "sysbus device initialization failed");
> + return;
> }
> - return sbc->init(sd);
> }
>
> DeviceState *sysbus_create_varargs(const char *name,
> @@ -324,7 +325,7 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
> static void sysbus_device_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *k = DEVICE_CLASS(klass);
> - k->init = sysbus_device_init;
> + k->realize = sysbus_device_realize;
> k->bus_type = TYPE_SYSTEM_BUS;
> /*
> * device_add plugs devices into a suitable bus. For "real" buses,
This doesn't look right. SysBus::init is something we're trying
to deprecate, I think, so we should be looking to complete
that process, not changing its semantics so it isn't called
until Device::realize.
thanks
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] sysbus: convert init() to realize()
2018-01-14 15:32 ` Peter Maydell
@ 2018-01-14 18:12 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-01-14 18:12 UTC (permalink / raw)
To: Peter Maydell
Cc: Andreas Färber, Eduardo Habkost, Marcel Apfelbaum,
Markus Armbruster, QEMU Developers
On 01/14/2018 12:32 PM, Peter Maydell wrote:
> On 14 January 2018 at 02:52, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>> hw/core/sysbus.c | 11 ++++++-----
>> 1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
>> index 5d0887f499..0531eb60ce 100644
>> --- a/hw/core/sysbus.c
>> +++ b/hw/core/sysbus.c
>> @@ -18,6 +18,7 @@
>> */
>>
>> #include "qemu/osdep.h"
>> +#include "qapi/error.h"
>> #include "hw/sysbus.h"
>> #include "monitor/monitor.h"
>> #include "exec/address-spaces.h"
>> @@ -200,15 +201,15 @@ void sysbus_init_ioports(SysBusDevice *dev, uint32_t ioport, uint32_t size)
>> }
>> }
>>
>> -static int sysbus_device_init(DeviceState *dev)
>> +static void sysbus_device_realize(DeviceState *dev, Error **errp)
>> {
>> SysBusDevice *sd = SYS_BUS_DEVICE(dev);
>> SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
>>
>> - if (!sbc->init) {
>> - return 0;
>> + if (sbc->init && sbc->init(sd)) {
>> + error_setg(errp, "sysbus device initialization failed");
>> + return;
>> }
>> - return sbc->init(sd);
>> }
>>
>> DeviceState *sysbus_create_varargs(const char *name,
>> @@ -324,7 +325,7 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
>> static void sysbus_device_class_init(ObjectClass *klass, void *data)
>> {
>> DeviceClass *k = DEVICE_CLASS(klass);
>> - k->init = sysbus_device_init;
>> + k->realize = sysbus_device_realize;
>> k->bus_type = TYPE_SYSTEM_BUS;
>> /*
>> * device_add plugs devices into a suitable bus. For "real" buses,
>
> This doesn't look right. SysBus::init is something we're trying
> to deprecate, I think, so we should be looking to complete
> that process, not changing its semantics so it isn't called
> until Device::realize.
Ok, I think if I put all those related patches altogether in the same
series this will make more sens.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-14 18:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-14 2:52 [Qemu-devel] [PATCH] sysbus: convert init() to realize() Philippe Mathieu-Daudé
2018-01-14 15:32 ` Peter Maydell
2018-01-14 18:12 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).