HOO八卦
妖魔鬼怪快离开

proxmox虚拟化显卡透传

由于gpu虚拟化还未能在proxmox的web管理界面提供支持,因此,要启用这个功能,得登录proxmox所在宿主机的系统debian,进行如下操作: 修改grub(与centos稍有差异)。编辑文件/etc/default/grub,修改行“GRUB_CMDLINE_LINUX_DEFAULT=”quiet”,使其为“GRUB_CMDLINE_LINUX_DEFAULT=”quiet intel_iommu=on” 。执行指令“update-grub” 使修改生效。

update-grub
检查是否生效
dmesg   | grep -e DMAR -e IOMMU
[    0.000000] ACPI: DMAR 0x0000000034960658 000070 (v01 ALASKA A M I    00000001 INTL 00000001)
[    0.000000] DMAR: IOMMU enabled
[    0.004000] DMAR: Host address width 39
[    0.004000] DMAR: DRHD base: 0x000000fed90000 flags: 0x1
[    0.004000] DMAR: dmar0: reg_base_addr fed90000 ver 1:0 cap d2008c40660462 ecap f050da
[    0.004000] DMAR: RMRR base: 0x00000034ea7000 end: 0x00000034ec6fff
[    0.004000] DMAR-IR: IOAPIC id 2 under DRHD base  0xfed90000 IOMMU 0
[    0.004000] DMAR-IR: HPET id 0 under DRHD base 0xfed90000
[    0.004000] DMAR-IR: x2apic is disabled because BIOS sets x2apic opt out bit.
[    0.004000] DMAR-IR: Use 'intremap=no_x2apic_optout' to override the BIOS setting.
[    0.004000] DMAR-IR: Enabled IRQ remapping in xapic mode
[    0.485644] DMAR: No ATSR found
[    0.485703] DMAR: dmar0: Using Queued invalidation
[    0.485707] DMAR: Setting RMRR:
[    0.485740] DMAR: Setting identity map for device 0000:00:14.0 [0x34ea7000 - 0x34ec6fff]
[    0.485745] DMAR: Prepare 0-16MiB unity mapping for LPC
[    0.485776] DMAR: Setting identity map for device 0000:00:1f.0 [0x0 - 0xffffff]
[    0.485780] DMAR: Intel(R) Virtualization Technology for Directed I/O
[    6.009279] DMAR: DRHD: handling fault status reg 2
[    6.009299] DMAR: [DMA Write] Request device [3d:00.0] fault addr 0 [fault reason 05] PTE Write access is not set

如果执行“dmesg | grep -e DMAR -e IOMMU”没有输出,则表明存在问题。极有可能是bios设置的问题,需要启动cpu的vt-x支持。对于amd类型的cpu,/etc/default/grub文件对于修改为“GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on”。该项目还支持几个值,可根据情况增加。

IOMMU隔离校验。执行指令 “find /sys/kernel/iommu_groups/ -type l”,有输出则表示正常。

root@chaiio:~# find   /sys/kernel/iommu_groups/ -type l
/sys/kernel/iommu_groups/7/devices/0000:00:1c.7
/sys/kernel/iommu_groups/5/devices/0000:00:1c.0
/sys/kernel/iommu_groups/3/devices/0000:00:16.0
/sys/kernel/iommu_groups/11/devices/0000:3c:00.0
/sys/kernel/iommu_groups/1/devices/0000:00:01.0
/sys/kernel/iommu_groups/1/devices/0000:01:00.0
/sys/kernel/iommu_groups/1/devices/0000:01:00.1
/sys/kernel/iommu_groups/8/devices/0000:00:1d.0
/sys/kernel/iommu_groups/6/devices/0000:00:1c.6
/sys/kernel/iommu_groups/4/devices/0000:00:17.0
/sys/kernel/iommu_groups/12/devices/0000:3d:00.0
/sys/kernel/iommu_groups/2/devices/0000:00:14.2
/sys/kernel/iommu_groups/2/devices/0000:00:14.0
/sys/kernel/iommu_groups/10/devices/0000:3b:00.0
/sys/kernel/iommu_groups/0/devices/0000:00:00.0
/sys/kernel/iommu_groups/9/devices/0000:00:1f.2
/sys/kernel/iommu_groups/9/devices/0000:00:1f.0
/sys/kernel/iommu_groups/9/devices/0000:00:1f.3

/sys/kernel/iommu_groups/9/devices/0000:00:1f.4 查看gpu显卡的地址,用于后边对虚拟机进行配置。查看硬件信息的指令为“lspci -i”,执行后,会有大量的信息输出,我们只需关心gpu显卡。
gpu直通
l  用刚刚得到的数值做参数,执行 lspci -n -s 01:00 ,得到两行输出,将该输出重定向到文件/etc/modprobe.d/vfio.conf.

root@chaiio:~# lspci   -n -s 01:00
01:00.0 0300: 10de:13d8 (rev a1)

01:00.1 0403: 10de:0fbb (rev a1) 驱动黑名单

echo "blacklist radeon" >> /etc/modprobe.d/blacklist.conf
echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf

echo “blacklist nvidia” >> /etc/modprobe.d/blacklist.conf 修改镜像源防止卡的不行

vi etc/apt/sources.list
deb http://mirrors.163.com/debian/ jessie main non-free contrib
deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib
deb http://mirrors.163.com/debian/ jessie-backports main non-free contrib
deb-src http://mirrors.163.com/debian/ jessie main non-free contrib
deb-src http://mirrors.163.com/debian/ jessie-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ jessie-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib

deb-src http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib 新增模块。修改文件/etc/modules,加入如下的行(默认为空):

vfio
vfio_iommu_type1
vfio_pci

vfio_virqfd 上传镜像目录

/var/lib/vz/template/iso

添加显卡

http://www.chaiio.com/index.php/2019/06/15/proxmox%E8%99%9A%E6%8B%9F%E5%8C%96%E6%98%BE%E5%8D%A1%E9%80%8F%E4%BC%A0/
赞(0)
未经允许不得转载:HOO八卦 » proxmox虚拟化显卡透传
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

Find More Interest

Contactsthrough