qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 8/9] memory: Allow memory region to display its subregions ow


From: Philippe Mathieu-Daudé
Subject: [RFC PATCH 8/9] memory: Allow memory region to display its subregions own descriptions
Date: Mon, 17 Aug 2020 18:18:52 +0200

If a MemoryRegion has subregion linked (but NOT mapped), these
subregions won't be displayed in the 'info mtree' HMP command.

Add the possibility to display such subregion descriptions.
It will result useful for the Interleaver memory device.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
Any clever idea?
---
 include/exec/memory.h |  6 ++++++
 softmmu/memory.c      | 22 ++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/include/exec/memory.h b/include/exec/memory.h
index 307e527835..8bcacfc79e 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -404,6 +404,12 @@ struct MemoryRegion {
     const char *name;
     unsigned ioeventfd_nb;
     MemoryRegionIoeventfd *ioeventfds;
+    /*
+     * If a memory region has subregions linked, it can use this
+     * handler to return an array of string, each string holding
+     * the subregion description.
+     */
+    GStrv (*subregions_description)(const MemoryRegion *mr);
 };
 
 struct IOMMUMemoryRegion {
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 8139da1a58..f8e27edbe2 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -2967,6 +2967,28 @@ static void mtree_print_mr(const MemoryRegion *mr, 
unsigned int level,
                 mtree_print_mr_owner(mr);
             }
             qemu_printf("\n");
+
+            if (mr->subregions_description) {
+                GStrv s = mr->subregions_description(mr);
+                for (int j = 0; s[j]; j++) {
+                    for (i = 0; i < level; i++) {
+                        qemu_printf(MTREE_INDENT);
+                    }
+                    qemu_printf(TARGET_FMT_plx "-" TARGET_FMT_plx
+                                " (prio %d, %s%s): %s%s",
+                                cur_start, cur_end,
+                                mr->priority,
+                                mr->nonvolatile ? "nv-" : "",
+                                memory_region_type((MemoryRegion *)mr),
+                                s[j],
+                                mr->enabled ? "" : " [disabled]");
+                    if (owner) {
+                        mtree_print_mr_owner(mr);
+                    }
+                    qemu_printf("\n");
+                }
+                g_strfreev(s);
+            }
         }
     }
 
-- 
2.26.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]