All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] how should a device implement an array of link(?) properties?
@ 2016-04-26 12:45 Peter Maydell
  2016-04-28 16:18 ` Peter Crosthwaite
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Maydell @ 2016-04-26 12:45 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Peter Crosthwaite, Paolo Bonzini, Andreas Färber

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] how should a device implement an array of link(?) properties?
  2016-04-26 12:45 [Qemu-devel] how should a device implement an array of link(?) properties? Peter Maydell
@ 2016-04-28 16:18 ` Peter Crosthwaite
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Crosthwaite @ 2016-04-28 16:18 UTC (permalink / raw)
  To: Peter Maydell
  Cc: QEMU Developers, Peter Crosthwaite, Paolo Bonzini, Andreas Färber

On Tue, Apr 26, 2016 at 5:45 AM, Peter Maydell <peter.maydell@linaro.org> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-28 16:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-26 12:45 [Qemu-devel] how should a device implement an array of link(?) properties? Peter Maydell
2016-04-28 16:18 ` Peter Crosthwaite

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.