xm is a management tool that communicates with the Xen hypervisor through xend—the Xen daemon. Running xm
commands requires administrative privileges on the system as it uses
the privileged communication channel between xend and the Hypervisor. xm is also designed to perform its functions in an asynchronous way.
Executing an xm
command will immediately return to the caller, but the actual operation
may not be complete. Some of the domain commands may actually take quite
a long time to complete. The only way to determine whether the command
is successfully completed is to print out the list periodically and
check it. The two most fundamental operations that we use xm
for are to create a domain and to list the state of all the domains in
the current Xen environment. The state field in the list of domains has
one of the five possible states for a domain:
r—running: Lists domains currently active on a CPU.
b—blocked: Lists domains that are blocked. This happens when the vcpu is waiting for an external event to happen for this domain.
p—paused:
Lists domains that are suspended. The paused domain will still consumes
allocated resources such as memory, but is not eligible for scheduling
by the Xen hypervisor.
s—shutdown: Lists domains that are in process of shutting down.
c—crashed: Lists domains that are crashed.
The normal listing of domains is in a table format that is not very easy for other tools to parse. therefore xm also provides a long option to list the domain information in an S‑Expression format that can be easily parsed by other tools.
Time for Action—Xen Manager
You need not install xm separately. On Fedora Core, installing Xen will include the installation of various Xen tools. We will now demonstrate some of the common tasks performed with xm.
Print a list of the running domains in the current Xen environment.
Print detailed information about the dom0 in the current Xen environment.
Print
detailed information about a domain in the current Xen environment. The
listing is quite long and is therefore broken up into the following two
screenshots.
# xm list -long centos-domU
Pause a running domU in the current Xen environment.
# xm pause ubuntu_feisty_domU
List the domains to make sure it has paused:
Unpause the previously paused domU:
# xm unpause ubuntu_feisty_domU
List the domains to make sure the domain has been unpaused.
Save
the state of a running domU in the current Xen environment to the
specified file. The following will save the state to the disk file and
remove it from the list of running domains.
# xm save ubuntu_feisty_domU feisty.save
List the domains to make sure the saved domain is no longer displayed in the list of running domains:
Restore
a domain from the saved state. This will restore the domain from the
file with the state information and put the domain back in a running
state.
List the domains to make sure the domain is once again displayed in the list of running domains:
Check the Xen kernel buffer messages. The following screenshot shows a partial listing from my machine.
Print the host information for the current Xen environment.
Print the Xen log. The following screenshot shows a partial listing from the Xen log on my machine.
Monitor the Xen domains in real time similar to the Unix top utility.
List all the block devices used by a domain:
# xm block-list ubuntu_feisty_domU
List all the block devices used by a domain in detail:
# xm block-list ubuntu_feisty_domU --long
List all the network interfaces used by a domain:
# xm network-list ubuntu_feisty_domU
List all the network interfaces used by a domain in detail:
# xm network-list ubuntu_feisty_domU
Display the uptime for all the domains in your Xen environment.
Reboot
a domain. This does not re-read the Xen configuration file for that
domain. If you want to reload the configuration for that domain, you
need to use a halt command followed by a create command.
# xm reboot ubuntu_feisty_domU
Suspend a domain:
# xm suspend ubuntu_feisty_domU
Resume a suspended domain:
# xm resume ubuntu_feisty_domU
Rename a running domain:
# xm rename ubuntu_feisty_domU prabhakar_domU
Connect to domain console:
# xm console ubuntu_feisty_domU
Shut down a domain:
# xm shutdown ubuntu_feisty_domU
What Just Happened?
xm is a tool that is provided with
the Xen installation. It is the main interface for the management of
Xen domains. It is very useful to get comfortable using xm
as it is guaranteed to be available on any system that is running Xen.
In this section we explored the various management tasks that can be
performed using xm.
Xm also provides the ability to perform other management functions :
Virtual devices:
Adds and removes virtual devices while the guest domain is running. You
can attach and detach both storage devices and network devices using xm.
Security: Manages security policies in Xen.
Migration: Migrates the guest domain.
There are also other less common management related operations you can perform with xm. Please check the latest Xen documentation or the xm manual page for details on these options.