0

我目前正在尝试将我的 nvidia GPU 设置为 Windows 来宾。我实际上正在使用拱门

这是我到目前为止所做的以及我面临的问题:

启用 iommu

dmesg|grep -i iommu
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-linux root=UUID=0b58f681-aba7-4bdd-983a-c3fb9e69201e rw cryptdevice=/dev/nvme0n1p2:cryptroot cryptkey=rootfs:/crypto/root.key intel_iommu=on iommu=pt nouveau.blacklist=1 quiet
[    0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-linux root=UUID=0b58f681-aba7-4bdd-983a-c3fb9e69201e rw cryptdevice=/dev/nvme0n1p2:cryptroot cryptkey=rootfs:/crypto/root.key intel_iommu=on iommu=pt nouveau.blacklist=1 quiet
[    0.000000] DMAR: IOMMU enabled
[    0.039812] DMAR-IR: IOAPIC id 2 under DRHD base  0xfed91000 IOMMU 1
[    0.608811] iommu: Adding device 0000:00:00.0 to group 0
[    0.608819] iommu: Adding device 0000:00:01.0 to group 1
[    0.608824] iommu: Adding device 0000:00:02.0 to group 2
[    0.608829] iommu: Adding device 0000:00:04.0 to group 3
[    0.608838] iommu: Adding device 0000:00:14.0 to group 4
[    0.608842] iommu: Adding device 0000:00:14.2 to group 4
[    0.608850] iommu: Adding device 0000:00:15.0 to group 5
[    0.608854] iommu: Adding device 0000:00:15.1 to group 5
[    0.608860] iommu: Adding device 0000:00:16.0 to group 6
[    0.608865] iommu: Adding device 0000:00:17.0 to group 7
[    0.608876] iommu: Adding device 0000:00:1c.0 to group 8
[    0.608886] iommu: Adding device 0000:00:1c.4 to group 9
[    0.608897] iommu: Adding device 0000:00:1c.5 to group 10
[    0.608907] iommu: Adding device 0000:00:1d.0 to group 11
[    0.608919] iommu: Adding device 0000:00:1f.0 to group 12
[    0.608924] iommu: Adding device 0000:00:1f.2 to group 12
[    0.608928] iommu: Adding device 0000:00:1f.3 to group 12
[    0.608933] iommu: Adding device 0000:00:1f.4 to group 12
[    0.608936] iommu: Adding device 0000:01:00.0 to group 1
[    0.608947] iommu: Adding device 0000:3b:00.0 to group 13
[    0.608957] iommu: Adding device 0000:3c:00.0 to group 14
[    0.608963] iommu: Adding device 0000:3d:00.0 to group 15

gpu的iommu组

IOMMU Group 1 00:01.0 PCI bridge [0604]: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16) [8086:1901] (rev 05)
IOMMU Group 1 01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP106M [GeForce GTX 1060 Mobile 3GB] [10de:1c20] (rev a1)

启用 vfio

lspci -k 
01:00.0 VGA compatible controller: NVIDIA Corporation GP106M [GeForce GTX 1060 Mobile 3GB] (rev a1)
    Kernel driver in use: vfio-pci
    Kernel modules: nouveau

libvirt 虚拟机配置

<domain type='kvm'>
  <name>windows10-gaming</name>
  <uuid>826da537-6982-40e3-a51c-f308d2c76c85</uuid>
  <memory unit='KiB'>8388608</memory>
  <currentMemory unit='KiB'>8388608</currentMemory>
  <vcpu placement='static'>4</vcpu>
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.11'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/ovmf/ovmf_code_x64.bin</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/windows10-gaming_VARS.fd</nvram>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
    </hyperv>
    <kvm>
      <hidden state='off'/>
    </kvm>
    <vmport state='off'/>
  </features>
  <cpu mode='host-passthrough' check='none'/>
  <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/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/home/guy/virtu/windows10-gaming.qcow2'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </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:96:d8:8e'/>
      <source network='default'/>
      <model type='rtl8139'/>
      <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'/>
    <graphics type='spice' autoport='yes'>
      <listen type='address'/>
      <image compression='off'/>
    </graphics>
    <sound model='ich6'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </sound>
    <video>
      <model type='vga' vram='16384' heads='1' primary='yes'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' 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='0x07' function='0x0'/>
    </memballoon>
  </devices>
</domain>

但是当客人启动我得到这个错误

2018-01-11T19:57:45.154191Z qemu-system-x86_64: vfio-pci: Cannot read device rom at 0000:01:00.0

设备选项 ROM 内容可能无效(检查 dmesg)。使用 rombar=0 跳过选项 ROM 探测,或使用 romfile= 从文件加载

我发现我应该能够转储这个 romfile 购买阅读足够的文件

[root@pc-guy guy]# cat /sys/bus/pci/devices/0000\:00\:01.0/0000\:01\:00.0/rom 
cat: '/sys/bus/pci/devices/0000:00:01.0/0000:01:00.0/rom': Erreur d'entrée/sortie

“输入/输出错误”(英文)

由于这个解决方案没有奏效,我试图从内存中读取它,我应该能够转储它,但我需要他在内存中的地址位置。我应该用 grep 'Video ROM' /proc/iomem找到它,但这个命令什么也不返回

我现在被卡住了,我正在寻找一种解决方案来使这个 gpu 直通工作,我不明白出了什么问题,欢迎提出每一个建议

4

2 回答 2

0

据我所知,你试图通过笔记本上的东西?这将是困难的,甚至是不可能的。您可以从https://www.techpowerup.com/vgabios/189965/189965获取 bios (也许您需要从中缩小一些起始字节,请查看https://github.com/Matoking/NVIDIA-vBIOS-VFIO -Patcher/blob/master/nvidia_vbios_vfio_patcher.py供参考)。但即使您启动 wm,nvidia 控制面板很可能会显示没有显示器连接到您的适配器。

笔记本上的通道通常是个坏主意,由于集成 gpu 和独立 gpu 之间共享屏幕的方式,在大多数情况下,如果独立 gpu 传递给 VM,它将无法使用 HDMI 端口或笔记本屏幕。暂时忘记它。

于 2018-02-08T22:59:43.240 回答
-1

在您的引导条目中,您应该有vfio-pci.ids=10de:1c20您的选项。10de:1c20我从您的dmesg输出中看到了您的 pci-id 值。通过运行验证这一点,lcpci -nn并添加与显卡一起使用的音频设备 ID。

此外,不幸的是,您的 iommu 组可能并非对每个设备都是唯一的。你能跑find /sys/kernel/iommu_groups/ -type l一下看看你的gpu是否在它自己独特的iommu上吗?

我也遇到过这个问题,但幸运的是通过 BIOS 主板更新解决了。如果您有最新的更新 BIOS,则必须使用 ACS 补丁重新编译内核。

GrayBoltWolf在这里写了一个非常好的指南。我听从了他的指导,并很好地帮助了我。在他的指南中,他在 ubuntu 中做了一个视频教程,但我使用运行 Arch Linux 的 gtx 1060 成功地做到了这一点。

希望这可以帮助!

于 2018-10-05T06:40:44.590 回答