VirtualBox

Changeset 81299 in vbox


Ignore:
Timestamp:
Oct 16, 2019 7:32:48 PM (5 years ago)
Author:
vboxsync
Message:

Main/Machine+BIOSSettings: simplify NVRAM handling, do everything in backwards c
ompatible way
Frontends/VBoxManage: adapt to API change

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/settings.h

    r81286 r81299  
    506506                    fLogoFadeIn,
    507507                    fLogoFadeOut,
    508                     fPXEDebugEnabled,
    509                     fNVRAMEnabled;
     508                    fPXEDebugEnabled;
    510509    uint32_t        ulLogoDisplayTime;
    511510    BIOSBootMenuMode_T biosBootMenuMode;
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r81087 r81299  
    870870
    871871    SHOW_LONG64_PROP(biosSettings,  TimeOffset,                 "biossystemtimeoffset", "Time offset:",  "ms");
    872     SHOW_BOOLEAN_PROP(biosSettings, NonVolatileStorageEnabled,  "biosnvram",            "BIOS NVRAM:");
    873872    Bstr bstrNVRAMFile;
    874873    CHECK_ERROR2I_RET(biosSettings, COMGETTER(NonVolatileStorageFile)(bstrNVRAMFile.asOutParam()), hrcCheck);
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r81289 r81299  
    107107    MODIFYVM_BIOSSYSTEMTIMEOFFSET,
    108108    MODIFYVM_BIOSPXEDEBUG,
    109     MODIFYVM_BIOSNVRAM,
    110109    MODIFYVM_BOOT,
    111110    MODIFYVM_HDA,                // deprecated
     
    301300    { "--biosapic",                 MODIFYVM_BIOSAPIC,                  RTGETOPT_REQ_STRING },
    302301    { "--biospxedebug",             MODIFYVM_BIOSPXEDEBUG,              RTGETOPT_REQ_BOOL_ONOFF },
    303     { "--biosnvram",                MODIFYVM_BIOSNVRAM,                 RTGETOPT_REQ_BOOL_ONOFF },
    304302    { "--boot",                     MODIFYVM_BOOT,                      RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
    305303    { "--hda",                      MODIFYVM_HDA,                       RTGETOPT_REQ_STRING },
     
    10161014            }
    10171015
    1018             case MODIFYVM_BIOSNVRAM:
    1019             {
    1020                 CHECK_ERROR(biosSettings, COMSETTER(NonVolatileStorageEnabled)(ValueUnion.f));
    1021                 break;
    1022             }
    1023 
    10241016            case MODIFYVM_BOOT:
    10251017            {
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r81286 r81299  
    51975197  <interface
    51985198    name="IBIOSSettings" extends="$unknown"
    5199     uuid="f13f667d-3624-4ac5-99c1-3d982ebd8d98"
     5199    uuid="73af4152-7e67-4144-bf34-41c38e8b4cc7"
    52005200    wsmap="managed"
    52015201    reservedMethods="1" reservedAttributes="8"
     
    52625262    </attribute>
    52635263
    5264     <attribute name="nonVolatileStorageEnabled" type="boolean">
    5265       <desc>
    5266         Controls the non-volatile memory device presence. If set, VirtualBox
    5267         will store the content in a file whose path can be queried with the
    5268         <link to="#nonVolatileStorageFile"/> attribute.
    5269       </desc>
    5270     </attribute>
    5271 
    52725264    <attribute name="nonVolatileStorageFile" type="wstring" readonly="yes">
    52735265      <desc>
    52745266        The location of the file storing the non-volatile memory content when
    52755267        the VM is powered off.  The file does not always exist.
    5276 
    5277         This feature will be realized after VirtualBox v4.3.0.
    52785268      </desc>
    52795269    </attribute>
  • trunk/src/VBox/Main/include/BIOSSettingsImpl.h

    r81087 r81299  
    5858    void i_applyDefaults(GuestOSType *aOsType);
    5959
     60    void i_updateNonVolatileStorageFile(const com::Utf8Str &aNonVolatileStorageFile);
     61
    6062private:
    6163
     
    8183    HRESULT getPXEDebugEnabled(BOOL *enabled);
    8284    HRESULT setPXEDebugEnabled(BOOL enable);
    83     HRESULT getNonVolatileStorageEnabled(BOOL *enabled);
    84     HRESULT setNonVolatileStorageEnabled(BOOL enable);
    8585    HRESULT getNonVolatileStorageFile(com::Utf8Str &aNonVolatileStorageFile);
    8686
  • trunk/src/VBox/Main/include/MachineImpl.h

    r81286 r81299  
    498498    Utf8Str i_getOSTypeId() const { return mUserData->s.strOsType; }
    499499    ChipsetType_T i_getChipsetType() const { return mHWData->mChipsetType; }
     500    FirmwareType_T i_getFirmwareType() const { return mHWData->mFirmwareType; }
    500501    ULONG i_getMonitorCount() const { return mHWData->mMonitorCount; }
    501502    ParavirtProvider_T i_getParavirtProvider() const { return mHWData->mParavirtProvider; }
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r81087 r81299  
    17501750            GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/EfiDeviceProps", &deviceProps);
    17511751
     1752            /* Get NVRAM file name */
     1753            Bstr bstrNVRAM;
     1754            hrc = biosSettings->COMGETTER(NonVolatileStorageFile)(bstrNVRAM.asOutParam());  H();
     1755
    17521756            /* Get graphics mode settings */
    17531757            uint32_t u32GraphicsMode = UINT32_MAX;
     
    18131817            InsertConfigBytes(pCfg,    "UUID", &HardwareUuid,sizeof(HardwareUuid));
    18141818            InsertConfigInteger(pCfg,  "64BitEntry",  f64BitEntry); /* boolean */
     1819            InsertConfigString(pCfg,   "NvramFile",   bstrNVRAM);
    18151820            if (u32GraphicsMode != UINT32_MAX)
    18161821                InsertConfigInteger(pCfg,  "GraphicsMode",  u32GraphicsMode);
     
    18311836            InsertConfigInteger(pCfg,  "PermanentSave", 1);
    18321837#endif
    1833 
    1834             BOOL fNVRAM = FALSE;
    1835             hrc = biosSettings->COMGETTER(NonVolatileStorageEnabled)(&fNVRAM);              H();
    1836             if (fNVRAM)
    1837             {
    1838                 hrc = biosSettings->COMGETTER(NonVolatileStorageFile)(bstr.asOutParam());   H();
    1839 
    1840                 /*
    1841                  * NVRAM device subtree.
    1842                  */
    1843                 InsertConfigNode(pDevices, "flash", &pDev);
    1844                 InsertConfigNode(pDev,     "0", &pInst);
    1845                 InsertConfigNode(pInst,    "Config", &pCfg);
    1846                 InsertConfigString(pCfg,   "FlashFile", bstr);
    1847             }
    18481838        }
    18491839
  • trunk/src/VBox/Main/src-server/BIOSSettingsImpl.cpp

    r81222 r81299  
    467467
    468468
    469 HRESULT BIOSSettings::getNonVolatileStorageEnabled(BOOL *enabled)
    470 {
    471     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    472 
    473     *enabled = m->bd->fNVRAMEnabled;
    474 
    475     return S_OK;
    476 }
    477 
    478 HRESULT BIOSSettings::setNonVolatileStorageEnabled(BOOL enable)
    479 {
    480     /* the machine needs to be mutable */
    481     AutoMutableStateDependency adep(m->pMachine);
    482     if (FAILED(adep.rc())) return adep.rc();
    483 
    484     AutoCaller autoMachineCaller(m->pMachine);
    485     AssertComRCReturnRC(autoMachineCaller.rc());
    486 
    487     {
    488         AutoReadLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    489         AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    490 
    491         m->bd.backup();
    492         m->bd->fNVRAMEnabled = RT_BOOL(enable);
    493         if (enable && m->bd->strNVRAMPath.isEmpty())
    494             m->bd->strNVRAMPath = m->pMachine->i_getDefaultNVRAMFilename();
    495     }
    496 
    497     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);  // mParent is const, needs no locking
    498     m->pMachine->i_setModified(Machine::IsModified_BIOS);
    499 
    500     return S_OK;
    501 }
    502 
    503 
    504469HRESULT BIOSSettings::getNonVolatileStorageFile(com::Utf8Str &aNonVolatileStorageFile)
    505470{
     
    510475    }
    511476
     477    AutoReadLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
     478    if (strTmp.isEmpty())
     479        strTmp = m->pMachine->i_getDefaultNVRAMFilename();
    512480    if (strTmp.isNotEmpty())
    513481        m->pMachine->i_calculateFullPath(strTmp, aNonVolatileStorageFile);
     
    544512
    545513    Utf8Str strTmp(m->bd->strNVRAMPath);
    546     m->pMachine->i_copyPathRelativeToMachine(strTmp, m->bd->strNVRAMPath);
     514    if (strTmp.isNotEmpty())
     515        m->pMachine->i_copyPathRelativeToMachine(strTmp, m->bd->strNVRAMPath);
     516    if (   m->pMachine->i_getFirmwareType() == FirmwareType_BIOS
     517        || m->bd->strNVRAMPath == m->pMachine->i_getDefaultNVRAMFilename())
     518        m->bd->strNVRAMPath.setNull();
    547519
    548520    return S_OK;
     
    636608}
    637609
     610void BIOSSettings::i_updateNonVolatileStorageFile(const Utf8Str &aNonVolatileStorageFile)
     611{
     612    /* sanity */
     613    AutoCaller autoCaller(this);
     614    AssertComRCReturnVoid(autoCaller.rc());
     615
     616    AutoReadLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
     617    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     618
     619    Utf8Str strTmp(aNonVolatileStorageFile);
     620    if (strTmp == m->pMachine->i_getDefaultNVRAMFilename())
     621        strTmp.setNull();
     622
     623    if (strTmp == m->bd->strNVRAMPath)
     624        return;
     625
     626    m->bd.backup();
     627    m->bd->strNVRAMPath = strTmp;
     628}
     629
    638630/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r81286 r81299  
    11451145    mHWData.backup();
    11461146    mHWData->mFirmwareType = aFirmwareType;
     1147    Utf8Str strNVRAM = i_getDefaultNVRAMFilename();
     1148    alock.release();
     1149
     1150    mBIOSSettings->i_updateNonVolatileStorageFile(strNVRAM);
    11471151
    11481152    return S_OK;
     
    73537357 * it is part of the current state. Taking a snapshot will use a similar naming
    73547358 * as for saved state, because these are actually read-only, retaining a
    7355  * a specific state just like saved state.
     7359 * a specific state just like saved state. Note that this is a relative path.
    73567360 */
    73577361
     
    73627366
    73637367    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    7364     Utf8Str strNVRAMFilePathAbs = mData->m_strConfigFileFull;
    7365     strNVRAMFilePathAbs.stripSuffix();
    7366     strNVRAMFilePathAbs += ".nvram";
    7367     Utf8Str strNVRAMFilePath;
    7368     i_copyPathRelativeToMachine(strNVRAMFilePathAbs, strNVRAMFilePath);
     7368
     7369    if (mHWData->mFirmwareType == FirmwareType_BIOS)
     7370        return Utf8Str::Empty;
     7371
     7372    Utf8Str strNVRAMFilePath = mData->m_strConfigFileFull;
     7373    strNVRAMFilePath.stripPath();
     7374    strNVRAMFilePath.stripSuffix();
     7375    strNVRAMFilePath += ".nvram";
    73697376
    73707377    return strNVRAMFilePath;
  • trunk/src/VBox/Main/xml/Settings.cpp

    r81286 r81299  
    24642464    fLogoFadeOut(true),
    24652465    fPXEDebugEnabled(false),
    2466     fNVRAMEnabled(false),
    24672466    ulLogoDisplayTime(0),
    24682467    biosBootMenuMode(BIOSBootMenuMode_MessageAndMenu),
     
    24822481        && fLogoFadeOut
    24832482        && !fPXEDebugEnabled
    2484         && !fNVRAMEnabled
    24852483        && ulLogoDisplayTime == 0
    24862484        && biosBootMenuMode == BIOSBootMenuMode_MessageAndMenu
     
    25042502            && fLogoFadeOut        == d.fLogoFadeOut
    25052503            && fPXEDebugEnabled    == d.fPXEDebugEnabled
    2506             && fNVRAMEnabled       == d.fNVRAMEnabled
    25072504            && ulLogoDisplayTime   == d.ulLogoDisplayTime
    25082505            && biosBootMenuMode    == d.biosBootMenuMode
     
    47294726                pelmBIOSChild->getAttributeValue("value", hw.biosSettings.llTimeOffset);
    47304727            if ((pelmBIOSChild = pelmHwChild->findChildElement("NVRAM")))
    4731             {
    4732                 pelmBIOSChild->getAttributeValue("enabled", hw.biosSettings.fNVRAMEnabled);
    47334728                pelmBIOSChild->getAttributeValue("path", hw.biosSettings.strNVRAMPath);
    4734             }
    47354729
    47364730            // legacy BIOS/IDEController (pre 1.7)
     
    62036197        if (hw.biosSettings.fPXEDebugEnabled)
    62046198            pelmBIOS->createChild("PXEDebug")->setAttribute("enabled", hw.biosSettings.fPXEDebugEnabled);
    6205         if (   hw.biosSettings.fNVRAMEnabled
    6206             || !hw.biosSettings.strNVRAMPath.isEmpty())
    6207         {
    6208             xml::ElementNode *pelmNVRAM = pelmBIOS->createChild("NVRAM");
    6209         if (hw.biosSettings.fNVRAMEnabled)
    6210                 pelmNVRAM->setAttribute("enabled", hw.biosSettings.fNVRAMEnabled);
    62116199        if (!hw.biosSettings.strNVRAMPath.isEmpty())
    6212                 pelmNVRAM->setAttribute("path", hw.biosSettings.strNVRAMPath);
    6213         }
     6200            pelmBIOS->createChild("NVRAM")->setAttribute("path", hw.biosSettings.strNVRAMPath);
    62146201    }
    62156202
     
    74797466    if (m->sv < SettingsVersion_v1_18)
    74807467    {
    7481         if (   hardwareMachine.biosSettings.fNVRAMEnabled
    7482             || !hardwareMachine.biosSettings.strNVRAMPath.isEmpty())
     7468        if (!hardwareMachine.biosSettings.strNVRAMPath.isEmpty())
    74837469        {
    74847470            m->sv = SettingsVersion_v1_18;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette