From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuhVc-0008Ib-5T for qemu-devel@nongnu.org; Wed, 11 Jun 2014 08:20:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WuhVW-0001W8-6W for qemu-devel@nongnu.org; Wed, 11 Jun 2014 08:20:04 -0400 Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:65086) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuhVW-0001Vk-0B for qemu-devel@nongnu.org; Wed, 11 Jun 2014 08:19:58 -0400 Received: by mail-wi0-f177.google.com with SMTP id f8so988896wiw.16 for ; Wed, 11 Jun 2014 05:19:57 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 11 Jun 2014 14:19:34 +0200 Message-Id: <1402489176-19738-12-git-send-email-pbonzini@redhat.com> In-Reply-To: <1402489176-19738-1-git-send-email-pbonzini@redhat.com> References: <1402489176-19738-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [RFC PATCH 11/13] memory: MemoryRegion: Add container and addr props List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.crosthwaite@xilinx.com, afaerber@suse.de From: Peter Crosthwaite Expose the already existing .parent and .addr fields as QOM properties. .parent (i.e. the field describing the memory region that contains this one in Memory hierachy) is renamed "container". This is to avoid confusion with the QOM parent. Signed-off-by: Peter Crosthwaite [Remove setters. Do not unref parent on releasing the property. Clean up error propagation. - Paolo] Signed-off-by: Paolo Bonzini --- memory.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/memory.c b/memory.c index acbab4c..13a9fe8 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" @@ -882,6 +883,38 @@ void memory_region_init(MemoryRegion *mr, } } +static void memory_region_get_addr(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + MemoryRegion *mr = MEMORY_REGION(obj); + uint64_t value = mr->addr; + + visit_type_uint64(v, &value, name, errp); +} + +static void memory_region_get_container(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + MemoryRegion *mr = MEMORY_REGION(obj); + gchar *path = (gchar *)""; + + if (mr->container) { + path = object_get_canonical_path(OBJECT(mr->container)); + } + visit_type_str(v, &path, name, errp); + if (mr->container) { + g_free(path); + } +} + +static Object *memory_region_resolve_container(Object *obj, void *opaque, + const char *part) +{ + MemoryRegion *mr = MEMORY_REGION(obj); + + return OBJECT(mr->container); +} + static void memory_region_initfn(Object *obj) { MemoryRegion *mr = MEMORY_REGION(obj); @@ -892,6 +925,18 @@ static void memory_region_initfn(Object *obj) mr->destructor = memory_region_destructor_none; QTAILQ_INIT(&mr->subregions); QTAILQ_INIT(&mr->coalesced); + + object_property_add_full(OBJECT(mr), "container", + "link<" TYPE_MEMORY_REGION ">", + memory_region_get_container, + NULL, /* memory_region_set_container */ + memory_region_resolve_container, + NULL, NULL, &error_abort); + + object_property_add(OBJECT(mr), "addr", "uint64", + memory_region_get_addr, + NULL, /* memory_region_set_addr */ + NULL, NULL, &error_abort); } static uint64_t unassigned_mem_read(void *opaque, hwaddr addr, -- 1.8.3.1