Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do QEMU monitor commands 'info mem' and 'info mtree' do?

I'm trying to understand QEMU memory management (using i386 guests, no KVM). QEMU monitor allows to list CPU registers info (info registers), USB devices (info usb), networking (info network) and so on.

But what about info mem and info mtree commands? There's a lack of documentation and it's difficult to figure out what these commands do.

For instance, I launched QEMU from some linux ISO and gave it 128MB of RAM. info mem gives the output:

(qemu) info mem
00000000c0000000-00000000c009b000 000000000009b000 -rw
00000000c009b000-00000000c009d000 0000000000002000 -r-
00000000c009d000-00000000c7ffe000 0000000007f61000 -rw
00000000c87fe000-00000000c87ff000 0000000000001000 -rw
...and more...
00000000c94f6000-00000000c94f7000 0000000000001000 -rw
00000000c94f8000-00000000c94fd000 0000000000005000 -rw
00000000c9500000-00000000c98c0000 00000000003c0000 -rw
00000000ff7f5000-00000000ff7f7000 0000000000002000 -rw
00000000ffffa000-00000000ffffc000 0000000000002000 -rw

Help states that you can use info mem to "show the active virtual memory mappings". First two columns give the virtual memory ranges, the third one shows the range length. But what are exactly these mappings? If it is the virtual memory, then what process it belongs to?

The similar situation with info mtree command.

like image 284
tonyo Avatar asked Feb 27 '13 08:02

tonyo


1 Answers

info mtree

This command shows the memory hiearchy of the process. In the commit log for QEmu, the following entry creates the first version of this feature. What info mtree does does is print a mapping of the system memory to different devices. The hierarchy of these devices is also represented.

commit 314e298735903035ba2b7b0f3cf39981f4171546
Author: Blue Swirl <[email protected]>
Date:   Sun Sep 11 20:22:05 2011 +0000

    memory: simple memory tree printer

    Add a monitor command 'info mtree' to show the memory hierarchy
    much like /proc/iomem in Linux.

    Signed-off-by: Blue Swirl <[email protected]>
    Signed-off-by: Avi Kivity <[email protected]>

The Qemu-devel list has a discussion of the feature for the original patch that added it as well as some improvements made to the feature over time.

info mem

As you stated, this command shows the active virtual memory mappings. It is not for a specific process, but instead just the current page table when you run the command. This page has a bit more information about the output format.

To get process level information you would need to do something inside the Linux OS you're emulating since Qemu only knows MMU-level information.

like image 99
kgraney Avatar answered Sep 29 '22 10:09

kgraney