This document describes how to divide a physical Intel GPU device into multiple virtual devices referred to as mediated devices, and how to assign these mediated devices to KVM virtual machines.

Setting up Intel vGPU devices

This feature is still under development, and may not work properly.

To set up Intel vGPU devices, you need to obtain and install the correct driver for your GPU device, then create mediated devices, and assign each mediated device to a virtual machine.

Before you begin

Download and install the i915 driver for the host. For more information, see https://01.org/igvt-g. For information on the guest drivers for Windows, see https://github.com/intel/gvt-linux/wiki/GVTg_Setup_Guide#42-windows-guest-setup.

Configuring the host

  1. Open /etc/default/grub in a text editor.

  2. Append the following to the GRUB_CMDLINX_LINUX environment variable i915.enable_gvt=1. For example:

    GRUB_CMDLINE_LINUX="rd.lvm.lv=vg_VolGroup00/LogVol01
    vconsole.font=latarcyrheb-sun16 rd.lvm.lv=vg_VolGroup_1/root
    vconsole.keymap=us $([ -x /usr/sbin/rhcrashkernel-param ]  &&
    /usr/sbin/rhcrashkernel-param || :) rhgb quiet intel_iommu=on pci-stub.ids=10de:11fa i915.enable_gvt=1"
  3. Regenerate boot loader configuration:

    # grub2-mkconfig -o /etc/grub2.cfg
  4. Open `/etc/dracut.conf.d/local.conf in a text editor.

  5. Set the line with: add_drivers+="" to add_drivers+="kvmgt"

  6. Regenerate the initial ramdisk for the current kernel, then reboot:

    # dracut --force --regenerate-all
    # reboot

    Alternatively, if you need to use a prior supported kernel version with mediated devices, regenerate the initial ramdisk for all installed kernel versions:

    # dracut --regenerate-all --force
    # reboot
  1. Get a list of available mdev types by entering the following lines in the terminal:

    for device in /sys/class/mdev_bus/; do
      for mdev_type in $device/mdev_supported_types/; do
        MDEV_TYPE=$(basename $mdev_type)
        DESCRIPTION=$(cat $mdev_type/description)
        NAME=$(cat $mdev_type/name)
        echo "mdev_type: $MDEV_TYPE --- description: $DESCRIPTION --- name: $NAME";
      done;
    done | sort | uniq

    Use this code in a script.

    The output is as follows:

    fence: 4
    high_gm_size: 384MB
    high_gm_size: 512MB
    mdev_type: i915-GVTg_V5_4 --- description: low_gm_size: 128MB
    mdev_type: i915-GVTg_V5_8 --- description: low_gm_size: 64MB
    resolution: 1024x768
    resolution: 1920x1200
    weight: 2
    weight: 4
  2. In the Administration Portal, click Compute  Virtual Machines. Select a virtual machine and click Edit. The Edit Virtual Machine dialog appears.

  3. Click Custom Properties. If you don’t see Custom Properties, click Show Advanced Options.

  4. In the Custom Properties dialog, click Please select a key  mdev_type. If you don’t see Please select a key, click the + button.

  5. In the text field that appears, enter the GPU type or types that you identified previously. For example: i915-GVTg_V5_8.You can add multiple vGPUs to a virtual machine using a comma-separated list. For example: i915-GVTg_V5_8,i915-GVTg_V5_8.

    Multiple vGPUs must be the same mdev type. You can’t, for example use i915-GVTg_V5_4,i915-GVTg_V5_8.

You have finished installing and configuring the GPU on the host. Now you can proceed to install and configure the vGPU on each virtual machine.

Installing the guest driver

To install the vGPU driver on a Linux or Windows virtual machine:

  1. Start the virtual machine using a serial console, such as SPICE or VNC.

  2. Download the driver to the virtual machine. For information on getting the driver, see ???

  3. Install the vGPU driver, following the instructions in ???

  4. After the driver finishes installing reboot the machine. For Windows virtual machines, fully power off the guest from the Administration portal or the VM portal, not from within the guest operating system.

    Windows only: Powering off the virtual machine from within the Windows guest operating system sometimes sends the virtual machine into hibernate mode, which does not completely clear the memory, possibly leading to subsequent problems. Using the Administration portal or the VM portal to power off the virtual machine forces it to fully clean the memory.

  5. Start the virtual machine using a remote visualizer, such as Mechdyne TGX and verify that the vGPU is recognized by ??? For more information, see ??? Alternatively, on Windows, open the Windows Device Manager. The vGPU should appear under Display adapters.

Removing Intel vGPU devices

To change the configuration of assigned vGPU mediated devices, the existing devices have to be removed from the assigned guests.

Procedure
  • To remove a mediated vGPU device, use the following command when the device is inactive, and replace uuid with the UUID of the device, for example 30820a6f-b1a5-4503-91ca-0c10ba58692a:

    # echo 1 > /sys/bus/mdev/devices/uuid/remove

    Note that attempting to remove a vGPU device that is currently in use by a VM triggers the following error:

    echo: write error: Device or resource busy