Markus Armbruster <arm...@redhat.com> writes:

> Anthony Liguori <aligu...@us.ibm.com> writes:
>
>> On 05/11/2012 10:22 AM, Markus Armbruster wrote:
[...]
>>> diff --git a/hw/fdc.c b/hw/fdc.c
>>> index d9c4fbf..98ff87a 100644
>>> --- a/hw/fdc.c
>>> +++ b/hw/fdc.c
>>> @@ -54,6 +54,33 @@
>>>   /********************************************************/
>>>   /* Floppy drive emulation                               */
>>>
>>> +typedef struct FDD {
>>> +    Object obj;
>>> +    BlockDriverState *bs;
>>> +} FDD;
>>> +
>>> +#define TYPE_FDD "fdd"
>>> +
>>> +static TypeInfo fdd_info = {
>>> +    .name          = TYPE_FDD,
>>> +    .parent        = TYPE_OBJECT,
>>> +    .instance_size = sizeof(FDD),
>>> +};
>>> +
>>> +static void fdd_create(Object *fdc, const char *link_name,
>>> +                       BlockDriverState *bs)
>>> +{
>>> +    Object *obj = object_new(TYPE_FDD);
>>> +    FDD *fdd = OBJECT_CHECK(FDD, obj, TYPE_FDD);
>>> +
>>> +    fdd->bs = bs;
>>> +    object_property_add_child(qdev_get_machine(), "fdd", obj, NULL);
>>> +    object_property_set_link(fdc, obj, link_name, NULL);
>>> +}
>>
>> This is not quite right.  You want to do the actual initialization in
>> instance_init as a method.
>
> Will do, thanks.
>
>>                             You should make the BlockDriverState a
>> property too. The fdd_create() call then because object_new() +
>> setting properties only.
>
> Last sentence no verb?

I'm guessing s/because/becomes/

I'm afraid adding a drive property would require way too much surgery
right now.  The existing drive property code is encapsulated in
qdev-properties.c, and works only for subtypes of TYPE_DEVICE.  I guess
I have to shelve this work until I can make TYPE_FDD one.

Reply via email to