[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] how should a device implement an array of link(?) prope
Re: [Qemu-devel] how should a device implement an array of link(?) properties?
Thu, 28 Apr 2016 09:18:50 -0700
On Tue, Apr 26, 2016 at 5:45 AM, Peter Maydell <address@hidden> 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.
+static void a9mpcore_set_num_cpus(Object *obj, Visitor *v,
I guess instead of object_initialize() you want to replace with
> * 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,
foo ... . 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
> -- PMM