22.1. virsh the command line interface tool for virtualization

22.1. virsh the command line interface tool for virtualization

The virsh command is an alternative command to manage a Red Hat Enterprise Linux 5 Xen environment using a Command Line Interface(CLI). The virsh command is provided as part of the libvirt API which provides a common API to applications requiring standardized access to interact with Xen using a stable interface. Besides providing virsh the libvirt API also provide a higher level language API for C, Python, and Perl (via the CPAN network) The virsh command is an interactive shell which can either be used in scripts or interactively. The following virsh commands assume you have already run virsh and are at a virsh# prompt.

Basic management options

The following are basic and commonly used virsh commands:

command description
help print help
list list domains
create create a domain from an XML file
start start a previously created inactive domain
destroy destroy a domain
define define (but do not start) a domain from an XML file
domid convert a domain name or UUID to domain id
domuuid convert a domain name or id to domain UUID
dominfo domain information
domname convert a domain id or UUID to domain name
domstate domain state
quit quit this interactive terminal
reboot reboot a domain
restore restore a domain from a saved state in a file
resume resume a domain
save save a domain state to a file
shutdown gracefully shutdown a domain
suspend suspend a domain
undefine undefine an inactive domain
Table 22.1. virsh commands

Resource management options

Use the following virsh commands to manage resources:

command description
setmem changes the allocated memory.
setmaxmem changes maximum memory limit.
setvcpus changes number of virtual CPUs.
vcpuinfo domain vcpu information.
vcpupin control the domain vcpu affinity.
Table 22.2. virsh resource management commands

Monitoring and troubleshooting options

Use the following virsh commands for monitoring and troubleshooting:

command description
version show version
dumpxml domain information in XML
nodeinfo node information
Table 22.3. virsh monitoring and troubleshooting commands

Presently unsupported options

The connect command that is used to connect or reconnect to a hypervisor.

virsh command output

The following are example outputs from common virsh commands:


Note: This documentation is provided {and copyrighted} by Red Hat®, Inc. and is released via the Open Publication License. The copyright holder has added the further requirement that Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. The CentOS project redistributes these original works (in their unmodified form) as a reference for CentOS-5 because CentOS-5 is built from publicly available, open source SRPMS. The documentation is unmodified to be compliant with upstream distribution policy. Neither CentOS-5 nor the CentOS Project are in any way affiliated with or sponsored by Red Hat®, Inc.