快速回忆
grubby --update-kernel=$(grubby --default-kernel) --args="intel_iommu=on iommu=pt pci=realloc"
reboot #修改后需要重启
echo 1 > /sys/class/net/enp6s0f0/device/sriov_numvfs
echo 0 > /sys/class/net/enp6s0f0/device/sriov_numvfs
echo 4 > /sys/class/net/enp6s0f0/device/sriov_numvfs
背景
本文记录的是Mellanox网卡打开SRIOV过程中遇到not enough MMIO resources 问题。
问题
执行:echo 1 > /sys/class/net/enp6s0f0/device/sriov_numvfs 会报错
[日 6月 15 11:13:15 2025] mlx5_core 0000:06:00.0: not enough MMIO resources for SR-IOV
[日 6月 15 11:13:15 2025] mlx5_core 0000:06:00.0: mlx5_pci_enable_sriov:166:(pid 13490): pci_enable_sriov failed : -12
[日 6月 15 11:13:15 2025] mlx5_core 0000:06:00.0: mlx5_sriov_enable:190:(pid 13490): mlx5_pci_enable_sriov failed : -12
解决办法
打开VF需要开启cpu的iommu,以及涉及到动态添加节点,需要开启pci支持realloc功能,才能d重新分配资源。
grubby --update-kernel=$(grubby --default-kernel) --args="intel_iommu=on iommu=pt pci=realloc"
reboot #修改后需要重启
参数说明:
intel_iommu=on 开启iommu(Intel 处理器的 IOMMU(又称 VT-d,Virtualization Technology for Directed I/O))
iommu=pt 开启iommu直通(Pass-Through),以支持虚拟机可直接与指定物理硬件通信(部分旧内核使用 iommu.passthrough=1 替代 iommu=pt)
pci=realloc。解决 PCI 设备在初始化时固定分配内存地址的问题
重启后
实操后效果:
not enough MMIO resources for SR-IOV已解决。
lspci也能看到设备:
继续实验,尝试修改为4个,也能正确看到,需要注意的是需要先将已经虚拟化的清空为0。
ip link查看生效情况: