Xen PCI 直通

来自 Alpine Linux

本指南旨在展示如何在 Alpine 上配置 PCI 直通。

首先,使用 lspci 查找您要直通的设备的 PCI 地址

node03:~# lspci
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 Processor Family DRAM Controller (rev 09)
00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit Network Connection (rev 05)
00:1a.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2 (rev 05)
00:1c.0 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 1 (rev b5)
00:1c.4 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 5 (rev b5)
00:1d.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #1 (rev 05)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev a5)
00:1f.0 ISA bridge: Intel Corporation C204 Chipset Family LPC Controller (rev 05)
00:1f.2 SATA controller: Intel Corporation 6 Series/C200 Series Chipset Family SATA AHCI Controller (rev 05)
00:1f.3 SMBus: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller (rev 05)
01:00.0 Serial Attached SCSI controller: LSI Logic / Symbios Logic SAS2008 PCI-Express Fusion-MPT SAS-2 [Falcon] (rev 03)
02:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
03:03.0 VGA compatible controller: Matrox Electronics Systems Ltd. MGA G200eW WPCM450 (rev 0a)

在本示例中,我想直通 SAS 控制器。因此地址是 01:00.0。目前 Alpine 中存在一个 #3609 的 bug,它阻止使用默认内核参数。

编辑 /etc/modules 并重启服务器

node03:~# grep pciback /etc/modules 
xen_pciback hide=(01:00.0)

重启后,您应该能够验证 pci 设备正在使用 pciback 内核模块,并且它可以通过 xl 直通可见

node03:~# lspci -k | grep -A2 '01:00.0'
01:00.0 Serial Attached SCSI controller: LSI Logic / Symbios Logic SAS2008 PCI-Express Fusion-MPT SAS-2 [Falcon] (rev 03)
        Subsystem: LSI Logic / Symbios Logic Device 3020
        Kernel driver in use: pciback
node03:~# xl pci-assignable-list
0000:01:00.0

将以下行添加到您的 DomU 配置

pci = [ '01:00.0' ]

LSI 控制器的已知问题

由于 LSI 控制器的内核模块已构建到 Alpine Initramfs 中,因此在可以分配 pciback 模块之前,会加载真正的模块。
您需要在 /etc/modprobe.d/blacklist.conf 中将 mpt2sas 模块列入黑名单,并重建您的 initramfs。

node03:~# grep sas /etc/modprobe.d/blacklist.conf 
blacklist mpt2sas
node03:~# mkinitfs 
==> initramfs: creating /boot/initramfs-grsec
11538 blocks
33641 blocks