有人设法使用单个直通显卡运行Linux和KVM Windows吗?

我有一个Ubuntu系统,它在一个KVM中运行FreeNAS,其中一个SATA控制器卡作为passthrough。 因此,我的主板上只有一个适合显卡的PCIe插槽。 我现在还想运行能够运行需要GPU的3D CAD软件的Windows KVM。

我已经阅读了几个描述使用第二张图形卡直通在KVM中运行的窗口的条目。 但是,我想只使用一个图形卡运行不同的设置:

  • 在没有显卡的情况下运行主Linux无头(仅在安装或维护连接时)
  • 通过单个图形卡到Windows KVM,也可以通过鼠标/键盘到Windows
  • 通过ssh操作linux,或者安装No-Machine服务器并通过Windows连接。

是否有一些资源可以描述如何实现这样的设置? 有没有人试过呢? 我想序列会是这样的:

  • 在linux中安装vnc服务器,通过vnc服务器接口运行
  • 添加GRUB引导设置,使vfio处理图形卡
  • 重新启动到无头并设置附带图形卡的自动启动的Windows KVM

听起来可行(?),但我猜有一些重要的陷阱,我不想冒风险我当前的设置……

从本教程开始,我使用以下脚本获得AMD 5450直通主显卡(主机运行无头)。

  • 做标准的vfio准备
  • video=efifb:off添加到cmdline,否则efifb会在vfio之前获取PCI栏。
  • 来宾UEFI(来自apt-get install ovmf
  • -vga qlx以及后来的qlx监视器在Windows中被禁用(显示设置)
  • AMD 5450没有romfiles。

我也尝试使用NVidia 710b,但是它仍然坚持使用“Code 43”。 可能是因为当试图通过主卡时需要romfiles。

脚本:

 #!/bin/bash b=$(pwd) passthrough=0 qxl=1 uefi=1 ovmf=0 net=0 while getopts "bpQUon" opt; do case $opt in p) passthrough=1 ;; Q) qxl=0 ;; U) uefi=0 ;; n) net=1 ;; o) ovmf=1 ;; esac done cp ${b}/uefi/usr/share/edk2.git/ovmf-x64/OVMF_VARS-pure-efi.fd . OPTS="" # Basic CPU settings. OPTS="$OPTS -cpu host,kvm=off" OPTS="$OPTS -smp 4,sockets=1,cores=4,threads=1" # Enable KVM full virtualization support. OPTS="$OPTS -enable-kvm" # Assign memory to the vm. OPTS="$OPTS -m 4000" # VFIO GPU and GPU sound passthrough. if [ "$passthrough" == "1" ]; then #,multifunction=on,romfile=/mnt/nvidia_efi.rom" ,romfile=${b}/bioses/XFX.HD5450.1024.110612.rom #OPTS="$OPTS -device vfio-pci,host=05:00.0,multifunction=on,romfile=${b}/bioses/XFX.HD5450.1024.110612.rom" #,romfile=${b}/bioses/XFX.HD5450.1024.110612_1.rom OPTS="$OPTS -device vfio-pci,host=01:00.0,multifunction=on" #,romfile=/mnt/data-n0/vms-win/romfile_radeon.bin #,romfile=/mnt/nvidia_efi.rom" OPTS="$OPTS -device vfio-pci,host=01:00.1" fi # Supply OVMF (general UEFI bios, needed for EFI boot support with GPT disks). if [ "$uefi" == "1" ]; then if [ "$ovmf" == "0" ]; then OPTS="$OPTS -drive if=pflash,format=raw,readonly,file=${b}/uefi/usr/share/edk2.git/ovmf-x64/OVMF_VARS-pure-efi.fd" OPTS="$OPTS -drive if=pflash,format=raw,file=${b}/OVMF_VARS-pure-efi.fd" else mkdir -p ${b}/hda-contents #OPTS="$OPTS -pflash ${b}/ovmf_pkg/OVMF.fd" OPTS="$OPTS -drive if=pflash,format=raw,readonly,file=${b}/ovmf_pkg/OVMF.fd" OPTS="$OPTS -drive if=pflash,format=raw,file=${b}/OVMF_VARS-pure-efi.fd" fi fi # Load our created VM image as a harddrive. OPTS="$OPTS -hda ${b}/win10_uefi_cpu_host_qemu_vm.qcow2" # Load our OS setup image eg ISO file. #OPTS="$OPTS -cdrom ${b}/windows_10.iso" OPTS="$OPTS -cdrom ${b}/virtio-win-0.1.141.iso" if [ "$qxl" == "1" ]; then # Use the following emulated video device (use none for disabled). OPTS="$OPTS -vga qxl" else # Use an emulated video device (use none for disabled). # -vga none -device qxl OPTS="$OPTS -vga none -device qxl " fi OPTS="$OPTS -spice port=5900,addr=127.0.0.1,disable-ticketing " # Redirect QEMU's console input and output. OPTS="$OPTS -monitor stdio" if [ "${net}" == "1" ]; then # Improve the network performance by utilizing virtio-net. OPTS="$OPTS -device virtio-net,netdev=net0,mac=de:ad:be:ef:33:4a" OPTS="$OPTS -netdev tap,id=net0,ifname=vmtap0,script=./qemu-ifup,downscript=./qemu-ifdown" else OPTS="$OPTS -net none " fi #Bus 003 Device 004: ID 1c4f:0002 SiGma Micro Keyboard TRACER Gamma Ivory #Bus 003 Device 002: ID 1a40:0201 Terminus Technology Inc. FE 2.1 7-port Hub # USB mouse if [ "$passthrough" == "1" ]; then OPTS="$OPTS -usb" OPTS="$OPTS -device usb-ehci,id=ehci" OPTS="$OPTS -device usb-host,bus=usb-bus.0,vendorid=0x17ef,productid=0x6019 " OPTS="$OPTS -device usb-host,bus=usb-bus.0,vendorid=0x1c4f,productid=0x0002 " fi #if [ "$passthrough" == "1" ]; then # OPTS="$OPTS -usb" # OPTS="$OPTS -device usb-ehci,id=ehci" # OPTS="$OPTS -device usb-host,bus=usb-bus.0,vendorid=0x17ef,productid=0x6019 " # OPTS="$OPTS -device usb-host,bus=usb-bus.0,vendorid=0x1c4f,productid=0x0002 " #fi #OPTS="$OPTS -device usb-host,hostbus=3,hostaddr=4" #OPTS="$OPTS -device usb-host,hostbus=3,hostaddr=2" #OPTS="$OPTS -device usb-host,bus=xhci.0,vendorid=0x1c4f,productid=0x0002 " #OPTS="$OPTS -device usb-host,bus=xhci.0,vendorid=0x1a40,productid=0x0201 " #OPTS="$OPTS -usbdevice host:1c4f:0002" # USB keyboard #OPTS="$OPTS -usbdevice host:1a40:0201" sudo qemu-system-x86_64 $OPTS