-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add fmo-tool configs - Add fmo-tool package - Add vhotplug package for dynamic device passthrough - Refactor fmo-services into host-services and vm-services - Move public filter into flake.nix Signed-off-by: Anh Huy Bui <[email protected]>
- Loading branch information
1 parent
fdf903f
commit 37e13b2
Showing
22 changed files
with
530 additions
and
55 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
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
34 changes: 34 additions & 0 deletions
34
modules/fmo-services/dynamic-device-passthrough-service-host/default.nix
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,34 @@ | ||
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
{ lib, pkgs, config, ... }: | ||
with lib; | ||
let | ||
cfg = config.services.fmo-dynamic-device-passthrough-service-host; | ||
in { | ||
options.services.fmo-dynamic-device-passthrough-service-host = { | ||
enable = mkEnableOption "FMO dynamic device passthrough service"; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
environment.systemPackages = [ pkgs.vhotplug ]; | ||
|
||
services.udev.extraRules = '' | ||
SUBSYSTEM=="usb", GROUP="kvm" | ||
KERNEL=="event*", GROUP="kvm" | ||
''; | ||
|
||
systemd.services."fmo-dynamic-device-passthrough-service" = { | ||
script = '' | ||
if ! [ -f /var/host/vmddp.conf ]; then | ||
${pkgs.fmo-tool}/bin/fmo-tool ddp generate | ||
fi | ||
${pkgs.vhotplug}/bin/vhotplug -a -c /var/host/vmddp.conf | ||
''; | ||
serviceConfig = { | ||
Type = "simple"; | ||
RemainAfterExit = true; | ||
}; | ||
wantedBy = [ "multi-user.target" ]; | ||
}; | ||
}; | ||
} |
23 changes: 23 additions & 0 deletions
23
modules/fmo-services/dynamic-device-passthrough-service/default.nix
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,23 @@ | ||
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
{ lib, pkgs, config, ... }: | ||
with lib; | ||
let | ||
cfg = config.services.fmo-dynamic-device-passthrough; | ||
in { | ||
options.services.fmo-dynamic-device-passthrough = { | ||
enable = mkEnableOption "FMO dynamic device passthrough devices"; | ||
|
||
devices = mkOption { | ||
type = types.listOf types.attrs; | ||
description = '' | ||
Device list to passthrough | ||
{ | ||
bus = bus type "usb | pci", only usb is valid for now, | ||
vendorid = vendorid for device, | ||
productid = productid for device, | ||
} | ||
''; | ||
}; | ||
}; | ||
} |
Oops, something went wrong.