在 Windows 2016 客户虚拟机上启用 Hyper-V

在 Windows 2016 客户虚拟机上启用 Hyper-V

我在虚拟机中安装了 Windows 2016,我想在其中使用 Hyper-V。主机是 XUbuntu。但是,每次我尝试启用它时,系统都会提示我未在 BIOS 中启用虚拟化。事实上,在使用英特尔处理器识别实用程序时,系统会提示我虽然虚拟化处理器可以处理虚拟化,但 VT-D 未启用。

对于虚拟机,我使用 UEFI 作为 BIOS 类型。我开始认为这就是整个问题所在。因为当我进入菜单时,没有一个与虚拟化相关的单一选项。

以下是 Windows 客户机的 XML:

<domain type='kvm'>
  <name>Gaming_Server</name>
  <uuid>ef50c993-194f-4090-9e07-917402fd5ae9</uuid>
  <memory unit='KiB'>10485760</memory>
  <currentMemory unit='KiB'>10485760</currentMemory>
  <vcpu placement='static'>10</vcpu>
  <os>
    <type arch='x86_64' machine='pc-q35-2.5'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/Gaming_Server_VARS.fd</nvram>
    <boot dev='hd'/>
    <bootmenu enable='yes'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
    </hyperv>
  </features>
  <cpu mode='host-model'>
    <model fallback='allow'/>
    <topology sockets='1' cores='5' threads='2'/>
  </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>restart</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='qcow2'/>
      <source file='xxxx/Windows_Gaming_Server.qcow2'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x05' function='0x0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source file='xxxx/Games.img'/>
      <target dev='vdb' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x06' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='sda' bus='sata'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='xxxx/virtio-win-0.1.126.iso'/>
      <target dev='sdb' bus='sata'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <controller type='usb' index='0' model='nec-xhci'>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0'/>
    </controller>
    <controller type='sata' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pcie-root'/>
    <controller type='pci' index='1' model='dmi-to-pci-bridge'>
      <model name='i82801b11-bridge'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/>
    </controller>
    <controller type='pci' index='2' model='pci-bridge'>
      <model name='pci-bridge'/>
      <target chassisNr='2'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x01' function='0x0'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/>
    </controller>
    <interface type='direct'>
      <mac address='52:54:00:ed:2a:69'/>
      <source dev='eno1' mode='bridge'/>
      <model type='rtl8139'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </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'/>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='spice' autoport='yes'>
      <image compression='off'/>
    </graphics>
    <sound model='ich6'>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/>
    </sound>
    <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </video>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x07' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x03' slot='0x00' function='0x1'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x08' function='0x0'/>
    </hostdev>
    <redirdev bus='usb' type='spicevmc'>
    </redirdev>
    <redirdev bus='usb' type='spicevmc'>
    </redirdev>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x09' function='0x0'/>
    </memballoon>
  </devices>
</domain>

为了证明我已经嵌套虚拟化:

$ cat /sys/module/kvm_intel/parameters/nested
Y

所以我真的不知道问题是什么以及如何解决它......

答案1

为了在 Windows 中使用虚拟化选项,您需要使用最新的 QEMU 和 Libvirt 版本。此外,对于 UEFI,您还需要最新版本的 OVMF (Titanocore)。一旦您编译和/或安装了上述软件(根据需要),您就需要在该 VM 的 XML 配置文件中添加以下几行:

<features>
 ...
  <hyperv>
    ...
    <vendor_id state='on' value='something'/>
  </hyperv>
  <kvm>
    <hidden state='on'/>
  </kvm>
 ...
</features>


<cpu mode='host-passthrough' check='none'>
  ...
  <feature policy='disable' name='hypervisor'/>
</cpu>

vendor_id现在,我对和值不太确定,kvm hidden state但对 值比较确定cpu hypervisor feature tag,但谨慎一点总比后悔好。这将确保:

  • Windows 无法通过 CPU 得知自己处于虚拟机管理程序中
  • Windows 将无法分辨它在 KVM 内。
  • 如果它以某种方式设法弄明白它是在虚拟机管理程序中,它将不知道来自哪个程序或公司,并且我相信它会简单地假设它是在 Windows VM 中,而不是其他地方。

我对这个主题的技术知识相当有限,因此如果需要,请参阅相关文档并了解更多信息。

答案2

尝试将 CPU 模式更改为“host-passthrough”。它应该可以工作,但担心您会遇到其他错误,例如“Microsoft Hyper-V 虚拟机总线提供程序”错误。

相关内容