@@ -46,22 +46,24 @@ in {
4646 message = "KVMGT is not properly supported for kernels older than 4.16";
4747 };
4848 boot.kernelParams = [ "i915.enable_gvt=1" ];
49+ systemd.paths = mapAttrs' (name: value:
50+ nameValuePair "kvmgt-${name}" {
51+ description = "KVMGT VGPU ${name} path";
52+ wantedBy = [ "multi-user.target" ];
53+ pathConfig = {
54+ PathExists = "/sys/bus/pci/devices/${cfg.device}/mdev_supported_types/${name}/create";
55+ };
56+ }
57+ ) cfg.vgpus;
4958 systemd.services = mapAttrs' (name: value:
5059 nameValuePair "kvmgt-${name}" {
5160 description = "KVMGT VGPU ${name}";
5261 serviceConfig = {
53− Type = "forking";
62+ Type = "oneshot";
5463 RemainAfterExit = true;
55− Restart = "on-failure";
56− RestartSec = 5;
5764 ExecStart = "${pkgs.runtimeShell} -c 'echo ${value.uuid} > /sys/bus/pci/devices/${cfg.device}/mdev_supported_types/${name}/create'";
5865 ExecStop = "${pkgs.runtimeShell} -c 'echo 1 > /sys/bus/pci/devices/${cfg.device}/${value.uuid}/remove'";
5966 };
60− unitConfig = {
61− StartLimitBurst = 5;
62− StartLimitIntervalSec = 30;
63− };
64− wantedBy = [ "multi-user.target" ];
6567 }
6668 ) cfg.vgpus;
6769 };