third_party/virtualbox/src/VBox/VMM/VMMR3/VM.cpp
/**
 * Reads the base configuation from CFGM.
 *
 * @returns VBox status code.
 * @param   pVM                The cross context VM structure.
 * @param   pUVM                The user mode VM structure.
 * @param   cCpus               The CPU count given to VMR3Create.
 */
Reads the base configuation from CFGM.
@returns VBox status code.
@param   pVM                The cross context VM structure.
@param   pUVM                The user mode VM structure.
@param   cCpus               The CPU count given to VMR3Create.
Reads the base configuation from CFGM . @returns VBox status code . @param pVM The cross context VM structure . @param pUVM The user mode VM structure . @param cCpus The CPU count given to VMR3Create .
static int vmR3ReadBaseConfig(PVM pVM, PUVM pUVM, uint32_t cCpus)
{
    int         rc;
    PCFGMNODE   pRoot = CFGMR3GetRoot(pVM);
    const char *psz = RTEnvGet("VBOX_SUPLIB_FAKE");
    if (psz && !strcmp(psz, "fake"))
    {
        CFGMR3RemoveValue(pRoot, "RawR3Enabled");
        CFGMR3InsertInteger(pRoot, "RawR3Enabled", 0);
        CFGMR3RemoveValue(pRoot, "RawR0Enabled");
        CFGMR3InsertInteger(pRoot, "RawR0Enabled", 0);
    }
    Assert(pVM->fRecompileUser == false); 
#ifdef VBOX_WITH_RAW_MODE
    bool        fEnabled;
    rc = CFGMR3QueryBoolDef(pRoot, "RawR3Enabled", &fEnabled, false); AssertRCReturn(rc, rc);
    pVM->fRecompileUser       = !fEnabled;
    rc = CFGMR3QueryBoolDef(pRoot, "RawR0Enabled", &fEnabled, false); AssertRCReturn(rc, rc);
    pVM->fRecompileSupervisor = !fEnabled;
# ifdef VBOX_WITH_RAW_RING1
    rc = CFGMR3QueryBoolDef(pRoot, "RawR1Enabled", &pVM->fRawRing1Enabled, false);
# endif
    rc = CFGMR3QueryBoolDef(pRoot, "PATMEnabled",  &pVM->fPATMEnabled, true);   AssertRCReturn(rc, rc);
    rc = CFGMR3QueryBoolDef(pRoot, "CSAMEnabled",  &pVM->fCSAMEnabled, true);   AssertRCReturn(rc, rc);
    rc = CFGMR3QueryBoolDef(pRoot, "HMEnabled",    &pVM->fHMEnabled, true);     AssertRCReturn(rc, rc);
#else
    pVM->fHMEnabled = true;
#endif
    Assert(!pVM->fHMEnabledFixed);
    LogRel(("VM: fHMEnabled=%RTbool (configured) fRecompileUser=%RTbool fRecompileSupervisor=%RTbool\n"
            "VM: fRawRing1Enabled=%RTbool CSAM=%RTbool PATM=%RTbool\n",
            pVM->fHMEnabled, pVM->fRecompileUser, pVM->fRecompileSupervisor,
            pVM->fRawRing1Enabled, pVM->fCSAMEnabled, pVM->fPATMEnabled));
    uint32_t cCPUsCfg;
    rc = CFGMR3QueryU32Def(pRoot, "NumCPUs", &cCPUsCfg, 1);
    AssertLogRelMsgRCReturn(rc, ("Configuration error: Querying \"NumCPUs\" as integer failed, rc=%Rrc\n", rc), rc);
    AssertLogRelMsgReturn(cCPUsCfg == cCpus,
                          ("Configuration error: \"NumCPUs\"=%RU32 and VMR3Create::cCpus=%RU32 does not match!\n",
                           cCPUsCfg, cCpus),
                          VERR_INVALID_PARAMETER);
    rc = CFGMR3QueryU32Def(pRoot, "CpuExecutionCap", &pVM->uCpuExecutionCap, 100);
    AssertLogRelMsgRCReturn(rc, ("Configuration error: Querying \"CpuExecutionCap\" as integer failed, rc=%Rrc\n", rc), rc);
    rc = CFGMR3QueryStringAllocDef(pRoot, "Name", &pUVM->vm.s.pszName, "<unknown>");
    AssertLogRelMsgRCReturn(rc, ("Configuration error: Querying \"Name\" failed, rc=%Rrc\n", rc), rc);
    rc = CFGMR3QueryBytes(pRoot, "UUID", &pUVM->vm.s.Uuid, sizeof(pUVM->vm.s.Uuid));
    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
        rc = VINF_SUCCESS;
    AssertLogRelMsgRCReturn(rc, ("Configuration error: Querying \"UUID\" failed, rc=%Rrc\n", rc), rc);
    rc = CFGMR3QueryBoolDef(pRoot, "PowerOffInsteadOfReset", &pVM->vm.s.fPowerOffInsteadOfReset, false);
    AssertLogRelMsgRCReturn(rc, ("Configuration error: Querying \"PowerOffInsteadOfReset\" failed, rc=%Rrc\n", rc), rc);
    return VINF_SUCCESS;
}
static int vmR3ReadBaseConfig ( PVM pVM , PUVM pUVM , uint32_t cCpus ) { int rc ; PCFGMNODE pRoot = CFGMR3GetRoot ( pVM ) ; const char * psz = RTEnvGet ( " " ) ; if ( psz && ! strcmp ( psz , " " ) ) { CFGMR3RemoveValue ( pRoot , " " ) ; CFGMR3InsertInteger ( pRoot , " " , 0 ) ; CFGMR3RemoveValue ( pRoot , " " ) ; CFGMR3InsertInteger ( pRoot , " " , 0 ) ; } Assert ( pVM -> fRecompileUser == false ) ; #ifdef VBOX_WITH_RAW_MODE bool fEnabled ; rc = CFGMR3QueryBoolDef ( pRoot , " " , & fEnabled , false ) ; AssertRCReturn ( rc , rc ) ; pVM -> fRecompileUser = ! fEnabled ; rc = CFGMR3QueryBoolDef ( pRoot , " " , & fEnabled , false ) ; AssertRCReturn ( rc , rc ) ; pVM -> fRecompileSupervisor = ! fEnabled ; # ifdef VBOX_WITH_RAW_RING1 rc = CFGMR3QueryBoolDef ( pRoot , " " , & pVM -> fRawRing1Enabled , false ) ; # endif rc = CFGMR3QueryBoolDef ( pRoot , " " , & pVM -> fPATMEnabled , true ) ; AssertRCReturn ( rc , rc ) ; rc = CFGMR3QueryBoolDef ( pRoot , " " , & pVM -> fCSAMEnabled , true ) ; AssertRCReturn ( rc , rc ) ; rc = CFGMR3QueryBoolDef ( pRoot , " " , & pVM -> fHMEnabled , true ) ; AssertRCReturn ( rc , rc ) ; #else pVM -> fHMEnabled = true ; #endif Assert ( ! pVM -> fHMEnabledFixed ) ; LogRel ( ( " \n " " \n " , pVM -> fHMEnabled , pVM -> fRecompileUser , pVM -> fRecompileSupervisor , pVM -> fRawRing1Enabled , pVM -> fCSAMEnabled , pVM -> fPATMEnabled ) ) ; uint32_t cCPUsCfg ; rc = CFGMR3QueryU32Def ( pRoot , " " , & cCPUsCfg , 1 ) ; AssertLogRelMsgRCReturn ( rc , ( " \" \" \n " , rc ) , rc ) ; AssertLogRelMsgReturn ( cCPUsCfg == cCpus , ( " \" \" \n " , cCPUsCfg , cCpus ) , VERR_INVALID_PARAMETER ) ; rc = CFGMR3QueryU32Def ( pRoot , " " , & pVM -> uCpuExecutionCap , 100 ) ; AssertLogRelMsgRCReturn ( rc , ( " \" \" \n " , rc ) , rc ) ; rc = CFGMR3QueryStringAllocDef ( pRoot , " " , & pUVM -> vm . s . pszName , " " ) ; AssertLogRelMsgRCReturn ( rc , ( " \" \" \n " , rc ) , rc ) ; rc = CFGMR3QueryBytes ( pRoot , " " , & pUVM -> vm . s . Uuid , sizeof ( pUVM -> vm . s . Uuid ) ) ; if ( rc == VERR_CFGM_VALUE_NOT_FOUND ) rc = VINF_SUCCESS ; AssertLogRelMsgRCReturn ( rc , ( " \" \" \n " , rc ) , rc ) ; rc = CFGMR3QueryBoolDef ( pRoot , " " , & pVM -> vm . s . fPowerOffInsteadOfReset , false ) ; AssertLogRelMsgRCReturn ( rc , ( " \" \" \n " , rc ) , rc ) ; return VINF_SUCCESS ; }
Reads the base configuation from CFGM.
Reads the base configuation from CFGM .
/*
     * If executing in fake suplib mode disable RR3 and RR0 in the config.
     */ /*
     * Base EM and HM config properties.
     */ /* ASSUMES all zeros at this point */ /*
     * Make sure the CPU count in the config data matches.
     */ /*
     * Get the CPU execution cap.
     */ /*
     * Get the VM name and UUID.
     */