我正在尝试通过我的集成英特尔 GPU 进行转码。
主持人
我在配备 Coffee Lake i7 处理器的 NUC 上运行,该处理器搭载 ubuntu 20.04 LTS Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
$ uname -a
Linux black-nuc 5.4.0-33-generic #37-Ubuntu SMP Thu May 21 12:53:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ virsh version
Compiled against library: libvirt 6.0.0
Using library: libvirt 6.0.0
Using API: QEMU 6.0.0
Running hypervisor: QEMU 4.2.0
我设置了 vfio 和 mdev 支持
$ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
vfio_mdev
kvmgt
intel_agp
i915
$ cat /etc/default/grup | grep DEFAULT
GRUB_CMDLINE_LINUX_DEFAULT="quiet i915.enable_gvt=1 i915.enable_guc=2 intel_iommu=on"
我认为在主机层面上这是可以的,尽管不太确定
$ dmesg | grep i915
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.4.0-33-generic root=UUID=a264d72d-88e2-4a8e-908e-13a93ffe8b3f ro quiet i915.enable_gvt=1 i915.enable_guc=2 intel_iommu=on
[ 0.103360] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.4.0-33-generic root=UUID=a264d72d-88e2-4a8e-908e-13a93ffe8b3f ro quiet i915.enable_gvt=1 i915.enable_guc=2 intel_iommu=on
[ 2.446932] i915 0000:00:02.0: Found 128MB of eDRAM
[ 2.446954] i915 0000:00:02.0: VT-d active for gfx access
[ 2.446956] i915 0000:00:02.0: vgaarb: deactivate vga console
[ 2.447316] i915 0000:00:02.0: Direct firmware load for i915/gvt/vid_0x8086_did_0x3ea5_rid_0x01.golden_hw_state failed with error -2
[ 2.492613] i915 0000:00:02.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=io+mem:owns=io+mem
[ 2.493395] [drm] Finished loading DMC firmware i915/kbl_dmc_ver1_04.bin (v1.4)
[ 2.563336] i915 0000:00:02.0: GuC firmware i915/kbl_guc_33.0.0.bin version 33.0 submission:disabled
[ 2.563337] i915 0000:00:02.0: HuC firmware i915/kbl_huc_ver02_00_1810.bin version 2.0 authenticated:yes
[ 2.565319] [drm] Initialized i915 1.6.0 20190822 for 0000:00:02.0 on minor 0
[ 4.766021] i915 0000:00:02.0: MDEV: Registered
[ 5.008090] snd_hda_intel 0000:00:1f.3: bound 0000:00:02.0 (ops i915_audio_component_bind_ops [i915])
$ lsmod | grep i915
i915 1986560 3 kvmgt
i2c_algo_bit 16384 1 i915
drm_kms_helper 184320 1 i915
drm 491520 4 drm_kms_helper,kvmgt,i915
video 49152 1 i915
$ ls /sys/class/drm/
card0 card0-DP-1 card0-DP-2 card0-HDMI-A-1 renderD128 version
我可以看到 MDEV 设备
$ ls /sys/bus/pci/devices/0000\:00\:02.0/mdev_supported_types/
i915-GVTg_V5_1
i915-GVTg_V5_2
i915-GVTg_V5_4
i915-GVTg_V5_8
我注册了一个带有 uuid 的 mdev,以便将其传递给虚拟机
$ echo "e08e572c-1b52-4f50-96e6-25f43d1f8d6e" > /sys/bus/pci/devices/0000\:00\:02.0/mdev_supported_types/i915-GVTg_V5_8/create
$ ls /sys/bus/mdev/devices/e08e572c-1b52-4f50-96e6-25f43d1f8d6e/
driver intel_vgpu iommu_group mdev_type power remove subsystem uevent
虚拟器
我将 mdev 设备添加到我的虚拟机
<hostdev mode="subsystem" type="mdev" managed="no" model="vfio-pci" display="off">
<source>
<address uuid="e08e572c-1b52-4f50-96e6-25f43d1f8d6e"/>
</source>
<address type="pci" domain="0x0000" bus="0x00" slot="0x09" function="0x0"/>
</hostdev>
客人
我不太清楚我需要为客人设置什么。
它运行的是 Ubuntu 20.04,镜像如下https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64.img
$ uname -a
Linux k3s-2 5.4.0-37-generic #41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
我可以看到设备,但驱动程序尚未初始化
$ lspci -s 00:09.0 -k
00:09.0 VGA compatible controller: Intel Corporation Iris Plus Graphics 655 (rev 01)
Subsystem: Intel Corporation Iris Plus Graphics 655
$ lsmod | grep i915
(empty)
$ modinfo i915
modinfo: ERROR: Module i915 not found
我希望看到一些文件,/sys/class/drm
就像我在主机中看到的一样,但我只看到版本文件
$ ls /sys/class/drm
version
我尝试了 clinfo 来查看是否检测到正确的设备
$ clinfo
Number of platforms 1
Platform Name Intel Gen OCL Driver
Platform Vendor Intel
Platform Version OpenCL 2.0 beignet 1.3
Platform Profile FULL_PROFILE
Platform Extensions cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_3d_image_writes cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_spir cl_khr_icd cl_intel_accelerator cl_intel_subgroups cl_intel_subgroups_short
Platform Extensions function suffix Intel
beignet-opencl-icd: no supported GPU found, this is probably the wrong opencl-icd package for this hardware
(If you have multiple ICDs installed and OpenCL works, you can ignore this message)
Platform Name Intel Gen OCL Driver
Number of devices 0
NULL platform behavior
clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...) Intel Gen OCL Driver
beignet-opencl-icd: no supported GPU found, this is probably the wrong opencl-icd package for this hardware
(If you have multiple ICDs installed and OpenCL works, you can ignore this message)
clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)
clCreateContext(NULL, ...) [default] No devices found in platform
beignet-opencl-icd: no supported GPU found, this is probably the wrong opencl-icd package for this hardware
(If you have multiple ICDs installed and OpenCL works, you can ignore this message)
clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT) No devices found in platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) No devices found in platform
beignet-opencl-icd: no supported GPU found, this is probably the wrong opencl-icd package for this hardware
(If you have multiple ICDs installed and OpenCL works, you can ignore this message)
clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) No devices found in platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No devices found in platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) No devices found in platform
beignet-opencl-icd: no supported GPU found, this is probably the wrong opencl-icd package for this hardware
(If you have multiple ICDs installed and OpenCL works, you can ignore this message)
clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) No devices found in platform
非常感谢您的帮助。我已经阅读了大量内容,并且理解了一半,所以也许我混淆了一些东西。
我也尝试过
- 将虚拟机中的 mdev pci 设备设置为 0x02
- 添加
vfio-pci.ids=8086:3ea5
到内核命令,但这会使我的 mdev 设备消失