qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/3] ide: add drive-id property


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 1/3] ide: add drive-id property
Date: Thu, 02 May 2013 07:59:19 -0500
User-agent: Notmuch/0.15.2+77~g661dcf8 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu)

Andreas Färber <address@hidden> 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 <address@hidden>
>> ---
>>  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

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