User:Shunlir/Intel GVT-g

From Gentoo Wiki
Jump to:navigation Jump to:search
Warning, this page is a work in progress by Shunlir (talk | contribs). Treat its contents with caution.


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

Enable GVT-g on host

Recompile the kernel

  1. Install sys-kernel/gentoo-sources version 5.4+ (may need patch, see below)
  3. If the GPU is SkyLake nor KabyLake, apply this patch to enable support for vfio edid.
  4. Compile the kernel:
    root #cd /usr/src/linux && make && make modules_install

Install the kernel

  1. Install kernel binaries:
    root #cd /usr/src/linux && make install
  2. Change /etc/default/grub with following contents:
    CODE /etc/default/grub
    GRUB_CMDLINE_LINUX_DEFAULT="i915.enable_gvt=1 kvm.ignore_msrs=1"
  3. Update grub config:
    root #grub-mkconfig -o /boot/grub/grub.cfg

Reboot and Verify

  1. Use lspci -nn to identify the <pci domain number>:<pci bus number>:<device number>.<function number> of the Intel GPU, it's typically 00:02.0
  2. 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
    the description file under the profile folder gives more information such as max resolution, V5_4: 1920x1200, V5_8: 1024x768
  3. 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
    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`.

  1. Shutdown the VM
  2. Edit the definition file of the VM:
    root # virsh edit <vm-name>
    Then add a mdev device (aka the Intel vGPU) in the file:
FILE virshXXXXXX.xml
    <hostdev mode='subsystem' type='mdev' managed='no' model='vfio-pci' display='off'>
       <address uuid='746afefa-89af-481d-ad4e-52e0d9f5f2e6'/>

Activate Intel vGPU for Guest

  • Do the following changes to enable the vGPU as primary device
FILE virshXXXXXX.xml
<domain type='kvm' xmlns:qemu=''>
    <graphics type='spice'>
      <listen type='none'/>
      <gl enable='yes' rendernode='/dev/dri/by-path/pci-0000:00:02.0-render'/>
      <model type='none'/>
    <hostdev mode='subsystem' type='mdev' managed='no' model='vfio-pci' display='on'>
        <address uuid='746afefa-89af-481d-ad4e-52e0d9f5f2e6'/>
    <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'/>
  • Reboot guest to take effect
* 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