March 4, 2019


Linux VM setup notes


My current version:
OS: Manjaro 18.0.3 Illyria
Kernel: x86_64 Linux 4.19.24-1-MANJARO

Let's run win10 in a VM. Install these pkgs:

sudo pacman -S virt-manager libvirt qemu vde2 ebtables dnsmasq bridge-utils openbsd-netcat ovmf


Edit this file, append to end.
/etc/libvirt/qemu.conf
nvram = [ "/usr/share/ovmf/x64/OVMF_CODE.fd:/usr/share/ovmf/x64/OVMF_VARS.fd" ]

Edit this file on line 7:
/etc/mkinitcpio.conf
MODULES=(vfio vfio_iommu_type1 vfio_pci vfio_virqfd)

And modconf should be in HOOKS=()

Edit this file on line 5:
/etc/default/grub and add intel_iommu=on somewhere

GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on rd.udev.log-priority=3"

sudo mkinitcpio -g /boot/initramfs-4.19-x86_64.img && sudo grub-mkconfig -o /boot/grub/grub.cfg

Virtual Machine Manager: > details > CPUs > configuration > model: host-passthrough And uncheck 'Copy host CPU configuration'.
You're done!

Start the service. Run Virtual Machine Manager (or in shell virt-manager).

sudo systemctl start libvirtd

Setup GPU passhthrough (optional)


I wasn't happy with using QXL beacuse it limits Virtual Machine Manager to 1920x1080, and it's laggy.
I installed my 2nd GPU (Nvidia 1060).
Follow this guide for a few steps: wiki.archlinux.org

You have to go Settings > Add hardware > PCI Host device
...and add your video card (both the VGA part and the audio part)

Create this file and add a single line:
/etc/modprobe.d/vfio.conf
options vfio-pci ids=10de:1c02,10de:10f1

Run a few shell commands to get those id's as seen.
Grab both the ID's from the VGA and audio device on the GPU. Mine was a Nvidia 1060, so it was on this line:
GP106 [GeForce GTX 1060 3GB]

          <hyperv>
            <relaxed state='on'/>
            <vapic state='on'/>
            <spinlocks state='on' retries='8191'/>
            <vendor_id state='on' value='whatever'/>
          </hyperv>
          <kvm>
            <hidden state='on'/>
          </kvm>
          
            
          
        

The above XML tags are located in the file /etc/libvirt/qemu/win10.xml

sudo subl win10.xml

You may need to copy the above XML data, but before you do don't overwrite it. Edit the file then save as... another name (win11.xml).
Then run the cmd:

sudo virsh define win11.xml



Reset from virtio to QXL


Ok, what if I dont like GPU passthrough and having to toggle HDMI or input modes on secondary monitor? Leave virtio and return to QXL by following a few steps:
1. Settings > Video > choose QXL
2. Remove hardware PCI devices (GPU)