VirtualBox

Ignore:
Timestamp:
Oct 16, 2019 7:32:48 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134004
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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: */
Note: See TracChangeset for help on using the changeset viewer.

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