SR-IOV配置

 1:bios开启vt-d

2:内核CMDLINE开启iommu  && 设置pf开启vf的个数

       crashkernel=auto rd.lvm.lv=cl00/rootrd.lvm.lv=cl00/swap rhgb quiet LANG=en_US.UTF-8     isolcpus=12,13,14,15,16,17,18,19,20 intel_iommu=on ixgbe.max_vfs=4

3:重启host

4:host起来后, lspci | grep Eth查看是否生成vf

[root@localhost ~]# lspci | grep Eth
07:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
07:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
82:00.0 Ethernet controller: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)
82:00.1 Ethernet controller: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)
82:10.0 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01)
82:10.1 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01)
82:10.2 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01)
82:10.3 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01)
82:10.4 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01)
82:10.5 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01)
82:10.6 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01)
82:10.7 Ethernet controller: Intel Corporation 82599 Ethernet Controller Virtual Function (rev 01)

5:ip linkshow可以发现vf的mac地址为空,通过 iplink set ens787f0 vf 0 mac aa:bb:cc:dd:ee:ff 设置vf的mac

	[root@localhost ~]# ip link show
	1: lo:  mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT qlen 1
	    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
	2: enp130s0f0:  mtu 1500 qdisc mq master br0 state UP mode DEFAULT qlen 1000
	    link/ether 00:1b:21:ba:99:a4 brd ff:ff:ff:ff:ff:ff
	    vf 0 MAC 00:00:00:00:00:00, spoof checking on, link-state auto, trust off
	    vf 1 MAC 00:00:00:00:00:00, spoof checking on, link-state auto, trust off
	    vf 2 MAC 00:00:00:00:00:00, spoof checking on, link-state auto, trust off
	    vf 3 MAC 00:00:00:00:00:00, spoof checking on, link-state auto, trust off
	3: enp7s0f0:  mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
	    link/ether 6c:92:bf:05:bf:ad brd ff:ff:ff:ff:ff:ff
	4: enp7s0f1:  mtu 1500 qdisc mq state DOWN mode DEFAULT qlen 1000
	    link/ether 6c:92:bf:05:bf:ac brd ff:ff:ff:ff:ff:ff
	5: enp130s0f1:  mtu 1500 qdisc mq state DOWN mode DEFAULT qlen 1000
	    link/ether 00:1b:21:ba:99:a6 brd ff:ff:ff:ff:ff:ff
	    vf 0 MAC 00:00:00:00:00:00, spoof checking on, link-state auto, trust off
	    vf 1 MAC 00:00:00:00:00:00, spoof checking on, link-state auto, trust off
	    vf 2 MAC 00:00:00:00:00:00, spoof checking on, link-state auto, trust off
	    vf 3 MAC 00:00:00:00:00:00, spoof checking on, link-state auto, trust off
	6: br0:  mtu 1500 qdisc noqueue state UP mode DEFAULT qlen 1000
	    link/ether 00:1b:21:ba:99:a4 brd ff:ff:ff:ff:ff:ff
	7: virbr0:  mtu 1500 qdisc noqueue state DOWN mode DEFAULT qlen 1000
	    link/ether 52:54:00:c4:f2:ec brd ff:ff:ff:ff:ff:ff
	8: virbr0-nic:  mtu 1500 qdisc pfifo_fast master virbr0 state DOWN mode DEFAULT qlen 1000
	    link/ether 52:54:00:c4:f2:ec brd ff:ff:ff:ff:ff:ff
6:virshnodedev-list | grep 0000_82查看vf的pci设备号

	[root@localhost ~]# virsh nodedev-list | grep 0000_82
	pci_0000_82_00_0
	pci_0000_82_00_1
	pci_0000_82_10_0
	pci_0000_82_10_1
	pci_0000_82_10_2
	pci_0000_82_10_3
	pci_0000_82_10_4
	pci_0000_82_10_5
	pci_0000_82_10_6
	pci_0000_82_10_7

7:virsh nodedev-dumpxml pci_0000_04_10_0 可以看具体信息

8:创建/tmp/vf-interface.xml文件,文件内容如下

	[root@localhost ~]# vi vf-interface.xml
	
	 
	  

9:将vf从host上deattach     

 virsh nodedev-detach pci_0000_82_10_0

10:将vf添加到vm

  virsh attach-device client1./vf-interface.xml --persistent

11:virsh start client1 启动虚拟机


你可能感兴趣的:(虚拟化)