Xen management : virsh commands

You can use virsh to manage xen virtual servers. Here are some basic commands using virsh.

To list all the xen virtual machines configured on the dom0 server :

[root@unixfoo-xen23 ~]# virsh list
 Id Name                 State
  0 Domain-0             running
 12 domU04foo           blocked
 14 domU02foo           running
 15 domU03foo           blocked
 19 domU05foo           blocked
 21 domU06foo           blocked
 22 domU07foo           blocked

See information of a particular  xen domain :

[root@unixfoo-xen23 ~]# virsh dominfo 12
Id:             12
Name:           domU04foo
UUID:           d3a108f2324fad2e0de2e5c20f
OS Type:        hvm
State:          blocked
CPU(s):         1
CPU time:       3183.1s
Max memory:     2097152 kB
Used memory:    2097152 kB

Gather the domain info in xml format : 

This will be easy to develop custom monitoring scripts for xen. This gives information about

  • Xen Domain name
  • UUID
  • Para-virt / Full-virt
  • domU memory
  • domU cpu count
  • domU mac-id
  • domU block-storage

[root@unixfoo-xen23 ~]# virsh dumpxml 12
<domain type=’xen’ id=’12’>
    <boot dev=’hd’/>
    <interface type=’bridge’>
      <source bridge=’xenbr0’/>
      <mac address=’00:XX:XX:XX:AD:XX’/>
      <script path=’vif-bridge’/>
    <disk type=’file’ device=’disk’>
      <driver name=’file’/>
      <source file=’/xen/domU04foo/domU04foo.img’/>
      <target dev=’hda’/>

Print CPU information for domU :

[root@unixfoo-xen23 ~]# virsh vcpuinfo 12
VCPU:           0
CPU:            6
State:          blocked
CPU time:       3184.2s
CPU Affinity:   yyyyyyyy

Print the information about dom0 Xen server :

[root@unixfoo-xen23 ~]# virsh nodeinfo
CPU model:           i686
CPU(s):              8
CPU frequency:       1861 MHz
CPU socket(s):       2
Core(s) per socket:  4
Thread(s) per core:  1
NUMA cell(s):        1
Memory size:         33553408 kB

Other virsh commands :

[root@unixfoo-xen23 ~]# virsh help

    connect         (re)connect to hypervisor
    create          create a domain from an XML file
    start           start a (previously defined) inactive domain
    destroy         destroy a domain
    define          define (but don’t 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
    dumpxml         domain information in XML
    help            print help
    list            list domains
    nodeinfo        node information
    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
    dump            dump the core of a domain to a file for analysis
    shutdown        gracefully shutdown a domain
    setmem          change memory allocation
    setmaxmem       change maximum memory limit
    setvcpus        change number of virtual CPUs
    suspend         suspend a domain
    undefine        undefine an inactive domain
    vcpuinfo        domain vcpu information
    vcpupin         control domain vcpu affinity
    version         show version

[root@unixfoo-xen23 ~]#

Read more on Virtualization : http://unixfoo.blogspot.com/search/label/virtualization

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

Linux : Tunable TCP /proc parameters

Next Post

Some Netapp terms..

Related Posts