commit 5084074d05f7907d6422382d1199bbe07e7353f4 Author: Karuri M. Karuri Date: Thu Sep 10 20:29:02 2020 +0300 Initial commit diff --git a/alloc_hugepages.sh b/alloc_hugepages.sh new file mode 100644 index 0000000..ca9af58 --- /dev/null +++ b/alloc_hugepages.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +## Load the config file +source "/etc/libvirt/hooks/kvm.conf" + +## Calculate number of hugepages to allocate from memory (in MB) +HUGEPAGES="$(($MEMORY/$(($(grep Hugepagesize /proc/meminfo | awk '{print $2}')/1024))))" + +echo "Allocating hugepages..." +echo $HUGEPAGES > /proc/sys/vm/nr_hugepages +ALLOC_PAGES=$(cat /proc/sys/vm/nr_hugepages) + +TRIES=0 +while (( $ALLOC_PAGES != $HUGEPAGES && $TRIES < 1000 )) +do + echo 1 > /proc/sys/vm/compact_memory ## defrag ram + echo $HUGEPAGES > /proc/sys/vm/nr_hugepages + ALLOC_PAGES=$(cat /proc/sys/vm/nr_hugepages) + echo "Succesfully allocated $ALLOC_PAGES / $HUGEPAGES" + let TRIES+=1 +done + +if [ "$ALLOC_PAGES" -ne "$HUGEPAGES" ] +then + echo "Not able to allocate all hugepages. Reverting..." + echo 0 > /proc/sys/vm/nr_hugepages + exit 1 +fi diff --git a/check-iommu.sh b/check-iommu.sh new file mode 100755 index 0000000..2dad4c6 --- /dev/null +++ b/check-iommu.sh @@ -0,0 +1,8 @@ +#!/bin/bash +shopt -s nullglob +for g in /sys/kernel/iommu_groups/*; do + echo "IOMMU Group ${g##*/}:" + for d in $g/devices/*; do + echo -e "\t$(lspci -nns ${d##*/})" + done; +done; diff --git a/cpu_mode_ondemand.sh b/cpu_mode_ondemand.sh new file mode 100755 index 0000000..07a5b4a --- /dev/null +++ b/cpu_mode_ondemand.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +## Enable CPU governor on-demand mode +cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor +for file in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo "ondemand" > $file; done +cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor diff --git a/cpu_mode_performance.sh b/cpu_mode_performance.sh new file mode 100755 index 0000000..7a1c821 --- /dev/null +++ b/cpu_mode_performance.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +## Enable CPU governor performance mode +cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor +for file in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo "performance" > $file; done +cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor diff --git a/dealloc_hugepages.sh b/dealloc_hugepages.sh new file mode 100644 index 0000000..2e35d1c --- /dev/null +++ b/dealloc_hugepages.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +## Load the config file +source "/etc/libvirt/hooks/kvm.conf" + +echo 0 > /proc/sys/vm/nr_hugepages diff --git a/revert.sh b/revert.sh new file mode 100755 index 0000000..b41dbbe --- /dev/null +++ b/revert.sh @@ -0,0 +1,36 @@ +#!/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 $VIRSH_GPU_USB +virsh nodedev-reattach $VIRSH_GPU_SERIAL + +# 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_modeset +modprobe drm_kms_helper +modprobe nvidia +modprobe i2c_nvidia_gpu +modprobe drm + +# Restart Display Manager +systemctl start lightdm.service + diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..48f1403 --- /dev/null +++ b/start.sh @@ -0,0 +1,39 @@ +#!/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 (KDE specific) +systemctl stop lightdm.service + +# 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 5 + +# Unload all Nvidia drivers +modprobe -r nvidia_drm +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 $VIRSH_GPU_USB +virsh nodedev-detach $VIRSH_GPU_SERIAL + +# Load VFIO kernel module +modprobe vfio +modprobe vfio_pci +modprobe vfio_iommu_type1 + diff --git a/win10.xml b/win10.xml new file mode 100644 index 0000000..9009fbb --- /dev/null +++ b/win10.xml @@ -0,0 +1,216 @@ + + win10 + 9a6c9e8d-403e-4dbb-bee3-dabfe3c747a6 + + + + + + 12582912 + 12582912 + + + + 8 + 4 + + + + + + + + + + + + + + + + + hvm + /usr/share/edk2-ovmf/x64/OVMF_CODE.secboot.fd + /var/lib/libvirt/qemu/nvram/win10_VARS.fd + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + destroy + restart + destroy + + + + + + /usr/bin/qemu-system-x86_64 + + + + + +
+ + +
+ + +
+ + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + +
+ + + + +
+ + + + +
+ + + + +
+ + +
+ + + + + +
+ + + + + + + + + + + + +
+ + + +
+ +
+ + + +
+ +
+ + + + + + +
+ + + + + + +
+ + + +
+ +
+ + + +
+ +
+ + + + + + +
+ + +
+ + +