From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvDuX-0007X3-Dp for qemu-devel@nongnu.org; Sun, 30 Nov 2014 18:28:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XvDuS-0004lm-14 for qemu-devel@nongnu.org; Sun, 30 Nov 2014 18:28:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57961) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvDuR-0004l1-P0 for qemu-devel@nongnu.org; Sun, 30 Nov 2014 18:28:07 -0500 Date: Sun, 30 Nov 2014 23:28:03 +0000 From: "Richard W.M. Jones" Message-ID: <20141130232803.GD14637@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] How does qemu know the virtual memory of the guest os? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jidong Xiao Cc: qemu-devel , KVM On Fri, Nov 28, 2014 at 04:17:10PM -0800, Jidong Xiao wrote: > Hi, > > I notice that Qemu supports dump virtual memory of Guest OS. As this > page suggests: > > ======== > http://doc.opensuse.org/products/draft/SLES/SLES-kvm_sd_draft/cha.qemu.monitor.html > > To save the content of the virtual machine memory to a disk or console > output, use the following commands: > > memsave addr size filename > > Saves virtual memory dump starting at addr of size size to file filename > > pmemsave addr size filename > > Saves physical memory dump starting at addr of size size to file filename > ========= > > I understand that hypervisors certainly know the physical memory of > virtual machine, but how does it know the virtual memory of the Guest > OS? I think the hypervisor has no semantic knowledge of the Guest OS, > and such knowledge should be different for different OS (e.g., Windows > vs Linux), so I am really surprised that Qemu can dump the virtual > memory of the Guest OS. Can someone kindly give me some explanation? > Thank you very much!! It's different for each *architecture*, but not for each OS. For example on x86 it starts by reading the CR* control registers, and then the page tables (see target-i386/helper.c: x86_cpu_get_phys_page_debug). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org