最近蛮多类似询问,虚拟机里面执行ethtool为何不显示速率,但是windows却能显示速率为10Gbps。上图上图:
与物理主机不同,在kvm虚拟化环境中,ethtool仅返回了网口状态。来看看红帽的说明:
Issue
- How do I check the network speed of a
virtio-netnetwork interface? - When a VM use virtio NICs,
ethtoolis not working - Why virtio network nic speed is 1G in subnetwork tab in RHEV Manager web interface ?
Resolution
- This is expected, there is no set speed that a
virtio-netinterface can operate at. - The 1Gbps is just a placeholder because the driver has to report something.
Root Cause
There's no "set speed" that a
virtio-netinterface obtains. It's a software implementation of a network interface,it obtains the fastest possible speed it can, and that speed will vary depending on the network/CPU/memory load on the virtualization host at the time, as well the traffic.Consider that the emulated
e1000network interfaces will report their speed as 1Gbps because they are a software emulation of a 1GbE interface. However, if you do traffic between two VMs on the same host using the emulatede1000interfaces, you will likely find you can exceed 1Gbps without a problem.If you emulate thise1000interface on a physical host with a 100Mbps network connection, then your guest will still say it has a 1-gigabit interface, but the maximum throughput attainable is 10% of that or less.Through all this,ethtoolwill still report the interface is operating at 1Gbps.The behavior of the
virtio-netinterfaces is the same, except the performance will be better because it's para-virtualized instead of emulated, and it won't report speed inethtool.There is no way the
ethtoolprocess within a guest can possibly know the maximum speed that a givenvirtio-netinterface can obtain at any given time, so there is nothing forvirtio-netto report toethtool.
总结下,在kvm环境,如果使用virtio_net驱动,linux下不会显示速率,会尽可能使用物理网络性能;如果配置的是e1000网卡,则会输出速率为1Gbps,但这个显示不代表实际能达到的速率,比如物理网络是100M,在e1000场景,也还是会显示1G。类似的,在windows下。默认不支持virtio驱动,需要安装驱动后才能支持,其速率也是驱动层面设置,而非实际的物理网络速率。