summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Justin Bauer <mjbauer95@gmail.com>2018-06-01 23:14:35 -0400
committerGitHub <noreply@github.com>2018-06-01 23:14:35 -0400
commit0135f04d778df96d4b6427ddc441f2eab565057b (patch)
tree459e653fd931180398004fa3e500f0842bf4efc2
parentcf152c2791c3a525736bcd540422d9b99a8f2a38 (diff)
parenta3e239ac6233dc895edaf90d8d4ba6728d4d4a41 (diff)
downloadnixlib-0135f04d778df96d4b6427ddc441f2eab565057b.tar
nixlib-0135f04d778df96d4b6427ddc441f2eab565057b.tar.gz
nixlib-0135f04d778df96d4b6427ddc441f2eab565057b.tar.bz2
nixlib-0135f04d778df96d4b6427ddc441f2eab565057b.tar.lz
nixlib-0135f04d778df96d4b6427ddc441f2eab565057b.tar.xz
nixlib-0135f04d778df96d4b6427ddc441f2eab565057b.tar.zst
nixlib-0135f04d778df96d4b6427ddc441f2eab565057b.zip
Merge pull request #40242 from gnidorah/gvt
linux: enable support for iGVT-g VGPU
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/virtualisation/kvmgt.nix64
-rw-r--r--pkgs/applications/virtualization/virt-viewer/default.nix7
-rw-r--r--pkgs/development/libraries/spice-gtk/default.nix6
-rw-r--r--pkgs/os-specific/linux/kernel/common-config.nix5
-rw-r--r--pkgs/tools/networking/phodav/default.nix25
-rw-r--r--pkgs/top-level/all-packages.nix2
7 files changed, 105 insertions, 5 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 12d9e1adf23d..d6f2c85a8109 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -787,6 +787,7 @@
   ./virtualisation/lxd.nix
   ./virtualisation/amazon-options.nix
   ./virtualisation/hyperv-guest.nix
+  ./virtualisation/kvmgt.nix
   ./virtualisation/openvswitch.nix
   ./virtualisation/parallels-guest.nix
   ./virtualisation/qemu-guest-agent.nix
diff --git a/nixos/modules/virtualisation/kvmgt.nix b/nixos/modules/virtualisation/kvmgt.nix
new file mode 100644
index 000000000000..fc0bedb68bd0
--- /dev/null
+++ b/nixos/modules/virtualisation/kvmgt.nix
@@ -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 ];
+}
diff --git a/pkgs/applications/virtualization/virt-viewer/default.nix b/pkgs/applications/virtualization/virt-viewer/default.nix
index eb48e1d3d300..33e12d109854 100644
--- a/pkgs/applications/virtualization/virt-viewer/default.nix
+++ b/pkgs/applications/virtualization/virt-viewer/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchurl, pkgconfig, intltool, glib, libxml2, gtk3, gtkvnc, gmp
 , libgcrypt, gnupg, cyrus_sasl, shared-mime-info, libvirt, yajl, xen
 , gsettings-desktop-schemas, makeWrapper, libvirt-glib, libcap_ng, numactl
-, libapparmor
+, libapparmor, gst_all_1
 , spiceSupport ? true
 , spice-gtk ? null, spice-protocol ? null, libcap ? null, gdbm ? null
 }:
@@ -30,11 +30,14 @@ stdenv.mkDerivation rec {
     xen
   ] ++ optionals spiceSupport [
     spice-gtk spice-protocol libcap gdbm
+    gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good
   ];
 
   postInstall = ''
     for f in "$out"/bin/*; do
-        wrapProgram "$f" --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH"
+        wrapProgram "$f" \
+          --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \
+          --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "$GST_PLUGIN_SYSTEM_PATH_1_0"
     done
   '';
 
diff --git a/pkgs/development/libraries/spice-gtk/default.nix b/pkgs/development/libraries/spice-gtk/default.nix
index 05fd952eb2e8..21359c4f0d0b 100644
--- a/pkgs/development/libraries/spice-gtk/default.nix
+++ b/pkgs/development/libraries/spice-gtk/default.nix
@@ -2,7 +2,7 @@
 , openssl, libpulseaudio, pixman, gobjectIntrospection, libjpeg_turbo, zlib
 , cyrus_sasl, python2Packages, autoreconfHook, usbredir, libsoup
 , withPolkit ? true, polkit, acl, usbutils
-, vala, gtk3, epoxy, libdrm }:
+, vala, gtk3, epoxy, libdrm, gst_all_1, phodav }:
 
 # If this package is built with polkit support (withPolkit=true),
 # usb redirection reqires spice-client-glib-usb-acl-helper to run setuid root.
@@ -46,8 +46,8 @@ in stdenv.mkDerivation rec {
   '';
 
   buildInputs = [
-    spice-protocol celt_0_5_1 openssl libpulseaudio pixman
-    libjpeg_turbo zlib cyrus_sasl python pygtk usbredir gtk3 epoxy libdrm
+    spice-protocol celt_0_5_1 openssl libpulseaudio gst_all_1.gst-plugins-base pixman
+    libjpeg_turbo zlib cyrus_sasl python pygtk usbredir gtk3 epoxy libdrm phodav
   ] ++ optionals withPolkit [ polkit acl usbutils ] ;
 
   nativeBuildInputs = [ pkgconfig gettext libsoup autoreconfHook vala gobjectIntrospection ];
diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix
index cee2197f3c7a..a226061ecbfa 100644
--- a/pkgs/os-specific/linux/kernel/common-config.nix
+++ b/pkgs/os-specific/linux/kernel/common-config.nix
@@ -214,6 +214,11 @@ with stdenv.lib;
   ${optionalString (versionOlder version "4.3") ''
     DRM_I915_KMS y
   ''}
+  # iGVT-g support
+  ${optionalString (versionAtLeast version "4.16") ''
+    DRM_I915_GVT y
+    DRM_I915_GVT_KVMGT m
+  ''}
   # Allow specifying custom EDID on the kernel command line
   DRM_LOAD_EDID_FIRMWARE y
   VGA_SWITCHEROO y # Hybrid graphics support
diff --git a/pkgs/tools/networking/phodav/default.nix b/pkgs/tools/networking/phodav/default.nix
new file mode 100644
index 000000000000..e585af81991e
--- /dev/null
+++ b/pkgs/tools/networking/phodav/default.nix
@@ -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;
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index fdd61a138eea..606b912c75ed 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -4398,6 +4398,8 @@ with pkgs;
 
   philter = callPackage ../tools/networking/philter { };
 
+  phodav = callPackage ../tools/networking/phodav { };
+
   pinentry = callPackage ../tools/security/pinentry {
     libcap = if stdenv.isDarwin then null else libcap;
   };