-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40242 from gnidorah/gvt
linux: enable support for iGVT-g VGPU
- Loading branch information
Showing
7 changed files
with
105 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
with lib; | ||
|
||
let | ||
cfg = config.virtualisation.kvmgt; | ||
kernelPackages = config.boot.kernelPackages; | ||
vgpuOptions = { | ||
uuid = mkOption { | ||
type = types.string; | ||
description = "UUID of VGPU device. You can generate one with <package>libossp_uuid</package>."; | ||
}; | ||
}; | ||
in { | ||
options = { | ||
virtualisation.kvmgt = { | ||
enable = mkEnableOption '' | ||
KVMGT (iGVT-g) VGPU support. Allows Qemu/KVM guests to share host's Intel integrated graphics card. | ||
Currently only one graphical device can be shared | ||
''; | ||
# multi GPU support is under the question | ||
device = mkOption { | ||
type = types.string; | ||
default = "0000:00:02.0"; | ||
description = "PCI ID of graphics card. You can figure it with <command>ls /sys/class/mdev_bus</command>."; | ||
}; | ||
vgpus = mkOption { | ||
default = {}; | ||
type = with types; attrsOf (submodule [ { options = vgpuOptions; } ]); | ||
description = '' | ||
Virtual GPUs to be used in Qemu. You can find devices via <command>ls /sys/bus/pci/devices/*/mdev_supported_types</command> | ||
and find info about device via <command>cat /sys/bus/pci/devices/*/mdev_supported_types/i915-GVTg_V5_4/description</command> | ||
''; | ||
example = { | ||
"i915-GVTg_V5_8" = { | ||
uuid = "a297db4a-f4c2-11e6-90f6-d3b88d6c9525"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
assertions = singleton { | ||
assertion = versionAtLeast kernelPackages.kernel.version "4.16"; | ||
message = "KVMGT is not properly supported for kernels older than 4.16"; | ||
}; | ||
boot.kernelParams = [ "i915.enable_gvt=1" ]; | ||
systemd.services = mapAttrs' (name: value: | ||
nameValuePair "kvmgt-${name}" { | ||
description = "KVMGT VGPU ${name}"; | ||
serviceConfig = { | ||
Type = "oneshot"; | ||
RemainAfterExit = true; | ||
ExecStart = "${pkgs.runtimeShell} -c 'echo ${value.uuid} > /sys/bus/pci/devices/${cfg.device}/mdev_supported_types/${name}/create'"; | ||
ExecStop = "${pkgs.runtimeShell} -c 'echo 1 > /sys/bus/pci/devices/${cfg.device}/${value.uuid}/remove'"; | ||
}; | ||
wantedBy = [ "multi-user.target" ]; | ||
} | ||
) cfg.vgpus; | ||
}; | ||
|
||
meta.maintainers = with maintainers; [ gnidorah ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ stdenv, fetchurl | ||
, intltool, pkgconfig, glib, libsoup }: | ||
|
||
let | ||
version = "2.2"; | ||
in stdenv.mkDerivation rec { | ||
name = "phodav-${version}"; | ||
|
||
src = fetchurl { | ||
url = "http://ftp.gnome.org/pub/GNOME/sources/phodav/${version}/${name}.tar.xz"; | ||
sha256 = "1hap0lncbcmivnflh0fbx7y58ry78p9wgj7z03r64ic0kvf0a0q8"; | ||
}; | ||
|
||
buildInputs = [ intltool glib libsoup ]; | ||
|
||
nativeBuildInputs = [ pkgconfig ]; | ||
|
||
meta = with stdenv.lib; { | ||
description = "WebDav server implementation and library using libsoup"; | ||
homepage = https://wiki.gnome.org/phodav; | ||
license = licenses.lgpl21; | ||
maintainers = with maintainers; [ gnidorah ]; | ||
platforms = platforms.linux; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters