Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions

  




 

 

System Administration Guide: Virtualization Using the Solaris Operating System
Previous Next

virsh Command and Domain Management

The main command interface used to control both Solaris xVM and guest domains is the virsh command. virsh provides a generic and stable interface for controlling virtualized operating systems. Use virsh instead of xm wherever possible.

Many virsh commands act asynchronously. This means that the system prompt can return before the operation has completed.

If you modify CPUs or memory by using the virsh command, these changes will be saved in the configuration file and persist across reboots.

virsh Command Structure

Most virsh commands follow the format:

# virsh subcommand domain-id | name | uuid [options]
subcommand

One of the subcommands listed in the virsh(1M) man page

domain-id, name, or uuid

A domain identifier

options

An option to a subcommand

Example 41-1 Using a virsh Command

This line connects to a domU named sxc18.

# virsh console sxc18

virshCommand

The virsh is used to manage domains. You must run the commands as the root user or by assuming the Primary Administrator role 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. Use --all to display both running and 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

Suspend and Resume Functions and Commands

Some xVM operations are not yet implemented in the virsh command. In those cases, the equivalent xm command can be used. Subcommand terminology differs between the xmand virsh commands. In particular, the suspend and resume commands have different meanings.

Table 41-1 Equivalent virsh and xmCommands

virsh

xm

suspend

pause

resume

unpause

save

suspend without an output file argument

restore

resume without an output file argument

Previous Next

 
 
  Published under the terms fo the Public Documentation License Version 1.01. Design by Interspire