idk
This commit is contained in:
parent
d616cdca1f
commit
9dc034ec86
23 changed files with 354 additions and 26 deletions
62
hosts/focalor/scripts/vm-win11-hook.sh
Executable file
62
hosts/focalor/scripts/vm-win11-hook.sh
Executable file
|
@ -0,0 +1,62 @@
|
|||
#!/run/current-system/sw/bin/bash
|
||||
|
||||
echo "qemu-hook: ${1} ${2}" >> /tmp/qemu-hook.log
|
||||
|
||||
set -x
|
||||
|
||||
readonly GUEST_NAME="$1"
|
||||
readonly HOOK_NAME="$2"
|
||||
readonly STATE_NAME="$3"
|
||||
|
||||
function start_hook() {
|
||||
# Stops GUI
|
||||
systemctl isolate multi-user.target
|
||||
|
||||
# Avoids race condition
|
||||
sleep 2
|
||||
|
||||
# Unloads the NVIDIA drivers
|
||||
modprobe -r nvidia_drm
|
||||
modprobe -r nvidia_uvm
|
||||
modprobe -r nvidia_modeset
|
||||
modprobe -r nvidia
|
||||
|
||||
# Other code you might want to run
|
||||
}
|
||||
|
||||
function revert_hook() {
|
||||
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
|
||||
|
||||
# Loads the NVIDIA drivers
|
||||
modprobe nvidia_modeset
|
||||
modprobe nvidia_uvm
|
||||
modprobe nvidia_drm
|
||||
modprobe nvidia
|
||||
|
||||
modprobe -r xhci_pci
|
||||
modprobe xhci_pci
|
||||
|
||||
# Starts the UI again
|
||||
systemctl restart display-manager
|
||||
systemctl isolate graphical.target
|
||||
}
|
||||
|
||||
# I am not using the script from Passthrough-Post
|
||||
# because hooks option saves it to /var/lib/libvirt/hooks/qemu.d.
|
||||
# It's simpler to just rewrite it for NixOS.
|
||||
if [[ "$GUEST_NAME" != "win11" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$HOOK_NAME" == "prepare" && "$STATE_NAME" == "begin" ]]; then
|
||||
#start_hook
|
||||
echo "do nothing"
|
||||
elif [[ "$HOOK_NAME" == "release" && "$STATE_NAME" == "end" ]]; then
|
||||
revert_hook
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue