Hyper-V

L0 KVM 和 Win10 L1 嵌套虛擬化不起作用(Windows 引導循環)

  • January 20, 2021

我很難在 KVM 主機上執行的 Win10 Pro 客戶機中實現嵌套虛擬化。啟用 Windows Hypervisorhypervisorlaunchtype auto會導致引導循環/引導到自動修復。

主持人:

CentOS Linux release 8.2.2004 (Core)

Intel(R) Xeon(R) E-2176G CPU @ 3.70GHz

# cat /sys/module/kvm_intel/parameters/nested
1

flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d

客人:

Microsoft Windows [Version 10.0.19041.508]

我嘗試了多種配置,將我的 Windows 從 BIOS 遷移到 UEFI,嘗試了乾淨的 Windows 安裝,禁用/重新啟動/啟用/重新啟動了 Hypervisor 功能等等。還沒有任何工作。

我目前的配置:

 <os>
   <type arch='x86_64' machine='pc-q35-rhel7.6.0'>hvm</type>
   <loader readonly='yes' secure='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.secboot.fd</loader>
   <nvram>/var/lib/libvirt/qemu/nvram/win10_VARS.fd</nvram>
 </os>
 <features>
   <acpi/>
   <apic eoi='on'/>
   <hyperv>
     <relaxed state='on'/>
     <vapic state='on'/>
     <spinlocks state='on' retries='8191'/>
   </hyperv>
   <kvm>
     <hidden state='on'/>
   </kvm>
   <vmport state='off'/>
   <smm state='on'/>
 </features>
 <cpu mode='host-passthrough' check='partial'>
   <topology sockets='1' cores='4' threads='2'/>
   <feature policy='require' name='ds'/>
   <feature policy='require' name='acpi'/>
   <feature policy='require' name='ss'/>
   <feature policy='require' name='ht'/>
   <feature policy='require' name='tm'/>
   <feature policy='require' name='pbe'/>
   <feature policy='require' name='dtes64'/>
   <feature policy='require' name='monitor'/>
   <feature policy='require' name='ds_cpl'/>
   <feature policy='require' name='vmx'/>
   <feature policy='require' name='smx'/>
   <feature policy='require' name='est'/>
   <feature policy='require' name='tm2'/>
   <feature policy='require' name='xtpr'/>
   <feature policy='require' name='pdcm'/>
   <feature policy='require' name='osxsave'/>
   <feature policy='require' name='tsc_adjust'/>
   <feature policy='require' name='clflushopt'/>
   <feature policy='require' name='intel-pt'/>
   <feature policy='require' name='md-clear'/>
   <feature policy='require' name='stibp'/>
   <feature policy='require' name='ssbd'/>
   <feature policy='require' name='xsaves'/>
   <feature policy='require' name='pdpe1gb'/>
   <feature policy='require' name='invtsc'/>
   <feature policy='disable' name='hypervisor'/>
 </cpu>

注意最後一點feature hypervisor:如果disableWindows 啟動並報告 Hyper-V 工作(systeminfo報告 Hyper-V 要求可用,TaskManager 顯示啟用虛擬化等),但 Hyper-V 無法啟動任何 VM,系統日誌報告管理程序未執行. 將該功能設置為require將我帶入引導循環/引導到自動修復。

而且由於在這種情況下搜尋此選項有點困難:

  • hypervisor功能的具體作用是什麼?它記錄在哪裡?

在我看來,Windows 虛擬機管理程序在啟用該功能和禁用該功能的情況下在啟動時崩潰,只是無法啟動並繼續啟動過程。

我現在不知道我還能嘗試什麼,並且相信我已經檢查了幾乎所有關於該主題的搜尋結果。但也許我錯過了什麼,所以請

  • 任何人都可以報告這樣的成功設置嗎?如果是這樣,共享來賓配置會很棒!
  • 我應該嘗試其他任何想法來完成這項工作嗎?

謝謝!

PS:虛擬化本身執行得很好而且速度很快,所以我很確定硬體方面的一切都很好,但也許我也應該檢查一些事情?!

幾個月前,我使用 CentOS 8.1.1911 設置了兩台 KVM 主機,並將 Hyper-V 虛擬機作為嵌套來賓,並且一切正常。

幾個月後,我設置了第三台 KVM 主機,其硬體和軟體配置幾乎相同。唯一的區別是主機板,它具有相同的晶片組,但前兩個是技嘉品牌而不是華碩品牌。我在 CentOS 8.2.2004 上設置了這個主機,並經歷了和你一樣的 - 引導循環。我當時嘗試了最新的 Fedora 版本,它也啟動了循環。由於這台主機上的嵌套虛擬化不是必需的,我只是沒有使用它,並認為技嘉主機板有問題。

快進到今天,當我決定將我的 8.1 主機升級到 8.2 時。升級完成後我重新啟動 - hyper-V 嵌套 VM 開始引導循環。

我使用 yum history undo 回滾到 8.1.1911,就這樣,hyper-v 客戶機再次開始工作。

TL;DR:可能是最新版本的 CentOS (8.2.2004) 的問題。嘗試安裝 8.1 (8.1.1911) 看看效果如何。

引用自:https://serverfault.com/questions/1036113