hiroの長い冒険日記

主にコンピュータ周辺の興味を持った内容を綴ります

仮想マシン Windows10 Hyper-V de VirtualBox その5 (未だ未完)

当日記ではアフィリエイト広告を利用しています

実PCの Windows10 Ver.1809 でも Hyper-V 仮想マシンの Ver.1803 でも、Hyper-V と Hypervisor Platform を有効の状態で、VirtualBox6.0 の仮想マシンは起動できなかった。
hiro20180901.hatenablog.com
VirtualBox の Forum で Log を post している方がいたので、自分の起動できない Log と比較してみた。

失敗 (私の Log)

00:00:04.702541 VirtualBox VM 6.0.2 r128162 win.amd64 (Jan 14 2019 14:48:15) release log
00:00:04.702565 Log opened 2019-01-22T18:35:23.668841900Z
00:00:04.702566 Build Type: release
00:00:04.702574 OS Product: Windows 10
00:00:04.702576 OS Release: 10.0.17763
…略…
00:00:06.236293 VM: fHMEnabled=true  (configured) fRecompileUser=false fRecompileSupervisor=false
00:00:06.236295 VM: fRawRing1Enabled=false CSAM=true  PATM=true
00:00:06.236639 HM: HMR3Init: Attempting fall back to NEM: VT-x is not available
00:00:06.330482 VMSetError: F:\tinderbox\win-rel\src\VBox\VMM\VMMR3\NEMR3Native-win.cpp(1299) int __cdecl nemR3NativeInit(struct VM *,bool,bool); rc=VERR_NEM_NOT_AVAILABLE
00:00:06.330898 VMSetError: WHvCapabilityCodeHypervisorPresent is FALSE! Make sure you have enabled the 'Windows Hypervisor Platform' feature.
00:00:06.330959 NEM: NEMR3Init: Native init failed: VERR_NEM_NOT_AVAILABLE.
00:00:06.330982 VMSetError: F:\tinderbox\win-rel\src\VBox\VMM\VMMR3\HM.cpp(835) int __cdecl HMR3Init(struct VM *); rc=VERR_VMX_NO_VMX
00:00:06.331034 VMSetError: VT-x is not available
…略…

起動するが freeze する? (Forum に post された Log:こちらの Ubuntu1804 の方)

00:00:04.702541 VirtualBox VM 6.0.2 r128162 win.amd64 (Jan 14 2019 14:48:15) release log
00:00:04.702565 Log opened 2019-01-22T18:35:23.668841900Z
00:00:04.702566 Build Type: release
00:00:04.702574 OS Product: Windows 10
00:00:04.702576 OS Release: 10.0.17763
…略…
00:00:05.152217 VM: fHMEnabled=true  (configured) fRecompileUser=false fRecompileSupervisor=false
00:00:05.152219 VM: fRawRing1Enabled=false CSAM=true  PATM=true
00:00:05.152520 HM: HMR3Init: Attempting fall back to NEM: VT-x is not available
00:00:05.225086 NEM: WHvCapabilityCodeHypervisorPresent is TRUE, so this might work...
…略…

比較した結果

  • Windows10 Ver.1809 で同じ、Virtualbox の Version も同じ。
  • Hyper-V を有効にしているので、VT-x が使えない状態なのも同じ。
  • WHvCapabilityCodeHypervisorPresent が FALSE か TRUE かの違い。

該当箇所の source

VirtualBox の source から該当箇所を探してみた。

VirtualBox-6.0.0/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp :

…略…
/**
 * Worker for nemR3NativeInit that gets the hypervisor capabilities.
 *
 * @returns VBox status code.
 * @param   pVM                 The cross context VM structure.
 * @param   pErrInfo            Where to always return error info.
 */
static int nemR3WinInitCheckCapabilities(PVM pVM, PRTERRINFO pErrInfo)
{
#define NEM_LOG_REL_CAP_EX(a_szField, a_szFmt, a_Value)     LogRel(("NEM: %-38s= " a_szFmt "\n", a_szField, a_Value))
#define NEM_LOG_REL_CAP_SUB_EX(a_szField, a_szFmt, a_Value) LogRel(("NEM:   %36s: " a_szFmt "\n", a_szField, a_Value))
#define NEM_LOG_REL_CAP_SUB(a_szField, a_Value)             NEM_LOG_REL_CAP_SUB_EX(a_szField, "%d", a_Value)

    /*
     * Is the hypervisor present with the desired capability?
     *
     * In build 17083 this translates into:
     *      - CPUID[0x00000001].HVP is set
     *      - CPUID[0x40000000] == "Microsoft Hv"
     *      - CPUID[0x40000001].eax == "Hv#1"
     *      - CPUID[0x40000003].ebx[12] is set.
     *      - VidGetExoPartitionProperty(INVALID_HANDLE_VALUE, 0x60000, &Ignored) returns
     *        a non-zero value.
     */
    /**
     * @todo Someone at Microsoft please explain weird API design:
     *   1. Pointless CapabilityCode duplication int the output;
     *   2. No output size.
     */
    WHV_CAPABILITY Caps;
    RT_ZERO(Caps);
    SetLastError(0);
    HRESULT hrc = WHvGetCapabilityWrapper(WHvCapabilityCodeHypervisorPresent, &Caps, sizeof(Caps));
    DWORD   rcWin = GetLastError();
    if (FAILED(hrc))
        return RTErrInfoSetF(pErrInfo, VERR_NEM_INIT_FAILED,
                             "WHvGetCapability/WHvCapabilityCodeHypervisorPresent failed: %Rhrc (Last=%#x/%u)",
                             hrc, RTNtLastStatusValue(), RTNtLastErrorValue());
    if (!Caps.HypervisorPresent)
    {
        if (!RTPathExists(RTPATH_NT_PASSTHRU_PREFIX "Device\\VidExo"))
            return RTErrInfoSetF(pErrInfo, VERR_NEM_NOT_AVAILABLE,
                                 "WHvCapabilityCodeHypervisorPresent is FALSE! Make sure you have enabled the 'WindowsHypervisor Platform' feature.");
        return RTErrInfoSetF(pErrInfo, VERR_NEM_NOT_AVAILABLE, "WHvCapabilityCodeHypervisorPresent is FALSE! (%u)", rcWin);
    }
    LogRel(("NEM: WHvCapabilityCodeHypervisorPresent is TRUE, so this might work...\n"));
…略…
  1. HRESULT hrc は fail ではない -> 一つ目の if は通過
  2. Caps.HypervisorPresent が FALSE -> 二つ目の if の中に
  3. RTPathExists 関数の返り値が FALSE -> 三つ目の if の中に

なので error message が表示されている。2 については、コメントの "CPUID[0x00000001].HVP is set" の条件かと思う。"@todo" の Microsoft 宛の message も興味深い。

結果

Hyper-VVirtualbox が起動しないのは、もしかして CPU の影響(Core i7 870は古すぎ)? Hyper-V に別の仮想マシンがあるとダメ? 情報が少ないので切り分けが難しい...