What's new

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

  • Thread starter Monopolyman
  • Start date
  • Views 184,264
E

EvilWiffles

Newbie
Messages
0
Reaction score
0
Points
35
Sin$
0
Nothing to say here really. You will need to check if your CPU supports VT-d/x. Also make sure you have integrated GPU to run Linux on or a second GPU. As long as you don't have some weird hardware peripheral, everything will probably work fine. Other than that, if you have time and the will to do it, backup your Windows partition and try to set it up.

You can also try Virt-manager to easily manage your VM.

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.
==> Verifying source file signatures with gpg...
linux-4.1.tar ... FAILED (unknown public key 79BE3E4300411886)
patch-4.1.22 ... FAILED (unknown public key 38DBBDC86092693E)
==> ERROR: One or more PGP signatures could not be verified!
I'm not savvy enough to know what I'd need to do without ripping out my hair at this point.
 
Last edited:
Monopolyman

Monopolyman

PC Gamer and Tech Enthusiast
Retired
Mr. Nice Guy Tutorial Creator Jokester
Messages
6,409
Reaction score
4,549
Points
1,105
Sin$
7
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.
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.
 
E

EvilWiffles

Newbie
Messages
0
Reaction score
0
Points
35
Sin$
0
Edit, fixed it.
Setting up qemu and trying to run it gives off
error: Failed to start domain gamingvm
error: internal error: /usr/lib/qemu/qemu-bridge-helper --br=br0 --fd=22: failed to communicate with bridge helper: Transport endpoint is not connected
 
Last edited:
E

EvilWiffles

Newbie
Messages
0
Reaction score
0
Points
35
Sin$
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:
F

Fragd

Newbie
Messages
0
Reaction score
0
Points
35
Sin$
-7
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
 
Odelpasso

Odelpasso

Newbie
Messages
0
Reaction score
0
Points
35
Sin$
7
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 :

odelpasso@debian64:~/Bureau/Qemu$ sudo ./CpuSet
cset: --> created cpuset "system"
cset: moving all tasks from root to /system
cset: moving 382 userspace tasks to /system
[==================================================]%
cset: done
cset: moving all kernel threads from / to /system
cset: moving 123 kernel threads to: /system
cset: --> not moving 58 threads (not unbound, use --force)
[==================================================]%
cset: **> 99 tasks are not movable, impossible to move
cset: done

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.
 
J

jaggernought

Newbie
Messages
0
Reaction score
0
Points
35
Sin$
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:
 
Monopolyman

Monopolyman

PC Gamer and Tech Enthusiast
Retired
Mr. Nice Guy Tutorial Creator Jokester
Messages
6,409
Reaction score
4,549
Points
1,105
Sin$
7
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:
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.
 
J

Jabor

Newbie
Messages
0
Reaction score
0
Points
35
Sin$
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!
 
J

jaggernought

Newbie
Messages
0
Reaction score
0
Points
35
Sin$
0
I get a permission error when starting the VM, it looks like qemu cannot access the vfio devices. Here's the error:

Error starting domain: internal error: qemu unexpectedly closed the monitor: 2016-07-06T22:35:49.474637Z qemu-system-x86_64: -device vfio-pci,host=1:00.1,bus=root.1,addr=00.0,multifunction=on,x-vga=on: vfio: error opening /dev/vfio/11: Operation not permitted
2016-07-06T22:35:49.474664Z qemu-system-x86_64: -device vfio-pci,host=1:00.1,bus=root.1,addr=00.0,multifunction=on,x-vga=on: vfio: failed to get group 11
2016-07-06T22:35:49.474669Z qemu-system-x86_64: -device vfio-pci,host=1:00.1,bus=root.1,addr=00.0,multifunction=on,x-vga=on: Device initialization failed

Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 88, in cb_wrapper
callback(asyncjob, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 124, in tmpcb
callback(*args, **kwargs)
File "/usr/share/virt-manager/virtManager/libvirtobject.py", line 83, in newfn
ret = fn(self, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/domain.py", line 1404, in startup
self._backend.create()
File "/usr/lib/python2.7/site-packages/libvirt.py", line 1035, in create
if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirtError: internal error: qemu unexpectedly closed the monitor: 2016-07-06T22:35:49.474637Z qemu-system-x86_64: -device vfio-pci,host=1:00.1,bus=root.1,addr=00.0,multifunction=on,x-vga=on: vfio: error opening /dev/vfio/11: Operation not permitted
2016-07-06T22:35:49.474664Z qemu-system-x86_64: -device vfio-pci,host=1:00.1,bus=root.1,addr=00.0,multifunction=on,x-vga=on: vfio: failed to get group 11
2016-07-06T22:35:49.474669Z qemu-system-x86_64: -device vfio-pci,host=1:00.1,bus=root.1,addr=00.0,multifunction=on,x-vga=on: Device initialization failed

Not sure what I should do to fix this, any suggestions? 
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!

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.
 
R

RecursiveDelta

Newbie
Messages
0
Reaction score
0
Points
35
Sin$
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!
 
G

Gerrit Hartwig

Newbie
Messages
0
Reaction score
5
Points
45
Sin$
7
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
 
R

RecursiveDelta

Newbie
Messages
0
Reaction score
0
Points
35
Sin$
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?
 
G

Gerrit Hartwig

Newbie
Messages
0
Reaction score
5
Points
45
Sin$
7
I changed from...
<emulator>/usr/bin/qemu-system-x86_64</emulator>
to...
<emulator>/usr/local/bin/qemu-system-x86_64</emulator>
 
G

Gerrit Hartwig

Newbie
Messages
0
Reaction score
5
Points
45
Sin$
7
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
 
R

RecursiveDelta

Newbie
Messages
0
Reaction score
0
Points
35
Sin$
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.
 
Jaykae

Jaykae

Removed
Grammar Nazi Hardened Veteran Reporter
Messages
2,273
Reaction score
1,623
Points
540
Sin$
0
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:
 
G

Gerrit Hartwig

Newbie
Messages
0
Reaction score
5
Points
45
Sin$
7
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
 
E

ELR77

Newbie
Messages
0
Reaction score
3
Points
45
Sin$
0
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.

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:
E

ELR77

Newbie
Messages
0
Reaction score
3
Points
45
Sin$
0
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


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
 
Top Bottom
Login
Register