我正在尝试在 RHEL9 下运行 KVM/QEMU VM,该 VM 通过 SR-IOV 从 VF 池中使用虚拟化 Infiniband 卡 (VF)。我可以使用 hostdev 指定某个 VF 的 PCI 设备,并且运行正常,但是这需要将 PCI 总线/插槽/等硬编码到 VM XML 表中。将 VM 迁移到另一台服务器时,这会成为一个问题。因此,我宁愿定义一个 VF 网络池,如本 RH 文档中所述,它会自动将空闲的 VF 分配给新启动的 VM。
我按照文档中描述的一切进行操作,并且来自单个 IB 卡的 8 个 VF 的网络池正常运行:
# virsh net-dumpxml IB-passthrough
<network>
<name>IB-passthrough</name>
<uuid>8dce28fa-97ea-43d4-a82b-5923fa1a2a4f</uuid>
<forward mode='hostdev' managed='yes'>
<address type='pci' domain='0x0000' bus='0xc1' slot='0x00' function='0x1'/>
<address type='pci' domain='0x0000' bus='0xc1' slot='0x00' function='0x2'/>
<address type='pci' domain='0x0000' bus='0xc1' slot='0x00' function='0x3'/>
<address type='pci' domain='0x0000' bus='0xc1' slot='0x00' function='0x4'/>
<address type='pci' domain='0x0000' bus='0xc1' slot='0x00' function='0x5'/>
<address type='pci' domain='0x0000' bus='0xc1' slot='0x00' function='0x6'/>
<address type='pci' domain='0x0000' bus='0xc1' slot='0x00' function='0x7'/>
<address type='pci' domain='0x0000' bus='0xc1' slot='0x01' function='0x0'/>
</forward>
</network>
我将以下条目写入虚拟机的 XML:
<interface type='network'>
<source network='IB-passthrough'/>
</interface>
但关闭 XML 编辑器后,条目会自动扩展mac
并address
显示以下条目:
<interface type='network'>
<mac address='52:54:00:44:db:0d'/>
<source network='IB-passthrough'/>
<address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
</interface>
然后由于无法设置 MAC 地址,虚拟机无法启动:
# virsh start rhel9.2-testvm
error: Failed to start domain 'rhel9.2-testvm'
error: Cannot set interface MAC to 52:54:00:05:72:5c for ifname ibp193s0 vf 0: Operation not supported
有没有办法省略自动 MAC?或者接口 MAC 更改?或者还有其他我遗漏的问题?
我在运行cmd时遇到了同样的错误:
virsh 附加接口 vm1 hostdev 0000:81:00.2 --managed --persistent
错误:无法连接接口错误:无法将 ifname ibp129s0f0 vf 1 的接口 MAC 设置为 52:54:00:6f:a1:89:不支持操作
此接口网络池似乎不适用于 IB(InfiniBand)卡,它仅适用于以太网卡,因为将 MAC 设置为 IB 卡会失败。仅无法设置节点、策略和端口。
$ ls /sys/class/net/ibp129s0f0/device/sriov/0/节点策略端口
最后,我设法通过 cmd 添加了 VF 设备:
virt-xml vm1 --添加设备 --update --hostdev 0000:81:00.2
您需要将 IB(InfiniBand)卡视为普通 PCI 设备,而不是以太网接口。
参考:https: //docs.nvidia.com/networking/display/mlnxofedv24101140lts/single+root+io+virtualization+(sr-iov) https://enterprise-support.nvidia.com/s/article/HowTo-Configure-SR-IOV-for-ConnectX-4-ConnectX-5-ConnectX-6-with-KVM-Ethernet https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/configuring_and_managing_virtualization/managing-virtual-devices_configuring-and-managing-virtualization#assembly_managing-virtual-devices-using-the-cli_managing-virtual-devices https://manpages.ubuntu.com/manpages/xenial/man1/virt-xml.1.html