VirtualBox

Changeset 108620 in vbox


Ignore:
Timestamp:
Mar 19, 2025 7:29:06 PM (2 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
168032
Message:

Main/NvramStore: Changeset r164311 modified the implementation of
NvramStore::getNonVolatileStorageFile() to return failure if no NVRAM
file however the API documents that this attribute may not exist. This
change breaks IMachine::moveTo() if the VM has a snapshot since
snapshots don't have an NVRAM file. Thus restore the behaviour of
getNonVolatileStorageFile() to its previous incarnation where the caller
is required to check for the attribute's existence upon successful
invocation.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/NvramStoreImpl.h

    r106061 r108620  
    8585#endif
    8686
    87     int i_getNonVolatileStorageFile(com::Utf8Str &aNonVolatileStorageFile);
    8887    com::Utf8Str i_getNonVolatileStorageFile();
    8988    void i_updateNonVolatileStorageFile(const com::Utf8Str &aNonVolatileStorageFile);
  • trunk/src/VBox/Main/src-all/NvramStoreImpl.cpp

    r108554 r108620  
    357357HRESULT NvramStore::getNonVolatileStorageFile(com::Utf8Str &aNonVolatileStorageFile)
    358358{
    359     int vrc = i_getNonVolatileStorageFile(aNonVolatileStorageFile);
    360     if (RT_FAILURE(vrc))
    361         return setError(E_FAIL, tr("This machine does not have an NVRAM store file"));
     359#ifndef VBOX_COM_INPROC
     360    Utf8Str strTmp;
     361    {
     362        AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     363        strTmp = m->bd->strNvramPath;
     364    }
     365
     366    AutoReadLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS);
     367    if (strTmp.isEmpty())
     368        strTmp = m->pParent->i_getDefaultNVRAMFilename();
     369    if (strTmp.isNotEmpty())
     370        m->pParent->i_calculateFullPath(strTmp, aNonVolatileStorageFile);
     371#else
     372    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     373    aNonVolatileStorageFile = m->bd->strNvramPath;
     374#endif
    362375
    363376    return S_OK;
     
    369382#ifndef VBOX_COM_INPROC
    370383    Utf8Str strPath;
    371     int vrc = i_getNonVolatileStorageFile(strPath);
    372     if (RT_FAILURE(vrc))
     384    NvramStore::getNonVolatileStorageFile(strPath);
     385    if (strPath.isEmpty())
    373386        return setError(E_FAIL, tr("No NVRAM store file found"));
    374387
     
    383396        if (!m->mapNvram.size())
    384397        {
    385             vrc = i_loadStore(strPath.c_str());
     398            int vrc = i_loadStore(strPath.c_str());
    386399            if (RT_FAILURE(vrc))
    387400                hrc = setError(E_FAIL, tr("Loading the NVRAM store failed (%Rrc)\n"), vrc);
     
    453466    if (FAILED(adep.hrc())) return adep.hrc();
    454467
    455     Utf8Str strPath = i_getNonVolatileStorageFile();
     468    Utf8Str strPath;
     469    NvramStore::getNonVolatileStorageFile(strPath);
    456470
    457471    /* We need a write lock because of the lazy initialization. */
     
    521535
    522536/**
    523  * Returns the path of the non-volatile storage file.
    524  *
    525  * @returns VBox status code.
    526  * @retval  VERR_FILE_NOT_FOUND if the storage file was not found.
    527  * @param   aNonVolatileStorageFile   Returns path to non-volatile stroage file on success.
    528  */
    529 int NvramStore::i_getNonVolatileStorageFile(com::Utf8Str &aNonVolatileStorageFile)
    530 {
    531 #ifndef VBOX_COM_INPROC
    532     Utf8Str strTmp;
    533     {
    534         AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    535         strTmp = m->bd->strNvramPath;
    536     }
    537 
    538     AutoReadLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS);
    539     if (strTmp.isEmpty())
    540         strTmp = m->pParent->i_getDefaultNVRAMFilename();
    541     if (strTmp.isNotEmpty())
    542         m->pParent->i_calculateFullPath(strTmp, aNonVolatileStorageFile);
    543 #else
    544     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    545     aNonVolatileStorageFile = m->bd->strNvramPath;
    546 #endif
    547 
    548     if (aNonVolatileStorageFile.isEmpty())
    549         return VERR_FILE_NOT_FOUND;
    550 
    551     return VINF_SUCCESS;
    552 }
    553 
    554 
    555 /**
    556537 * Returns the path of the non-volatile stroage file.
    557538 *
     
    566547
    567548    Utf8Str strTmp;
    568     /* rc ignored */ i_getNonVolatileStorageFile(strTmp);
     549    NvramStore::getNonVolatileStorageFile(strTmp);
    569550    return strTmp;
    570551}
     
    11971178    int vrc = VINF_SUCCESS;
    11981179
    1199     Utf8Str strPath = i_getNonVolatileStorageFile();
     1180    Utf8Str strPath;
     1181    NvramStore::getNonVolatileStorageFile(strPath);
    12001182
    12011183    /*
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