qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 06/11] sysbus: add realize() and unrealize()


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [PATCH 06/11] sysbus: add realize() and unrealize()
Date: Fri, 19 Jan 2018 16:03:19 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

On 01/19/2018 03:03 PM, Eduardo Habkost wrote:
> On Tue, Jan 16, 2018 at 10:15:50AM -0300, Philippe Mathieu-Daudé wrote:
> [...]
>> +static void sysbus_realize(DeviceState *dev, Error **errp)
>> +{
>> +    SysBusDevice *sd = SYS_BUS_DEVICE(dev);
>> +    SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
>> +
>> +    if (sbc->realize) {
>> +        sbc->realize(sd, errp);
>> +    }
>> +}
>> +
>> +static void sysbus_unrealize(DeviceState *dev, Error **errp)
>> +{
>> +    SysBusDevice *sd = SYS_BUS_DEVICE(dev);
>> +    SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
>> +
>> +    if (sbc->unrealize) {
>> +        sbc->unrealize(sd, errp);
>> +    }
>> +}
> 
> Why not just let the subclasses set DeviceClass::realize and
> DeviceClass::unrealize directly?

yes, clever :)

> 
>> +
>>  DeviceState *sysbus_create_varargs(const char *name,
>>                                     hwaddr addr, ...)
>>  {
>> @@ -325,6 +346,8 @@ static void sysbus_device_class_init(ObjectClass *klass, 
>> void *data)
>>  {
>>      DeviceClass *k = DEVICE_CLASS(klass);
>>      k->init = sysbus_device_init;
>> +    k->realize = sysbus_realize;
>> +    k->unrealize = sysbus_unrealize;
>>      k->bus_type = TYPE_SYSTEM_BUS;
>>      /*
>>       * device_add plugs devices into a suitable bus.  For "real" buses,
>> -- 
>> 2.15.1
>>
>>
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]