KVM GPU 直通

KVM GPU 直通

现在我知道这个问题以前已经讨论过了,但是那些话题现在已经过时了。

因此,我最近一直在遵循一些不同的指南来使这个系统正常运行,主要是;

http://www.howtogeek.com/117635/how-to-install-kvm-and-create-virtual-machines-on-ubuntu/
http://www.pugetsystems.com/labs/articles/Multiheaded-NVIDIA-Gaming-using-Ubuntu-14-04-KVM-585/

到目前为止我还没有运气。我的系统包括:

Intel Xeon e3-1230V2 with VT-d
Asrock Fatal1ty Pro z77 with VT-d enabled
A nvida 9800gt - for main host
a gtx 780 for windows vm
a gtx 750ti for windows vm

使用第二个指南,我能够获得我想要的“由存根声明”的卡,但是我在尝试运行虚拟机时遇到了一个问题。

目前,我的系统将我的 780(设备 0000:01:00.0)与 9800gt(设备 0000:02:00.0)组合在一起,这告诉我,我无法运行虚拟机,因为我没有为其分配整个组。

我曾看到有人提到,安装 acs 覆盖补丁可能会通过将设备分成更小的组来允许我传递 GPU,但到目前为止,每个教程或主题都只是说“编译补丁”或“将此行添加到 grub cmd”。

我还没有看到任何地方解释如何在 ubuntu 14.04 上实际安装补丁或者我是否需要做任何其他事情。

还有其他人能让这一切顺利运行吗?

非常感谢大家的帮助,如果可能的话,请尽量解释得简单些。虽然我了解 Linux,但我并不是一下子就能理解的

注意:9800gt 实际上是系统中的第二张卡,它们的排列无法更改,因此默认显示设备目前为 780

编辑

我刚刚找到了这些 Debian 指南

修补

#!/bin/bash
# patch --dry-run --verbose -p 1 -i re_xxxxxxxxxxxxx

echo
echo ... PATCHING ... VGA Arbiter
patch -b -p 1 -i re_patch_01_i915_313rc4.patch
echo
echo ... PATCHING ... acs override
patch -b -p 1 -i re_patch_02_override_for_missing_acs_capabilities.patch
echo
echo ... PATCHING ... memleak
patch -b -p 1 -i re_patch_03_fix_memleak.patch
echo
echo ... PATCHING ... read DR6
patch -b -p 1 -i re_patch_04_fix_reading_of_DR6.patch
echo
echo ... PATCHING ... debug registers - has problem, needs to follow DR6 patch
patch -b -p 1 -i re_patch_05_debug_registers.patch
# patch -b -p 1 -i re_debug_registers_RE.patch   # Corrected to add additional lines before DR6 patch runs
echo
echo ... PATCHING ... kernel__gcc
patch -b -p 1 -i re_patch_06_kernel-38-gcc48-2.patch

编译

To compile a new kernel
https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel
https://help.ubuntu.com/community/Kernel/Compile
https://wiki.ubuntu.com/KernelTeam/KernelMaintenance
https://www.debian.org/releases/stable/i386/ch08s06.html.en

architecture is "amd64" or "x86_64"

1) download the source into the current directory using "apt-get source linux-image-xxxxx"  where xxxx is the name of the version eg. apt-get source linux-image-3.13.0-32-generic

This should download the tarball(s) and extract the source code into a directory (which should be renamed immediately because all versions use the same directory name !!!)

2) Open the new directory, clean up and prepare
  chmod a+x debian/scripts/*
  chmod a+x debian/scripts/misc/*
  fakeroot debian/rules clean

  and generate the required config by either -
  a) editing using "fakeroot debian/rules editconfigs"  (for all targets, one after another) ... or 
  b) "make menuconfig" and work through the various options. Remember to save before exit
  c) copy the current config from the boot directory as ".config" in the root direcotry for the new kernel and then use  "make oldconfig" ... which will ask a question for the value of each new config option

  Required config options are
    CONFIG_VFIO_IOMMU_TYPE1=y     in Device Drivers. 2 pages back from end
    CONFIG_VFIO=y
    CONFIG_VFIO_PCI=y
    CONFIG_VFIO_PCI_VGA=y
    CONFIG_PCI_STUB=y             in Bus Options, second page down
    HZ_1000=y                     in Processor Type & Features (last page)
    PREEMPT=voluntary

3) apply any patches /// remember to verify that they worked ok (look for fail)
   "sh re_apply_patches.sh > re_output_patch.txt"

4) "fakeroot debian/rules clean"   to remove any old build information / files

5) Ignore modules not created with new parameters ... copy re_modules.ignore to ...debian.master/abi/<previous-version>/modules.ignore

   and ignore other ABI errors by copying re_prevrelease_arch_ignore (rename to  "ignore") to debian.master/abi/<previous-version>/<arch>    eg. to debian.master/abi/3.13.0-32.56/amd64/

6) "DEB_BUILD_OPTIONS=parallel=3 skipmodule=true fakeroot debian/rules binary-headers binary-generic  > re_output_compile.txt"   to generate the deb files which can be installed (second thoughts don't pipe the poutput to a file - it will prevent selection of the CPU type)

7) Install all the Debs with command "sudo dpkg -i linux*<ver>*.deb
eg.   sudo dpkg -i linux*3.13.0-32_3.13.0-32.57*.deb
      sudo dpkg -i linux*3.13.0-32-generic_3.13.0-32.57*.deb

8) go into Synaptic and lock all the newly installed elements (linux-image*, linux-header*, linux-tool*, linx-cloud-tool*) - to prevent the new kernel and components being overwritten in the next upgrade

不确定这是否可以在 ubuntu 中工作?

答案1

我知道这个帖子实际上已有近三年的历史,但 ACS 覆盖补丁已过时,因为它已内置到 Ubuntu 内核 4.8 中。目前,通过在 ubuntu 16.04 LTS Xenial 上安装最新内核,apt-get install linux-generic-hwe-16.04您将获得内核 4.10,它将所有 PCI 设备完全拆分为单独的 IOMMU 组。因此,现在可以非常轻松地将显卡逐个传递到多个虚拟机。

相关内容