[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/41] memory: hmp: add "-f" for "info mtree"
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 09/41] memory: hmp: add "-f" for "info mtree" |
Date: |
Fri, 27 Jan 2017 14:45:17 +0100 |
From: Peter Xu <address@hidden>
Adding one more option "-f" for "info mtree" to dump the flat views of
all the address spaces.
This will be useful to debug the memory rendering logic, also it'll be
much easier with it to know what memory region is handling what address
range.
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hmp-commands-info.hx | 6 +++---
include/exec/memory.h | 2 +-
memory.c | 41 ++++++++++++++++++++++++++++++++++++++++-
monitor.c | 4 +++-
4 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 55d50c4..b0f35e6 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -249,9 +249,9 @@ ETEXI
{
.name = "mtree",
- .args_type = "",
- .params = "",
- .help = "show memory tree",
+ .args_type = "flatview:-f",
+ .params = "[-f]",
+ .help = "show memory tree (-f: dump flat view for address
spaces)",
.cmd = hmp_info_mtree,
},
diff --git a/include/exec/memory.h b/include/exec/memory.h
index a10044f..987f925 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -1250,7 +1250,7 @@ void memory_global_dirty_log_start(void);
*/
void memory_global_dirty_log_stop(void);
-void mtree_info(fprintf_function mon_printf, void *f);
+void mtree_info(fprintf_function mon_printf, void *f, bool flatview);
/**
* memory_region_dispatch_read: perform a read directly to the specified
diff --git a/memory.c b/memory.c
index c42bde4..6498727 100644
--- a/memory.c
+++ b/memory.c
@@ -2564,12 +2564,51 @@ static void mtree_print_mr(fprintf_function mon_printf,
void *f,
}
}
-void mtree_info(fprintf_function mon_printf, void *f)
+static void mtree_print_flatview(fprintf_function p, void *f,
+ AddressSpace *as)
+{
+ FlatView *view = address_space_get_flatview(as);
+ FlatRange *range = &view->ranges[0];
+ MemoryRegion *mr;
+ int n = view->nr;
+
+ if (n <= 0) {
+ p(f, MTREE_INDENT "No rendered FlatView for "
+ "address space '%s'\n", as->name);
+ flatview_unref(view);
+ return;
+ }
+
+ while (n--) {
+ mr = range->mr;
+ p(f, MTREE_INDENT TARGET_FMT_plx "-"
+ TARGET_FMT_plx " (prio %d, %s): %s\n",
+ int128_get64(range->addr.start),
+ int128_get64(range->addr.start) + MR_SIZE(range->addr.size),
+ mr->priority,
+ memory_region_type(mr),
+ memory_region_name(mr));
+ range++;
+ }
+
+ flatview_unref(view);
+}
+
+void mtree_info(fprintf_function mon_printf, void *f, bool flatview)
{
MemoryRegionListHead ml_head;
MemoryRegionList *ml, *ml2;
AddressSpace *as;
+ if (flatview) {
+ QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
+ mon_printf(f, "address-space (flat view): %s\n", as->name);
+ mtree_print_flatview(mon_printf, f, as);
+ mon_printf(f, "\n");
+ }
+ return;
+ }
+
QTAILQ_INIT(&ml_head);
QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
diff --git a/monitor.c b/monitor.c
index 8b06b63..6ac4e95 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1529,7 +1529,9 @@ static void hmp_boot_set(Monitor *mon, const QDict *qdict)
static void hmp_info_mtree(Monitor *mon, const QDict *qdict)
{
- mtree_info((fprintf_function)monitor_printf, mon);
+ bool flatview = qdict_get_try_bool(qdict, "flatview", false);
+
+ mtree_info((fprintf_function)monitor_printf, mon, flatview);
}
static void hmp_info_numa(Monitor *mon, const QDict *qdict)
--
1.8.3.1
- [Qemu-devel] [PULL 04/41] savevm: add public save_vmstate function, (continued)
- [Qemu-devel] [PULL 04/41] savevm: add public save_vmstate function, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 05/41] replay: save/load initial state, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 01/41] icount: update instruction counter on apic patching, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 02/41] replay: improve interrupt handling, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 06/41] replay: exception replay fix, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 07/41] apic: save apic_delivered flag, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 08/41] memory: tune mtree_print_mr() to dump mr type, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 12/41] hw/isa/lpc_ich9: negotiate SMI broadcast on pc-q35-2.9+ machine types, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 11/41] hw/isa/lpc_ich9: add broadcast SMI feature, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 13/41] block/iscsi: avoid data corruption with cache=writeback, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 09/41] memory: hmp: add "-f" for "info mtree",
Paolo Bonzini <=
- [Qemu-devel] [PULL 10/41] hw/isa/lpc_ich9: add SMI feature negotiation via fw_cfg, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 14/41] Introduce DEVICE_CATEGORY_CPU for CPU devices, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 15/41] hw/scsi: Fix debug message of cdb structure in scsi-generic, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 17/41] block: get max_transfer limit for char (scsi-generic) devices, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 18/41] x86-KVM: Supply TSC and APIC clock rates to guest like VMWare, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 16/41] block: Fix target variable of BLKSECTGET ioctl, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 19/41] pc: Enable vmware-cpuid-freq CPU option for 2.9+ machine types, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 23/41] char: add qemu_chr_fe_add_watch() Returns description, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 20/41] block/iscsi: statically link qemu_iscsi_opts, Paolo Bonzini, 2017/01/27
- [Qemu-devel] [PULL 24/41] doc: fix spelling, Paolo Bonzini, 2017/01/27