NAME
virsh - management user interface
SYNOPSIS
virsh <subcommand>
[args]
DESCRIPTION
The virsh program
is the main interface for managing virsh guest domains. The program
can be used to create, suspend, resume, save, and shutdown domains.
It can also be used to list current domains. Libvirt is a C toolkit
to interact with the virtualization capabilities of recent versions
of Linux (and other OSes). It is free software available under the
GNU Lesser General Public License.
Virtualization of the Linux Operating System means the ability to
run multiple instances of Operating Systems concurrently on a
single hardware system where the basic resources are driven by a
Linux instance. The library aim at providing long term stable C
API initially for the Xen paravirtualization
but should be able to integrate other virtualization mechanisms if
needed.
The basic structure of every virsh command is almost always:
virsh <subcommand> <domain-id|name|uuid> [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
command in question acts on all domains, the entire machine, or
directly on the xen hypervisor. Those exceptions will be explained
for each of those sub commands.
NOTES
All virsh operations rely
upon the libvirt library. So any virsh commands may require to run
xend or qemu (or which ever virtualization layer that libvirt will
use). For this reason you should start xend or qemu as a service
when your system first boots.
Most virsh commands require root privledges to run due to
the communications channels used to talk to the hypervisor. Running
as non root will return an error.
Most virsh commands act asynchronously, so just because
the virsh command returned, doesn't mean the action is
complete. This is important, as many operations on domains, like
create and shutdown, can take considerable time (30 seconds or
more) to bring the machine into a fully compliant state. If you
want to know when one of these actions has finished you must poll
through virsh list periodically.
DOMAIN SUBCOMMANDS
The following sub
commands manipulate domains directly, as stated previously most
commands take domain-id as the first parameter.
- connect optional --readonly
- Connect to local hypervisor. This is
build-in command after shell start up.
The --readonly option read-only connection
- create FILE
- Create a domain from an XML <file> an easy way to create one if you have
a pre-existing xen guest created via xm create
<XMLFILE>.
- dumpxml domain-name, id or uuid
- Ouput the domain informations as an
XML dump to stdout, this format can be used
by the create sub command.
- destroy domain-name, id or uuid
- Immediately terminate the domain
domain-id. This doesn't give the domain OS
any chance to react, and it is 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 mapping.
- dominfo domain-name, id or uuid
- Returns basic information about the
domain.
- domname domain-id
- convert a domain Id to domain name
- domstate domain-name, id or uuid
- Returns state about a running domain.
- help optional subcommand
- Displays the short help message (i.e.
common commands).
help subcommand will print out a detailed help
message on that sub command
- list
- 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:
virsh list
Id Name State
----------------------------------
0 Domain-0 running
2 fedora paused
Name is the name of the domain. ID the
domain numeric id.
State is the run state (see below).
-
- STATES
The State field lists 6 states for a Xen Domain, and which ones
the current Domain is in. =back
- running
- The domain is currently running on a
CPU
- blocked
- The domain is blocked, and not running or
runable. 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.
- paused
- The domain has been paused, usually
occurring through the administrator running virsh suspend.
When in a suspend state the domain will still consume allocated
resources like memory, but will not be eligible for scheduling by
the Xen hypervisor.
- in shutdown
- The domain is in process of dying, but
hasn't completely shutdown or crashed.
- shut off
- The domain is down.
- crashed
- The domain has crashed, which is always a
violent ending. Usually this state can only occur if the domain has
been configured not to restart on crash. See xmdomain.cfg for more
info.
- nodeinfo domain-name, id or uuid
- Returns basic information about the node.
- quit
- quit this interactive terminal
- reboot domain-name, id or uuid
- 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 started the reboot action, but it
may take significantly longuer before the domain actually reboots.
For xen vm 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.
- restore state-file
- Restores a domain from an virsh
save state file. See save for more info.
- save domain-name, id or uuid 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. virsh restore
restores from this state file.
This is roughly equivalent to doing a hibernate on a running
computer, with all the same limitations. Open network connections
may be severed upon restore, as TCP timeouts
may have expired.
- shutdown domain-name, id or uuid
- Gracefully shuts down a domain. This
coordinates with the domain OS to perform
graceful shutdown, so there is no guaruntee that it will succeed,
and may take a variable length of time depending on what services
must be shutdown in the domain.
For a xen guest vm 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.
- suspend domain-name, id or uuid
- Suspend a domain. When in a suspened state
the domain will still consume allocated resources such as memory,
but will not be eligible for scheduling by the Xen hypervisor.
- resume domain-name, id or uuid
- Moves a domain out of the paused state.
This will allow a previously paused domain to now be eligible for
scheduling by the the under lying hypervisor.
- version
- Will print out the major version info
about what this built from.
-
- virsh version
Compiled against library: libvir 0.0.6
Using library: libvir 0.0.6
Using API: Xen 3.0.0
Running hypervisor: Xen 3.0.0
SEE ALSO
xm(1),
(5),
xentop(1)
, <http://www.libvirt.org<sol>>
AUTHOR
Andrew Puch <apuch @ redhat.com>
Daniel Veillard <veillard @ redhat.com>
Karel Zak <kzak @ redhat.com>
Based on the xm man paged by
Sean Dague <sean at dague dot net>
Daniel Stekloff <dsteklof at us dot ibm dot com>
BUGS
Can be seen on the RedHat buzilla
page under the libvirt <https://bugzilla.redhat.com/>