Skip to contentSkip to conversation

Xen source code structure

DISCUSSION Yi Wang 3 participants 3 messages Jul 12, 2007 – Jul 13, 2007 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected] m

#2 lore raw
Quoted 7 lines · Yi Wang

Hello,

Is there any document about the structure of the Xen source code? I downloaded the source code from
http://bits.xensource.com/oss-xen/release/3.1.0/src.tgz/xen-3.1.0-src.tgz,
but I had a hard time finding the part of code that handles the live migration.

Xen is a pretty large project, and understanding where things live can take a bit to understand.

I'm writing this without looking at sources, so please treat any paths as "approximate".

Live migration works with the PV/HVM save-restore concept along with some code to track writes to memory in the relevant page-table handling (in HVM case that would be the .../xen/arch/x86/mm/shadow code - not sure about PV code). Look for "logdirty", as that's the name of the method used to indicate which pages has been written to since the last transfer of "still running" domain.

In the HVM case, the actual save/restore is done by the SVM/VMX code. Not sure about PV-code.

The overall save/restore/migrate is initiated by the "xm" command, which is in .../tools/python/xen/xm/... (I can't remember if there is a "xm_save.py" and "xm_restore.py" or if they are part of the overall "main.py". This code executes a .../tools/xcutil/xc_{save,restore}.c which in turn calls functions in ../tools/libxc/xc_domain_{save,restore}.c

I hope this does give you some idea of where to start looking.

What problem are you trying to solve?

--
Mats

Quoted 8 lines

Could anybody give me some hints?

Thanks!

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
In reply to Yi Wang
Quoted 5 lines

Is there any document about the structure of the Xen source code? I downloaded the source code from
http://bits.xensource.com/oss-xen/release/3.1.0/src.tgz/xen-3.1.0-src.tgz,
but I had a hard time finding the part of code that handles the live migration.

For the userspace side, the most important code is in tools/libxc. Try taking a look at tools/libxc/xc_domain_{save,restore}.c which are used both for normal suspend / resume of guests and for live migration.

Other relevant code is the shadow pagetable implementation - used, amongst other things, to enable logging of page dirtying for live migration. The shadow op XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY is used to enable this (this DOMCTL is implemented in xen/arch/x86/mm/shadow/paging.c).

Also, for PV domains, there is some communication with the domain itself telling it to quiesce ready for migration. This involves Xenstore, the control tools, the guest's core kernel and the Xen device drivers within the guest.

For HVM domains, the Qemu device model must serialise its state so that it can be restored elsewhere.

That's a high speed, high altitude overview of a few interesting points. I've probably missed something important, but maybe this'll get you started ;-)

HTH,
Mark

Signature · 4 lines
Dave: Just a question. What use is a unicyle with no seat?  And no pedals!
Mark: To answer a question with a question: What use is a skateboard?
Dave: Skateboards have wheels.
Mark: My wheel has a wheel!