Board logo

標題: [軟件] KVM with VT-d passthrough for gaming? (Benchmarked) [打印本頁]

作者: Sandbo    時間: 2016-2-13 01:00     標題: KVM with VT-d passthrough for gaming? (Benchmarked)

Benchmark result, i5-6600+AMD 7950

Virtual Machine:



Bare metal:


[ 本帖最後由 Sandbo 於 2016-2-21 03:06 編輯 ]
作者: YCST    時間: 2016-2-13 15:53

pass咩hardware入VM裡面?display card?
作者: Sandbo    時間: 2016-2-13 16:07

引用:
原帖由 YCST 於 2016-2-13 15:53 發表
pass咩hardware入VM裡面?display card?
Sorry for missing the focus out
Yes, mainly it is the graphics card (AMD HD 7950).

From the others it can give >95% of performance to the guest (given I use Intel IGP for Linux host).
作者: YCST    時間: 2016-2-13 16:22

剩係試過pass LAN卡同USB
作者: Sandbo    時間: 2016-2-13 17:25

引用:
原帖由 YCST 於 2016-2-13 16:22 發表
剩係試過pass LAN卡同USB
USB usually doesn't need VT-d, LAN card not sure.
I will try to give more details if I successfully play GTA V on Windows 10 guest
作者: YCST    時間: 2016-2-13 17:51

如果張LAN卡支援SR-IOV, 配合VT-d
Network 效能唔錯,降低d cpu usage
不過kvm 用virtio network driver,  cpu usage 都已經比其他driver 大大降低左
我玩kvm 都係因為起server, 所以都係試network 野多,display card 未試過
作者: dom    時間: 2016-2-14 01:39

Display 應該唔多夠力....
經左VMWare Player 後佢入面上Driver 都唔係show 翻 GTX970 反而係show SVGA 3D
作者: Sandbo    時間: 2016-2-14 02:28

引用:
原帖由 dom 於 2016-2-14 01:39 發表
Display 應該唔多夠力....
經左VMWare Player 後佢入面上Driver 都唔係show 翻 GTX970 反而係show SVGA 3D
依個就係有冇VT-d的分别
用VT-d好似真係pass到九成, 而且係直接 show張卡....想一陣試下,
但要 backup左部機先唔係一陣抄左 kernel就奶野

[ 本帖最後由 Sandbo 於 2016-2-15 04:42 編輯 ]
作者: Sandbo    時間: 2016-2-15 03:13

唉,好灰,整到天光都唔 work,一加 PCI device個vm就唔 boot

已經detach左AMD graphics+audio,再做埋vfio-bind,
就係唔work....可能會reset左個QEMU-KVM搞過哂……

Damn:
https://bugzilla.kernel.org/show_bug.cgi?id=107561

[ 本帖最後由 Sandbo 於 2016-2-15 12:46 編輯 ]
作者: Sandbo    時間: 2016-2-16 04:45

Working!
Not a kernel issue, but the point being having the PCI bridge in the same IOMMU group caused some complications in the passthrough.
Swapping the graphics card to PCI-E slot 2 solved the problem, and I can install AMD driver on guest.
作者: qcmadness    時間: 2016-2-16 04:47

引用:
原帖由 Sandbo 於 2016-2-16 04:45 發表
Working!
Not a kernel issue, but the point being having the PCI bridge in the same IOMMU group caused some complications in the passthrough.
Swapping the graphics card to PCI-E slot 2 solved the probl ...
Chipset problem?
作者: Sandbo    時間: 2016-2-16 05:36

引用:
原帖由 qcmadness 於 2016-2-16 04:47 發表

Chipset problem?
I can't tell, it seems in terms of IOMMU group, the PCI bridge is linked to whatever connected to PCI-E x16 slot 1 (it reports three devices in the IOMMU group), this is also the case for z97 so I don't think it's z170 bound.

Swapping to slot 2, the IOMMU group reported no components other than AMD graphics and audio (only 2 devices as oppose to 3 in the above case), then it worked.
One important point being for VT-d pass through, the whole group has always to be passed together.

[ 本帖最後由 Sandbo 於 2016-2-16 07:17 編輯 ]
作者: Sandbo    時間: 2016-2-16 11:12

?size_id=8
作者: Sandbo    時間: 2016-2-17 13:29

Exact reason for passthrough failure before:
Not the slot, but in fact the setting of CPU:
Nothing but host-passthrough (type manually) can work, if anyone concerns.
作者: Sandbo    時間: 2016-2-17 15:33


Exactly like on bare metal

[ 本帖最後由 Sandbo 於 2016-2-17 15:36 編輯 ]
作者: XT    時間: 2016-2-17 15:50

KVM for normal home using?

How to? I'm interesting
作者: Sandbo    時間: 2016-2-17 16:56

引用:
原帖由 XT 於 2016-2-17 15:50 發表
KVM for normal home using?

How to? I'm interesting
It's actually very simple,
you first need hardware supporting VT-d, that is your mainboard and CPU.
This can be checked, for Intel, http://ark.intel.com/, see if you can find VT-d in your CPU/mainboard chipset.
You also need 2 GPUs, 1 of them can be Intel Graphics, another is any discrete card.
At the end you need 2 video cables, connecting from both the Intel IGP and your discrete graphics card to the same monitor, or you can do a dual monitor setup like what I showed.

Then, follow this tutorial closely:
http://vfio.blogspot.ca/2015/05/ ... es-part-3-host.html
http://vfio.blogspot.ca/2015/05/ ... es-part-4-host.html

A shorter tutorial (which can be used without referring to the above two), is easier to follow but not using the best method (imho):
http://www.andrewklau.com/my-fed ... without-compromise/

And there is a good video showing the whole process from bare metal, he basically followed the first 2 links I gave:
https://www.youtube.com/watch?v=GtV_pYIgxOA

In short, here is what I did (just a general description, excluding detailed scripting, please refer to the above tutorials and their explanation are excellent)
1. Enable VT-d in BIOS/UEFI interface (suppose you have the mainboard+CPU, graphics card shouldn't matter except it's too old, I am using AMD HD7950)
2. In your Linux host, install the virtualization tools. I am using qemu-kvm and virt-manager, plus OVMF (installed separated from the normal qemu-kvm packages)
3. Then enable IOMMU and set to prevent the graphics card from being loaded by Linux host (meaning that the pass-through GPU cannot be used by Linux).
For step 3 I suggest you follow the first 2 links, Alex's blog. It outlined a more advanced method with a direct vfio-bind, without first passing the graphics to pci-stub.
4.You can then move on to set up the virtual machine, and add the PCI devices in virt-manager.
-When creating the virtual machine, don't start it right away, check the box to configure it first. Over there,
in Overview set the Firmware to UEFI instead of BIOS.
-(very important, spent me 3 days to figure out) In CPUs configuration, in Model, type host-passthrough.
Without this, the virtual machine will always boot into BSoD.
-You have to add both the graphics card's graphic processor and HD audio, so there will be 2 PCI devices to be added.
If after adding, the machine doesn't boot, try to uncheck the box in the PCI devices "ROM_BAR". My machine works only without them. It seems they are useful when you want to give it a specific ROM file.
5. If everything works, you should be able to enter Windows and see the cards there. Go ahead and install the driver, on installation completed successfully, the graphics card will start to generate signal output.

It will be better if you start by following the tutorial, and I can then help with specific issues that you might find (I have 3 days of experience LOL)
作者: dom    時間: 2016-2-17 17:10

引用:
原帖由 Sandbo 於 2016/2/17 15:33 發表

Exactly like on bare metal
竟然玩到?!!!
Performance hit 差幾多
作者: dom    時間: 2016-2-17 17:11

Damn ... B85 not support VT-D
要最高級既  x99 ...

[ 本帖最後由 dom 於 2016-2-17 17:13 編輯 ]
作者: Sandbo    時間: 2016-2-17 21:14

引用:
原帖由 dom 於 2016-2-17 17:10 發表


竟然玩到?!!!
Performance hit 差幾多
GTA V做到60fps,但就有時一疾,要睇下點tune,
今晚行轉3DMark再對比下bare metal performance
作者: tamalemon    時間: 2016-2-17 22:11

引用:
原帖由 dom 於 2016-2-17 17:11 發表
Damn ... B85 not support VT-D
要最高級既  x99 ...
即係點?
想玩vt-d只可以砌機?
作者: YCST    時間: 2016-2-17 23:30

引用:
原帖由 dom 於 2016-2-17 17:11 發表
Damn ... B85 not support VT-D
要最高級既  x99 ...
Q87同Q77都得
印象中夾到Skylake果隻底板就H系chipset都得
作者: YCST    時間: 2016-2-17 23:34

引用:
原帖由 Sandbo 於 2016-2-16 05:36 發表

I can't tell, it seems in terms of IOMMU group, the PCI bridge is linked to whatever connected to PCI-E x16 slot 1 (it reports three devices in the IOMMU group), this is also the case for z97 so I do ...
我太耐無玩都唔醒起
我以前都試過呢個問題
作者: XT    時間: 2016-2-18 00:14

引用:
原帖由 YCST 於 2016-2-17 23:30 發表

Q87同Q77都得
印象中夾到Skylake果隻底板就H系chipset都得
z77 係咪唔得 ...
作者: YCST    時間: 2016-2-18 00:16

引用:
原帖由 XT 於 2016-2-18 00:14 發表

z77 係咪唔得 ...
應該唔得
作者: XT    時間: 2016-2-18 00:16

引用:
原帖由 XT 於 2016-2-18 00:14 發表

z77 係咪唔得 ...
https://www-ssl.intel.com/conten ... ards/000005758.html

要check板
作者: dom    時間: 2016-2-18 01:18

引用:
原帖由 tamalemon 於 2016/2/17 22:11 發表


即係點?
想玩vt-d只可以砌機?
我粒 U 行到 VT-d (Core i7-4790) , 係chipset (B85) 無話support VT-d
但係 ASUS 係 BIOS 係有 VT-d support , 我又開左

[ 本帖最後由 dom 於 2016-2-18 01:22 編輯 ]
作者: Sandbo    時間: 2016-2-18 01:19

引用:
原帖由 XT 於 2016-2-18 00:16 發表

https://www-ssl.intel.com/conten ... ards/000005758.html

要check板
I think most boards after Haswell should just work, it's also the time the people started doing this.
作者: Sandbo    時間: 2016-2-18 01:23

引用:
原帖由 YCST 於 2016-2-17 23:34 發表

我太耐無玩都唔醒起
我以前都試過呢個問題
At the end it was my fault, I didn't follow strictly the tutorial to set the CPU model to "host-passthrough",
this is not in the drop down menu nor anywhere, I have to type it manually.

This is the only choice that allows a true passthrough of CPU configuration to the guest, any other options will have a mismatch and bring down the graphics once it's accessed.
作者: XT    時間: 2016-2-18 17:15

引用:
原帖由 Sandbo 於 2016-2-18 01:19 發表

I think most boards after Haswell should just work, it's also the time the people started doing this.
using e3 1245 v2
作者: dom    時間: 2016-2-18 18:33

引用:
原帖由 XT 於 2016/2/18 17:15 發表

using e3 1245 v2
Check your mainboard BIOS for VT-d enable...
作者: XT    時間: 2016-2-18 20:46

引用:
原帖由 dom 於 2016-2-18 18:33 發表


Check your mainboard BIOS for VT-d enable...
Asus 成堆 z77 得一個 vt option
作者: Sandbo    時間: 2016-2-19 00:39

對比返 bare metal, 個fire strike分竟然高左幾乎10%

PS: Buying a PCI USB3 card for the VM, that way I can pass the PCI card directly without using the Spice (which I believe would have performance hit)

[ 本帖最後由 Sandbo 於 2016-2-19 02:05 編輯 ]
作者: BlackBird    時間: 2016-3-18 17:29

引用:
原帖由 XT 於 2016-2-18 20:46 發表

Asus 成堆 z77 得一個 vt option
換塊assrock
作者: XT    時間: 2016-3-28 03:25

諗住SET好個CentOS介面, 之後裝AMD Driver準備試啦
佢老闆, 一裝完個rpm之後restart就炒晒

把幾火即裝 fedora 23
作者: Sandbo    時間: 2016-3-28 10:12

引用:
原帖由 XT 於 2016-3-28 03:25 發表
諗住SET好個CentOS介面, 之後裝AMD Driver準備試啦
佢老闆, 一裝完個rpm之後restart就炒晒

把幾火即裝 fedora 23

Actually there is no need to install AMD driver for host; (installing proprietary graphics card driver is not helpful and most of the time destructive, from my experience)
the graphics card is all the way belong to the guest and host should never access it.

The general idea is: Turn on VT-d --> Set in Grub to prevent the host from using the card (assigning the card to vfio) --> Tell the guest to use it when setting up the virtual machine.

Let me know in case you were stuck somewhere, I maybe able to help.

[ 本帖最後由 Sandbo 於 2016-3-28 10:18 編輯 ]




歡迎光臨 HKSpot (https://bbs.hk-spot.com/) Powered by Discuz! 6.0 Lite