qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 1/5] ide: Split qdev "ide-drive" into "ide-hd


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v2 1/5] ide: Split qdev "ide-drive" into "ide-hd" and "ide-cd"
Date: Tue, 10 May 2011 10:14:40 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Gerd Hoffmann <address@hidden> 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

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