From 1a13656f958ebdd855058b524176c1c964420d56 Mon Sep 17 00:00:00 2001 From: waveringana Date: Sun, 15 Jun 2025 05:35:32 -0400 Subject: [PATCH] add end script --- hosts/focalor/hardware.nix | 6 +++++- hosts/focalor/scripts/end.sh | 20 ++++++++++++++++++++ hosts/focalor/vfio.nix | 3 +++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 hosts/focalor/scripts/end.sh diff --git a/hosts/focalor/hardware.nix b/hosts/focalor/hardware.nix index b290f2f..126d39c 100755 --- a/hosts/focalor/hardware.nix +++ b/hosts/focalor/hardware.nix @@ -9,8 +9,12 @@ ]; boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "uas" "usbhid" "sd_mod" ]; - boot.initrd.kernelModules = [ ]; + boot.initrd.kernelModules = [ "vfio" "vfio_iommu_type1" "vfio_pci" ]; boot.kernelModules = [ "kvm-amd" ]; + boot.kernelParams = [ + "amd_iommu=on" + "vfio-pci.ids=10de:2484,10de228b,1022:149c,15b7:5045,1dbe:5236,1022:149c" + ]; boot.extraModulePackages = [ ]; fileSystems."/" = diff --git a/hosts/focalor/scripts/end.sh b/hosts/focalor/scripts/end.sh new file mode 100644 index 0000000..a08a269 --- /dev/null +++ b/hosts/focalor/scripts/end.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -x + +virsh nodedev-reattach pci_0000_0a_00_0 +virsh nodedev-reattach pci_0000_0a_00_1 +virsh nodedev-reattach pci_0000_06_00_1 +virsh nodedev-reattach pci_0000_06_00_3 +virsh nodedev-reattach pci_0000_0c_00_3 + +modprobe -r vfio-pci + +modprobe nvidia_modeset +modprobe nvidia_uvm +modprobe nvidia_drm +modprobe nvidia + +modprobe -r xhci_pci +modprobe xhci_pci + +systemctl restart display-manager diff --git a/hosts/focalor/vfio.nix b/hosts/focalor/vfio.nix index eb144df..e0d73f7 100755 --- a/hosts/focalor/vfio.nix +++ b/hosts/focalor/vfio.nix @@ -17,6 +17,9 @@ }).fd]; }; }; + hooks.qemu = { + end = "./scripts/end.sh"; + }; }; users.extraUsers.regent.extraGroups = [ "libvirtd" ];