fix structure
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
VIRSH_GPU_VIDEO=pci_0000_08_00_0
|
||||
VIRSH_GPU_AUDIO=pci_0000_08_00_1
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Author: SharkWipf
|
||||
#
|
||||
# Copy this file to /etc/libvirt/hooks, make sure it's called "qemu".
|
||||
# After this file is installed, restart libvirt.
|
||||
# From now on, you can easily add per-guest qemu hooks.
|
||||
# Add your hooks in /etc/libvirt/hooks/qemu.d/vm_name/hook_name/state_name.
|
||||
# For a list of available hooks, please refer to https://www.libvirt.org/hooks.html
|
||||
#
|
||||
|
||||
GUEST_NAME="$1"
|
||||
HOOK_NAME="$2"
|
||||
STATE_NAME="$3"
|
||||
MISC="${@:4}"
|
||||
|
||||
BASEDIR="$(dirname $0)"
|
||||
|
||||
HOOKPATH="$BASEDIR/qemu.d/$GUEST_NAME/$HOOK_NAME/$STATE_NAME"
|
||||
|
||||
set -e # If a script exits with an error, we should as well.
|
||||
|
||||
# check if it's a non-empty executable file
|
||||
if [ -f "$HOOKPATH" ] && [ -s "$HOOKPATH" ] && [ -x "$HOOKPATH" ]; then
|
||||
eval \"$HOOKPATH\" "$@"
|
||||
elif [ -d "$HOOKPATH" ]; then
|
||||
while read file; do
|
||||
# check for null string
|
||||
if [ ! -z "$file" ]; then
|
||||
eval \"$file\" "$@"
|
||||
fi
|
||||
done <<< "$(find -L "$HOOKPATH" -maxdepth 1 -type f -executable -print;)"
|
||||
fi
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
# Helpful to read output when debugging
|
||||
set -x
|
||||
|
||||
## Load the config file with our environmental variables
|
||||
#source "/etc/libvirt/hooks/kvm.conf"
|
||||
|
||||
# Stop display manager
|
||||
systemctl stop gdm3
|
||||
# Stop ollama
|
||||
# systemctl stop ollama
|
||||
|
||||
# Unbind VTconsoles
|
||||
echo 0 > /sys/class/vtconsole/vtcon0/bind
|
||||
echo 0 > /sys/class/vtconsole/vtcon1/bind
|
||||
|
||||
# Unbind EFI-Framebuffer
|
||||
echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
|
||||
|
||||
# Avoid a race condition
|
||||
sleep 2
|
||||
|
||||
# Unload all Nvidia drivers
|
||||
modprobe -r nvidia_drm
|
||||
modprobe -r nvidia_uvm
|
||||
modprobe -r nvidia_modeset
|
||||
modprobe -r drm_kms_helper
|
||||
modprobe -r nvidia
|
||||
modprobe -r i2c_nvidia_gpu
|
||||
modprobe -r drm
|
||||
|
||||
# Unbind the GPU from display driver
|
||||
#virsh nodedev-detach $VIRSH_GPU_VIDEO
|
||||
#virsh nodedev-detach $VIRSH_GPU_AUDIO
|
||||
virsh nodedev-detach pci_0000_08_00_0
|
||||
virsh nodedev-detach pci_0000_08_00_1
|
||||
|
||||
# Load VFIO kernel module
|
||||
modprobe vfio
|
||||
modprobe vfio_pci
|
||||
modprobe vfio_iommu_type1
|
||||
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
set -x
|
||||
|
||||
## Load the config file
|
||||
#source "/etc/libvirt/hooks/kvm.conf"
|
||||
|
||||
# Unload VFIO-PCI Kernel Driver
|
||||
modprobe -r vfio_pci
|
||||
modprobe -r vfio_iommu_type1
|
||||
modprobe -r vfio
|
||||
|
||||
# Re-Bind GPU to AMD Driver
|
||||
#virsh nodedev-reattach $VIRSH_GPU_VIDEO
|
||||
#virsh nodedev-reattach $VIRSH_GPU_AUDIO
|
||||
virsh nodedev-reattach pci_0000_08_00_0
|
||||
virsh nodedev-reattach pci_0000_08_00_1
|
||||
|
||||
|
||||
# Rebind VT consoles
|
||||
echo 1 > /sys/class/vtconsole/vtcon0/bind
|
||||
echo 0 > /sys/class/vtconsole/vtcon1/bind
|
||||
|
||||
#nvidia-xconfig --query-gpu-info > /dev/null 2>&1
|
||||
# Re-Bind EFI-Framebuffer
|
||||
echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind
|
||||
|
||||
#Load nvidia driver
|
||||
modprobe nvidia_drm
|
||||
modprobe nvidia_uvm
|
||||
modprobe nvidia_modeset
|
||||
modprobe drm_kms_helper
|
||||
modprobe nvidia
|
||||
modprobe i2c_nvidia_gpu
|
||||
modprobe drm
|
||||
|
||||
# Restart Display Manager
|
||||
systemctl start gdm3
|
||||
Reference in New Issue
Block a user