On Fri, May 16, 2014 at 11:53 AM, Peter Crosthwaite <peter.crosthwa...@xilinx.com> wrote: > Expose the already existing .parent and .addr fields as QOM properties. > Setting the address will cause the memory subregion adding to happen if > it has not already. If the memory region is already contained, then > change it's address as per the established memory_region_set_address() > semantics. > > Signed-off-by: Peter Crosthwaite <peter.crosthwa...@xilinx.com> > --- > > memory.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 54 insertions(+) > > diff --git a/memory.c b/memory.c > index a37fdd2..4a70920 100644 > --- a/memory.c > +++ b/memory.c > @@ -16,6 +16,7 @@ > #include "exec/memory.h" > #include "exec/address-spaces.h" > #include "exec/ioport.h" > +#include "qapi/visitor.h" > #include "qemu/bitops.h" > #include "qom/object.h" > #include "trace.h" > @@ -844,6 +845,49 @@ void memory_region_init(MemoryRegion *mr, > mr->name = g_strdup(name); > } > > +static void do_memory_region_add_subregion_common(MemoryRegion *subregion); > + > +static void memory_region_get_addr(Object *obj, Visitor *v, void *opaque, > + const char *name, Error **errp) > +{ > + MemoryRegion *mr = MEMORY_REGION(obj); > + Error *local_err = NULL; > + uint64_t value = mr->addr; > + > + visit_type_uint64(v, &value, name, &local_err); > + if (local_err) { > + error_propagate(errp, local_err); > + } > +} > + > +static void memory_region_set_addr(Object *obj, Visitor *v, void *opaque, > + const char *name, Error **errp) > +{ > + MemoryRegion *mr = MEMORY_REGION(obj); > + Error *local_err = NULL; > + uint64_t value; > + > + visit_type_uint64(v, &value, name, &local_err); > + if (local_err) { > + error_propagate(errp, local_err); > + return; > + } > + > + /* In an ideal world we wait until both the parent and address is set in > + * either order, then call do_memory_region_add_subregion_common() > + * from the latter property setter. However, as parent is just a dumb > link > + * we only support setting from the address setter. We therefore assert > + * here that the two props are set in correct order. > + */
So I have a fix on this. I just rolled my own link property with object_property_add (and a few callbacks) rather than use object_property_add_link. The memory_region_add_subregion then happens from the link setter. Regards, Peter