Figuring out “what’s going on?” is always something very important. For example, knowing what processes were running on which processors can be very useful if you are doing OS development and/or performances evaluation. If applied to virtualization, that turns into figuring out what VMs were running on which processors (or, better, what virtual CPUs were running on which physical CPUs), during the execution of some workload.
When using Xen as hypervisor, all that is possible by means of two tools: xentrace and xenalyze.
Xen has a number of trace points at key locations to allow developers to get a picture of what is going on inside of Xen. When these trace points are enabled, Xen will write the tracing information into per-cpu buffers within Xen. Then a program in dom0, called xentrace, which sets up and enables tracing, and periodically reads these buffers and writes them to disk. Xentrace is part of the xen.org tree and will come with every distribution of Xen.Â A very basic, but already quite useful invocation of the tool is the following:
# xentrace -D -e EVT_MASK > trace_file.bin &
# killall xentrace
EVT_MASK can be one of the following values:
0x0001f000 Â Â Â Â Â TRC_GEN
0x0002f000 Â Â Â Â Â TRC_SCHED
0x0004f000 Â Â Â Â Â TRC_DOM0OP
0x0008f000 Â Â Â Â Â TRC_HVM
0x0010f000 Â Â Â Â Â TRC_MEM
0xfffff000 Â Â Â Â Â TRC_ALL
These are Event Classes. Using one of them tells xentrace to gather information about a group of events. For exampleÂ
0x0002f000 can be used to obtain all the events related to vCPU scheduling. There are other options available, and it is also possible to achieve a finer grain control on the events (for complete list, refer to
xentrace -? and/or
Unlike xentrace, xenalyze is an external tool, available from its own source code repository (see below). It has been publicly released in 2009 by George Dunlap, and the latest version is always available in this mercurial repository:Â http://xenbits.xen.org/gitweb/?p=xenalyze.git . Getting and installing xenalyze is really worthwhile. There also are slides and videos explaining what it is and what it does, so go check them out! 🙂