IGVT-g: Difference between revisions
imported>Offlinehacker m Add `MESA_LOADER_DRIVER_OVERRIDE` env to command line flags, as it fixes garbled graphic issues |
imported>Whazor Add note about GVT-g removal and SR-IOV future |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
Intel GVT-g is a | Intel GVT-g is a technology that allows to "slice" an Intel GPU into virtualized GPUs that can be then passed into virtual machines. | ||
Note that Intel GVT-g only supports Intel Broadwell (5th gen) to Comet Lake (10th gen), where in 10th gen support for IVGT-g was removed. For 11th gen, and 12th gen, there is SR-IOV coming up for virtualized GPUs, but that did not yet arrive in Linux mainline. | |||
== | == Configuring GPU == | ||
First, enable iGVT-g with: | |||
= | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
virtualisation.kvmgt.enable = true; | |||
</nowiki>}} | |||
... then rebuild and reboot. | |||
After rebooting, check if the driver was successfully loaded: | |||
</nowiki>}} | |||
then rebuild and reboot. | $ ls /sys/bus/pci/devices/0000:00:02.0/mdev_supported_types/ | ||
... if you get <code>No such file or directory</code>, it means you might be using an older CPU that needs an extra configuration option: | |||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | |||
boot.extraModprobeConfig = "options i915 enable_guc=2"; | |||
</nowiki>}} | |||
... then rebuild and reboot once again (unless that previous <code>ls</code> succeeded, in which case you don't have to modify that <code>extraModprobeConfig</code> at all). | |||
Now, using <code>ls</code> you can list which variants your Intel GPU is able to virtualise: | |||
$ ls /sys/bus/pci/devices/0000:00:02.0/mdev_supported_types/ | $ ls /sys/bus/pci/devices/0000:00:02.0/mdev_supported_types/ | ||
i915-GVTg_V5_4/ i915-GVTg_V5_8/ | i915-GVTg_V5_4/ i915-GVTg_V5_8/ | ||
E.g.: | |||
$ cat /sys/bus/pci/devices/0000:00:02.0/mdev_supported_types/i915-GVTg_V5_8/description | $ cat /sys/bus/pci/devices/0000:00:02.0/mdev_supported_types/i915-GVTg_V5_8/description | ||
Line 24: | Line 39: | ||
weight: 2 | weight: 2 | ||
Find some variant that matches your expectations (resolution, memory size etc.), note down its name, generate a random UUID: | |||
# If you're using Nix Flakes: | |||
$ nix shell nixpkgs#libossp_uuid -c uuid | |||
a297db4a-f4c2-11e6-90f6-d3b88d6c9525 | |||
# If you're not using Nix Flakes: | |||
$ nix run nixpkgs.libossp_uuid -c uuid | $ nix run nixpkgs.libossp_uuid -c uuid | ||
a297db4a-f4c2-11e6-90f6-d3b88d6c9525 | a297db4a-f4c2-11e6-90f6-d3b88d6c9525 | ||
... and add that variant's name into your configuration: | |||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
virtualisation.kvmgt.enable = true; | |||
virtualisation.kvmgt.vgpus = { | |||
"i915-GVTg_V5_8" = { | |||
uuid = [ "a297db4a-f4c2-11e6-90f6-d3b88d6c9525" ]; | |||
}; | }; | ||
}; | |||
environment.systemPackages = with pkgs; [ | |||
virtmanager | virtmanager | ||
]; | |||
virtualisation.libvirtd.enable = true; | |||
users.extraUsers.user.extraGroups = [ "libvirtd" ]; | |||
</nowiki>}} | </nowiki>}} | ||
== | Rebuild & voilá - your virtualized GPU is ready; now you just have to attach it to some virtual machine. | ||
== Attaching GPU == | |||
=== Bare Qemu === | === Bare Qemu === | ||
Line 56: | Line 80: | ||
-device vfio-pci,sysfsdev=/sys/bus/mdev/devices/'''a297db4a-f4c2-11e6-90f6-d3b88d6c9525''',display=on,x-igd-opregion=on,driver=vfio-pci-nohotplug,ramfb=on,xres=1920,yres=1080 | -device vfio-pci,sysfsdev=/sys/bus/mdev/devices/'''a297db4a-f4c2-11e6-90f6-d3b88d6c9525''',display=on,x-igd-opregion=on,driver=vfio-pci-nohotplug,ramfb=on,xres=1920,yres=1080 | ||
=== | === libvirt === | ||
If using virt-manager, create new or open existing VM. Change existing <code><graphics></code> and <code><video></code> sections. | If using virt-manager, create new or open existing VM. Change existing <code><graphics></code> and <code><video></code> sections. |