User:Shunlir/Intel GVT-g
From Gentoo Wiki
Jump to:navigation
Jump to:search
Introduction
This guide describes the setup steps for Intel GVT-g vGPU in Windows 10 Guest.
QEMU/KVM + SPICE + virt-manager are covered since I'm using this combination.
Install Required Packages
- app-emulation/qemu version 4.2 (at least enable
spice
USE flag) - app-emulation/spice-protocol version 0.14+
- app-emulation/spice version 0.14+
- net-misc/spice-gtk version 0.37+
- app-emulation/virt-manager
Enable GVT-g on host
Recompile the kernel
- Install sys-kernel/gentoo-sources version 5.4+ (may need patch, see below)
- Enable
CONFIG_DRM_I915_GVT
,CONFIG_DRM_I915_GVT_KVMGT
which depends onCONFIG_VFIO_MDEV
andCONFIG_VFIO_MDEV_DEVICE
- If the GPU is SkyLake nor KabyLake, apply this patch to enable support for vfio edid.
- Compile the kernel:
root #
cd /usr/src/linux && make && make modules_install
Install the kernel
- Install kernel binaries:
root #
cd /usr/src/linux && make install
- Change /etc/default/grub with following contents:
GRUB_CMDLINE_LINUX_DEFAULT="i915.enable_gvt=1 kvm.ignore_msrs=1"
- Update grub config:
root #
grub-mkconfig -o /boot/grub/grub.cfg
Reboot and Verify
- Use
lspci -nn
to identify the<pci domain number>:<pci bus number>:<device number>.<function number>
of the Intel GPU, it's typically00:02.0
- Check the available vGPU profiles:
root #
ls /sys/bus/pci/devices/0000:00:02.0/mdev_supported_types
i915-GVTg_V5_4 i915-GVTg_V5_8
- Note
the description file under the profile folder gives more information such as max resolution, V5_4: 1920x1200, V5_8: 1024x768
- Use
uuidgen
command to generate a UUID, say,746afefa-89af-481d-ad4e-52e0d9f5f2e6
then create a vGPU instance with the following command:root #
echo 746afefa-89af-481d-ad4e-52e0d9f5f2e6 > /sys/bus/pci/devices/0000:00:02.0/mdev_supported_types/i915-GVTg_V5_4/create
- Note
The vGPU instance needs to be re-created after each host reboot
Install Intel driver in Guest
GVT-g vGPU doesn't support VGA mode in guest, in order to install Intel driver, there should be a GPU supporting VGA mode working as the primary GPU, for virt-manager, the default GPU is `qxl-vga`.
- Shutdown the VM
- Edit the definition file of the VM:
root #
virsh edit <vm-name>
- Then add a mdev device (aka the Intel vGPU) in the file:
<devices>
...
<hostdev mode='subsystem' type='mdev' managed='no' model='vfio-pci' display='off'>
<source>
<address uuid='746afefa-89af-481d-ad4e-52e0d9f5f2e6'/>
</source>
</hostdev>
...
</devices>
Activate Intel vGPU for Guest
- Do the following changes to enable the vGPU as primary device
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<devices>
...
<graphics type='spice'>
<listen type='none'/>
<gl enable='yes' rendernode='/dev/dri/by-path/pci-0000:00:02.0-render'/>
</graphics>
<video>
<model type='none'/>
</video>
<hostdev mode='subsystem' type='mdev' managed='no' model='vfio-pci' display='on'>
<source>
<address uuid='746afefa-89af-481d-ad4e-52e0d9f5f2e6'/>
</source>
</hostdev>
...
</devices>
<qemu:commandline>
<qemu:arg value='-set'/>
<qemu:arg value='device.hostdev0.ramfb=on'/>
<qemu:arg value='-set'/>
<qemu:arg value='device.hostdev0.driver=vfio-pci-nohotplug'/>
<qemu:arg value='-set'/>
<qemu:arg value='device.hostdev0.x-igd-opregion=on'/>
<qemu:arg value='-set'/>
<qemu:arg value='device.hostdev0.xres=1920'/>
<qemu:arg value='-set'/>
<qemu:arg value='device.hostdev0.yres=1080'/>
</qemu:commandline>
</domain>
- Reboot guest to take effect
Note
* the ramfb device, specified by ramfb and vfio-pci-nohotplug, is used as boot display, to show screen content during early boot phase, before Intel guest driver is initialized.
* the ramfb device, specified by ramfb and vfio-pci-nohotplug, is used as boot display, to show screen content during early boot phase, before Intel guest driver is initialized.
- xres and yres are used to set EDID of the mdev device, otherwise it will be default to 1920x1200, changing resolution in Guest OS may cause mouse position out of sync issue