virsh (1) - Linux Manuals
virsh: management user interface
NAME
virsh - management user interface
SYNOPSIS
virsh [OPTION]... [COMMAND_STRING]virsh [OPTION]... COMMAND [ARG]...
DESCRIPTION
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 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 aims at providing a long term stable C API. It currently supports Xen, QEMU, KVM, LXC, OpenVZ, VirtualBox and VMware ESX.The basic structure of most virsh usage is:
virsh [OPTION]... <command> <domain> [ARG]...
Where command is one of the commands listed below; domain is the numeric domain id, or the domain name, or the domain UUID; and ARGS are command specific options. There are a few exceptions to this rule in the cases where the 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 commands. Note: it is permissible to give numeric names to domains, however, doing so will result in a domain that can only be identified by domain id. In other words, if a numeric value is supplied it will be interpreted as a domain id, not as a name.
The virsh program can be used either to run one COMMAND by giving the command and its arguments on the shell command line, or a COMMAND_STRING which is a single shell argument consisting of multiple COMMAND actions and their arguments joined with whitespace, and separated by semicolons between commands. Within COMMAND_STRING, virsh understands the same single, double, and backslash escapes as the shell, although you must add another layer of shell escaping in creating the single shell argument. If no command is given in the command line, virsh will then start a minimal interpreter waiting for your commands, and the quit command will then exit the program.
The virsh program understands the following OPTIONS.
- -c, --connect URI
- Connect to the specified URI, as if by the connect command, instead of the default connection.
- -d, --debug LEVEL
- Enable debug messages at integer LEVEL and above. LEVEL can range from 0 to 4 (default). See the documentation of VIRSH_DEBUG environment variable below for the description of each LEVEL.
- -e, --escape string
- Set alternative escape sequence for console command. By default, telnet's ^] is used. Allowed characters when using hat notation are: alphabetic character, @, [, ], \, ^, _.
- -h, --help
- Ignore all other arguments, and behave as if the help command were given instead.
- -k, --keepalive-interval INTERVAL
- Set an INTERVAL (in seconds) for sending keepalive messages to check whether connection to the server is still alive. Setting the interval to 0 disables client keepalive mechanism.
- -K, --keepalive-count COUNT
- Set a number of times keepalive message can be sent without getting an answer from the server without marking the connection dead. There is no effect to this setting in case the INTERVAL is set to 0.
- -l, --log FILE
- Output logging details to FILE.
- -q, --quiet
- Avoid extra informational messages.
- -r, --readonly
- Make the initial connection read-only, as if by the --readonly option of the connect command.
- -t, --timing
- Output elapsed time information for each command.
- -v, --version[=short]
- Ignore all other arguments, and prints the version of the libvirt library virsh is coming from
- -V, --version=long
- Ignore all other arguments, and prints the version of the libvirt library virsh is coming from and which options and driver are compiled in.
NOTES
Most virsh operations rely upon the libvirt library being able to connect to an already running libvirtd service. This can usually be done using the command service libvirtd start.Most virsh commands require root privileges 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 synchronously, except maybe shutdown, setvcpus and setmem. In those cases the fact that the virsh program returned, may not mean the action is complete and you must poll periodically to detect that the guest completed the operation.
virsh strives for backward compatibility. Although the help command only lists the preferred usage of a command, if an older version of virsh supported an alternate spelling of a command or option (such as --tunnelled instead of --tunneled), then scripts using that older spelling will continue to work.
Several virsh commands take an optionally scaled integer; if no
scale is provided, then the default is listed in the command (for
historical reasons, some commands default to bytes, while other
commands default to kibibytes). The following case-insensitive
suffixes can be used to select a specific scale:
To display only commands for a specific group, give the keyword for that
group as an option. For example:
To display detailed information for a specific command, give its name as the
option instead. For example:
This command is only available in interactive mode.
To find the currently used URI, check the uri command documented below.
For remote access see the documentation page at
<http://libvirt.org/uri.html> on how to make URIs.
The --readonly option allows for read-only connection
With --pretty the online CPUs are printed as a range instead of a list.
Note: Currently the ``shared memory service'' only means KSM (Kernel Samepage
Merging).
Each hypervisor will have different requirements regarding which options
are required and which are optional. A hypervisor can support providing
a default value for any of the options.
The virttype option specifies the virtualization type used. The value
to be used is either from the 'type' attribute of the <domain/> top
level element from the domain XML or the 'type' attribute found within
each <guest/> element from the virsh capabilities output. The
emulatorbin option specifies the path to the emulator. The value to
be used is either the <emulator> element in the domain XML or the
virsh capabilities output. The arch option specifies the
architecture to be used for the domain. The value to be used is either
the ``arch'' attribute from the domain's XML <os/> element and <type/>
subelement or the ``name'' attribute of an <arch/> element from the
virsh capabililites output. The machine specifies the machine type
for the emulator. The value to be used is either the ``machine'' attribute
from the domain's XML <os/> element and <type/> subelement or one from a
list of machines from the virsh capabilities output for a specific
architecture and domain type.
For the qemu hypervisor, a virttype of either 'qemu' or 'kvm' must be
supplied along with either the emulatorbin or arch in order to
generate output for the default machine. Supplying a machine
value will generate output for the specific machine.
An example format for the list is as follows:
virsh list
Name is the name of the domain. ID the domain numeric id.
State is the run state (see below).
STATES
The State field lists what state each domain is currently in. A domain
can be in one of the following possible states:
Normally only active domains are listed. To list inactive domains specify
--inactive or --all to list both active and inactive domains.
To further filter the list of domains you may specify one or more of filtering
flags supported by the list command. These flags are grouped by function.
Specifying one or more flags from a group enables the filter group. Note that
some combinations of flags may yield no results. Supported filtering flags and
groups:
When talking to older servers, this command is forced to use a series of API
calls with an inherent race, where a domain might not be listed or might appear
more than once if it changed state between calls while the list was being
collected. Newer servers do not have this problem.
If --managed-save is specified, then domains that have managed save state
(only possible if they are in the shut off state, so you need to specify
--inactive or --all to actually list them) will instead show as saved
in the listing. This flag is usable only with the default --table output.
Note that this flag does not filter the list of domains.
If --name is specified, domain names are printed instead of the table
formatted one per line. If --uuid is specified domain's UUID's are printed
instead of names. Flag --table specifies that the legacy table-formatted
output should be used. This is the default.
If both --name and --uuid are specified, domain UUID's and names
are printed side by side without any header. Flag --table specifies
that the legacy table-formatted output should be used. This is the
default if neither --name nor --uuid are specified. Option
--table is mutually exclusive with options --uuid and --name.
If --title is specified, then the short domain description (title) is
printed in an extra column. This flag is usable only with the default
--table output.
Example:
virsh list --title
GENERIC COMMANDS
The following commands are generic i.e. not specific to a domain.
virsh # help host
Host and Hypervisor (help keyword 'host'):
capabilities capabilities
cpu-models show the CPU models for an architecture
connect (re)connect to hypervisor
freecell NUMA free memory
hostname print the hypervisor hostname
qemu-attach Attach to existing QEMU process
qemu-monitor-command QEMU Monitor Command
qemu-agent-command QEMU Guest Agent Command
sysinfo print the hypervisor sysinfo
uri print the hypervisor canonical URI
virsh # help list
NAME
list - list domains
SYNOPSIS
list [--inactive] [--all]
DESCRIPTION
Returns list of domains.
OPTIONS
--inactive list inactive domains
--all list inactive & active domains
$ virsh version
Compiled against library: libvirt 1.2.3
Using library: libvirt 1.2.3
Using API: QEMU 1.2.3
Running hypervisor: QEMU 2.0.50
$ virsh version --daemon
Compiled against library: libvirt 1.2.3
Using library: libvirt 1.2.3
Using API: QEMU 1.2.3
Running hypervisor: QEMU 2.0.50
Running against daemon: 1.2.6