PCI pass though (Ethernet port)

1
ifconfig

58d2fbc072f3f7bf1ce2a499b5351171.png

1
2
3
4
5
6
7
8
9
10
11
[root@SMC-KVM ~]# ethtool -i eno2
driver: ixgbe
version: 4.18.0-305.10.2.el8_4.x86_64
firmware-version: 0x800007f6, 1.1747.0
expansion-rom-version:
bus-info: 0000:01:00.1
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: yes

3211af94caf301c7b3f8e2c6733a0a41.png

1
2
3
4
# vim /etc/grub2-efi.cfg
# vim /etc/grub2.cfg
set kernelopts="...iommu.passthrough=1"

9ab23b9c1a1cf4a1a7c3112cf9b149c7.png

Enable intel iommu:

1
2
3
4
vim /etc/default/grub

GRUB_CMDLINE_LINUX="... intel_iommu=on iommu=pt
#GRUB_CMDLINE_LINUX=" ... amd_iommu=on

If intel_iommu=on or amd_iommu=on works, you can try replacing them with iommu=pt or amd_iommu=pt.

1
2
3
grub2-mkconfig -o /boot/grub2/grub.cfg
cat /etc/grub2.cfg | grep 'set kernelopt' # 这时候上面的设置已经被映射过来了
reboot
1
dmesg | grep IOMMU

c7a7c4f84766890e7a208a172e89536f.png

Modify VM’s specification:

1
2
cp /etc/libvirt/qemu/cjl-test.xml /etc/libvirt/qemu/cjl-test.xml.bak
vim /etc/libvirt/qemu/cjl-test.xml
1
2
3
4
5
6
7
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
</source>
##<address type='pci' domain='0x0000' bus='0x01' slot='0x02' function='0x0'/>
</hostdev>

b78244be8645b79ac8943a0048b30856.png

1
virsh define &VMname
1
2
ethtool -i eno2
ethtool -i eno1

Guest (VM)

287e347b89b51b80dd46d4a9d1e9651c.png

1
2
[root@localhost ~]# lspci | grep Ethernet
00:02.0 Ethernet controller: Intel Corporation Ethernet Controller 10G X550T (rev 01)
1
2
3
4
5
6
7
8
9
10
11
[root@localhost ~]# ethtool -i ens2
driver: ixgbe
version: 4.18.0-305.10.2.el8_4.x86_64
firmware-version: 0x800007f6, 1.1747.0
expansion-rom-version:
bus-info: 0000:00:02.0
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: yes