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

[libvirt] Re: virDomainMemoryPeek for Xen?



On Wed, Aug 13, 2008 at 01:19:42PM +0900, Jun Koi wrote:
> According to the comment in your driver code for virDomainMemoryPeek,
> libvirt is not currently supporting Xen. Why is that? As far as I see,
> Xen is use the same GPL2 version as libvirt.
> 
> I am thinking about implementing the driver for Xen, so have this question.

It'd be really good to have a driver for this for libvirt.

QEMU does virtual->physical translation for us, through the guest's
CR3 & page tables.  [This discussion will concentrate on x86 for the
moment :-)] If you look at the qemu source, file target-i386/
helper2.c, function cpu_get_phys_page_debug, you will see the code
they use to navigate through the 3 or 4 levels of page tables for i386
& x86-64 respectively.

The QEMU memsave command made it almost trivial to write
virDomainMemoryPeek (...VIR_MEMORY_VIRTUAL...);

On Xen things are a bit different.  You can map in physical pages from
another guest using the libxc call xc_map_foreign_range.  Note that
you cannot just call xc_map_foreign_range because the libxc & libvirt
licenses are _not_ compatible.  So instead you'd need to do the
underlying sequence of mmap / ioctl / munmap.  (See tools/libxc/
xc_linux.c in the Xen source).

But you still need to do virtual to physical page translation, either
using the qemu source as an example, or using
xc_translate_foreign_address as a guide (or just using the Intel
Programmers Reference Manual and doing it from first principles).

Another alternative is to implement virDomainMemoryPeek
(...VIR_MEMORY_PHYSICAL...).  It is not possible to implement this for
QEMU at all, at least not without changing QEMU.  Implementing this
for Xen would be much easier because you don't need to do address
translation, but it does push the problem of address translation up to
the callers.

Places to look in the QEMU source for inspiration:

  monitor.c:do_memory_save
  target-i386/helper2.c:cpu_get_phys_page_debug

Other places to look in the Xen source for inspiration:

  tools/libxc/xc_linux.c
  tools/libxc/xc_pagetab.c
  tools/xentrace/xenctx.c  (thanks Mark McLoughlin)

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top


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