Gerd Hoffmann <kra...@redhat.com> writes:

>   Hi,
>
>> +#define DEFINE_IDE_DEV_PROPERTIES()                     \
>> +    DEFINE_PROP_UINT32("unit", IDEDrive, dev.unit, -1), \
>> +    DEFINE_BLOCK_PROPERTIES(IDEDrive, dev.conf),        \
>> +    DEFINE_PROP_STRING("ver",  IDEDrive, dev.version),  \
>> +    DEFINE_PROP_STRING("serial",  IDEDrive, dev.serial)
>
> This can also be done this way:
>
> static Property ide_properties[] = {
>     DEFINE_PROP_UINT32("unit", IDEDrive, dev.unit, -1),
>     [ ... ]
>     DEFINE_PROP_END_OF_LIST(),
> };
>
>> +static IDEDeviceInfo ide_dev_info[] = {
>> +    {
>> +        .qdev.name    = "ide-hd",
>> +        .qdev.fw_name = "drive",
>> +        .qdev.desc    = "virtual IDE disk",
>> +        .qdev.size    = sizeof(IDEDrive),
>> +        .init         = ide_hd_initfn,
>
>            .qdev.props   = ide_properties,
>
> Works only as long as all devices have exactly the same set (i.e. for
> scsi it wouldn't work as not all devices have the "removable"
> property).
>
> I tend to like this more than the #define.  YMMV, matter of taste.

In general, I prefer shared variables rather to duplication via #define,
too.  But in this case, I went with #define anyway, so we don't have to
change from variable to #define when a device-specific property comes
along, and for consistency with scsi-disk.c (whatever that's worth).

Reply via email to