获取 virtio-net 网络适配器的链接速度

ddi*_*dio 4 linux linux-networking kvm-virtualization virtio

我有一个使用 virtio-net 在 kvm 上运行的 linux vm,我想检查链接速度。我怎样才能做到这一点?

到目前为止我尝试过的:

# ethtool eth0
Settings for eth0:
Link detected: yes
Run Code Online (Sandbox Code Playgroud)

似乎 ethtool 不支持 virtio-net(还没有?)我有来自 debian jessie 的 3.16-1 版本,ethtool 是否在较新版本中支持它?它接缝版本 6 是最新版本。

 # cat /sys/class/net/eth0/speed
cat: /sys/class/net/eth0/speed: Invalid argument


 # lspci | grep -iE --color 'network|ethernet'
00:12.0 Ethernet controller: Red Hat, Inc Virtio network device

  # lshw -class network
  *-network
       description: Ethernet interface
       product: Virtio network device
       vendor: Red Hat, Inc
       physical id: 12
       bus info: pci@0000:00:12.0
       logical name: eth0
       version: 00
       serial: 4e:ff:a8:bf:61:12
       width: 32 bits
       clock: 33MHz
       capabilities: msix bus_master cap_list rom ethernet physical
       configuration: broadcast=yes driver=virtio_net driverversion=1.0.0 ip=172.30.2.152 latency=0 link=yes multicast=yes
       resources: irq:10 ioport:c080(size=32) memory:febf2000-febf2fff memory:febe0000-febeffff
Run Code Online (Sandbox Code Playgroud)

我在redhat kb 中找到了一个描述问题的链接,但不幸的是我没有订阅阅读它。

Nat*_*ath 13

Virtio 是半虚拟化驱动程序,这意味着操作系统和驱动程序知道它不是物理设备。驱动程序实际上是来宾和管理程序之间的 API,因此它的速度与任何物理设备或以太网标准完全断开。

这是一件好事,因为这比假装是物理设备并应用任意“链接速度”概念的虚拟机管理程序更快。

VM 只是将帧转储到总线上,主机的工作是处理物理设备;VM 无需知道或关心主机物理设备的链接速度。

这样做的一个优点是,当数据包在同一主机上的 2 个 VM 之间移动时,它们发送数据包的速度与主机的 CPU 将它们从一组内存移动到另一组内存的速度一样快,在这里设置“链接速度”只是放入一个不必要的限速。

这还允许主机进行适配器组合并跨多个链接传播流量,而无需明确配置每个 VM 以获得设置的全部带宽。

如果您想知道实际将数据从 VM 传输到另一个位置的速度有多快,您需要使用诸如iperf.