====== Linux KVM ======
===== How to install =====
* https://linuxize.com/post/how-to-install-kvm-on-ubuntu-20-04/
===== How to boot Dual Boot Windows Partition =====
* https://jianmin.dev/2020/jul/19/boot-your-windows-partition-from-linux-using-kvm/
* http://disq.us/p/2ltujmy
==== Windows Partition Dual Mount ====
* https://superuser.com/a/1010125
==== Spoof BIOS & Mainboard to avoid re-activation ====
* https://www.remembertheusers.com/2021/06/0758-windows-10-p2v.html
* https://gist.github.com/smoser/290f74c256c89cb3f3bd434a27b9f64c
* https://libvirt.org/formatdomain.html#smbios-system-information
===== GPU Acceleration =====
* https://wiki.archlinux.org/title/QEMU/Guest_graphics_acceleration
* https://arccompute.com/blog/libvfio-commodity-gpu-multiplexing/
* https://github.com/Arc-Compute/LibVF.IO/
* https://github.com/manalito/LibVF.IO
* https://askubuntu.com/a/1389829
* https://www.spice-space.org/download.html (spice-guest-tools)
* https://github.com/mysteryx93/GPU-Passthrough-with-Optimus-Manager-Guide
* https://forum.level1techs.com/t/solved-unable-to-isolate-gpu-for-vfio-workaround/196250/69?page=4
* https://github.com/tuh8888/libvirt_win10_vm
* https://github.com/QaidVoid/Complete-Single-GPU-Passthrough
* https://superuser.com/questions/1804067/how-do-i-get-a-multi-display-virgl-3d-accelerated-qemu-vm-on-a-nvidia-card-in-vi
Due to NVIDIA GPUs needing a license to be able to use vGPU it's currently not really recommended to passthrough a vGPU but instead the whole GPU. The best approach for a desktop machine is to use the single GPU passthrough approach which stops the X server and starts up a pre-configured virtual machine.
===== Seamless Windows =====
* https://github.com/Fmstrat/winapps
* Newer/More up-to-date: https://github.com/winapps-org/winapps
* https://github.com/Xpra-org/xpra
* Snap does not work inside xpra (or so it seems).
* https://www.baeldung.com/linux/snap-remove-disable
===== Input Passthrough =====
* https://passthroughpo.st/using-evdev-passthrough-seamless-vm-input/
===== Hooks =====
* https://github.com/portellam/libvirt-hooks/tree/master
* https://github.com/PassthroughPOST/VFIO-Tools/tree/master
===== Nested Virtualization =====
* https://docs.fedoraproject.org/en-US/quick-docs/using-nested-virtualization-in-kvm/
===== Drivers =====
==== NVIDIA ====
* https://www.nvidia.com/download/driverResults.aspx/213194/en-us/
* https://cloud.google.com/compute/docs/gpus/grid-drivers-table
* https://foxi.buduanwang.vip/pan/vGPU/vgpu_unlock/drivers/
=== 535.129.03 ===
* https://us.download.nvidia.com/XFree86/Linux-x86_64/535.129.03/NVIDIA-Linux-x86_64-535.129.03.run
* https://storage.googleapis.com/nvidia-drivers-us-public/GRID/vGPU16.2/NVIDIA-Linux-x86_64-535.129.03-grid.run
* https://foxi.buduanwang.vip/pan/vGPU/vgpu_unlock/drivers/NVIDIA-Linux-x86_64-535.129.03-vgpu-kvm-custom.run
===== Sample Configurations =====
==== Old Notebook ====
[[infrastructure:inventory:hardware:notebooks:g500s]]
win11
4d99fd4a-4ffc-486f-8cf8-652c23f07b46
7168000
7168000
4
hvm
destroy
restart
destroy
/usr/bin/qemu-system-x86_64
==== Desktop ====
[[infrastructure:inventory:kiryu|kiryu]]
win11-gpu
6b1631e5-82b1-4667-ae10-d3fa5d436a2b
20971520
20971520
20
hvm
destroy
restart
destroy
/usr/bin/qemu-system-x86_64
#!/bin/bash
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.
echo "QEMU hook: $GUEST_NAME/$HOOK_NAME/$STATE_NAME" >> /var/log/libvirt/custom_hooks.log
if [ -f "$HOOKPATH" ]; then
eval \""$HOOKPATH"\" "$@" >> /var/log/libvirt/custom_hooks.log
elif [ -d "$HOOKPATH" ]; then
while read file; do
eval \""$file"\" "$@" >> /var/log/libvirt/custom_hooks.log
done <<< "$(find -L "$HOOKPATH" -maxdepth 1 -type f -executable -print;)"
fi
#!/bin/bash
set -x
# Stop display manager
systemctl stop display-manager
# systemctl --user -M YOUR_USERNAME@ stop plasma*
# Unbind VTconsoles: might not be needed
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
# Unload NVIDIA kernel modules
modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia
# Unload AMD kernel module
# modprobe -r amdgpu
# Detach GPU devices from host
# Use your GPU and HDMI Audio PCI host device
virsh nodedev-detach pci_0000_01_00_0
virsh nodedev-detach pci_0000_01_00_1
virsh nodedev-detach pci_0000_01_00_2
virsh nodedev-detach pci_0000_01_00_3
# Load vfio module
modprobe vfio-pci
#!/bin/bash
set -x
# Attach GPU devices to host
# Use your GPU and HDMI Audio PCI host device
virsh nodedev-reattach pci_0000_01_00_0
virsh nodedev-reattach pci_0000_01_00_1
virsh nodedev-reattach pci_0000_01_00_2
virsh nodedev-reattach pci_0000_01_00_3
# Unload vfio module
modprobe -r vfio-pci
# Load AMD kernel module
#modprobe amdgpu
# Rebind framebuffer to host
echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind
# Load NVIDIA kernel modules
modprobe nvidia_drm
modprobe nvidia_modeset
modprobe nvidia_uvm
modprobe nvidia
# Bind VTconsoles: might not be needed
echo 1 > /sys/class/vtconsole/vtcon0/bind
echo 1 > /sys/class/vtconsole/vtcon1/bind
# Restart Display Manager
systemctl start display-manager