QEMU Virtual Machine Installation - LeandroTheDev/arch_linux GitHub Wiki
- 
sudo pacman -S qemu-full virt-manager virt-viewer dnsmasq vde2 bridge-utils openbsd-netcat ebtables iptables 
- 
Enable libvirtd 
- 
sudo systemctl enable libvirtd 
- 
Add you to the libvirt groups 
- 
sudo usermod -aG libvirt $USER 
- 
Restart your system 
- 
sudo reboot now 
- sudo virsh net-start default
- sudo virsh net-autostart default
- 
TPM Dependency 
- sudo pacman -S swtpm
- Open virt-manager
- Open your VM
- Show virtual hardware details
- Add Hardware
- TPM
 
- 
Download Fedora available secure boot for linux 
- auracle clone edk2-ovmf-fedora-bin
- 
If the secure boot is not auto enabled in your machine, go to xml and find for: 
<os firmware="efi">
    <type arch="x86_64" machine="pc-q35-10.1">hvm</type>
    <firmware>
      <feature enabled="no" name="enrolled-keys"/> <!-- ADD THIS -->
      <feature enabled="yes" name="secure-boot"/> <!-- ADD THIS -->
    </firmware>
    <loader readonly="yes" secure="yes" type="pflash" format="raw">/usr/share/edk2/x64/OVMF_CODE.secboot.4m.fd</loader> <!-- ADD THIS -->
    <nvram template="/usr/share/edk2/x64/OVMF_VARS.4m.fd" templateFormat="raw" format="raw">/var/lib/libvirt/qemu/nvram/VIRTUALMACHINENAME!!!!!!_VARS.fd</nvram> <!-- ADD THIS -->
  </os>- Don't forget to add the machine name in !
This methods creates a virtual GPU for the VM (slow performance also not support nvidia gpus)
- Open virt-manager
- Open your VM
- Show virtual hardware details
- Display Spice
- 
  
- Add Hardware
- Video
- Model = Virtio
- 
  
- If your VM uses Windows consider installing: VirtIO Drivers
This methods completly remove your gpu from the main host machine, and put it on VM Unfortunately to this works you will need a secondary gpu
- go to BIOS in your system
- enable virtualization
- enable IOMMU
Get the GPU id and GPU audio id, find than and save it, this is the gpu used for the main linux
- lspci -nn / NVIDIA simple: lspci -nn | grep "NVIDIA"
ID Example
[0030]: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] [10de:1b06] <-- this is the graphics id
[0030]: NVIDIA Corporation GP102 HDMI Audio Controller [10de:10ef] <-- this is the audio id
Enabling IOMMU in grub
- sudo vim /etc/default/grub
#AMD for AMD intel for intel..., change the id by the one you get from previous section
GRUB_CMDLINE_LINUX_DEFAULT="amd/intel_iommu=on vfio-pci.ids=graphicsId,audioId"
- sudo update-grub
- reboot
Now pickup the id from your integrated gpu or secondary gpu, this is the gpu used for virtual machine Add the ids in vfio
- sudo vim /etc/modprobe.d/vfio.conf
options vfio-pci ids=graphicsId,audioId
#This is not necessary but if you having problems try this, i dont know what this does but maybe your games outside the VM stop working
softdep nvidia pre: vfio-pci
Rebuilt init
- sudo mkinitcpio -p linux
- reboot
Open your virtual manager and check somethings
- chipset: Q35
- firmware: UEFI
Add new PCI Host device
Graphics
- 0000:001:... [NVIDIA]...
Audio
- 0000:002:... [NVIDIA]...
- have fun