qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 6/7] pcspk: Convert to qdev


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH v3 6/7] pcspk: Convert to qdev
Date: Tue, 31 Jan 2012 17:23:03 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Lightning/1.0b2 Thunderbird/3.1.15

On 01/31/2012 04:48 PM, Jan Kiszka wrote:
On 2012-01-31 23:40, Anthony Liguori wrote:
Why is what's in the tree not usable?

Just don't do pcspk_init as a static inline (which is not that nice to
do anyway) and you don't need to worry about the availability of an
accessor.

The current pattern requested by some reviewers used to be the one I
applied here. I dislike it as well when the device can't be seriously
configured out. But I can switch over, no problem.


And BTW, there is strict type checking now, which makes it already an
improvement over property pointers.

OK, for my slow understanding: I use qdev_property_add_link in the
device init function to create the property, letting it point to a state
field. But what should I call from the outside to actually set its
value?

You have a few options:

1) you can add a generic set_child function to qdev... but don't do this, I'll fix it right in my future series

2) You can take advantage of the fact that the only thing that ever sets this is pcspk_init, move pcspk_init to pcspk.c, and then since you have access to the state structure, directly assign it there.

3) Introduce a pcspk_set_pit() function that just does the same thing as (2).

4) Introduce (1) and then have a pcspk_set_pit() that just calls (1). This is what I think we should do moving forward and I plan to do this in my future refactorings.

That all said, I think this isn't going to work for you until my next series is merged. Right now, the link properties have strict type checking. You really need a link<PITCommon> in order to be able to accept either a KVMPIT or a normal PIT. My series on the list relaxes the type checking to use implements instead of a strict equality check.

So maybe the best thing to do is drop the ptr type entirely, make pcspk_init() be in pcspk.c and touch the private state, and then I'll refactor it later to use a link<> property.

And what C type does this value have?

PITState *.

Regards,

Anthony Liguroi

 A DeviceState * or a char *
(path)?

Jan




reply via email to

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