How to setup a gaming virtual machine with GPU passthrough (QEMU, KVM, libvirt, and VFIO)

Discussion in 'Linux' started by Monopolyman, Aug 18, 2015 with 161 replies and 148,904 views.

  1. EvilWiffles

    EvilWiffles Newbie

    Messages:
    4
    Ratings:
    0
    Can I create a new partiton on my C drive for this, so I don't have to touch Windows partition? Anyways, I think I'll try Antergos since Archlinux installation looks like a pain to go through, especially partitioning.

    Edit, I have Antergos but I can't use pacaur -S qemu libvirt bridge-utils linux-vfio-lts without errors.
    I'm not savvy enough to know what I'd need to do without ripping out my hair at this point.
     
    Last edited: Apr 23, 2016
  2. OP
    Monopolyman

    Monopolyman PC Gamer and Tech Enthusiast Retired

    Messages:
    6,525
    Ratings:
    4,339
    Strange that you don't have those keys. Try running "gpg --recv-key 79BE3E4300411886" and "gpg --recv-key 38DBBDC86092693E" and see if that fixes the issue.
     
  3. EvilWiffles

    EvilWiffles Newbie

    Messages:
    4
    Ratings:
    0
    Edit, fixed it.
    Setting up qemu and trying to run it gives off
     
    Last edited: Apr 24, 2016
  4. EvilWiffles

    EvilWiffles Newbie

    Messages:
    4
    Ratings:
    0
    Just an update, I have everything up and running but not with libvirt/libvirt-manager. It started working when I reinstalled it but by then, I was using CLI.
    - my cli

    Only issue is low FPS and FPS drips. Dead Space 2 for instance drops to 40 FPS on my GTX 970+4790k setup. Dark Souls 3 does the same.
    Is there any optimizations that I can do?

    Edit, think I solved it by using only 3 cores. I believe the fourth one was being emulated.
     
    Last edited: Apr 28, 2016
  5. Fragd

    Fragd Newbie

    Messages:
    1
    Ratings:
    0
    I have followed the first post to the letter 3 times and everything looks right to me. I'm not sure what i'm missing.
    Been working on this for a couple days and no matter what I try I get
    Code:
    dmesg | grep vfio
    [  9.062641] vfio-pci: probe of 0000:09:00.0 failed with error -22
    [  9.062647] vfio_pci: add [10de:13c0[ffff:ffff]] class 0x000000/00000000 
    [  9.062661] vfio-pci: probe of 0000:09:00.0 failed with error -22 
    [  9.062667] vfio-pci: probe of 0000:09:00.1 failed with error -22 
    [  9.062670] vfio_pci: add [10de:0fbb[ffff:ffff]] class 0x000000/00000000
    
    I think this is because the card is still attached and NVIDIA is loading first?

    Code:
    lspci -nnk | grep -i nvidia                                                                                            
    01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GM206 [GeForce GTX 960] [10de:1401] (rev a1)       
            Kernel driver in use: nvidia                                                                                                             
            Kernel modules: nouveau, nvidia                                                                                                          
    01:00.1 Audio device [0403]: NVIDIA Corporation Device [10de:0fba] (rev a1)                                                              
    09:00.0 VGA compatible controller [0300]: NVIDIA Corporation GM204 [GeForce GTX 980] [10de:13c0] (rev a1)      
            Kernel driver in use: nvidia                                                                                                             
            Kernel modules: nouveau, nvidia
    09:00.1 Audio device [0403]: NVIDIA Corporation GM204 High Definition Audio Controller [10de:0fbb] (rev a1)
    I added
    Code:
    MODULES="vfio vfio_iommu_type1 vfio_pci vfio_virqfd"
    To mkinitcpio.conf and it still shows the card being used by the NVIDIA driver.
    In a last ditch effort I Installed linux-vfio-lts and I still have the error 22's

    Any help is greatly appreciated
    Fragd
     
  6. Odelpasso

    Odelpasso Newbie

    Messages:
    1
    Ratings:
    0
    Hi,

    MonopolyMan, i follow you first port about the CPU pinning in libvirt. But, when i launch your script before the VM, i have this message :

    I would like to know if these message are normal. Because in fact, if I use 2 Nvidia GPU, one for the Host and one for the Guest (Win10), i have glitches, corruption and freeze in the Guest and the system is not usable.
     
  7. jaggernought

    jaggernought Newbie

    Messages:
    2
    Ratings:
    0
    Hi,

    Firstly thanks for the great guide!

    I've followed it to the end but when it comes to starting the virtual machine I get the error

    + virsh start gamingvm
    error: Failed to start domain gamingvm
    error: unsupported configuration: IDE controllers are unsupported for this QEMU binary or machine type

    My host will be Arch with i5-4660 intergrated graphics
    My guest will be Windows 10 with AMD r9 270 GPU.

    Thanks for any help :smile:
     
  8. OP
    Monopolyman

    Monopolyman PC Gamer and Tech Enthusiast Retired

    Messages:
    6,525
    Ratings:
    4,339
    I saw you posted on the subreddit, but I'll reply here incase anyone has the same issue. In your XML change where it says bus="ide" to bus="sata". I have updated the tutorial to fix this.
     
  9. Jabor

    Jabor Newbie

    Messages:
    1
    Ratings:
    0
    Hi,
    this is my first VM, so maybe I'm overlooking something obvious, but I've run into two problems:

    1: When I try to start the vm with the script, it says
    Code:
    + echo 1
    + virsh start gamingvm
    error: Failed to start domain gamingvm
    error: unsupported configuration: bus must be 0 for ide controller
    
    ++ virsh list
    ++ grep gamingvm
    + [[ '' == '' ]]
    + exit 0
    I guess this is connected to the problem jaggernought posted a few weeks ago, but I'm confused - according to the opening post it seems like I do not need an IDE controller? I've tried guessing and changed the bus of the first file to "ide", but it didn't change the error message. The - I guess - relevant part of my xml file is
    Code:
     <disk type="file" device="cdrom">
      <driver name="qemu" type="raw" />
      <source file="/home/lukas/windows/win10.iso" />
      <target dev="hdc" bus="sata" />
      <readonly />
      <address type="drive" controller="0" bus="1" unit="0" />
      </disk>
      <disk type="file" device="disk">
      <source file="/windows/win10ssd.img" />
      <target dev="vda" bus="sata" />
      <address type="drive" bus="0" />
      </disk>
      <disk type="file" device="disk">
      <source file="/home/lukas/windows/win10.img" />
      <target dev="vdb" bus="sata" />
      <address type="drive" bus="1" />
      </disk>
      </devices>
    2.: I've skipped a part of step 9 as it didn't work for me:
    On this new installation I at first didn't have a file in /etc/netctl, but creating one for the ethernet didn't change much (though the boot is about 3 seconds slower) - but as soon as I enable the bridge connection and reboot, I do not get a connection to the internet anymore.
    My "normal" ethernet file:
    Code:
    Description='A basic dhcp ethernet connection'
    Interface=enp3s0
    Connection=ethernet
    IP=no
    #IP=dhcp
    and the bridge file:
    Code:
    Description="Bridge connection"
    Interface=br0
    Connection=bridge
    BindsToInterfaces=(enp3s0)
    IP=static
    Address='192.168.1.202/24'
    Gateway='192.168.1.1'
    ## Ignore (R)STP and immediately activate the bridge
    SkipForwardingDelay=yes
    I haven't worked with netctl or networks in general too much, so this might again be something obvious.
    Of course I'll provide any additional information necessary. Thanks for help for any of the two problems!
     
  10. jaggernought

    jaggernought Newbie

    Messages:
    2
    Ratings:
    0
    I get a permission error when starting the VM, it looks like qemu cannot access the vfio devices. Here's the error:

    Not sure what I should do to fix this, any suggestions?[DOUBLEPOST=1467844742][/DOUBLEPOST]
    Hi, instead of configuring my disks in the xml file I defined the machine without them (just deleted the xml nodes). Then I used virt-manager (from the AUR) to add storage on.
     
  11. RecursiveDelta

    RecursiveDelta Newbie

    Messages:
    3
    Ratings:
    0
    Hello, First off thanks for the guide. It has been an amazing tool in getting something I've wanted to do for a long time to work.

    Now the fun part - I have everything (besides audio, that can come later) working to the point of a bios boot screen. The issue is booting from an iso for install. I see the bios line confirming the boot material and it acts as if it's doing so.... and the screen just stays black forever (i've waited 20/30 minutes). I saw a previous comment about something like this and added the cputune settings, nothing has changed. I also saw that person mention an issue with linux 4.2, which 4.3 fixed. I'm on 4.7, so there's nothing for me to update to! Any help is appreciated, thanks!
     
  12. Gerrit Hartwig

    Gerrit Hartwig Newbie

    Messages:
    6
    Ratings:
    5
    Hi,

    I guess you are working with Qemu 2.6.0.1 and arch or arch based derivat? With this version I had this issue too and could only solve it by using qemu 2.7.0-rc2 (http://wiki.qemu.org/Download) . So I compiled it and changed path to qemu in XML file.

    Greetz
     
    • Like Like x 2
  13. RecursiveDelta

    RecursiveDelta Newbie

    Messages:
    3
    Ratings:
    0
    Thanks for the info Gerrit! I never would have figured that out. I'm compiling the new qemu right now!

    What path did you change btw?
     
  14. Gerrit Hartwig

    Gerrit Hartwig Newbie

    Messages:
    6
    Ratings:
    5
    I changed from...
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    to...
    <emulator>/usr/local/bin/qemu-system-x86_64</emulator>
     
    • Like Like x 2
  15. Gerrit Hartwig

    Gerrit Hartwig Newbie

    Messages:
    6
    Ratings:
    5
    additional:
    For me the sound is not working on qemu 2.7.0-rc2. My workaround is:

    1. Compiling 2.7.0-rc2 and change path in xml
    2. Install WIndows 10 in VM
    3. Change path in xml back to 2.6.0.1

    For me it is working with installed OS and 2.6.0.1 but only installation is not working
     
    • Like Like x 1
  16. RecursiveDelta

    RecursiveDelta Newbie

    Messages:
    3
    Ratings:
    0
    Thanks for the info! I found just now so far that even with windows installed, I can't boot this 2.6, so for now i'll keep the 2.7. Hopefully I can find a way to get audio to work until 2.6 is patched/2.7 is released to repo.
     
  17. Jaykae

    Jaykae Member

    Messages:
    1,975
    Ratings:
    964
    Forgive me for being a noob...

    I have just built a new system with an i3 6100 and I plan on buying a GTX 1060.
    Can I use this for gaming with virtualbox and windows 10? or should I just dual boot with windows?!


    I'm using a 64bit ArchLinux distro. I have virtualbox installed and the addon package installed.

    Waiting for your reply. :smile:
     
  18. Gerrit Hartwig

    Gerrit Hartwig Newbie

    Messages:
    6
    Ratings:
    5
    for all using arch based distro with this tutorial:

    since libvirt 3.0.0.1 is online in repo of arch I had problems starting my vm. After setting loglevel to debug for libvirtd I found out that it sticks together with following bug.

    http://www.spinics.net/linux/fedora/libvir/msg141586.html

    The mentioned workaround ist working for me.

    Maybe it is helpful for one or the other.

    Regards
    GertPfert
     
  19. ELR77

    ELR77 Newbie

    Messages:
    16
    Ratings:
    3
    Hi
    I recently installed the latest version of Apricity OS (an Arch based distro) and I am also getting issues with the keys installing vifo and the acs patch.
    I end up with this error
    Code:
    Verifying source file signatures with gpg...
        linux-4.4.tar ... FAILED (unknown public key 79BE3E4300411886)
        patch-4.4.32 ... FAILED (unknown public key 38DBBDC86092693E)
    ==> ERROR: One or more PGP signatures could not be verified!
    :: failed to verify linux-vfio-lts integrity
    I try running the code to fetch the keys as you said but end up with a

    Code:
    gpg: keyserver receive failed: No keyserver available
    I am completely lost on this. Is there a way to force make to ignore these checks, they are very annoying, from searching online a lot of people have the same issue with these keys and there's no universal solution.

    Last night I wiped my Apricity OS install and replaced it with Manjaro 16.10.3 and still have the same issue with the public keys not existing anywhere
     
    Last edited: Feb 14, 2017
  20. ELR77

    ELR77 Newbie

    Messages:
    16
    Ratings:
    3

    I managed to get a solution to the problem now from the Manjaro forum. It was to do with the keyservers. For some reason, the install defaulted to just 2 keyservers and neither had the public keys

    The full description is on this link

    https://forum.manjaro.org/t/failed-to-verify-linux-vfio-lts-integrity/17641/2
     

Share This Page