Andreas Färber <afaer...@suse.de> writes:

> Am 26.04.2013 21:43, schrieb Anthony Liguori:
>> This returns a string similar to what the guest would display in
>> something like Linux's /dev/disk/by-id/ path.
>> 
>> Signed-off-by: Anthony Liguori <aligu...@us.ibm.com>
>> ---
>>  hw/ide/qdev.c | 15 +++++++++++++++
>>  1 file changed, 15 insertions(+)
>> 
>> diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
>> index 8a9a891..94b1664 100644
>> --- a/hw/ide/qdev.c
>> +++ b/hw/ide/qdev.c
>> @@ -270,6 +270,20 @@ static const TypeInfo ide_drive_info = {
>>      .class_init    = ide_drive_class_init,
>>  };
>>  
>> +static char *ide_device_get_model(Object *obj, Error **errp)
>> +{
>> +    IDEDevice *dev = IDE_DEVICE(obj);
>> +    IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus);
>
> IDEBus *bus = IDE_BUS(qdev_get_parent_bus(DEVICE(obj)));
>
> You're breaking your own rules. :)

Yeah, I copy/pasted, I'll clean up.

>
>> +    IDEState *s = bus->ifs + dev->unit;
>> +
>> +    return g_strdup_printf("%s %s", s->drive_model_str, 
>> s->drive_serial_str);
>> +}
>> +
>> +static void ide_device_initfn(Object *obj)
>> +{
>> +    object_property_add_str(obj, "drive-id", ide_device_get_model, NULL, 
>> NULL);
>> +}
>> +
>>  static void ide_device_class_init(ObjectClass *klass, void *data)
>>  {
>>      DeviceClass *k = DEVICE_CLASS(klass);
>> @@ -285,6 +299,7 @@ static const TypeInfo ide_device_type_info = {
>>      .abstract = true,
>>      .class_size = sizeof(IDEDeviceClass),
>>      .class_init = ide_device_class_init,
>> +    .instance_init = ide_device_initfn,
>
> You recently said ..._initfn was only a workaround for avoiding ..._init
> vs. ..._initfn name conflicts. I've therefore started changing new code
> to that pattern. There is no conflicting ide_device_init here.
>
> I don't really care which suffix we choose, but consistency is good.

I'm happy with using initfn consistently but I really don't care that
much.

Regards,

Anthony Liguori

>
>>  };
>>  
>>  static void ide_register_types(void)
>
> Regards,
> Andreas
>
> -- 
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg


Reply via email to