Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /etc/libvirt/hooks/qemu
- #!/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
- --------------------------------------------------------------------------------------------------------------------
- /etc/libvirt/hooks/qemu.d/win11/prepare/begin/start.sh
- set -x
- source "/etc/libvirt/hooks/kvm.conf"
- # systemctl stop display-manager
- echo 0 > /sys/class/vtconsole/vtcon0/bind
- echo 0 > /sys/class/vtconsole/vtcon1/bind
- #uncomment the next line if you're getting a black screen
- echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
- sleep 10
- modprobe -r amdgpu
- modprobe -r snd_hda_intel
- virsh nodedev-detach $VIRSH_GPU_VIDEO
- virsh nodedev-detach $VIRSH_GPU_AUDIO
- sleep 10
- modprobe vfio
- modprobe vfio_pci
- modprobe vfio_iommu_type1
- --------------------------------------------------------------------------------------------------------------------
- /etc/libvirt/hooks/qemu.d/win11/release/end/revert.sh
- set -x
- #reboot
- source "/etc/libvirt/hooks/kvm.conf"
- modprobe -r vfio
- modprobe -r vfio_pci
- modprobe -r vfio_iommu_type1
- sleep 10
- virsh nodedev-reattach $VIRSH_GPU_VIDEO
- virsh nodedev-reattach $VIRSH_GPU_AUDIO
- echo 1 > /sys/class/vtconsole/vtcon0/bind
- echo 1 > /sys/class/vtconsole/vtcon1/bind
- sleep 3
- echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind
- modprobe amdgpu
- modprobe snd_hda_intel
- sleep 3
- # systemctl start display-manager
Advertisement
Add Comment
Please, Sign In to add comment