xm - Xen management user interface
xm <subcommand> [args]
The xm program is the main interface for managing Xen guest domains.
The program can be used to create, pause, and shutdown domains. It can
also be used to list current domains, enable or pin VCPUs, and attach
or detach virtual block devices.
The basic structure of every xm command is almost always:
xm <subcommand> <domain-id> [OPTIONS]
Where subcommand is one of the sub commands listed below, domain-id is
the numeric domain id, or the domain name (which will be internally
translated to domain id), and OPTIONS are sub command specific options.
There are a few exceptions to this rule in the cases where the sub com-
mand in question acts on all domains, the entire machine, or directly
on the xen hypervisor. Those exceptions will be clear for each of
those sub commands.
All xm operations rely upon the Xen control daemon, aka xend. For any
xm commands to run xend must also be running. For this reason you
should start xend as a service when your system first boots using xen.
Most xm commands require root privileges to run due to the communica-
tions channels used to talk to the hypervisor. Running as non root
will return an error.
Most xm commands act asynchronously, so just because the xm command
returned, doesn't mean the action is complete. This is important, as
many operations on domains, like create and shutdown, can take consid-
erable time (30 seconds or more) to bring the machine into a fully com-
pliant state. If you want to know when one of these actions has fin-
ished you must poll through xm list periodically.
The following sub commands manipulate domains directly, as stated pre-
viously most commands take domain-id as the first parameter.
console domain-id
Attach to domain domain-id's console. If you've set up your
Domains to have a traditional log in console this will look much
like a normal text log in screen.
This uses the back end xenconsole service which currently only
works for para-virtual domains.
The attached console will perform much like a standard serial con-
sole, so running curses based interfaces over the console is not
advised. Vi tends to get very odd when using it over this inter-
face.
create [-c] configfile [name=value]..
The create sub command requires a configfile and can optional take
a series of name value pairs that add to or override variables
defined in the config file. See xmdomain.cfg for full details of
that file format, and possible options used in either the
configfile or Name=Value combinations.
Configfile can either be an absolute path to a file, or a relative
path to a file located in /etc/xen.
Create will return as soon as the domain is started. This does not
mean the guest OS in the domain has actually booted, or is avail-
able for input.
OPTIONS
-c Attache console to the domain as soon as it has started. This
is useful for determining issues with crashing domains.
EXAMPLES
with config file
xm create Fedora4
This creates a domain with the file /etc/xen/Fedora4, and
returns as soon as it is run.
without config file
xm create /dev/null ramdisk=initrd.img /
kernel=/boot/vmlinuz-2.6.12.6-xenU /
name=ramdisk nics=0 vcpus=1 /
memory=64 root=/dev/ram0
This creates the domain without using a config file (more
specifically using /dev/null as an empty config file), kernel
and ramdisk as specified, setting the name of the domain to
"ramdisk", also disabling virtual networking. (This example
comes from the xm-test test suite.)
destroy domain-id
Immediately terminate the domain domain-id. This doesn't give the
domain OS any chance to react, and it the equivalent of ripping the
power cord out on a physical machine. In most cases you will want
to use the shutdown command instead.
domid domain-name
Converts a domain name to a domain id using xend's internal map-
ping.
domname domain-id
Converts a domain id to a domain name using xend's internal map-
ping.
help [--long]
Displays the short help message (i.e. common commands).
The --long option prints out the complete set of xm subcommands,
grouped by function.
list [--long | --label] [domain-id, ...]
Prints information about one or more domains. If no domains are
specified it prints out information about all domains.
An example format for the list is as follows:
Name ID Mem(MiB) VCPUs State Time(s)
Domain-0 0 98 1 r----- 5068.6
Fedora3 164 128 1 r----- 7.6
Fedora4 165 128 1 ------ 0.6
Mandrake2006 166 128 1 -b---- 3.6
Mandrake10.2 167 128 1 ------ 2.5
Suse9.2 168 100 1 ------ 1.8
Name is the name of the domain. ID the domain numeric id. Mem is
the size of the memory allocated to the domain. VCPUS is the num-
ber of VCPUS allocated to domain. State is the run state (see
below). Time is the total run time of the domain as accounted for
by Xen.
STATES
The State field lists 6 states for a Xen Domain, and which ones
the current Domain is in.
r - running
The domain is currently running on a CPU
b - blocked
The domain is blocked, and not running or runnable. This can
be caused because the domain is waiting on IO (a traditional
wait state) or has gone to sleep because there was nothing else
for it to do.
p - paused
The domain has been paused, usually occurring through the
administrator running xm pause. When in a paused state the
domain will still consume allocated resources like memory, but
will not be eligible for scheduling by the Xen hypervisor.
s - shutdown
FIXME: Why would you ever see this state?
c - crashed
The domain has crashed, which is always a violent ending. Usu-
ally this state can only occur if the domain has been config-
ured not to restart on crash. See xmdomain.cfg for more info.
d - dying
The domain is in process of dying, but hasn't completely shut-
down or crashed.
FIXME: Is this right?
LONG OUTPUT
If --long is specified, the output for xm list is not the table
view shown above, but instead is an S-Expression representing
all information known about all domains asked for. This is
mostly only useful for external programs to parse the data.
Note: there is no stable guarantees on the format of this data.
Use at your own risk.
LABEL OUTPUT
If --label is specified, the security labels are added to the
output of xm list and the lines are sorted by the labels
(ignoring case). The --long option prints the labels by default
and cannot be combined with --label. See the ACCESS CONTROL
SUBCOMMAND section of this man page for more information about
labels.
NOTES
The Time column is deceptive. Virtual IO (network and block
devices) used by Domains requires coordination by Domain0,
which means that Domain0 is actually charged for much of the
time that a DomainU is doing IO. Use of this time value to
determine relative utilizations by domains is thus very sus-
pect, as a high IO workload may show as less utilized than a
high CPU workload. Consider yourself warned.
mem-max domain-id mem
Specify the maximum amount of memory the Domain is able to use.
Mem is specified in megabytes.
The mem-max value may not correspond to the actual memory used in
the Domain, as it may balloon down it's memory to give more back to
the OS.
mem-set domain-id mem
Set the domain's used memory using the balloon driver. Because
this operation requires cooperation from the domain operating sys-
tem, there is no guarantee that it will succeed.
Warning: there is no good way to know in advance how small of a
mem-set will make a domain unstable and cause it to crash. Be very
careful when using this command on running domains.
migrate domain-id host [options]
Migrate a domain to another Host machine. Xend must be running on
other host machine, it must be running the same version of xen, it
must have the migration TCP port open and accepting connections
from the source host, and there must be sufficient resources for
the domain to run (memory, disk, etc).
Migration is pretty complicated, and has many security implica-
tions, please read the Xen Users Guide to ensure you understand the
ramifications and limitations on migration before attempting it in
production.
OPTIONS
-l, --live
Use live migration. This will migrate the domain between hosts
without shutting down the domain. See the Xen Users Guide for
more information.
-r, --resource Mbs
Set maximum Mbs allowed for migrating the domain. This ensures
that the network link is not saturated with migration traffic
while attempting to do other useful work.
pause domain-id
Pause a domain. When in a paused state the domain will still con-
sume allocated resources such as memory, but will not be eligible
for scheduling by the Xen hypervisor.
reboot [options] domain-id
Reboot a domain. This acts just as if the domain had the reboot
command run from the console. The command returns as soon as it
has executed the reboot action, which may be significantly before
the domain actually reboots.
The behavior of what happens to a domain when it reboots is set by
the on_reboot parameter of the xmdomain.cfg file when the domain
was created.
OPTIONS
-a, --all
Reboot all domains
-w, --wait
Wait for reboot to complete before returning. This may take a
while, as all services in the domain will have to be shut down
cleanly.
restore state-file
Build a domain from an xm save state file. See save for more info.
save domain-id state-file
Saves a running domain to a state file so that it can be restored
later. Once saved, the domain will no longer be running on the
system, thus the memory allocated for the domain will be free for
other domains to use. xm restore restores from this state file.
This is roughly equivalent to doing a hibernate on a running com-
puter, with all the same limitations. Open network connections may
be severed upon restore, as TCP timeouts may have expired.
shutdown [options] domain-id
Gracefully shuts down a domain. This coordinates with the domain
OS to perform graceful shutdown, so there is no guarantee that it
will succeed, and may take a variable length of time depending on
what services must be shutdown in the domain. The command returns
immediately after signally the domain unless that -w flag is used.
The behavior of what happens to a domain when it reboots is set by
the on_shutdown parameter of the xmdomain.cfg file when the domain
was created.
OPTIONS
-a Shutdown all domains. Often used when doing a complete shut-
down of a Xen system.
-w Wait for the domain to complete shutdown before returning.
sysrq domain-id letter
Send a Magic System Request signal to the domain. For more infor-
mation on available magic sys req operations, see sysrq.txt in your
Linux Kernel sources.
unpause domain-id
Moves a domain out of the paused state. This will allow a previ-
ously paused domain to now be eligible for scheduling by the Xen
hypervisor.
vcpu-set domain-id vcpu-count
Enables the vcpu-count virtual CPUs for the domain in question.
Like mem-set, this command can only allocate up to the maximum vir-
tual CPU count configured at boot for the domain.
If the vcpu-count is smaller than the current number of active
VCPUs, the highest number VCPUs will be hotplug removed. This may
be important for pinning purposes.
Attempting to set the VCPUs to a number larger than the initially
configured VCPU count is an error. Trying to set VCPUs to < 1 will
be quietly ignored.
vcpu-list [domain-id]
Lists VCPU information for a specific domain. If no domain is
specified, VCPU information for all domains will be provided.
vcpu-pin domain-id vcpu cpus
Pins the the VCPU to only run on the specific CPUs. The keyword
all can be used to apply the cpus list to all VCPUs in the domain.
Normally VCPUs can float between available CPUs whenever Xen deems
a different run state is appropriate. Pinning can be used to
restrict this, by ensuring certain VCPUs can only run on certain
physical CPUs.
dmesg [-c]
Reads the Xen message buffer, similar to dmesg on a Linux system.
The buffer contains informational, warning, and error messages cre-
ated during Xen's boot process. If you are having problems with
Xen, this is one of the first places to look as part of problem
determination.
OPTIONS
-c, --clear
Clears Xen's message buffer.
info
Print information about the Xen host in name : value format. When
reporting a Xen bug, please provide this information as part of the
bug report.
Sample xen domain info looks as follows (lines wrapped manually to
make the man page more readable):
host : talon
release : 2.6.12.6-xen0
version : #1 Mon Nov 14 14:26:26 EST 2005
machine : i686
nr_cpus : 2
nr_nodes : 1
sockets_per_node : 2
cores_per_socket : 1
threads_per_core : 1
cpu_mhz : 696
hw_caps : 0383fbff:00000000:00000000:00000040
total_memory : 767
free_memory : 37
xen_major : 3
xen_minor : 0
xen_extra : -devel
xen_caps : xen-3.0-x86_32
xen_pagesize : 4096
platform_params : virt_start=0xfc000000
xen_changeset : Mon Nov 14 18:13:38 2005 +0100
7793:090e44133d40
cc_compiler : gcc version 3.4.3 (Mandrakelinux
10.2 3.4.3-7mdk)
cc_compile_by : sdague
cc_compile_domain : (none)
cc_compile_date : Mon Nov 14 14:16:48 EST 2005
xend_config_format : 2
FIELDS
Not all fields will be explained here, but some of the less
obvious ones deserve explanation:
hw_caps
A vector showing what hardware capabilities are supported by
your processor. This is equivalent to, though more cryptic,
the flags field in /proc/cpuinfo on a normal Linux machine.
free_memory
Available memory (in MB) not allocated to Xen, or any other
Domains.
xen_caps
The xen version, architecture. Architecture values can be one
of: x86_32, x86_32p (i.e. PAE enabled), x86_64, ia64.
xen_changeset
The xen mercurial changeset id. Very useful for determining
exactly what version of code your Xen system was built from.
log Print out the xend log. This log file can be found in
/var/log/xend.log.
top Executes the xentop command, which provides real time monitoring of
domains. Xentop is a curses interface, and reasonably self
explanatory.
Xen ships with a number of domain schedulers, which can be set at boot
time with the sched= parameter on the Xen command line. By default
sedf is used for scheduling.
FIXME: we really need a scheduler expert to write up this section.
sched-sedf period slice latency-hint extratime weight
Set Simple EDF (Earliest Deadline First) scheduler parameters.
This scheduler provides weighted CPU sharing in an intuitive way
and uses realtime-algorithms to ensure time guarantees. For more
information see docs/misc/sedf_scheduler_mini-HOWTO.txt in the Xen
distribution.
PARAMETERS
period
The normal EDF scheduling usage in nanoseconds
slice
The normal EDF scheduling usage in nanoseconds
FIXME: these are lame, should explain more.
latency-hint
Scaled period if domain is doing heavy I/O.
extratime
Flag for allowing domain to run in extra time.
weight
Another way of setting cpu slice.
EXAMPLES
normal EDF (20ms/5ms):
xm sched-sedf <dom-id> 20000000 5000000 0 0 0
best-effort domains (i.e. non-realtime):
xm sched-sedf <dom-id> 20000000 0 0 1 0
I<normal EDF (20ms/5ms) + share of extra-time:>
xm sched-sedf <dom-id> 20000000 5000000 0 1 0
4 domains with weights 2:3:4:2
xm sched-sedf <d1> 0 0 0 0 2
xm sched-sedf <d2> 0 0 0 0 3
xm sched-sedf <d3> 0 0 0 0 4
xm sched-sedf <d4> 0 0 0 0 2
1 fully-specified (10ms/3ms) domain, 3 other domains share avail-
able rest in 2:7:3 ratio:
xm sched-sedf <d1> 10000000 3000000 0 0 0
xm sched-sedf <d2> 0 0 0 0 2
xm sched-sedf <d3> 0 0 0 0 7
xm sched-sedf <d4> 0 0 0 0 3
ref:http://man.cx/xm