System Administration Guide: Virtualization Using the Solaris Operating System

virshCommand

The virsh is used to manage domains. You must run the commands as the root user or by assuming the appropriate role account on the host operating system. The commands cannot be run in the guest domain.

virsh Command

Description 

virshattach-device

Attach device from an XML file  

virsh attach-disk

Attach disk device 

virsh autostart

Configure a domain to automatically start at boot time. 

virsh capabilities

Return capabilities of the hypervisor and drivers. 

virsh connect

Connect to the hypervisor. 

virsh connect--readonly

Connect to the hypervisor in read-only mode. 

virsh consoledomain

Connect to a guest console 

virsh create file

Create a domain based on the parameters contained in the XML file, where file is an absolute pathname. Such a file can be created using virsh dumpxml subcommand. The XML configuration file should not be directly edited.

virsh define file

Define a domain from an XML file, but do not start the domain 

virsh destroy domain-id

Terminate a domain immediately 

virsh detach-device domain-idfile

Detach a device defined by the given XML file from the specified domain. 

virsh domid domain_name

Converts a domain name to a numeric domain ID. 

virsh dominfo domain_id

Return basic info about a domain 

virsh domname domain_id

Converts a numeric domain ID to a domain name. 

virsh domstate domain_id

Returns the state of a running domain. See the list subcommand.

virsh domuuid domain

Convert the specified domain name or ID to a domain UUID.  

virsh dump domainfile

Dump the core of the domain specified by domain to the file specified by file for analysis.

virsh dumpxml domain-id

Obtain domain information in XML 

virsh help

Display descriptions of the subcommands. Include a subcommand at the end of the command line to display help about that subcommand. 

virsh list

List domains. By default, only running domains are displayed. Use --inactive to display only non-running domains.

virsh nodeinfo

Print basic information about a node. 


# virsh nodeinfo
CPU model:           i86pc
CPU(s):              2
CPU frequency:       2391 MHz
CPU socket(s):       2
Core(s) per socket:  1
Thread(s) per core:  1
NUMA cell(s):        1
Memory size:         4127744 kB

virsh quit

Quit this interactive terminal 

virsh reboot domain-id

Reboot a domain. 

This command is identical to the effect of running init 6. The command returns immediately, but the entire reboot process might take a minute or more.

virsh restore state-file

Restore a domain from a saved state file. 

virsh resume domain-id

Moves a domain out of the paused state, making the domain eligible for scheduling by the hypervisor. 

virsh reboot domain-id

Reboot a domain 

virsh restore domain-id

Restore a domain from a saved state 

virsh resume domain-id

Resume running a suspended domain. 

virsh save domain state-file

Save a running domain to a state file so that it can be restored by using the restore subcommand at a later time. In this state, the domain is not running on the system, thus the memory allocated for the domain will be free for use br other domains.

Note that network connections present before the save operation might be severed because TCP timeouts might have expired. 

virsh setvcpus domaincount

Change the number of virtual CPUs active in the specified guest domain. The count parameter is the number of virtual CPUs.

virsh schedinfo domain

Show or set the scheduling paramaters for the specified domain name, ID, or UUID. This subcommand takes the options --weight number and --cap number.

virsh setmaxmem domain kilobytes

Change the maximum memory allocation limit in the specified guest domain. The kilobytes parameter is the maximum memory limit in kilobytes.

virsh setmem domain kilobytes

Change the current memory allocation in the specified guest domain. The kilobytes parameter is the number of kilobytes in memory.

virsh setvcpus domain count

Change the number of virtual CPUs active in the specified guest domain. The count parameter is the number of virtual CPUs.

virsh shutdown domain

Coordinates with the domain operating system to perform graceful shutdown. The effect of this command is identical to the effect of running init 5.

The shutdown might take an unexpected length of time, depending on the services that must be shut down in the domain. In addition, it is possible that the subcommand will not succeed. 

virsh start domain

Start a previously defined inactive domain. 

virsh suspend domain

Suspend a domain. A domain in this state still consumes allocated resources, such as memory, but is not eligible for scheduling by the hypervisor. 

virsh undefine domain

Undefine the configuration for the inactive domain by specifying either its domain name or UUID. 

virsh vcpuinfo domain

Return basic information about the domain's virtual CPUs. 

virsh vcpupin domain vcpu cpulist

Pin domain's virtual CPUs to the host's physical CPUs. The domain parameter is the domain name, ID, or UUID. The vcpu parameter is the VCPU number. The cpulist parameter is a list of host CPU numbers, separated by commas.

virsh version

Display version information. 

virsh vncdisplay domain-id

VNC display