此时,你可以看到PF上有4个VF:
PCI 编号 VF 编号0000:02:00.1 0
0000:02:00.2 1
0000:02:00.3 2
0000:02:00.4 3
在ip池查看VFS
ip link show......
4: ib0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 2044 qdisc mq state UP mode DEFAULT group default qlen 256
link/infiniband 20:00:0a:12:fe:80:00:00:00:00:00:00:ec:0d:9a:03:00:c0:41:d4 brd 00:ff:ff:ff:ff:12:40:1b:ff:ff:00:00:00:00:00:00:ff:ff:ff:ff
vf 0 MAC 00:00:00:00:00:00, spoof checking off, link-state disable, trust off, query_rss off
vf 1 MAC 00:00:00:00:00:00, spoof checking off, link-state disable, trust off, query_rss off
vf 2 MAC 00:00:00:00:00:00, spoof checking off, link-state disable, trust off, query_rss off
vf 3 MAC 00:00:00:00:00:00, spoof checking off, link-state disable, trust off, query_rss off
......
4.3 为qemu添加SR-IOV虚拟化的网卡
查看PCI设备信息
lshw -c network -businfoBus info Device Class Description
========================================================
......
pci@0000:02:00.1 ib2 network MT27800 Family [ConnectX-5 Virtual Function]
pci@0000:02:00.2 ib3 network MT27800 Family [ConnectX-5 Virtual Function]
pci@0000:02:00.3 ib4 network MT27800 Family [ConnectX-5 Virtual Function]
pci@0000:02:00.4 ib5 network MT27800 Family [ConnectX-5 Virtual Function]
......
这一步看到的信息,其实在刚才通过 "ibdev2netdev -v" 命令已经得到了。
将设备从宿主机deattach
virsh nodedev-detach pci_0000_02_00_1命令中,pci_0000_02_00_1 是根据上面由SR-IOV虚拟化出来的PCI设备编号拼接起来的:
0000:02:00.1 --> pci_0000_02_00_1
也可以直接通过如下命令查看:
virsh nodedev-list --tree | grep pci......
| +- pci_0000_02_00_1
| +- pci_0000_02_00_2
......
如果该虚拟设备不再被使用,需要在 virt-manager 中首先将该设备移除,然后在主机上重新挂载该设备:
virsh nodedev-reattach pci_0000_02_00_1
配置VF直通
方法1(interface):在devices段落里加入(该方法未成功)
virsh edit ubuntu14_04内容如下:
<interface type='hostdev' managed='yes'> <mac address='52:54:00:ad:ef:8d'/> <source> <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x1'/> </source> <vlan> <tag/> </vlan> </interface>如不需要设置mac和vlan,可以去掉相应标签。
其中,address中的参数是根据 "lshw -c network -businfo" 获得的信息配置的,例如,我要配置的PCI设备编号是:
pci@0000:02:00.1 ib2
注意对应关系,domain: 0x0000, bus: 0x02, slot: 0x00, function: 0x1.