KVM virtual machines generally provide better network performance, but every administrator knows that this is not enough to solve all problems. You can optimize the network performance in two ways: VirtIO drive or PCI pass-through disk. The method selection depends on the network performance you need and the RedHatEnterpriseLinux version used.
Use VirtIO driver to optimize network performance
Network performance begins with a virtual Nic, but VirtIO drives have a huge impact on network performance. VirtIO drives provide semi-virtualization at different layers, including the network layer. If you have installed a Linux virtual machine, the VirtIO drive is used by default. If the virtual machine uses another operating system, you need to manually install the VirtIO drive.
To verify whether the virtual machine is using the VirtIO drive, you can run the lspci-v command in the virtual machine. Then, find the Ethernet controller in the output result. The results should be shown in List 1, showing the virtio-pci kernel module in use and the kernel driver.
List 1:
GoodKVMnetworkperformancestartsbyusingtheVirtIOdriver
00:03. 0
Ethernetcontroller: RedHat, IncVirtIOnetworkdevice
Subsystem: RedHat, IncDevice0001
PhysicalSlot: 3
Flags: fastdevsel, IRQ10
I/Oportsatc040 [size = 32]
Memoryatf2020000 (32-bit, non-prefetchable) [size = 4 K]
ExpansionROMatf2030000 [disabled] [size = 64 K]
Capabilities: [40] MSI-X: Enable + Count = 3Masked-
Kerneldriverinuse: virtio-pci
Kernelmodules: virtio_pci
In versions earlier than KVM, even if VirtIO drives are used, network traffic is also handled by QEMU, which is located at the simulation layer between the host and the virtual machine. The latest KVM version replaces QEMU with vhost-net. The RedHat function is provided from Version 6.1 to ensure that the Network Package uses the Linux kernel instead of QEMU for routing between the client and the host. This feature is automatically enabled in RHEL6.1 and later versions. If you are using an older host platform, you must upgrade the software package or the network performance will be affected.
Use a dedicated Nic
If you have already used a VirtIO network drive but still encountered performance problems, you can consider using PCI passthrough. PCI pass-through assigns dedicated physical NICs to virtual machines. Only the virtual machine can directly access this physical Nic.
To configure PCI pass-through, you must first disconnect the network device of the host. Find the ID of the network device, and then use lspci-nn to find the NIC definition:
. 0 Networkcontroller [0280]: IntelCorporationCentrinoAdvanced-N6205 [8086: 0082] (rev34)
Now you need to disable the client operating system and edit the XML definition of the client. You can use virsh to edit it. In the <device> section, the client XML code is displayed to ensure that the PCI device is defined. The example in List 2 shows related definitions. The most important line is the definition of the domain, bus, slot and function used to match the PCIID as seen by the lspci-vv command:
List 2:
AddingaPCIpass-throughdevicetoaKVMvirtualmachine
<Devices>
...
<Hostdevmode = 'subsystem' type = 'pci 'managed = 'yes'>
<Source>
<Addressdomain = '0x000000' bus = '0x02' slot = '0x00' function = '0x0'/>
</Source>
</Hostdev>
</Devices>
You can restart the VM and verify the support of the PCI pass-through device.
Never think that you need to handle poor KVM network performance. VirtIO drive and PCI pass-through disk are two ways to achieve better performance. (Text/Internet)
This article from the "Lu xiaok Network Studio" blog, please be sure to keep this source http://luxiaok.blog.51cto.com/2177896/1300155