Edit /etc/mkinitcpio.conf
as root
MODULES=(kvmgt vfio vfio-iommu-type1 vfio-mdev)
sudo mkinitcpio --allpresets
Edit /etc/default/grub
as root
GRUB_CMDLINE_LINUX_DEFAULT="i915.enable_gvt=1 kvm.ignore_msrs=1 intel_iommu=on i915.enable_guc=0"
sudo update-grub
Reboot.
After reboot:
# Find your PCI device
lspci # Mine is '00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 630 (Desktop)'
GVT_PCI='00:02.0'
# Make sure folder exists:
ll /sys/devices/pci0000:00/0000:${GVT_PCI}/mdev_supported_types/
# Read description:
GVT_TYPE='i915-GVTg_V5_8'
cat /sys/devices/pci0000:00/0000:${GVT_PCI}/mdev_supported_types/${GVT_TYPE}/description
# Create UUID
GVT_GUID="$(uuidgen -r)"
# Create vGPU
echo "${GVT_GUID}" > /sys/devices/pci0000:00/0000:${GVT_PCI}/mdev_supported_types/${GVT_TYPE}/create
# Validate
ls -l /sys/devices/pci0000:00/0000:${GVT_PCI} | grep "${GVT_GUID}"
# Create service
cat >/etc/systemd/system/gvtvgpu.service<<EOF
[Unit]
Description=Create Intel GVT-g vGPU
[Service]
Type=oneshot
ExecStart=/bin/sh -c "echo '${GVT_GUID}' > /sys/devices/pci0000:00/0000:${GVT_PCI}/mdev_supported_types/${GVT_TYPE}/create"
ExecStop=/bin/sh -c "echo '1' > /sys/devices/pci0000:00/0000:${GVT_PCI}/${GVT_GUID}/remove"
RemainAfterExit=yes
[Install]
WantedBy=graphical.target
EOF
# Then enable it
systemctl enable gvtvgpu
echo "GVT_PCI='$GVT_PCI'"
echo "GVT_TYPE='$GVT_TYPE'"
echo "GVT_GUID='$GVT_GUID'"
# Create QEMU machine launch script
cat > ${HOME}/qemu.sh <<EOF
#!/usr/bin/env bash
# Use \`lsblk -f\` to see drives
if [ "\$(id -u)" != "0" ]; then
kdesu \$0
exit 0
fi
qemu-system-x86_64 \\
-runas $(whoami) \\
-enable-kvm \\
-m 4G \\
-smp cores=2,threads=2,sockets=1,maxcpus=4 \\
-cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time \\
-machine type=pc,accel=kvm,kernel_irqchip=on \\
-global PIIX4_PM.disable_s3=1 \\
-global PIIX4_PM.disable_s4=1 \\
-name windows-gvt-g-guest \\
-soundhw hda \\
-usb \\
-device usb-tablet \\
-display gtk,gl=on \\
-device vfio-pci,sysfsdev=/sys/devices/pci0000:00/0000:${GVT_PCI}/${GVT_GUID},x-igd-opregion=on,display=on \\
-drive file="/dev/sdb",format=raw,if=ide \\
-vga qxl \\
-nic none
EOF
chmod +x ${HOME}/qemu.sh
# Modify ${HOME}/qemu.sh at your own.
Wiki: https://wiki.archlinux.org/index.php/Intel_GVT-g
Details: https://www.reddit.com/r/VFIO/comments/8h352p/guide_running_windows_via_qemukvm_and_intel_gvtg/