Re: [Qemu-devel] how should a device implement an array of link(?) properties?

2016-04-28 Thread Peter Crosthwaite
On Tue, Apr 26, 2016 at 5:45 AM, Peter Maydell  wrote:
> Hi; I have what seems like a fairly straightforward requirement for
> a QOM device but no idea how to implement it, so I'm looking for
> advice on the right "modern" way to do it...
>
> Specifically, this is the GICv3 device. It would like to have
> a pointer to every CPU object it needs to be connected to.
> My guess is that this should be an array of QOM link properties
> of some kind, so that the board level code can do:
>  * create the gicv3 device

>  * set the 'num-cpu' property

I guess you want to init the array of links here?

I had something similar for the MPCore refactoring, but instead of
initing a number of links in the property setter, it inited an array
of child devices and property value passthroughs.

https://lists.nongnu.org/archive/html/qemu-devel/2015-06/msg03633.html

see:
+static void a9mpcore_set_num_cpus(Object *obj, Visitor *v,

I guess instead of object_initialize() you want to replace with
object_property_add_link()?

>  * for each cpu: set the cpu[i] property to that CPU
>  * realize the device
>
> But how should I implement this in the device? There are
> qdev array properties, but there's no link qdev property type.
> Or should I not be using a link property at all?
> Suggestions for the right approach welcome.
>

Does the [*] syntax work? This can implement arrays of props
implicitly. See object_property_add() and the special casing of "[*]"
suffix. In init code, you should be able to create your link property
in a loop with "foo[*]" naming then then elements will be foo[0],
foo[1] ... . May be worth adding a helper to QOM to do the array
instantiation but for the underlying QOM representation, we already
have precedent for just using "[]" suffixes as special names for
arrays.

Regards,
Peter

> thanks
> -- PMM



[Qemu-devel] how should a device implement an array of link(?) properties?

2016-04-26 Thread Peter Maydell
Hi; I have what seems like a fairly straightforward requirement for
a QOM device but no idea how to implement it, so I'm looking for
advice on the right "modern" way to do it...

Specifically, this is the GICv3 device. It would like to have
a pointer to every CPU object it needs to be connected to.
My guess is that this should be an array of QOM link properties
of some kind, so that the board level code can do:
 * create the gicv3 device
 * set the 'num-cpu' property
 * for each cpu: set the cpu[i] property to that CPU
 * realize the device

But how should I implement this in the device? There are
qdev array properties, but there's no link qdev property type.
Or should I not be using a link property at all?
Suggestions for the right approach welcome.

thanks
-- PMM