nixos/kvmgt: fix starting condition
This commit is contained in:
parent
bc94dcf500
commit
eac62f61d1
1 changed files with 10 additions and 8 deletions
|
@ -46,22 +46,24 @@ in {
|
||||||
message = "KVMGT is not properly supported for kernels older than 4.16";
|
message = "KVMGT is not properly supported for kernels older than 4.16";
|
||||||
};
|
};
|
||||||
boot.kernelParams = [ "i915.enable_gvt=1" ];
|
boot.kernelParams = [ "i915.enable_gvt=1" ];
|
||||||
|
systemd.paths = mapAttrs' (name: value:
|
||||||
|
nameValuePair "kvmgt-${name}" {
|
||||||
|
description = "KVMGT VGPU ${name} path";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
pathConfig = {
|
||||||
|
PathExists = "/sys/bus/pci/devices/${cfg.device}/mdev_supported_types/${name}/create";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
) cfg.vgpus;
|
||||||
systemd.services = mapAttrs' (name: value:
|
systemd.services = mapAttrs' (name: value:
|
||||||
nameValuePair "kvmgt-${name}" {
|
nameValuePair "kvmgt-${name}" {
|
||||||
description = "KVMGT VGPU ${name}";
|
description = "KVMGT VGPU ${name}";
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "forking";
|
Type = "oneshot";
|
||||||
RemainAfterExit = true;
|
RemainAfterExit = true;
|
||||||
Restart = "on-failure";
|
|
||||||
RestartSec = 5;
|
|
||||||
ExecStart = "${pkgs.runtimeShell} -c 'echo ${value.uuid} > /sys/bus/pci/devices/${cfg.device}/mdev_supported_types/${name}/create'";
|
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'";
|
ExecStop = "${pkgs.runtimeShell} -c 'echo 1 > /sys/bus/pci/devices/${cfg.device}/${value.uuid}/remove'";
|
||||||
};
|
};
|
||||||
unitConfig = {
|
|
||||||
StartLimitBurst = 5;
|
|
||||||
StartLimitIntervalSec = 30;
|
|
||||||
};
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
}
|
}
|
||||||
) cfg.vgpus;
|
) cfg.vgpus;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue