AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 478129
Accepted
Stonecraft
Stonecraft
Asked: 2018-10-28 07:48:06 +0800 CST2018-10-28 07:48:06 +0800 CST 2018-10-28 07:48:06 +0800 CST

GPU 直通适用于 UEFI 固件,但不适用于 Windows iso

  • 772

我正在尝试使用直通图形设置虚拟机。我能够让 UEFI shell 的直通工作,但不是官方的 Windows 安装程序。我可以让 Windows 安装程序工作,但只能使用模拟图形

这会在 QEMU 窗口中启动 Windows 安装程序:

sudo qemu-system-x86_64 --enable-kvm \
-name TESTVM,process=TESTVM \
-cdrom /media/big-tank-8TB/OSISOS/Windows/WindowsOct2018.iso \
-smp 4 \
-cpu core2duo \
-m 4096 \
-vga qxl

这也会在 QEMU 窗口中启动 Windows 安装程序(仍然没有直通)

sudo qemu-system-x86_64 --enable-kvm \
-name TESTVM,process=TESTVM \
-cdrom /media/big-tank-8TB/OSISOS/Windows/WindowsOct2018.iso \
-smp 4 \
-cpu core2duo \
-m 4096 \
-device vfio-pci,host=43:00.0,multifunction=on \
-device vfio-pci,host=43:00.1 

但是,如果我指定 UEFI 固件的路径,我会在连接到我的直通视频卡的显示器和 QEMU 窗口中获得 Tiano slpash 屏幕,然后是 UEFI shell。

sudo qemu-system-x86_64 --enable-kvm \
-name TESTVM,process=TESTVM \
-cdrom /media/big-tank-8TB/OSISOS/Windows/WindowsOct2018.iso \
-smp 4 \
-cpu core2duo \
-m 4096 \
-device vfio-pci,host=43:00.0,multifunction=on \
-device vfio-pci,host=43:00.1 \
-drive if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_CODE.fd \
-drive if=pflash,format=raw,file=/usr/share/OVMF/OVMF_VARS.fd 

为什么只有在没有 UEFI 文件的情况下才能进行直通?或者,为什么指定 UEFI 文件会阻止我启动 Windows?

编辑:尝试下载不同版本的 Windows(2018 年 4 月而不是 10 月),同样的问题。

编辑:尝试清除并重新安装 OVMF,但没有运气。

编辑:我可以通过在 shell 中键入“exit”进入启动管理器,但选择可用的 DVD 驱动器(和所有其他选项)会立即退回到启动管理器。

编辑:跑这个:

-name TESTVM,process=TESTVM \
-drive file=/media/big-tank-8TB/OSISOS/Windows/Win10_1803_English_x64.iso,index=1,media=cdrom  \
-drive file=/media/big-tank-8TB/OSISOS/Windows/virtio-win-0.1.160.iso,index=2,media=cdrom \
-smp 4 \
-cpu core2duo \
-m 4096 \
-device vfio-pci,host=43:00.0,multifunction=on \
-device vfio-pci,host=43:00.1 \
-drive if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_CODE.fd \
-drive if=pflash,format=raw,file=/usr/share/OVMF/OVMF_VARS.fd 

当我得到 uefi shell 时,我输入“exit”进入启动管理器。在启动管理器中,选择可用的 DVD 驱动器会立即退回到启动管理器。

然后我通过 Boot Maintenance Manager > Boot Options > Add boot option 添加了另一个 DVD 驱动器,然后在 Boot Manager 菜单中选择了它。 我选择的引导条目.

这给了我一个非常简短的“按任意键从 CD 启动”。如果我足够快,它会启动到 Windows 安装程序,但只能在 QEMU 窗口中。连接到直通卡的屏幕是黑色的,带有一个简单的光标,而不是像 UEFI/Boot Manager 那样镜像。

编辑:我正在尝试通过 NVIDIA GTX1070。Mobo 是华擎 x399 Taichi,CPU 是 Threadripper 1950X。操作系统是安装了 XFCE 的 Ubuntu Server。

编辑:如果我继续安装,QEMU 窗口中仍然有 Windows,并且直通卡上只有一个 TianoCore 闪屏。如果我转到设备管理器,Windows 会看到该卡,但由于某种原因它被停止了。 错误 43

编辑:我尝试使用这些说明来摆脱代码 43,但无济于事。为了尝试这个,我使用了 virt-install 而不是 qemu-system,这样做时没有 TianoCore 闪屏。但是当我进入 Windows 时仍然是代码 43。

编辑:使用 dmesg 检查内存预留错误,如此处所述。没有找到。编辑:同样从上面的链接,使用 ROM 解析器并确认存在“类型 3 (EFI)”

kvm windows
  • 3 3 个回答
  • 7705 Views

3 个回答

  • Voted
  1. Best Answer
    FreeSoftwareServers
    2018-11-01T21:34:33+08:002018-11-01T21:34:33+08:00

    你已经在正确的轨道上。GPU Passthrough 并不完美,特别是如果它是 NVidia 卡(您没有提到 NVidia 或 AMD)。在 Qemu 窗口上完成设置。确保 Windows 机器已连接到 Internet,并让 Windows Update 为您安装图形驱动程序。当您回来时,您应该会看到第二台显示器,如果没有,请重新启动。然后我通常会移除 spice/vnc 控制台,只连接 GPU 监视器。让 GPU Passthrough 正常工作就是反复试验。

    其他要尝试的事情:

    • 在没有 GPU 直通的情况下安装 Windows,然后尝试直通 GPU。
    • 通过 NVidia_drivers.exe 安装驱动程序
    • 通过 Windows 更新安装驱动程序
    • BIOS 与 UEFI
    • Q35 与 i440fx

    注意:代码 43 是与 NVidia 相关的已知错误,与 NVidia 驱动程序检查它们是否在 VM 中运行有关。NVidia 销售专门用于在 VM 环境中运行的卡,并试图阻止在 VM 中安装消费级卡的驱动程序。您需要确保在 domain.xml 中使用以下内容

    <kvm>
     <hidden state='on'/>
    </kvm>
    

    有关示例,请参阅https://passthroughpo.st/apply-error-43-workaround/和其他资源。

    这是我的配置的屏幕截图:

    QEMU GPU 通道设置

    这是我的 domain.xml 的“相关”部分,如果你愿意,我可以分享整个内容,但它有一堆不必要的东西。

      <os>
        <type arch='x86_64' machine='pc-i440fx-2.10'>hvm</type>
        <loader readonly='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.fd</loader>
        <nvram>/var/lib/libvirt/qemu/nvram/Windows10_VARS.fd</nvram>
        <boot dev='hd'/>
      </os>
      <features>
        <acpi/>
        <apic/>
        <kvm>
          <hidden state='on'/>
        </kvm>
        <vmport state='off'/>
      </features>
      <clock offset='localtime'>
        <timer name='rtc' tickpolicy='catchup'/>
        <timer name='pit' tickpolicy='delay'/>
        <timer name='hpet' present='no'/>
      </clock>
    
    • 7
  2. Stonecraft
    2018-11-05T11:57:47+08:002018-11-05T11:57:47+08:00

    我这样做了:

    sudo qemu-system-x86_64 --enable-kvm \
    -name TESTVM,process=TESTVM \
    -drive id=disk0,if=virtio,cache=none,format=raw,file=/dev/nvme-tank/ntfs-zvol,index=2 \
    -smp 4 \
    -cpu core2duo,kvm=off \
    -m 4096 \
    -device vfio-pci,host=43:00.0,multifunction=on \
    -device vfio-pci,host=43:00.1 \
    -drive if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_CODE.fd \
    -drive if=pflash,format=raw,file=/usr/share/OVMF/OVMF_VARS.fd 
    

    然后转到设备管理器中的 GTX 1070 条目并更新驱动程序。上次(使用 virt-install)我从 NVIDIA 网站安装了更新。现在用 virt-install 让它工作,这样我就可以拥有一个可编辑的域 XML。

    编辑:到目前为止,当使用 virt-install 时,我现在(再次)获得了 Tiano 屏幕,但是这次按照上述方式安装驱动程序还不够,使用 virt-install 导入上述安装也不起作用(在旁注,我花了一段时间才意识到要使 virt-install 与我现有的安装一起工作,我所要做的就是包含引导 iso,允许它从安装中引导而不会出错)。

    编辑:所以,我想我现在可以工作了。

    1. 使用上面的 qemu-system-x86_64 进行初始安装
    2. 使用设备管理器更新驱动程序
    3. 然后执行 virt-install (但再次出现错误 43):

      virt-install \ --name myWINVM1 \ --boot uefi \ --ram 4096 \ --features kvm_hidden=on \ --hostdev 43:00.0,address.type=pci,address.multifunction=on \ --hostdev 43: 00.1,address.type=pci\--磁盘路径=/dev/nvme-tank/ntfs-zvol-part2\--cpu core2duo\--vcpus 4\--os-type windows\--os-variant win10\ --network bridge=virbr0 \ --console pty,target_type=serial \ --disk /media/big-tank-8TB/OSISOS/Windows/WindowsOct2018.iso,device=cdrom \ --disk /media/big-tank- 8TB/OSISOS/Windows/virtio-win-0.1.160.iso,device=cdrom

    4. 从 myWINVM1 XML 中删除了 spice 图形设备。仍然无法通过TianoCore。

    5. 将伪造的供应商 ID 行添加到我的 XML

    6. 添加了我的 USB 设备

    我的最终 xml:

    <domain type='kvm' id='24'>
      <name>myWINVM1</name>
      <uuid>43e052b3-b3da-4025-92d8-ec7c8ff96ae9</uuid>
      <memory unit='KiB'>4194304</memory>
      <currentMemory unit='KiB'>4194304</currentMemory>
      <vcpu placement='static'>4</vcpu>
      <resource>
        <partition>/machine</partition>
      </resource>
      <os>
        <type arch='x86_64' machine='pc-i440fx-bionic'>hvm</type>
        <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
        <nvram>/var/lib/libvirt/qemu/nvram/myWINVM1_VARS.fd</nvram>
        <boot dev='hd'/>
      </os>
      <features>
        <acpi/>
        <apic/>
        <hyperv>
          <relaxed state='on'/>
          <vapic state='on'/>
          <spinlocks state='on' retries='8191'/>
          <vendor_id state='on' value='1234567890ab'/>
        </hyperv>
        <kvm>
          <hidden state='on'/>
        </kvm>
        <vmport state='off'/>
      </features>
      <cpu mode='custom' match='exact' check='full'>
        <model fallback='forbid'>core2duo</model>
        <feature policy='disable' name='ss'/>
        <feature policy='disable' name='monitor'/>
        <feature policy='require' name='cx16'/>
        <feature policy='require' name='x2apic'/>
        <feature policy='require' name='hypervisor'/>
        <feature policy='require' name='lahf_lm'/>
      </cpu>
      <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/kvm-spice</emulator>
        <disk type='file' device='disk'>
          <driver name='qemu' type='raw'/>
          <source file='/dev/nvme-tank/ntfs-zvol-part2'/>
          <backingStore/>
          <target dev='hda' bus='ide'/>
          <alias name='ide0-0-0'/>
          <address type='drive' controller='0' bus='0' target='0' unit='0'/>
        </disk>
        <disk type='file' device='cdrom'>
          <driver name='qemu' type='raw'/>
          <source file='/media/big-tank-8TB/OSISOS/Windows/WindowsOct2018.iso'/>
          <backingStore/>
          <target dev='hdb' bus='ide'/>
          <readonly/>
          <alias name='ide0-0-1'/>
          <address type='drive' controller='0' bus='0' target='0' unit='1'/>
        </disk>
        <disk type='file' device='cdrom'>
          <driver name='qemu' type='raw'/>
          <source file='/media/big-tank-8TB/OSISOS/Windows/virtio-win-0.1.160.iso'/>
          <backingStore/>
          <target dev='hdc' bus='ide'/>
          <readonly/>
          <alias name='ide0-1-0'/>
          <address type='drive' controller='0' bus='1' target='0' unit='0'/>
        </disk>
        <controller type='usb' index='0' model='ich9-ehci1'>
          <alias name='usb'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x7'/>
        </controller>
        <controller type='usb' index='0' model='ich9-uhci1'>
          <alias name='usb'/>
          <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'>
          <alias name='usb'/>
          <master startport='2'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x1'/>
        </controller>
        <controller type='usb' index='0' model='ich9-uhci3'>
          <alias name='usb'/>
          <master startport='4'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x2'/>
        </controller>
        <controller type='pci' index='0' model='pci-root'>
          <alias name='pci.0'/>
        </controller>
        <controller type='ide' index='0'>
          <alias name='ide'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
        </controller>
        <controller type='virtio-serial' index='0'>
          <alias name='virtio-serial0'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
        </controller>
        <interface type='bridge'>
          <mac address='52:54:00:36:1d:c4'/>
          <source bridge='virbr0'/>
          <target dev='vnet0'/>
          <model type='rtl8139'/>
          <alias name='net0'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
        </interface>
        <serial type='pty'>
          <source path='/dev/pts/4'/>
          <target type='isa-serial' port='0'>
            <model name='isa-serial'/>
          </target>
          <alias name='serial0'/>
        </serial>
        <console type='pty' tty='/dev/pts/4'>
          <source path='/dev/pts/4'/>
          <target type='serial' port='0'/>
          <alias name='serial0'/>
        </console>
        <channel type='spicevmc'>
          <target type='virtio' name='com.redhat.spice.0' state='disconnected'/>
          <alias name='channel0'/>
          <address type='virtio-serial' controller='0' bus='0' port='1'/>
        </channel>
        <input type='tablet' bus='usb'>
          <alias name='input0'/>
          <address type='usb' bus='0' port='1'/>
        </input>
        <input type='mouse' bus='ps2'>
          <alias name='input1'/>
        </input>
        <input type='keyboard' bus='ps2'>
          <alias name='input2'/>
        </input>
        <sound model='ich6'>
          <alias name='sound0'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
        </sound>
        <video>
          <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
          <alias name='video0'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
        </video>
        <hostdev mode='subsystem' type='usb' managed='no'>
          <source>
            <vendor id='0x046d'/>
            <product id='0xc33b'/>
            <address bus='5' device='3'/>
          </source>
          <alias name='hostdev0'/>
          <address type='usb' bus='0' port='4'/>
        </hostdev>
        <hostdev mode='subsystem' type='usb' managed='no'>
          <source>
            <vendor id='0x046d'/>
            <product id='0xc52b'/>
            <address bus='5' device='4'/>
          </source>
          <alias name='hostdev1'/>
          <address type='usb' bus='0' port='5'/>
        </hostdev>
        <hostdev mode='subsystem' type='pci' managed='yes'>
          <driver name='vfio'/>
          <source>
            <address domain='0x0000' bus='0x43' slot='0x00' function='0x0'/>
          </source>
          <alias name='hostdev2'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
        </hostdev>
        <hostdev mode='subsystem' type='pci' managed='yes'>
          <driver name='vfio'/>
          <source>
            <address domain='0x0000' bus='0x43' slot='0x00' function='0x1'/>
          </source>
          <alias name='hostdev3'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
        </hostdev>
        <redirdev bus='usb' type='spicevmc'>
          <alias name='redir0'/>
          <address type='usb' bus='0' port='2'/>
        </redirdev>
        <redirdev bus='usb' type='spicevmc'>
          <alias name='redir1'/>
          <address type='usb' bus='0' port='3'/>
        </redirdev>
        <memballoon model='virtio'>
          <alias name='balloon0'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
        </memballoon>
      </devices>
      <seclabel type='dynamic' model='apparmor' relabel='yes'>
        <label>libvirt-43e052b3-b3da-4025-92d8-ec7c8ff96ae9</label>
        <imagelabel>libvirt-43e052b3-b3da-4025-92d8-ec7c8ff96ae9</imagelabel>
      </seclabel>
      <seclabel type='dynamic' model='dac' relabel='yes'>
        <label>+64055:+120</label>
        <imagelabel>+64055:+120</imagelabel>
      </seclabel>
    </domain>
    
    • 4
  3. tarzanello666
    2019-01-16T06:25:04+08:002019-01-16T06:25:04+08:00

    经过长时间的斗争,这对我有用:

    • 首先以这种方式编辑 qemu VM 配置文件:

       cd /etc/libvirt/qemu    
       sudo virsh define win10_GPU.xml
       sudo virsh edit win10_GPU
      

      其中“win10_GPU”当然是您的虚拟机名称并添加

       <qemu:commandline>
         <qemu:arg value='-cpu'/>
         <qemu:arg value='host,hv_time,kvm=off,hv_vendor_id=null,-hypervisor'/>   
       </qemu:commandline>
      

      </devices>几乎在文件末尾之后,然后按
      ctrl+O(保存),ctrl+X(退出)并 sudo virsh define win10_GPU.xml再次输入;

    • 在开始安装 Windows 之前从虚拟机中删除所有其他显示界面(如 spice、video cirrus 等);

    • 请勿安装 windows10 的 18xx 版本。我安装了一个 16xx 版本,即使在完全更新后也能正常工作。

    这是我的个人经历。我尝试过的任何其他事情都会导致我出现错误代码 43。

    • -1

相关问题

  • 如何为 plink.exe 设置环境变量?

  • 验证安装位置时出错:我们的字典中不存在发行版“centos7”|| 主机操作系统 CentOS 7 [关闭]

  • 如何在运行时从命令行更改 KVM VNC 端口?

  • 为什么 KVM/QEMU 中的 vm 称为域?

  • 在 Kali Linux 中的 Windows 7 分区上安装 grub

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    ssh 无法协商:“找不到匹配的密码”,正在拒绝 cbc

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    如何卸载内核模块“nvidia-drm”?

    • 13 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Wong Jia Hau ssh-add 返回:“连接代理时出错:没有这样的文件或目录” 2018-08-24 23:28:13 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST
  • Martin Hope
    Bagas Sanjaya 为什么 Linux 使用 LF 作为换行符? 2017-12-20 05:48:21 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve