virsh - management user interface
virsh <subcommand> [args]
The virsh program is the main interface for managing virsh guest domains. The program can be used to create, pause, and shutdown domains. It can also be used to list current domains. Libvirt is a C toolkit to interract 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 concurently 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> [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 clear for each of those sub commands.
All virsh opperations rely upon the libvirt library. For any virsh commands to run xend/qemu, or what ever virtual library that libvirt suports. For this reason you should start xend/qemu as a service when your system first boots using xen/qemu.
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.
The following sub commands manipulate domains directly, as stated previously most commands take domain-id as the first parameter.
The --readonly option read-only connection
Example
virsh dumpxml <domain-name or id> to a file.
help subcommand will print out a detailed help message on that sub command
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
FIXME: Is this right?
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.
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.
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.
Example
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
xm(1), xmdomain.cfg(5), xentop(1) , http://www.libvirt.org/
Andrew Puch <apuch @ redhat.com> Daniel Veillard <veillard @ 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 view on the RedHat buzilla page under the libvirt https://bugzilla.redhat.com/
=