Virsh Commands: Why They Are Important

After installing Openstack, I got KVM/QEMU installed as a by-product. To get myself familiar with the functionalities, I played with Virtulization Manager and the virsh command line. By comparing with the libvirt API, I found they are pretty similar. Therefore, I think it’s a good starting point before jumping to the APIs. Also, the virsh is implemented on top of the libvirt APIs.

So I took some time to run through the possible virsh commands. The following are the recording of what’s tried. Note that some of the commands require additional inputs like XML files, therefore not included here. When I get to the APIs, some of these XMLs will be discussed in details.

Lost VMs or Containers? Too Many Consoles? Too Slow GUI? Time to learn how to "Google" and manage your VMware and clouds in a fast and secure HTML5 App.

 
virsh # domid instance-0000000d
1
 
virsh # screenshot  instance-0000000d
Screenshot saved to instance-0000000d-2013-06-17-11:16:14.ppm, with type of image/x-portable-pixmap
 
virsh # schedinfo  instance-0000000d
Scheduler      : posix
cpu_shares     : 1024
vcpu_period    : 100000
vcpu_quota     : -1
emulator_period: 100000
emulator_quota : -1
 
virsh # domdisplay  instance-0000000d
vnc://192.168.45.22:0
 
virsh # domblkinfo  instance-0000000d --device vda
Capacity:       1073741824
Allocation:     1847296
Physical:       1847296
 
virsh # domblkstat  instance-0000000d --device vda
vda rd_req 1285
vda rd_bytes 23444480
vda wr_req 234
vda wr_bytes 618496
vda flush_operations 2
vda rd_total_times 1065128196
vda wr_total_times 960359872
vda flush_total_times 1741727
 
 
virsh # domiflist  instance-0000000d
Interface  Type       Source     Model       MAC
-------------------------------------------------------
tap09266687-51 bridge     qbr09266687-51 virtio      fa:16:3e:45:5b:67
 
 
virsh # dominfo instance-0000000d
Id:             1
Name:           instance-0000000d
UUID:           5a70225f-87c4-42f4-8f95-b12bbae282c7
OS Type:        hvm
State:          running
CPU(s):         1
CPU time:       16284.2s
Max memory:     524288 KiB
Used memory:    524288 KiB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: selinux
Security DOI:   0
Security label: system_u:system_r:svirt_t:s0:c317,c621 (enforcing)
 
 
virsh # dommemstat instance-0000000d
actual 524288
rss 223640
 
virsh # domstate instance-0000000d
running
 
virsh # list
 Id    Name                           State
----------------------------------------------------
 1     instance-0000000d              running
 2     instance-0000000f              running
 
virsh # capabilities
<capabilities>
 
  <host>
    <uuid>c92d59a0-277c-11e2-3210-32100000001e</uuid>
    <cpu>
      <arch>x86_64</arch>
      <model>Westmere</model>
      <vendor>Intel</vendor>
      <topology sockets='1' cores='6' threads='2'/>
      <feature name='rdtscp'/>
      <feature name='pdpe1gb'/>
      <feature name='dca'/>
      <feature name='pcid'/>
      <feature name='pdcm'/>
      <feature name='xtpr'/>
      <feature name='tm2'/>
      <feature name='est'/>
      <feature name='smx'/>
      <feature name='vmx'/>
      <feature name='ds_cpl'/>
      <feature name='monitor'/>
      <feature name='dtes64'/>
      <feature name='pclmuldq'/>
      <feature name='pbe'/>
      <feature name='tm'/>
      <feature name='ht'/>
      <feature name='ss'/>
      <feature name='acpi'/>
      <feature name='ds'/>
      <feature name='vme'/>
    </cpu>
    <power_management>
      <suspend_disk/>
    </power_management>
    <migration_features>
      <live/>
      <uri_transports>
        <uri_transport>tcp</uri_transport>
      </uri_transports>
    </migration_features>
    <topology>
      <cells num='2'>
        <cell id='0'>
          <cpus num='12'>
            <cpu id='0' socket_id='0' core_id='0' siblings='0,12'/>
            <cpu id='2' socket_id='0' core_id='1' siblings='2,14'/>
            <cpu id='4' socket_id='0' core_id='2' siblings='4,16'/>
            <cpu id='6' socket_id='0' core_id='8' siblings='6,18'/>
            <cpu id='8' socket_id='0' core_id='9' siblings='8,20'/>
            <cpu id='10' socket_id='0' core_id='10' siblings='10,22'/>
            <cpu id='12' socket_id='0' core_id='0' siblings='0,12'/>
            <cpu id='14' socket_id='0' core_id='1' siblings='2,14'/>
            <cpu id='16' socket_id='0' core_id='2' siblings='4,16'/>
            <cpu id='18' socket_id='0' core_id='8' siblings='6,18'/>
            <cpu id='20' socket_id='0' core_id='9' siblings='8,20'/>
            <cpu id='22' socket_id='0' core_id='10' siblings='10,22'/>
          </cpus>
        </cell>
        <cell id='1'>
          <cpus num='12'>
            <cpu id='1' socket_id='1' core_id='0' siblings='1,13'/>
            <cpu id='3' socket_id='1' core_id='1' siblings='3,15'/>
            <cpu id='5' socket_id='1' core_id='2' siblings='5,17'/>
            <cpu id='7' socket_id='1' core_id='8' siblings='7,19'/>
            <cpu id='9' socket_id='1' core_id='9' siblings='9,21'/>
            <cpu id='11' socket_id='1' core_id='10' siblings='11,23'/>
            <cpu id='13' socket_id='1' core_id='0' siblings='1,13'/>
            <cpu id='15' socket_id='1' core_id='1' siblings='3,15'/>
            <cpu id='17' socket_id='1' core_id='2' siblings='5,17'/>
            <cpu id='19' socket_id='1' core_id='8' siblings='7,19'/>
            <cpu id='21' socket_id='1' core_id='9' siblings='9,21'/>
            <cpu id='23' socket_id='1' core_id='10' siblings='11,23'/>
          </cpus>
        </cell>
      </cells>
    </topology>
    <secmodel>
      <model>selinux</model>
      <doi>0</doi>
    </secmodel>
    <secmodel>
      <model>dac</model>
      <doi>0</doi>
    </secmodel>
  </host>
 
  <guest>
    <os_type>hvm</os_type>
    <arch name='i686'>
      <wordsize>32</wordsize>
      <emulator>/usr/libexec/qemu-kvm</emulator>
      <machine>rhel6.4.0</machine>
      <machine canonical='rhel6.4.0'>pc</machine>
      <machine>rhel6.3.0</machine>
      <machine>rhel6.2.0</machine>
      <machine>rhel6.1.0</machine>
      <machine>rhel6.0.0</machine>
      <machine>rhel5.5.0</machine>
      <machine>rhel5.4.4</machine>
      <machine>rhel5.4.0</machine>
      <domain type='qemu'>
      </domain>
      <domain type='kvm'>
        <emulator>/usr/libexec/qemu-kvm</emulator>
      </domain>
    </arch>
    <features>
      <cpuselection/>
      <deviceboot/>
      <acpi default='on' toggle='yes'/>
      <apic default='on' toggle='no'/>
      <pae/>
      <nonpae/>
    </features>
  </guest>
 
  <guest>
    <os_type>hvm</os_type>
    <arch name='x86_64'>
      <wordsize>64</wordsize>
      <emulator>/usr/libexec/qemu-kvm</emulator>
      <machine>rhel6.4.0</machine>
      <machine canonical='rhel6.4.0'>pc</machine>
      <machine>rhel6.3.0</machine>
      <machine>rhel6.2.0</machine>
      <machine>rhel6.1.0</machine>
      <machine>rhel6.0.0</machine>
      <machine>rhel5.5.0</machine>
      <machine>rhel5.4.4</machine>
      <machine>rhel5.4.0</machine>
      <domain type='qemu'>
      </domain>
      <domain type='kvm'>
        <emulator>/usr/libexec/qemu-kvm</emulator>
      </domain>
    </arch>
    <features>
      <cpuselection/>
      <deviceboot/>
      <acpi default='on' toggle='yes'/>
      <apic default='on' toggle='no'/>
    </features>
  </guest>
 
</capabilities>
 
 
virsh # freecell
Total: 96667008 KiB
 
virsh # hostname
node1.openstack
 
virsh # node-memory-tune
Shared memory:
        shm_pages_to_scan 100
        shm_sleep_millisecs 20
        shm_pages_shared 0
        shm_pages_sharing 0
        shm_pages_unshared 0
        shm_pages_volatile 0
        shm_full_scans  0
 
virsh # nodecpustats
user:                  9224730000000
system:               26277740000000
idle:               5821335310000000
iowait:                  41260000000
 
virsh # nodeinfo
CPU model:           x86_64
CPU(s):              24
CPU frequency:       2927 MHz
CPU socket(s):       1
Core(s) per socket:  6
Thread(s) per core:  2
NUMA cell(s):        2
Memory size:         99006632 KiB
 
## none of the possible targets (mem, disk, hybrid) works.
virsh # nodesuspend --target hybrid --duration 1
error: The host was not suspended
error: argument unsupported: Hybrid-Suspend
 
 
virsh # qemu-attach
error: command 'qemu-attach' requires <pid> option
virsh # sysinfo
<sysinfo type='smbios'>
  <bios>
    <entry name='vendor'>Cisco Systems, Inc.</entry>
    <entry name='version'>S5500.2.1.1b.0.020620132148</entry>
    <entry name='date'>02/06/2013</entry>
    <entry name='release'>2.1</entry>
  </bios>
  <system>
    <entry name='manufacturer'>Cisco Systems Inc</entry>
    <entry name='product'>N20-B6625-1</entry>
    <entry name='version'>.</entry>
    <entry name='serial'>FCH1506704C</entry>
    <entry name='uuid'>C92D59A0-277C-11E2-3210-32100000001E</entry>
    <entry name='sku'>Not Specified</entry>
    <entry name='family'>Not Specified</entry>
  </system>
  <processor>
    <entry name='socket_destination'>CPU1</entry>
    <entry name='type'>Central Processor</entry>
    <entry name='family'>Xeon</entry>
    <entry name='manufacturer'>Intel(R) Corporation</entry>
    <entry name='signature'>Type 0, Family 6, Model 44, Stepping 2</entry>
    <entry name='version'>Intel(R) Xeon(R) CPU           X5670  @ 2.93GHz</entry>
    <entry name='external_clock'>133 MHz</entry>
    <entry name='max_speed'>4000 MHz</entry>
    <entry name='status'>Populated, Enabled</entry>
    <entry name='serial_number'>Not Specified</entry>
    <entry name='part_number'>Not Specified</entry>
  </processor>
  <processor>
    <entry name='socket_destination'>CPU2</entry>
    <entry name='type'>Central Processor</entry>
    <entry name='family'>Xeon</entry>
    <entry name='manufacturer'>Intel(R) Corporation</entry>
    <entry name='signature'>Type 0, Family 6, Model 44, Stepping 2</entry>
    <entry name='version'>Intel(R) Xeon(R) CPU           X5670  @ 2.93GHz</entry>
    <entry name='external_clock'>133 MHz</entry>
    <entry name='max_speed'>4000 MHz</entry>
    <entry name='status'>Populated, Enabled</entry>
    <entry name='serial_number'>Not Specified</entry>
    <entry name='part_number'>Not Specified</entry>
  </processor>
  <memory_device>
    <entry name='size'>8192 MB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM_A1</entry>
    <entry name='bank_locator'>NODE 0 CHANNEL 0 DIMM 0</entry>
    <entry name='type'>Other</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1333 MHz</entry>
    <entry name='manufacturer'>0x80CE</entry>
    <entry name='serial_number'>0x8563AD9D</entry>
    <entry name='part_number'>M393B1K70CH0-YH9</entry>
  </memory_device>
  <memory_device>
    <entry name='size'>8192 MB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM_A2</entry>
    <entry name='bank_locator'>NODE 0 CHANNEL 0 DIMM 1</entry>
    <entry name='type'>Other</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1333 MHz</entry>
    <entry name='manufacturer'>0x80CE</entry>
    <entry name='serial_number'>0x8268388D</entry>
    <entry name='part_number'>M393B1K70CH0-YH9</entry>
  </memory_device>
  <memory_device>
    <entry name='size'>8192 MB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM_B1</entry>
    <entry name='bank_locator'>NODE 0 CHANNEL 1 DIMM 0</entry>
    <entry name='type'>Other</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1333 MHz</entry>
    <entry name='manufacturer'>0x80CE</entry>
    <entry name='serial_number'>0x875E934F</entry>
    <entry name='part_number'>M393B1K70CH0-YH9</entry>
  </memory_device>
  <memory_device>
    <entry name='size'>8192 MB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM_B2</entry>
    <entry name='bank_locator'>NODE 0 CHANNEL 1 DIMM 1</entry>
    <entry name='type'>Other</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1333 MHz</entry>
    <entry name='manufacturer'>0x80CE</entry>
    <entry name='serial_number'>0x8618B27F</entry>
    <entry name='part_number'>M393B1K70CH0-YH9</entry>
  </memory_device>
  <memory_device>
    <entry name='size'>8192 MB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM_C1</entry>
    <entry name='bank_locator'>NODE 0 CHANNEL 2 DIMM 0</entry>
    <entry name='type'>Other</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1333 MHz</entry>
    <entry name='manufacturer'>0x80CE</entry>
    <entry name='serial_number'>0x8561A5B4</entry>
    <entry name='part_number'>M393B1K70CH0-YH9</entry>
  </memory_device>
  <memory_device>
    <entry name='size'>8192 MB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM_C2</entry>
    <entry name='bank_locator'>NODE 0 CHANNEL 2 DIMM 1</entry>
    <entry name='type'>Other</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1333 MHz</entry>
    <entry name='manufacturer'>0x80CE</entry>
    <entry name='serial_number'>0x875E93EE</entry>
    <entry name='part_number'>M393B1K70CH0-YH9</entry>
  </memory_device>
  <memory_device>
    <entry name='size'>8192 MB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM_D1</entry>
    <entry name='bank_locator'>NODE 1 CHANNEL 0 DIMM 0</entry>
    <entry name='type'>Other</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1333 MHz</entry>
    <entry name='manufacturer'>0x80CE</entry>
    <entry name='serial_number'>0x8563ADA1</entry>
    <entry name='part_number'>M393B1K70CH0-YH9</entry>
  </memory_device>
  <memory_device>
    <entry name='size'>8192 MB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM_D2</entry>
    <entry name='bank_locator'>NODE 1 CHANNEL 0 DIMM 1</entry>
    <entry name='type'>Other</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1333 MHz</entry>
    <entry name='manufacturer'>0x80CE</entry>
    <entry name='serial_number'>0x8561A55D</entry>
    <entry name='part_number'>M393B1K70CH0-YH9</entry>
  </memory_device>
  <memory_device>
    <entry name='size'>8192 MB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM_E1</entry>
    <entry name='bank_locator'>NODE 1 CHANNEL 1 DIMM 0</entry>
    <entry name='type'>Other</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1333 MHz</entry>
    <entry name='manufacturer'>0x80CE</entry>
    <entry name='serial_number'>0x8561A522</entry>
    <entry name='part_number'>M393B1K70CH0-YH9</entry>
  </memory_device>
  <memory_device>
    <entry name='size'>8192 MB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM_E2</entry>
    <entry name='bank_locator'>NODE 1 CHANNEL 1 DIMM 1</entry>
    <entry name='type'>Other</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1333 MHz</entry>
    <entry name='manufacturer'>0x80CE</entry>
    <entry name='serial_number'>0x8618B1FF</entry>
    <entry name='part_number'>M393B1K70CH0-YH9</entry>
  </memory_device>
  <memory_device>
    <entry name='size'>8192 MB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM_F1</entry>
    <entry name='bank_locator'>NODE 1 CHANNEL 2 DIMM 0</entry>
    <entry name='type'>Other</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1333 MHz</entry>
    <entry name='manufacturer'>0x80CE</entry>
    <entry name='serial_number'>0x875E9353</entry>
    <entry name='part_number'>M393B1K70CH0-YH9</entry>
  </memory_device>
  <memory_device>
    <entry name='size'>8192 MB</entry>
    <entry name='form_factor'>DIMM</entry>
    <entry name='locator'>DIMM_F2</entry>
    <entry name='bank_locator'>NODE 1 CHANNEL 2 DIMM 1</entry>
    <entry name='type'>Other</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1333 MHz</entry>
    <entry name='manufacturer'>0x80CE</entry>
    <entry name='serial_number'>0x875D4363</entry>
    <entry name='part_number'>M393B1K70CH0-YH9</entry>
  </memory_device>
</sysinfo>
 
 
virsh # uri
qemu:///system
 
virsh # version
Compiled against library: libvirt 0.10.2
Using library: libvirt 0.10.2
Using API: QEMU 0.10.2
Running hypervisor: QEMU 0.12.1
 
virsh # iface-dumpxml
error: command 'iface-dumpxml' requires <interface> option
 
virsh # iface-list
Name                 State      MAC Address
--------------------------------------------
lo                   active     00:00:00:00:00:00
 
virsh # iface-dumpxml --interface lo
<interface type='ethernet' name='lo'>
  <protocol family='ipv4'>
    <ip address='127.0.0.1' prefix='8'/>
  </protocol>
  <protocol family='ipv6'>
    <ip address='::1' prefix='128'/>
  </protocol>
</interface>
 
## iface-list does not show eth0, but it does exist and its content can be retrieved
virsh # iface-dumpxml --interface eth0
<interface type='ethernet' name='eth0'>
  <mac address='00:25:30:21:00:1e'/>
  <protocol family='ipv4'>
    <ip address='192.168.45.22' prefix='24'/>
  </protocol>
  <protocol family='ipv6'>
    <ip address='fe80::225:30ff:fe21:1e' prefix='64'/>
  </protocol>
</interface>
 
virsh # net-list
Name                 State      Autostart     Persistent
--------------------------------------------------
default              active     yes           yes
 
 
virsh # net-dumpxml --network default
<network>
  <name>default</name>
  <uuid>0b421501-9a01-432e-9d0c-1dc652aebbb7</uuid>
  <forward mode='nat'/>
  <bridge name='virbr0' stp='on' delay='0' />
  <mac address='52:54:00:03:D3:11'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254' />
    </dhcp>
  </ip>
</network>
 
virsh # net-uuid --network default
0b421501-9a01-432e-9d0c-1dc652aebbb7
 
virsh # nwfilter-list
UUID                                  Name
----------------------------------------------------------------
30a8b2a8-dd04-ae1d-c368-404a9a3f3b05  allow-arp
25d1c638-bd77-ecb1-b5b3-cd659d961245  allow-dhcp
dd143419-29be-1c56-a68a-e8f4ffaf2cf3  allow-dhcp-server
bd9074c0-da02-cb8d-085b-2d92609d1048  allow-incoming-ipv4
0a329f48-7cac-377a-f2ab-b55fb1684475  allow-ipv4
d10bd9d8-e6b6-b504-ce9d-821bbce1eba6  clean-traffic
f13e982d-b115-cb6e-1ab6-9aa5ca06f1ea  no-arp-ip-spoofing
06cf743c-04a1-975c-2589-877e52f3724b  no-arp-mac-spoofing
5e051394-0b59-bfdd-b837-792c8f4129c8  no-arp-spoofing
1edcf936-f9e7-6953-2294-4f976291e003  no-ip-multicast
fd4ba879-e5d2-2716-b6e6-6ac739ab2980  no-ip-spoofing
12f053ec-d996-3fec-c8b0-29e8727096da  no-mac-broadcast
d7d9c931-4d54-e324-ea4d-4313a4c327a8  no-mac-spoofing
df799087-146d-df0f-a970-ffb01538f81c  no-other-l2-traffic
a6b2f4f0-434f-86bc-4885-2286d417ff8f  no-other-rarp-traffic
625214a2-3c18-16fb-93d8-685a4aab6bdb  qemu-announce-self
efeab16e-cc62-0cfd-2b1d-9f99a60187d2  qemu-announce-self-rarp
 
 
virsh # net-list
Name                 State      Autostart     Persistent
--------------------------------------------------
default              active     yes           yes
 
virsh # net-dumpxml --network default
<network>
  <name>default</name>
  <uuid>0b421501-9a01-432e-9d0c-1dc652aebbb7</uuid>
  <forward mode='nat'/>
  <bridge name='virbr0' stp='on' delay='0' />
  <mac address='52:54:00:03:D3:11'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254' />
    </dhcp>
  </ip>
</network>
 
virsh # net-info --network default
Name            default
UUID            0b421501-9a01-432e-9d0c-1dc652aebbb7
Active:         yes
Persistent:     yes
Autostart:      yes
Bridge:         virbr0
 
virsh # nodedev-list
block_sda_36006016087cb34008aa7d102a4d1e211
block_sdb_350060160bde0338f50060160bde0338f
computer
net_1000_76_69_84_34_cc_cb
net_br_int_a6_9e_37_66_17_cb
net_eth0_00_25_30_21_00_1e
net_eth1_00_25_30_21_01_1e
net_eth2_00_25_30_21_02_1e
net_lo_00_00_00_00_00_00
net_ovs_system_c2_87_da_50_d2_49
net_qvb09266687_51_7a_bb_7f_1e_8e_ef
net_qvbd6e4fa7a_37_86_dc_4b_60_1f_01
net_qvo09266687_51_b2_3e_b0_c2_92_71
net_qvod6e4fa7a_37_de_eb_2d_9a_ef_c8
net_tap09266687_51_fe_16_3e_45_5b_67
net_tapd6e4fa7a_37_fe_16_3e_f0_e3_3f
net_virbr0_nic_52_54_00_03_d3_11
pci_0000_00_00_0
pci_0000_00_01_0
pci_0000_00_02_0
pci_0000_00_03_0
pci_0000_00_07_0
pci_0000_00_08_0
pci_0000_00_09_0
pci_0000_00_0a_0
pci_0000_00_10_0
pci_0000_00_10_1
pci_0000_00_11_0
pci_0000_00_11_1
pci_0000_00_13_0
pci_0000_00_14_0
pci_0000_00_14_1
pci_0000_00_14_2
pci_0000_00_14_3
pci_0000_00_16_0
pci_0000_00_16_1
pci_0000_00_16_2
pci_0000_00_16_3
pci_0000_00_16_4
pci_0000_00_16_5
pci_0000_00_16_6
pci_0000_00_16_7
pci_0000_00_1a_0
pci_0000_00_1a_1
pci_0000_00_1a_2
pci_0000_00_1a_7
pci_0000_00_1c_0
pci_0000_00_1c_4
pci_0000_00_1c_5
pci_0000_00_1d_0
pci_0000_00_1d_1
pci_0000_00_1d_2
pci_0000_00_1d_7
pci_0000_00_1e_0
pci_0000_00_1f_0
pci_0000_00_1f_3
pci_0000_01_00_0
pci_0000_04_00_0
pci_0000_05_00_0
pci_0000_06_00_0
pci_0000_07_00_0
pci_0000_07_01_0
pci_0000_07_02_0
pci_0000_07_03_0
pci_0000_07_04_0
pci_0000_08_00_0
pci_0000_09_00_0
pci_0000_0a_00_0
pci_0000_0b_00_0
pci_0000_0c_00_0
pci_0000_11_00_0
scsi_1_0_0_0
scsi_2_0_0_0
scsi_host0
scsi_host1
scsi_host2
scsi_target1_0_0
scsi_target2_0_0
usb_1_0_1_0
usb_2_0_1_0
usb_2_1
usb_2_1_1_0
usb_3_0_1_0
usb_4_0_1_0
usb_4_1
usb_4_1_1_0
usb_4_1_1_1
usb_4_1_1_2
usb_5_0_1_0
usb_6_0_1_0
usb_7_0_1_0
usb_8_0_1_0
usb_usb1
usb_usb2
usb_usb3
usb_usb4
usb_usb5
usb_usb6
usb_usb7
usb_usb8
 
virsh # secret-list
UUID                                 Usage
-----------------------------------------------------------
 
virsh # snapshot-list
error: command 'snapshot-list' requires <domain> option
virsh # snapshot-list --doamin instance-0000000d
error: command 'snapshot-list' doesn't support option --doamin
virsh # snapshot-list instance-0000000d
 Name                 Creation Time             State
------------------------------------------------------------
 
virsh # snapshot-create instance-0000000d baseline
error: Failed to open file 'baseline': No such file or directory
 
virsh # snapshot-create instance-0000000d
Domain snapshot 1371498470 created
 
virsh # snapshot-revert instance-0000000d --current
error: revert requires force: Target device address type none does not match sou                                                                                                                                                              rce pci
 
virsh # snapshot-revert instance-0000000d --snapshotname 1371498470
error: revert requires force: Target device address type none does not match sou                                                                                                                                                              rce pci
 
 
virsh # snapshot-current instance-0000000d
error: domain 'instance-0000000d' has no current snapshot
 
virsh # snapshot-info instance-0000000d
error: --snapshotname or --current is required
 
virsh # snapshot-info instance-0000000d --snapshotname 1371498470
Name:           1371498470
Domain:         instance-0000000d
Current:        no
State:          running
Location:       internal
Parent:         -
Children:       0
Descendants:    0
Metadata:       yes
 
volvirsh # snapshot-parent instance-0000000d --snapshotname 1371498470
error: snapshot '1371498470' has no parent
 
virsh # pool-list
Name                 State      Autostart
-----------------------------------------
 
virsh # pwd
/root
 
virsh # cd
 
virsh # echo
 
virsh # echo helloKVM
helloKVM
virsh # quit

Appendix: List of Virsh commands

The following list of commands are captured from running the virsh help.

# virsh --help > virshhelp.txt
virsh [options]... [<command_string>]
virsh [options]... <command> [args...]
 
  options:
    -c | --connect=URI      hypervisor connection URI
    -r | --readonly         connect readonly
    -d | --debug=NUM        debug level [0-4]
    -h | --help             this help
    -q | --quiet            quiet mode
    -t | --timing           print timing information
    -l | --log=FILE         output logging to file
    -v                      short version
    -V                      long version
         --version[=TYPE]   version, TYPE is short or long (default short)
    -e | --escape <char>    set escape sequence for console
 
  commands (non interactive mode):
 
 Domain Management (help keyword 'domain')
    attach-device                  attach device from an XML file
    attach-disk                    attach disk device
    attach-interface               attach network interface
    autostart                      autostart a domain
    blkdeviotune                   Set or query a block device I/O tuning parameters.
    blkiotune                      Get or set blkio parameters
    blockcommit                    Start a block commit operation.
    blockcopy                      Start a block copy operation.
    blockjob                       Manage active block operations
    blockpull                      Populate a disk from its backing image.
    blockresize                    Resize block device of domain.
    change-media                   Change media of CD or floppy drive
    console                        connect to the guest console
    cpu-baseline                   compute baseline CPU
    cpu-compare                    compare host CPU with a CPU described by an XML file
    cpu-stats                      show domain cpu statistics
    create                         create a domain from an XML file
    define                         define (but don't start) a domain from an XML file
    desc                           show or set domain's description or title
    destroy                        destroy (stop) a domain
    detach-device                  detach device from an XML file
    detach-disk                    detach disk device
    detach-interface               detach network interface
    domdisplay                     domain display connection URI
    domhostname                    print the domain's hostname
    domid                          convert a domain name or UUID to domain id
    domif-setlink                  set link state of a virtual interface
    domiftune                      get/set parameters of a virtual interface
    domjobabort                    abort active domain job
    domjobinfo                     domain job information
    domname                        convert a domain id or UUID to domain name
    dompmsuspend                   suspend a domain gracefully using power management functions
    dompmwakeup                    wakeup a domain from pmsuspended state
    domuuid                        convert a domain name or id to domain UUID
    domxml-from-native             Convert native config to domain XML
    domxml-to-native               Convert domain XML to native config
    dump                           dump the core of a domain to a file for analysis
    dumpxml                        domain information in XML
    edit                           edit XML configuration for a domain
    inject-nmi                     Inject NMI to the guest
    send-key                       Send keycodes to the guest
    managedsave                    managed save of a domain state
    managedsave-remove             Remove managed save of a domain
    maxvcpus                       connection vcpu maximum
    memtune                        Get or set memory parameters
    migrate                        migrate domain to another host
    migrate-setmaxdowntime         set maximum tolerable downtime
    migrate-setspeed               Set the maximum migration bandwidth
    migrate-getspeed               Get the maximum migration bandwidth
    numatune                       Get or set numa parameters
    reboot                         reboot a domain
    reset                          reset 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
    save-image-define              redefine the XML for a domain's saved state file
    save-image-dumpxml             saved state domain information in XML
    save-image-edit                edit XML for a domain's saved state file
    schedinfo                      show/set scheduler parameters
    screenshot                     take a screenshot of a current domain console and store it into a file
    setmaxmem                      change maximum memory limit
    setmem                         change memory allocation
    setvcpus                       change number of virtual CPUs
    shutdown                       gracefully shutdown a domain
    start                          start a (previously defined) inactive domain
    suspend                        suspend a domain
    ttyconsole                     tty console
    undefine                       undefine a domain
    update-device                  update device from an XML file
    vcpucount                      domain vcpu counts
    vcpuinfo                       detailed domain vcpu information
    vcpupin                        control or query domain vcpu affinity
    emulatorpin                    control or query domain emulator affinity
    vncdisplay                     vnc display
 
 Domain Monitoring (help keyword 'monitor')
    domblkerror                    Show errors on block devices
    domblkinfo                     domain block device size information
    domblklist                     list all domain blocks
    domblkstat                     get device block stats for a domain
    domcontrol                     domain control interface state
    domif-getlink                  get link state of a virtual interface
    domiflist                      list all domain virtual interfaces
    domifstat                      get network interface stats for a domain
    dominfo                        domain information
    dommemstat                     get memory statistics for a domain
    domstate                       domain state
    list                           list domains
 
 Host and Hypervisor (help keyword 'host')
    capabilities                   capabilities
    freecell                       NUMA free memory
    hostname                       print the hypervisor hostname
    node-memory-tune               Get or set node memory parameters
    nodecpustats                   Prints cpu stats of the node.
    nodeinfo                       node information
    nodememstats                   Prints memory stats of the node.
    nodesuspend                    suspend the host node for a given time duration
    qemu-attach                    QEMU Attach
    qemu-monitor-command           QEMU Monitor Command
    qemu-agent-command             QEMU Guest Agent Command
    sysinfo                        print the hypervisor sysinfo
    uri                            print the hypervisor canonical URI
    version                        show version
 
 Interface (help keyword 'interface')
    iface-begin                    create a snapshot of current interfaces settings, which can be later committed (iface-commit) or restored (iface-rollback)
    iface-bridge                   create a bridge device and attach an existing network device to it
    iface-commit                   commit changes made since iface-begin and free restore point
    iface-define                   define (but don't start) a physical host interface from an XML file
    iface-destroy                  destroy a physical host interface (disable it / "if-down")
    iface-dumpxml                  interface information in XML
    iface-edit                     edit XML configuration for a physical host interface
    iface-list                     list physical host interfaces
    iface-mac                      convert an interface name to interface MAC address
    iface-name                     convert an interface MAC address to interface name
    iface-rollback                 rollback to previous saved configuration created via iface-begin
    iface-start                    start a physical host interface (enable it / "if-up")
    iface-unbridge                 undefine a bridge device after detaching its slave device
    iface-undefine                 undefine a physical host interface (remove it from configuration)
 
 Network Filter (help keyword 'filter')
    nwfilter-define                define or update a network filter from an XML file
    nwfilter-dumpxml               network filter information in XML
    nwfilter-edit                  edit XML configuration for a network filter
    nwfilter-list                  list network filters
    nwfilter-undefine              undefine a network filter
 
 Networking (help keyword 'network')
    net-autostart                  autostart a network
    net-create                     create a network from an XML file
    net-define                     define (but don't start) a network from an XML file
    net-destroy                    destroy (stop) a network
    net-dumpxml                    network information in XML
    net-edit                       edit XML configuration for a network
    net-info                       network information
    net-list                       list networks
    net-name                       convert a network UUID to network name
    net-start                      start a (previously defined) inactive network
    net-undefine                   undefine an inactive network
    net-update                     update parts of an existing network's configuration
    net-uuid                       convert a network name to network UUID
 
 Node Device (help keyword 'nodedev')
    nodedev-create                 create a device defined by an XML file on the node
    nodedev-destroy                destroy (stop) a device on the node
    nodedev-detach                 detach node device from its device driver
    nodedev-dumpxml                node device details in XML
    nodedev-list                   enumerate devices on this host
    nodedev-reattach               reattach node device to its device driver
    nodedev-reset                  reset node device
 
 Secret (help keyword 'secret')
    secret-define                  define or modify a secret from an XML file
    secret-dumpxml                 secret attributes in XML
    secret-get-value               Output a secret value
    secret-list                    list secrets
    secret-set-value               set a secret value
    secret-undefine                undefine a secret
 
 Snapshot (help keyword 'snapshot')
    snapshot-create                Create a snapshot from XML
    snapshot-create-as             Create a snapshot from a set of args
    snapshot-current               Get or set the current snapshot
    snapshot-delete                Delete a domain snapshot
    snapshot-dumpxml               Dump XML for a domain snapshot
    snapshot-edit                  edit XML for a snapshot
    snapshot-info                  snapshot information
    snapshot-list                  List snapshots for a domain
    snapshot-parent                Get the name of the parent of a snapshot
    snapshot-revert                Revert a domain to a snapshot
 
 Storage Pool (help keyword 'pool')
    find-storage-pool-sources-as   find potential storage pool sources
    find-storage-pool-sources      discover potential storage pool sources
    pool-autostart                 autostart a pool
    pool-build                     build a pool
    pool-create-as                 create a pool from a set of args
    pool-create                    create a pool from an XML file
    pool-define-as                 define a pool from a set of args
    pool-define                    define (but don't start) a pool from an XML file
    pool-delete                    delete a pool
    pool-destroy                   destroy (stop) a pool
    pool-dumpxml                   pool information in XML
    pool-edit                      edit XML configuration for a storage pool
    pool-info                      storage pool information
    pool-list                      list pools
    pool-name                      convert a pool UUID to pool name
    pool-refresh                   refresh a pool
    pool-start                     start a (previously defined) inactive pool
    pool-undefine                  undefine an inactive pool
    pool-uuid                      convert a pool name to pool UUID
 
 Storage Volume (help keyword 'volume')
    vol-clone                      clone a volume.
    vol-create-as                  create a volume from a set of args
    vol-create                     create a vol from an XML file
    vol-create-from                create a vol, using another volume as input
    vol-delete                     delete a vol
    vol-download                   Download a volume to a file
    vol-dumpxml                    vol information in XML
    vol-info                       storage vol information
    vol-key                        returns the volume key for a given volume name or path
    vol-list                       list vols
    vol-name                       returns the volume name for a given volume key or path
    vol-path                       returns the volume path for a given volume name or key
    vol-pool                       returns the storage pool for a given volume key or path
    vol-resize                     resize a vol
    vol-upload                     upload a file into a volume
    vol-wipe                       wipe a vol
 
 Virsh itself (help keyword 'virsh')
    cd                             change the current directory
    connect                        (re)connect to hypervisor
    echo                           echo arguments
    exit                           quit this interactive terminal
    help                           print help
    pwd                            print the current directory
    quit                           quit this interactive terminal
 
 
  (specify help <group> for details about the commands in the group)
 
  (specify help <command> for details about the command)
This entry was posted in Virtualization and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Trackback

  • […] and QEMU support the same libvirt APIs, you would not notice any difference using command line like virsh, or Virtualization Manager. That is the beauty of standard APIs with different implementations, […]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  • NEED HELP?


    My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__ doublecloud.org.

    Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.