几天来,我一直在尝试让 PCI/GPU 直通工作,但遇到了瓶颈。我无法从通过的 GPU 获得任何视频输出。我密切关注 Arch Wiki 上的教程,偶尔检查一下这个来自 Level1Techs。我正在虚拟化的操作系统是 Windows 10 家庭版。
电脑规格:
- 操作系统:Arch Linux,内核版本 4.10.9-1-ARCH
- 处理器:英特尔酷睿 i5-6600K
- GPU:Intel HD Graphics 530(iGPU,Linux 使用)
- GPU:AMD Radeon R9 380(通过)
- 主板:Asus Z170 Pro Gaming
VT-d 从 UEFI BIOS 启用,IOMMU 在内核中启用(输出dmesg | grep -i iommu
):
[ 0.000000] Command line: BOOT_IMAGE=/vmlinuz-linux root=UUID=c6c3c8f3-030c-4dce-be63-8938386ac963 rw quiet intel_iommu=on
[ 0.000000] Kernel command line: BOOT_IMAGE=/vmlinuz-linux root=UUID=c6c3c8f3-030c-4dce-be63-8938386ac963 rw quiet intel_iommu=on
[ 0.000000] DMAR: IOMMU enabled
...
我的 GPU 和 HDMI 音频控制器正在使用该vfio-pci
驱动程序,并且与 PCIe 控制器(的输出)位于 IOMMU 组 1 中lspci -nnk
:
01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Tonga PRO [Radeon R9 285/380] [1002:6939] (rev f1)
Subsystem: Micro-Star International Co., Ltd. [MSI] Device [1462:2015]
Kernel driver in use: vfio-pci
Kernel modules: amdgpu
01:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Tonga HDMI Audio [Radeon R9 285/380] [1002:aad8]
Subsystem: Micro-Star International Co., Ltd. [MSI] Device [1462:aad8]
Kernel driver in use: vfio-pci
Kernel modules: snd_hda_intel
vfio-pci
运行正常,证明dmesg | grep -i vfio
:
[ 0.773952] VFIO - User Level meta-driver version: 0.3
[ 0.774978] vfio-pci 0000:01:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=io+mem:owns=none
[ 0.789351] vfio_pci: add [1002:6939[ffff:ffff]] class 0x000000/00000000
[ 0.806016] vfio_pci: add [1002:aad8[ffff:ffff]] class 0x000000/00000000
[ 2.767507] vfio-pci 0000:01:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=io+mem:owns=none
[ 1310.412510] vfio-pci 0000:01:00.0: enabling device (0000 -> 0003)
qemu
、libvirt
和已安装并ovmf-git
正在运行( 的输出):virt-manager
libvirtd
systemctl status libvirtd
● libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2017-04-15 12:16:01 EEST; 4h 10min ago
Docs: man:libvirtd(8)
http://libvirt.org
Main PID: 469 (libvirtd)
Tasks: 21 (limit: 4915)
CGroup: /system.slice/libvirtd.service
├─469 /usr/bin/libvirtd
├─708 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─709 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─754 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/wireless.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
└─755 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/wireless.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
Apr 15 15:46:21 elias-arch dnsmasq[754]: using nameserver 192.168.43.1#53
Apr 15 15:46:21 elias-arch dnsmasq[708]: reading /etc/resolv.conf
Apr 15 15:46:21 elias-arch dnsmasq[708]: using nameserver 2001:14b8:1000::1#53
Apr 15 15:46:21 elias-arch dnsmasq[708]: using nameserver fe80::e658:b8ff:fe4a:5394%wlp4s0#53
Apr 15 15:46:21 elias-arch dnsmasq[708]: using nameserver 192.168.43.1#53
Apr 15 15:52:23 elias-arch libvirtd[469]: 2017-04-15 12:52:23.783+0000: 525: warning : qemuDomainObjTaint:4148 : Domain id=3 name='Windows10' uuid=dd4cb32a-0311-4b7c-9bd6-4553051945be is tainted: host-cpu
Apr 15 15:52:24 elias-arch libvirtd[469]: 2017-04-15 12:52:24.017+0000: 469: error : qemuMonitorIORead:588 : Unable to read from monitor: Connection reset by peer
Apr 15 15:52:24 elias-arch libvirtd[469]: 2017-04-15 12:52:24.038+0000: 469: error : qemuProcessReportLogError:1845 : internal error: qemu unexpectedly closed the monitor: 2017-04-15T12:52:23.899918Z qemu-system-x86_64: cannot set up guest memory 'pc.ram
Apr 15 15:52:24 elias-arch libvirtd[469]: 2017-04-15 12:52:24.041+0000: 525: error : qemuProcessReportLogError:1845 : internal error: process exited while connecting to monitor: 2017-04-15T12:52:23.899918Z qemu-system-x86_64: cannot set up guest memory '
Apr 15 15:52:48 elias-arch libvirtd[469]: 2017-04-15 12:52:48.858+0000: 524: warning : qemuDomainObjTaint:4148 : Domain id=4 name='Windows10' uuid=dd4cb32a-0311-4b7c-9bd6-4553051945be is tainted: host-cpu
不要担心那个cannot set up guest memory
错误,这是我的错误,给虚拟机提供的 RAM 太少了。
我的virt-manager
设置应该没问题。我主要使用默认设置,但以下设置除外:
- 我使用的是 UEFI 固件
/usr/share/ovmf/x64/ovmf_x64.bin
- CPU型号是
host-passthrough
- 两个虚拟存储磁盘:均为 SCSI 且使用写回缓存模式
- 两个虚拟 CDROM 磁盘:都是 SATA,一个包含 Win10 ISO,另一个包含 Red Hat 的 SCSI 驱动器驱动程序。
- VirtIO SCSI 的额外控制器
- USB 控制器使用 USB 3
我在 QXL 视频适配器中安装了 Windows,成功了。之后,我移除了 Spice 通道、QXL 视频适配器、模拟鼠标和键盘、USB 平板设备和两个 USB 重定向器。我还添加了两个 PCI 主机设备:我的 GPU 及其 HDMI 音频控制器。之后,通过的 GPU 没有输出(我知道输出应该到达插入专用视频卡的显示器)。系统显然正在启动:它正在分配 RAM 并使用处理器。本周早些时候,我已经在 Fedora 上尝试过这个,但在同一阶段失败了。
这是来自 /var/log/libvirt/qemu/Windows10.log 的日志文件
我需要包含任何日志文件吗?我对 KVM 不太熟悉,所以我不知道。这可能是硬件问题还是我只是做了一些愚蠢的事情?
谢谢!
编辑:我的 XML 配置来自virsh edit Windows10
:
<domain type='kvm'>
<name>Windows10</name>
<uuid>dd4cb32a-0311-4b7c-9bd6-4553051945be</uuid>
<memory unit='KiB'>5120000</memory>
<currentMemory unit='KiB'>5120000</currentMemory>
<vcpu placement='static'>4</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-2.8'>hvm</type>
<loader readonly='yes' type='pflash'>/usr/share/ovmf/x64/ovmf_x64.bin</loader>
<nvram>/var/lib/libvirt/qemu/nvram/Windows10_VARS.fd</nvram>
<bootmenu enable='yes'/>
</os>
<features>
<acpi/>
<apic/>
<hyperv>
<relaxed state='on'/>
<vapic state='on'/>
<spinlocks state='on' retries='8191'/>
</hyperv>
<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/sbin/qemu-system-x86_64</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='writeback'/>
<source file='/opt/os-storage/win10.qcow2'/>
<target dev='sda' bus='scsi'/>
<boot order='1'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='writeback'/>
<source file='/home/elias/os-images/storage/win10-data.qcow2'/>
<target dev='sdb' bus='scsi'/>
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/home/elias/os-images/win10-amd64.iso'/>
<target dev='sdc' bus='sata'/>
<readonly/>
<boot order='2'/>
<address type='drive' controller='0' bus='0' target='0' unit='2'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/home/elias/os-images/virtio-win-0.1.126.iso'/>
<target dev='sdd' bus='sata'/>
<readonly/>
<address type='drive' controller='0' bus='0' target='0' unit='3'/>
</disk>
<controller type='scsi' index='0' model='virtio-scsi'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</controller>
<controller type='usb' index='0' model='nec-xhci'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<controller type='sata' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</controller>
<controller type='virtio-serial' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</controller>
<interface type='network'>
<mac address='52:54:00:98:06:a4'/>
<source network='default'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<interface type='network'>
<mac address='52:54:00:2e:5c:88'/>
<source network='wireless'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
</interface>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<sound model='ich6'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</source>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</hostdev>
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
</source>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
</hostdev>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
</memballoon>
</devices>
</domain>