From d8d95814609e89e5438a3318a647ec322fc4ff16 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 11 Jun 2014 12:42:01 +0200 Subject: memory: convert memory_region_destroy to object_unparent Explicitly call object_unparent in the few places where we will re-create the memory region. If the memory region is simply being destroyed as part of device teardown, let QOM handle it. Signed-off-by: Paolo Bonzini --- memory.c | 1 - 1 file changed, 1 deletion(-) (limited to 'memory.c') diff --git a/memory.c b/memory.c index 64d7176193..23c5269b8e 100644 --- a/memory.c +++ b/memory.c @@ -1266,7 +1266,6 @@ static void memory_region_finalize(Object *obj) void memory_region_destroy(MemoryRegion *mr) { - object_unparent(OBJECT(mr)); } -- cgit v1.2.1 From 469b046ead0671932ff3af8d6f95045b19b186ef Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 11 Jun 2014 12:50:43 +0200 Subject: memory: remove memory_region_destroy The function is empty after the previous patch, so remove it. Reviewed-by: Peter Crosthwaite Signed-off-by: Paolo Bonzini --- memory.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'memory.c') diff --git a/memory.c b/memory.c index 23c5269b8e..f11c035f0e 100644 --- a/memory.c +++ b/memory.c @@ -1264,11 +1264,6 @@ static void memory_region_finalize(Object *obj) g_free(mr->ioeventfds); } -void memory_region_destroy(MemoryRegion *mr) -{ -} - - Object *memory_region_owner(MemoryRegion *mr) { Object *obj = OBJECT(mr); -- cgit v1.2.1 From 5d546d4b65a3751172286e299528de15c5f05576 Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Thu, 14 Aug 2014 23:55:03 -0700 Subject: memory: constify memory_region_name It doesn't change the MR and some prospective call sites will have const MRs at hand. Signed-off-by: Peter Crosthwaite Signed-off-by: Paolo Bonzini --- memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'memory.c') diff --git a/memory.c b/memory.c index f11c035f0e..1cde6ff660 100644 --- a/memory.c +++ b/memory.c @@ -1308,7 +1308,7 @@ uint64_t memory_region_size(MemoryRegion *mr) return int128_get64(mr->size); } -const char *memory_region_name(MemoryRegion *mr) +const char *memory_region_name(const MemoryRegion *mr) { return mr->name; } -- cgit v1.2.1 From 3fb18b4da7a545321e38b4a59f38995630a8d752 Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Thu, 14 Aug 2014 23:55:36 -0700 Subject: memory: Use memory_region_name for name access Despite being local to memory.c, use the helper function. This prepares support for fully QOMifiying the name field of MR (which will remove this state from MR completely). Signed-off-by: Peter Crosthwaite Signed-off-by: Paolo Bonzini --- memory.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'memory.c') diff --git a/memory.c b/memory.c index 1cde6ff660..b6b208fa95 100644 --- a/memory.c +++ b/memory.c @@ -2027,8 +2027,8 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f, mr->romd_mode ? 'R' : '-', !mr->readonly && !(mr->rom_device && mr->romd_mode) ? 'W' : '-', - mr->name, - mr->alias->name, + memory_region_name(mr), + memory_region_name(mr->alias), mr->alias_offset, mr->alias_offset + (int128_nz(mr->size) ? @@ -2046,7 +2046,7 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f, mr->romd_mode ? 'R' : '-', !mr->readonly && !(mr->rom_device && mr->romd_mode) ? 'W' : '-', - mr->name); + memory_region_name(mr)); } QTAILQ_INIT(&submr_print_queue); @@ -2095,7 +2095,7 @@ void mtree_info(fprintf_function mon_printf, void *f) /* print aliased regions */ QTAILQ_FOREACH(ml, &ml_head, queue) { if (!ml->printed) { - mon_printf(f, "%s\n", ml->mr->name); + mon_printf(f, "%s\n", memory_region_name(ml->mr)); mtree_print_mr(mon_printf, f, ml->mr, 0, 0, &ml_head); } } -- cgit v1.2.1 From b0225c2c0d89200a29dc3d0b59d2e87a79cbaeb8 Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Thu, 14 Aug 2014 23:56:08 -0700 Subject: memory: Use canonical path component as the name Rather than having the name as separate state. This prepares support for creating a MemoryRegion dynamically (i.e. without memory_region_init() and friends) and the MemoryRegion still getting a usable name. Signed-off-by: Peter Crosthwaite Signed-off-by: Paolo Bonzini --- memory.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'memory.c') diff --git a/memory.c b/memory.c index b6b208fa95..8da29af672 100644 --- a/memory.c +++ b/memory.c @@ -915,7 +915,6 @@ void memory_region_init(MemoryRegion *mr, if (size == UINT64_MAX) { mr->size = int128_2_64(); } - mr->name = g_strdup(name); if (name) { object_property_add_child_array(owner, name, OBJECT(mr)); @@ -1260,7 +1259,6 @@ static void memory_region_finalize(Object *obj) assert(memory_region_transaction_depth == 0); mr->destructor(mr); memory_region_clear_coalescing(mr); - g_free((char *)mr->name); g_free(mr->ioeventfds); } @@ -1310,7 +1308,7 @@ uint64_t memory_region_size(MemoryRegion *mr) const char *memory_region_name(const MemoryRegion *mr) { - return mr->name; + return object_get_canonical_path_component(OBJECT(mr)); } bool memory_region_is_ram(MemoryRegion *mr) -- cgit v1.2.1 From f54bb15f9d373877954e44db3a8bb368aff45b42 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 11 Dec 2013 12:51:46 +0100 Subject: mtree: remove write-only field ml->printed is never set to true. Signed-off-by: Paolo Bonzini --- memory.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'memory.c') diff --git a/memory.c b/memory.c index 8da29af672..031ff516ae 100644 --- a/memory.c +++ b/memory.c @@ -1972,7 +1972,6 @@ typedef struct MemoryRegionList MemoryRegionList; struct MemoryRegionList { const MemoryRegion *mr; - bool printed; QTAILQ_ENTRY(MemoryRegionList) queue; }; @@ -2002,7 +2001,7 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f, /* check if the alias is already in the queue */ QTAILQ_FOREACH(ml, alias_print_queue, queue) { - if (ml->mr == mr->alias && !ml->printed) { + if (ml->mr == mr->alias) { found = true; } } @@ -2010,7 +2009,6 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f, if (!found) { ml = g_new(MemoryRegionList, 1); ml->mr = mr->alias; - ml->printed = false; QTAILQ_INSERT_TAIL(alias_print_queue, ml, queue); } mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx @@ -2092,10 +2090,8 @@ void mtree_info(fprintf_function mon_printf, void *f) mon_printf(f, "aliases\n"); /* print aliased regions */ QTAILQ_FOREACH(ml, &ml_head, queue) { - if (!ml->printed) { - mon_printf(f, "%s\n", memory_region_name(ml->mr)); - mtree_print_mr(mon_printf, f, ml->mr, 0, 0, &ml_head); - } + mon_printf(f, "%s\n", memory_region_name(ml->mr)); + mtree_print_mr(mon_printf, f, ml->mr, 0, 0, &ml_head); } QTAILQ_FOREACH_SAFE(ml, &ml_head, queue, ml2) { -- cgit v1.2.1