PCIE 랜카드를 가상머신에 패스스루로 할당하고자 설정을 시도함

본 사항은 랜카드 외 비디오 카드, nvme ssd의  pcie 디바이스에도 적용 가능하다. 

Ubuntu 18.04 + Intel J4105 에서 성공적으로 적용완료




1. 바이오스에서 VT-d 활성화


2. /etc/default/grub 에서 GRUB_CMDLINE_LINUX_DEFAULT 명령 줄 수정

  GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

  ==> GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_iommu=on intel_iommu=igfx_off"

   *intel_iommu=igfx_off 를 넣지 않을 경우 정상 부팅을 실패하여 고생함


3. update-grub 실행


4. lspci -nn 명령으로 pcie 디바이스 확인

 내 경우는 다음과 같음

root@04Ubuntu:/etc/init.d# lspci -nn

00:00.0 Host bridge [0600]: Intel Corporation Device [8086:31f0] (rev 03)

00:00.1 Signal processing controller [1180]: Intel Corporation Celeron/Pentium Silver Processor Dynamic Platform and Therm                       al Framework Processor Participant [8086:318c] (rev 03)

00:02.0 VGA compatible controller [0300]: Intel Corporation Device [8086:3185] (rev 03)

00:0e.0 Audio device [0403]: Intel Corporation Device [8086:3198] (rev 03)

00:0f.0 Communication controller [0780]: Intel Corporation Celeron/Pentium Silver Processor Trusted Execution Engine Inter                       face [8086:319a] (rev 03)

00:12.0 SATA controller [0106]: Intel Corporation Device [8086:31e3] (rev 03)

00:13.0 PCI bridge [0604]: Intel Corporation Device [8086:31d8] (rev f3)

00:13.1 PCI bridge [0604]: Intel Corporation Device [8086:31d9] (rev f3)

00:13.2 PCI bridge [0604]: Intel Corporation Device [8086:31da] (rev f3)

00:13.3 PCI bridge [0604]: Intel Corporation Device [8086:31db] (rev f3)

00:15.0 USB controller [0c03]: Intel Corporation Device [8086:31a8] (rev 03)

00:1f.0 ISA bridge [0601]: Intel Corporation Device [8086:31e8] (rev 03)

00:1f.1 SMBus [0c05]: Intel Corporation Celeron/Pentium Silver Processor Gaussian Mixture Model [8086:31d4] (rev 03)

02:00.0 Ethernet controller [0200]: Intel Corporation I350 Gigabit Network Connection [8086:1521] (rev 01)

02:00.1 Ethernet controller [0200]: Intel Corporation I350 Gigabit Network Connection [8086:1521] (rev 01)

02:00.2 Ethernet controller [0200]: Intel Corporation I350 Gigabit Network Connection [8086:1521] (rev 01)

02:00.3 Ethernet controller [0200]: Intel Corporation I350 Gigabit Network Connection [8086:1521] (rev 01)

03:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Control                       ler [10ec:8168] (rev 0c) 


5. 위 정보를 기반으로 VFIO-PCI 커널 모듈 추가

sudo nano /etc/modprobe.d/vfio.conf

options vfio-pci ids=8086:1521


6. 자동 모듈 로드 엔트리 추가

sudo echo 'vfio-pci' > /etc/modules-load.d/vfio-pci.conf


7. 리부팅

8. 명령어로 패스스루를 위한 환경 점검

root@04Ubuntu:/etc/init.d# dmesg | grep -E "DMAR|IOMMU"

[    0.000000] ACPI: DMAR 0x000000006D68D0F0 0000A8 (v01 INTEL  GLK-SOC  00000003 BRXT 0100000D)

[    0.000000] DMAR: IOMMU enabled

[    0.000000] DMAR: Disable GFX device mapping

[    0.004000] DMAR: Host address width 39

[    0.004000] DMAR: DRHD base: 0x000000fed64000 flags: 0x0

[    0.004000] DMAR: dmar0: reg_base_addr fed64000 ver 1:0 cap 1c0000c40660462 ecap 9e2ff0505e

[    0.004000] DMAR: DRHD base: 0x000000fed65000 flags: 0x1

[    0.004000] DMAR: dmar1: reg_base_addr fed65000 ver 1:0 cap d2008c40660462 ecap f050da

[    0.004000] DMAR: RMRR base: 0x0000006d5f4000 end: 0x0000006d613fff

[    0.004000] DMAR: RMRR base: 0x0000006f800000 end: 0x0000007fffffff

[    0.004000] DMAR-IR: IOAPIC id 1 under DRHD base  0xfed65000 IOMMU 1

[    0.004000] DMAR-IR: HPET id 0 under DRHD base 0xfed65000

[    0.004000] DMAR-IR: Queued invalidation will be enabled to support x2apic and Intr-remapping.

[    0.004000] DMAR-IR: Enabled IRQ remapping in x2apic mode

[    1.697604] DMAR: No ATSR found

[    1.697671] DMAR: dmar1: Using Queued invalidation

[    1.697687] DMAR: Setting RMRR:

[    1.697811] DMAR: Setting identity map for device 0000:00:15.0 [0x6d5f4000 - 0x6d613fff]

[    1.697824] DMAR: Prepare 0-16MiB unity mapping for LPC

[    1.697890] DMAR: Setting identity map for device 0000:00:1f.0 [0x0 - 0xffffff]

[    1.697903] DMAR: Intel(R) Virtualization Technology for Directed I/O

root@04Ubuntu:/etc/init.d# dmesg | grep -i vfio

[    4.668229] VFIO - User Level meta-driver version: 0.3

[    4.684477] vfio_pci: add [8086:1521[ffff:ffff]] class 0x000000/00000000


9. 이제 해당 디바이스를 KVM에 머신 생성시 할당할 수 있다.