20.12. Retrieving Information about Your Virtual Machine
20.12.1. Displaying Device Block Statistics
virsh domblkstatcommand displays the block statistics for the first block device defined for the domain. To view statistics of other block devices, use the
virsh domblklist domaincommand to list all block devices, and then select a specific block device and display it by specifying either the Target or Source name from the
virsh domblklistcommand output after the domain name. Note that not every hypervisor can display every field. To make sure that the output is presented in its most legible form use the
Example 20.21. How to display block statistics for a guest virtual machine
virsh domblklist guest1Target Source ------------------------------------------------ vda /VirtualMachines/guest1.img hdc - #
virsh domblkstat guest1 vda --humanDevice: vda number of read operations: 174670 number of bytes read: 3219440128 number of write operations: 23897 number of bytes written: 164849664 number of flush operations: 11577 total duration of reads (ns): 1005410244506 total duration of writes (ns): 1085306686457 total duration of flushes (ns): 340645193294
20.12.2. Retrieving Network Interface Statistics
virsh domifstat domain interface-devicecommand displays the network interface statistics for the specified device running on a given guest virtual machine.
virsh domiflistcommand and use the output in the Interface column.
Example 20.22. How to display networking statistics for a guest virtual machine
virsh domiflist guest1Interface Type Source Model MAC ------------------------------------------------------- macvtap0 direct em1 rtl8139 12:34:00:0f:8a:4a #
virsh domifstat guest1 macvtap0macvtap0 rx_bytes 51120 macvtap0 rx_packets 440 macvtap0 rx_errs 0 macvtap0 rx_drop 0 macvtap0 tx_bytes 231666 macvtap0 tx_packets 520 macvtap0 tx_errs 0 macvtap0 tx_drop 0
20.12.5. Setting Network Interface Bandwidth Parameters
virsh domiftune domain interface-devicecommand either retrieves or sets the specified domain's interface bandwidth parameters. To determine which interface devices are defined for the domain, use the
virsh domiflistcommand and use either the
MACcolumn as the interface device option. The following format should be used:
virsh domiftune domain interface [--inbound] [--outbound] [--config] [--live] [--current]
--currentoptions are described in Section 20.43, “Setting Schedule Parameters”. If the
--outboundoption is not specified,
virsh domiftunequeries the specified network interface and displays the bandwidth settings. By specifying
--outbound, or both, and the average, peak, and burst values,
virsh domiftunesets the bandwidth settings. At minimum the average value is required. In order to clear the bandwidth settings, provide 0 (zero). For a description of the average, peak, and burst values, see Section 126.96.36.199, “Attaching interface devices”.
Example 20.25. How to set the guest virtual machine network interface parameters
virsh domiftune guest1
20.12.6. Retrieving Memory Statistics
virsh dommemstat domain [<period in seconds>] [--config] [--live] [--current]command displays the memory statistics for a running guest virtual machine. Using the optional
periodswitch requires a time period in seconds. Setting this option to a value larger than 0 will allow the balloon driver to return additional statistics which will be displayed by running subsequent
dommemstatcommands. Setting the
periodoption to 0, stops the balloon driver collection but does not clear the statistics already in the balloon driver. You cannot use the
--currentoptions without also setting the
periodoption. If the
--liveoption is specified, only the guest's running statistics will be collected. If the
--configoption is used, it will collect the statistics for a persistent guest, but only after the next boot. If the
--currentoption is used, it will collect the current statistics.
--configoptions may be used but
--currentis exclusive. If no flag is specified, the guest's state will dictate the behavior of the statistics collection (running or not).
Example 20.26. How to collect memory statistics for a running guest virtual machine
virsh dommemstat rhel7actual 1048576 swap_in 0 swap_out 0 major_fault 2974 minor_fault 1272454 unused 246020 available 1011248 rss 865172
20.12.7. Displaying Errors on Block Devices
virsh domblkerror domaincommand lists all the block devices in the error state and the error detected on each of them. This command is best used after a
virsh domstatecommand reports that a guest virtual machine is paused due to an I/O error.
Example 20.27. How to display the block device errors for a virtual machine
virsh domblkerror guest1
20.12.8. Displaying the Block Device Size
virsh domblkinfo domaincommand lists the capacity, allocation, and physical block sizes for a specific block device in the virtual machine. Use the virsh domblklist command to list all block devices and then choose to display a specific block device by specifying either the Target or Source name from the
virsh domblklistoutput after the domain name.
Example 20.28. How to display the block device size
virsh domblklist rhel7Target Source ------------------------------------------------ vda /home/vm-images/rhel7-os vdb /home/vm-images/rhel7-data #
virsh domblkinfo rhel7 vdaCapacity: 10737418240 Allocation: 8211980288 Physical: 10737418240 #
virsh domblkinfo rhel7 /home/vm-images/rhel7-dataCapacity: 104857600 Allocation: 104857600 Physical: 104857600
20.12.9. Displaying the Block Devices Associated with a Guest Virtual Machine
virsh domblklist domaincommand displays a table of all block devices that are associated with the specified guest virtual machine.
--inactiveis specified, the result will show the devices that are to be used at the next boot and will not show those that are currently running in use by the running guest virtual machine. If
--detailsis specified, the disk type and device value will be included in the table. The information displayed in this table can be used with other commands that require a block-device to be provided, such as
virsh snapshot-create. The disk Target or Source contexts can also be used when generating the xmlfile context information for the
Example 20.29. How to display the block devices that are associated with a virtual machine
virsh domblklist rhel7 --detailsType Device Target Source ------------------------------------------------ file disk vda /home/vm-images/rhel7-os file disk vdb /home/vm-images/rhel7-data
20.12.10. Displaying Virtual Interfaces Associated with a Guest Virtual Machine
virsh domblklist domaincommand displays a table of all the virtual interfaces that are associated with the specified domain. The
virsh domiflistcommand requires the name of the virtual machine (or domain), and optionally can take the
--inactiveargument. The latter retrieves the inactive rather than the running configuration, which is retrieved with the default setting. If
--inactiveis specified, the result shows devices that are to be used at the next boot, and does not show devices that are currently in use by the running guest. Virsh commands that require a MAC address of a virtual interface (such as
domiftune) accept the output displayed by this command.
Example 20.30. How to display the virtual interfaces associated with a guest virtual machine
virsh domiflist rhel7Interface Type Source Model MAC ------------------------------------------------------- vnet0 network default virtio 52:54:00:01:1d:d0 #
virsh domifstat rhel7 vnet0vnet0 rx_bytes 55308 vnet0 rx_packets 969 vnet0 rx_errs 0 vnet0 rx_drop 0 vnet0 tx_bytes 14341 vnet0 tx_packets 148 vnet0 tx_errs 0 vnet0 tx_drop 0