20.12. Retrieving Information about Your Virtual Machine
20.12.1. Displaying Device Block Statistics
virsh domblkstat command displays the block statistics for the first block device defined for the domain. To view statistics of other block devices, use the virsh domblklist domain command 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 domblklist command 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 --human argument.
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-device command displays the network interface statistics for the specified device running on a given guest virtual machine.
virsh domiflist command 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.3. Modifying the Link State of a Guest Virtual Machine's Virtual Interface
virsh domif-setlink domain interface-device state command configures the status of the specified interface device link state as either up or down. To determine which interface devices are defined for the domain, use the virsh domiflist command and use either the Interface or MAC column as the interface device option. By default, virsh domif-setlink changes the link state for the running domain. To modify the domain's persistent configuration use the --config argument.
Example 20.23. How to enable a guest virtual machine interface
# virsh domiflist rhel7Interface Type Source Model MAC ------------------------------------------------------- vnet0 network default virtio 52:54:00:01:1d:d0 #virsh domif-setlink rhel7 vnet0 downDevice updated successfully #virsh domif-setlink rhel7 52:54:00:01:1d:d0 upDevice updated successfully
20.12.4. Listing the Link State of a Guest Virtual Machine's Virtual Interface
virsh domif-getlink domain interface-device command retrieves the specified interface device link state. To determine which interface devices are defined for the domain, use the virsh domiflist command and use either the Interface or MAC column as the interface device option. By default, virsh domif-getlink retrieves the link state for the running domain. To retrieve the domain's persistent configuration use the --config option.
Example 20.24. How to display the link state of a guest virtual machine's interface
#virsh domiflist rhel7Interface Type Source Model MAC ------------------------------------------------------- vnet0 network default virtio 52:54:00:01:1d:d0 #virsh domif-getlink rhel7 52:54:00:01:1d:d052:54:00:01:1d:d0 up #virsh domif-setlink rhel7 vnet0 downDevice updated successfully #virsh domif-getlink rhel7 vnet0vnet0 down
20.12.5. Setting Network Interface Bandwidth Parameters
virsh domiftune domain interface-device command either retrieves or sets the specified domain's interface bandwidth parameters. To determine which interface devices are defined for the domain, use the virsh domiflist command and use either the Interface or MAC column as the interface device option. The following format should be used:
# virsh domiftune domain interface [--inbound] [--outbound] [--config] [--live] [--current]--config, --live, and --current options are described in Section 20.43, “Setting Schedule Parameters”. If the --inbound or the --outbound option is not specified, virsh domiftune queries the specified network interface and displays the bandwidth settings. By specifying --inbound or --outbound, or both, and the average, peak, and burst values, virsh domiftune sets 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 20.27.6.2, “Attaching interface devices”.
Example 20.25. How to set the guest virtual machine network interface parameters
# virsh domiftune guest1 eth0 outbound --live20.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 period switch 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 dommemstat commands. Setting the period option to 0, stops the balloon driver collection but does not clear the statistics already in the balloon driver. You cannot use the --live, --config, or --current options without also setting the period option. If the --live option is specified, only the guest's running statistics will be collected. If the --config option is used, it will collect the statistics for a persistent guest, but only after the next boot. If the --current option is used, it will collect the current statistics.
--live and --config options may be used but --current is 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 rhel7
actual 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 domain command 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 domstate command 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 guest120.12.8. Displaying the Block Device Size
virsh domblkinfo domain command 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 domblklist output 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 domain [--inactive] [--details] command displays a table of all block devices that are associated with the specified guest virtual machine.
--inactive is 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 --details is 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 domblkinfo and virsh snapshot-create. The disk Target or Source contexts can also be used when generating the xmlfile context information for the virsh snapshot-create command.
Example 20.29. How to display the block devices that are associated with a virtual machine
# virsh domblklist rhel7 --details
Type 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 domain command displays a table of all the virtual interfaces that are associated with the specified domain. The virsh domiflist command requires the name of the virtual machine (or domain), and optionally can take the --inactive argument. The latter retrieves the inactive rather than the running configuration, which is retrieved with the default setting. If --inactive is 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 detach-interface, domif-setlink, domif-getlink, domifstat, and 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

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.