先BIOS设置VT- D
查询网卡信息
lspci | grep -i ethernet
显示
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root@pve:~# lspci | grep -i ethernet
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (2) I219-LM
01:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
01:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
01:00.2 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
01:00.3 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 16)
root@pve:~#
Intel CPU
修改grub
编辑文件/etc/default/grub
修改行“GRUB_CMDLINE_LINUX_DEFAULT=“quiet”
使其为“GRUB_CMDLINE_LINUX_DEFAULT=“quiet intel_iommu=on”
使用update-grub更新
验证其有效性,从命令行运行“dmesg | grep -e DMAR -e IOMMU”。如果没有输出,则出现问题。极有可能是bios设置的问题,需要启动cpu的vt-x支持。
vi /etc/default/grub
找到 GRUB_CMDLINE_LINUX_DEFAULT="quiet"
修改为 GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"
update-grub
dmesg | grep -e DMAR -e IOMMU
新增所需模块
修改文件/etc/modules,加入如下的行
nano /etc/modules
写入
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
执行命令来更新initramfs
update-initramfs -u -k all.
添加PCI设备
命令模式添加
使用命令找到网卡PCI的地址,地址应采用以下形式:01:00.0
打开文件进行手工添加
集群:/etc/pve/nodes/你的集群名称/qemu-server/虚拟机id.conf
PCI:/etc/pve/qemu-server/vmid.conf
PCIE: /etc/pve/qemu-server/.conf
查找网卡ID
lspci | grep net
或者
lspci
添加PCI
vi /etc/pve/qemu-server/vmid.conf
添加一个pci地址:
hostpci0: 01:00.0
添加多个pci地址方式1:
hostpci0: 01:00.0;01:00.1
添加多个pci地址方式2:
hostpci0: 01:00.0
hostpci1: 01:00.1
添加统称所有pci地址,自动传递所有功能:
hostpci0: 01:00
添加PCIE
vi /etc/pve/qemu-server/111.conf
machine: q35
hostpci0: 01:00.0,pcie=1