0

KVM (Kernel Virtual Machine) Ubuntu 18.04 MSI MPG x570 Gaming Plus Ryzen 5 3600 Nvidia RTX 2070 Super

I am utilizing GPU passthrough, the purpose of this setup is to give me optimal performance in gaming, as well as maintaining the ability to have Ubuntu as my main platform. This will give me the ability to distro-hop and test out my skills on harder distros without nuking and paving.

The issue I have ran in to that I am having troubles with, is that my Windows 10 guest that I will be primarily using for gaming is not seeing any hyperthreading going on, I'm looking in to this because I've noticed frame rate drops as low as 50-70 fps than prior to virtualizing and big frame drops that almost appear as mini lag spikes, I know I will see performance loss but I want to do all that I can for maximum performance.

When I was utilizing the default container qemu, I was getting errors after changing settings in the xml file that said

qemu-system-x86_64: AMD CPU doesn't support hyperthreading. Please configure -smp options properly.

This error went away when I updated to qemu 4.1.0, although in my windows guest I can confirm hyperthreading is not being seen by utilizing the commands

wmic 
CPU GET NumberOfCores,NumberOfLogicalProcessors /Format:List

Number of cores and logical processors match, indicating Windows sees all threads as real cores.

I found numerous articles I've been chasing online for the past couple days attempting to make something work, although I have not had any success.

I initially followed this guide

After that all my further edits have either been to resolve error code 43. and then cpu pinning mostly.

My motherboard has 3 seperate sata controllers, so I have one of the sata controllers (2 drives, ssd and hdd) passed directly through. The GPU is passed directly through, numerous USB are passed directly through. My host is running a 2GB Nvidia Quadro card.

Any direction would be greatly helpful.

XML Config file

<domain type='kvm'>
  <name>Windows10</name>
  <uuid>de7e92c8-cde1-4722-a20d-a3c791db265e</uuid>
  <memory unit='KiB'>12386304</memory>
  <currentMemory unit='KiB'>12386304</currentMemory>
  <vcpu placement='static'>8</vcpu>
  <iothreads>4</iothreads>
  <cputune>
    <vcpupin vcpu='0' cpuset='4'/>
    <vcpupin vcpu='1' cpuset='5'/>
    <vcpupin vcpu='2' cpuset='6'/>
    <vcpupin vcpu='3' cpuset='7'/>
    <vcpupin vcpu='4' cpuset='8'/>
    <vcpupin vcpu='5' cpuset='9'/>
    <vcpupin vcpu='6' cpuset='10'/>
    <vcpupin vcpu='7' cpuset='11'/>
    <iothreadpin iothread='1' cpuset='4-5'/>
    <iothreadpin iothread='2' cpuset='6-7'/>
    <iothreadpin iothread='3' cpuset='8-9'/>
    <iothreadpin iothread='4' cpuset='10-11'/>
  </cputune>
  <os>
    <type arch='x86_64' machine='pc-i440fx-bionic'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/Windows10_VARS.fd</nvram>
    <bootmenu enable='no'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
      <vendor_id state='on' value='1234567890ab'/>
    </hyperv>
    <kvm>
      <hidden state='on'/>
    </kvm>
    <vmport state='off'/>
  </features>
  <cpu mode='host-passthrough' check='none'>
    <topology sockets='1' cores='4' threads='2'/>
    <cache level='3' mode='emulate'/>
    <feature policy='require' name='topoext'/>
  </cpu>
  <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
    <timer name='hypervclock' present='yes'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/usr/bin/kvm-spice</emulator>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/home/terry/Downloads/Win10_1903_V1_English_x64.iso'/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/home/terry/.kvm/virtio/virtio-win-0.1.141.iso'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </controller>
    <interface type='network'>
      <mac address='52:54:00:fb:32:91'/>
      <source network='default'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <channel type='spicevmc'>
      <target type='virtio' name='com.redhat.spice.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='tablet' bus='usb'>
      <address type='usb' bus='0' port='1'/>
    </input>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <sound model='ich6'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </sound>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x2d' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x2d' slot='0x00' function='0x1'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x2d' slot='0x00' function='0x2'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x2d' slot='0x00' function='0x3'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x2a' slot='0x00' function='0x1'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x2a' slot='0x00' function='0x3'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x26' slot='0x00' function='0x0'/>
      </source>
      <boot order='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0f' function='0x0'/>
    </hostdev>
    <redirdev bus='usb' type='spicevmc'>
      <address type='usb' bus='0' port='2'/>
    </redirdev>
    <redirdev bus='usb' type='spicevmc'>
      <address type='usb' bus='0' port='3'/>
    </redirdev>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </memballoon>
  </devices>
</domain>

Research I have found and referenced to some extent thus far, is below.

http://mathiashueber.com/cpu-pinning-on-amd-ryzen/#comments
https://www.reddit.com/r/VFIO/comments/9iukj5/whats_best_practice_for_ryzen_1800x_cpu_pinning/

This claims since numa is on auto already that emulatorpin is not necessary, so I removed emulatorpin from my xml.

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_tuning_and_optimization_guide/sect-Virtualization_Tuning_Optimization_Guide-NUMA-NUMA_and_libvirt#sect-Virtualization_Tuning_Optimization_Guide-NUMA-NUMA_and_libvirt-Using_emulatorpin



https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_tuning_and_optimization_guide/sect-virtualization_tuning_optimization_guide-numa-numa_and_libvirt

And I have tried with CPU model of Epyc as well as host-model with similar results

0

Well, I literally ran miles in a circle around my answer.

As my initial guide says at the bottom of building qemu 3.1 section

When this is done you can later use:

<os>
  ...
  <type arch='x86_64' machine='pc-q35-3.1'>hvm</type>
  ...
</os>
and

<devices>
  ...
  <emulator>/usr/local/bin/qemu3.1-system-x86_64</emulator>
  ...
</devices>

I didn't understand what this stuff meant though, so the machine type having the "3.1" at the end stood out as he was installing version 3.1, after more digging around the internet I found people saying that's the patched version to boot, it is not applied by default nor listed in virtual manager. I am not utilizing q35, but by running

/usr/local/bin/qemu-system-x86_64 -machine help

This gave me supported machine types, where I saw mine and utilized the 4.1 corresponding.

the next piece of this is specifying the emulator. We now want the new downloaded 4.1 qemu-system-x86_64 to emulate. Therefore this needs to be defined as well.

This one guide of his pretty much gets everything set if you pay attention to detail, which I do not feel I did.

I hope this can help others in the future. Goodluck

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.