C H A P T E R  3

Using the Virtual Shell (virsh) Commands

This chapter describes using the virtual shell, virsh(1M), which is a new shell environment and is a management user interface for logical domains. The virsh commands can be used to perform various actions on a logical domain. See TABLE 3-1 for the virsh commands you can use with LDoms.


The virsh Commands Used With LDoms

Refer to the following site for overall information about virsh(1M) in the virsh(1M) man page. This man page contains all the commands available for use with OpenSolaris xVM.

http://opensolaris.org/os/community/xen/docs/

The following table shows the virsh commands that are available for use with the Logical Domains 1.0.1 software.


TABLE 3-1   The virsh Commands Used with LDoms
virsh Command Usage Description
console console domain Connect the virtual serial console for the guest domain

Note - This command cannot be used to connect to the console for the control, or primary, domain.

create create file Create a domain from an XML file, and leave it in the inactive state
define define file Define (but do not start) a domain from an XML file, and leave it in the bound state
destroy destroy domain Destroy an active/bound domain and leave it in the inactive state.
domid domid domain Convert a domain name or UUID to a domain ID
dominfo dominfo domain Provide basic information about the domain.
domname domname domain Convert a domain ID or UUID to a domain name
domstate domstate domain Show a domain state.
domuuid domuuid domain Convert a domain name or ID to a domain UUID
dumpxml dumpxml domain Provide domain information in XML to standard output (stdout). The output is similar to that from an ldm list-constraints domain command.
help help [command_name] Print usage for one or all virsh commands used with LDoms
hostname hostname Print the hypervisor host name
list list [--inactive | --all] List domains
nodeinfo nodeinfo Show node, or system, information
quit quit Quit this interactive terminal
setmem setmem domain kilobytes Change a logical domain’s memory allocation in kilobytes

Note - The amount of memory must be greater than 4000 kilobytes, or you receive an error.

setvcpus setvcpus domain count Change the number of virtual CPUs assigned to a logical domain
shutdown shutdown domain Shut down a logical domain gracefully to the bound state
start start domain Start an inactive or bound logical domain
undefine undefine domain Undefine and delete an inactive logical domain
vcpuinfo vcpuinfo domain Provide basic domain virtual CPU information
version version Show the version of the libvirt library, the Logical Domains Manager, and the hypervisor.


Using the Virtual Shell (virsh) with LDoms



Note - You must be a superuser to run the virsh commands.



This section contains examples of using some of the virsh commands with LDoms and some output examples.

procedure icon  To Start the Virtual Shell (virsh)

procedure icon  To Get Help for Virtual Shell (virsh) Commands

procedure icon  To Get Node Information

  1. To obtain the following node, or system, information, type:


    virsh # nodeinfo
    CPU model:           SPARC
    CPU(s):              32
    CPU frequency:       502 MHz
    CPU socket(s):       1
    Core(s) per socket:  8
    Thread(s) per core:  4
    NUMA cell(s):        1
    Memory size:         33481216 kB
    

    • CPU model, CPU sockets, Cores per socket and NUMA cells are all static data and display data as shown in the preceding example.

    • Threads per core is either 4 or 8 depending on whether you have a Sun UltraSPARCtrademark T1– or T2–based server.

  2. Verify CPU frequency by using the psrinfo -v command on the control domain.

  3. Verify memory by using the ldm list-bindings and ldm list-devices commands and adding the memory sizes together.

procedure icon  To Get Virtual CPU Information

  1. To obtain virtual CPU information from the control, or primary, domain, type:


    virsh # vcpuinfo primary
    VCPU:           0
    CPU:            0
    State:          running
    CPU time:       1460460.0s
    

    • Output shows valid CPU time only for CPUs in the control domain. This time is the same for all CPUs and is the same as uptime for the control domain.

  2. To obtain virtual CPU information from a guest domain (ldom1 in this example), type:


    virsh # vcpuinfo ldom1
    VCPU:           0
    CPU:            15
    State:          unknown
     
    

    • All guest CPU time is not displayed.

    • All guest CPU states are unknown.

procedure icon  To Get Version Information

  1. To obtain version information for the libvirt library, the Logical Domains Manager, and the hypervisor, type:


    virsh # version
    Compiled against library: libvir 0.3.2
    Using library: libvir 0.3.2
    Using API: LDoms 1.0.1
    Running hypervisor: LDoms 1.5.1
    

  2. Verify the hypervisor version by using the ldm -V command.

procedure icon  To Quit the Virtual Shell (virsh)