diff mbox

[v2,01/16] memory: Allow subregions to not be printed by info mtree

Message ID cc170c44bbc7d3701ea51e5f09b33ce05aeeceea.1453237258.git.alistair.francis@xilinx.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alistair Francis Jan. 19, 2016, 10:34 p.m. UTC
Add a function called memory_region_add_subregion_no_print() that
creates memory subregions that won't be printed when running
the 'info mtree' command.

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
---

 include/exec/memory.h | 17 +++++++++++++++++
 memory.c              | 10 +++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

Comments

KONRAD Frédéric Jan. 27, 2016, 3:05 p.m. UTC | #1
Le 19/01/2016 23:34, Alistair Francis a écrit :
> Add a function called memory_region_add_subregion_no_print() that
> creates memory subregions that won't be printed when running
> the 'info mtree' command.
>
> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
> ---
>
>   include/exec/memory.h | 17 +++++++++++++++++
>   memory.c              | 10 +++++++++-
>   2 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index 01f1004..eff2a89 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -186,6 +186,7 @@ struct MemoryRegion {
>       bool skip_dump;
>       bool enabled;
>       bool warning_printed; /* For reservations */
> +    bool do_not_print;
>       uint8_t vga_logging_count;
>       MemoryRegion *alias;
>       hwaddr alias_offset;
> @@ -952,6 +953,22 @@ void memory_region_del_eventfd(MemoryRegion *mr,
>   void memory_region_add_subregion(MemoryRegion *mr,
>                                    hwaddr offset,
>                                    MemoryRegion *subregion);
> +
> +/**
> + * memory_region_add_subregion_no_print: Add a subregion to a container.
> + *
> + * The same functionality as memory_region_add_subregion except that any
> + * memory regions added by this function are not printed by 'info mtree'.
> + *
> + * @mr: the region to contain the new subregion; must be a container
> + *      initialized with memory_region_init().
> + * @offset: the offset relative to @mr where @subregion is added.
> + * @subregion: the subregion to be added.
> + */
> +void memory_region_add_subregion_no_print(MemoryRegion *mr,
> +                                          hwaddr offset,
> +                                          MemoryRegion *subregion);
> +
>   /**
>    * memory_region_add_subregion_overlap: Add a subregion to a container
>    *                                      with overlap.
> diff --git a/memory.c b/memory.c
> index 93bd8ed..ee90682 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -1827,6 +1827,14 @@ void memory_region_add_subregion(MemoryRegion *mr,
>       memory_region_add_subregion_common(mr, offset, subregion);
>   }
>   
> +void memory_region_add_subregion_no_print(MemoryRegion *mr,
> +                                          hwaddr offset,
> +                                          MemoryRegion *subregion)
> +{
> +    memory_region_add_subregion(mr, offset, subregion);
> +    subregion->do_not_print = true;
> +}
> +
>   void memory_region_add_subregion_overlap(MemoryRegion *mr,
>                                            hwaddr offset,
>                                            MemoryRegion *subregion,
> @@ -2190,7 +2198,7 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
>       const MemoryRegion *submr;
>       unsigned int i;
>   
> -    if (!mr) {
> +    if (!mr || mr->do_not_print) {
>           return;
>       }
>   
Seems OK to me.
Reviewed-by: KONRAD Frederic <fred.konrad@greensocs.com>
diff mbox

Patch

diff --git a/include/exec/memory.h b/include/exec/memory.h
index 01f1004..eff2a89 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -186,6 +186,7 @@  struct MemoryRegion {
     bool skip_dump;
     bool enabled;
     bool warning_printed; /* For reservations */
+    bool do_not_print;
     uint8_t vga_logging_count;
     MemoryRegion *alias;
     hwaddr alias_offset;
@@ -952,6 +953,22 @@  void memory_region_del_eventfd(MemoryRegion *mr,
 void memory_region_add_subregion(MemoryRegion *mr,
                                  hwaddr offset,
                                  MemoryRegion *subregion);
+
+/**
+ * memory_region_add_subregion_no_print: Add a subregion to a container.
+ *
+ * The same functionality as memory_region_add_subregion except that any
+ * memory regions added by this function are not printed by 'info mtree'.
+ *
+ * @mr: the region to contain the new subregion; must be a container
+ *      initialized with memory_region_init().
+ * @offset: the offset relative to @mr where @subregion is added.
+ * @subregion: the subregion to be added.
+ */
+void memory_region_add_subregion_no_print(MemoryRegion *mr,
+                                          hwaddr offset,
+                                          MemoryRegion *subregion);
+
 /**
  * memory_region_add_subregion_overlap: Add a subregion to a container
  *                                      with overlap.
diff --git a/memory.c b/memory.c
index 93bd8ed..ee90682 100644
--- a/memory.c
+++ b/memory.c
@@ -1827,6 +1827,14 @@  void memory_region_add_subregion(MemoryRegion *mr,
     memory_region_add_subregion_common(mr, offset, subregion);
 }
 
+void memory_region_add_subregion_no_print(MemoryRegion *mr,
+                                          hwaddr offset,
+                                          MemoryRegion *subregion)
+{
+    memory_region_add_subregion(mr, offset, subregion);
+    subregion->do_not_print = true;
+}
+
 void memory_region_add_subregion_overlap(MemoryRegion *mr,
                                          hwaddr offset,
                                          MemoryRegion *subregion,
@@ -2190,7 +2198,7 @@  static void mtree_print_mr(fprintf_function mon_printf, void *f,
     const MemoryRegion *submr;
     unsigned int i;
 
-    if (!mr) {
+    if (!mr || mr->do_not_print) {
         return;
     }