VirtualBox

Changeset 81087 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Sep 30, 2019 6:55:28 PM (5 years ago)
Author:
vboxsync
Message:

Main/Machine+BIOSSettings: bare bones NVRAM logic, many parts missing (no snapshot handling, no move VM handling, no remove VM handling).
Main/Settings: adaptions to store NVRAM config in the settings file
Frontends/VBoxManage: support enabling and showing state

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r81084 r81087  
    599599      <desc>Settings version "1.17", written by VirtualBox 6.0.x.</desc>
    600600      <!--
    601           Machine changes: nested hardware virtualization, UART type selection.
     601          Machine changes: nested hardware virtualization, hardware
     602          virtualization using native APU, shared folder automount point,
     603          UART type selection and VM process priority.
    602604      -->
    603605    </const>
     
    605607      <desc>Settings version "1.18", written by VirtualBox 6.1.x.</desc>
    606608      <!--
    607           Machine changes: nested hardware virtualization, UART type selection.
     609          Machine changes: virtio-scsi storage controller, NVRAM device.
    608610      -->
    609611    </const>
     
    52575259    </attribute>
    52585260
     5261    <attribute name="nonVolatileStorageEnabled" type="boolean">
     5262      <desc>
     5263        Controls the non-volatile memory device presence. If set, VirtualBox
     5264        will store the content in a file whose path can be queried with the
     5265        <link to="#nonVolatileStorageFile"/> attribute.
     5266      </desc>
     5267    </attribute>
     5268
    52595269    <attribute name="nonVolatileStorageFile" type="wstring" readonly="yes">
    52605270      <desc>
  • trunk/src/VBox/Main/include/BIOSSettingsImpl.h

    r76562 r81087  
    8181    HRESULT getPXEDebugEnabled(BOOL *enabled);
    8282    HRESULT setPXEDebugEnabled(BOOL enable);
     83    HRESULT getNonVolatileStorageEnabled(BOOL *enabled);
     84    HRESULT setNonVolatileStorageEnabled(BOOL enable);
    8385    HRESULT getNonVolatileStorageFile(com::Utf8Str &aNonVolatileStorageFile);
    8486
  • trunk/src/VBox/Main/include/MachineImpl.h

    r80824 r81087  
    542542    Utf8Str i_getLogFilename(ULONG idx);
    543543    Utf8Str i_getHardeningLogFilename(void);
     544    Utf8Str i_getDefaultNVRAMFilename();
    544545
    545546    void i_composeSavedStateFilename(Utf8Str &strStateFilePath);
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r80847 r81087  
    18311831            InsertConfigInteger(pCfg,  "PermanentSave", 1);
    18321832#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            }
    18331848        }
    18341849
  • trunk/src/VBox/Main/src-server/BIOSSettingsImpl.cpp

    r76592 r81087  
    224224}
    225225
    226 
    227226HRESULT BIOSSettings::setLogoFadeOut(BOOL enable)
    228227{
     
    256255}
    257256
    258 
    259257HRESULT BIOSSettings::setLogoDisplayTime(ULONG displayTime)
    260258{
     
    284282}
    285283
    286 
    287284HRESULT BIOSSettings::setLogoImagePath(const com::Utf8Str &imagePath)
    288285{
     
    311308}
    312309
    313 
    314310HRESULT BIOSSettings::setBootMenuMode(BIOSBootMenuMode_T bootMenuMode)
    315311{
     
    340336}
    341337
    342 
    343338HRESULT BIOSSettings::setACPIEnabled(BOOL enable)
    344339{
     
    369364}
    370365
    371 
    372366HRESULT BIOSSettings::setIOAPICEnabled(BOOL aIOAPICEnabled)
    373367{
     
    398392}
    399393
    400 
    401394HRESULT BIOSSettings::setAPICMode(APICMode_T aAPICMode)
    402395{
     
    427420}
    428421
    429 
    430422HRESULT BIOSSettings::setPXEDebugEnabled(BOOL enable)
    431423{
     
    446438}
    447439
     440
    448441HRESULT BIOSSettings::getTimeOffset(LONG64 *offset)
    449442{
     
    455448}
    456449
    457 
    458450HRESULT BIOSSettings::setTimeOffset(LONG64 offset)
    459451{
     
    474466}
    475467
     468
     469HRESULT 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
     478HRESULT 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
    476504HRESULT BIOSSettings::getNonVolatileStorageFile(com::Utf8Str &aNonVolatileStorageFile)
    477505{
    478     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    479 
    480     aNonVolatileStorageFile = "";
     506    Utf8Str strTmp;
     507    {
     508        AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     509        strTmp = m->bd->strNVRAMPath;
     510    }
     511
     512    m->pMachine->i_calculateFullPath(strTmp, aNonVolatileStorageFile);
    481513
    482514    return S_OK;
     
    504536    AssertComRCReturnRC(autoCaller.rc());
    505537
     538    AutoReadLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    506539    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    507540
    508541    // simply copy
    509542    m->bd.assignCopy(&data);
     543
     544    Utf8Str strTmp(m->bd->strNVRAMPath);
     545    m->pMachine->i_copyPathRelativeToMachine(strTmp, m->bd->strNVRAMPath);
    510546
    511547    return S_OK;
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r80849 r81087  
    73097309    strFilename.append(RTPATH_SLASH_STR "VBoxHardening.log");
    73107310    return strFilename;
     7311}
     7312
     7313/**
     7314 * Returns the default NVRAM filename based on the location of the VM config.
     7315 * This intentionally works differently than the saved state file naming since
     7316 * it is part of the current state. Taking a snapshot will use a similar naming
     7317 * as for saved state, because these are actually read-only, retaining a
     7318 * a specific state just like saved state.
     7319 */
     7320
     7321Utf8Str Machine::i_getDefaultNVRAMFilename()
     7322{
     7323    AutoCaller autoCaller(this);
     7324    AssertComRCReturn(autoCaller.rc(), Utf8Str::Empty);
     7325
     7326    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     7327    Utf8Str strNVRAMFilePathAbs = mData->m_strConfigFileFull;
     7328    strNVRAMFilePathAbs.stripSuffix();
     7329    strNVRAMFilePathAbs += ".nvram";
     7330    Utf8Str strNVRAMFilePath;
     7331    i_copyPathRelativeToMachine(strNVRAMFilePathAbs, strNVRAMFilePath);
     7332
     7333    return strNVRAMFilePath;
    73117334}
    73127335
  • trunk/src/VBox/Main/xml/Settings.cpp

    r80074 r81087  
    24642464    fLogoFadeOut(true),
    24652465    fPXEDebugEnabled(false),
     2466    fNVRAMEnabled(false),
    24662467    ulLogoDisplayTime(0),
    24672468    biosBootMenuMode(BIOSBootMenuMode_MessageAndMenu),
     
    24812482        && fLogoFadeOut
    24822483        && !fPXEDebugEnabled
     2484        && !fNVRAMEnabled
    24832485        && ulLogoDisplayTime == 0
    24842486        && biosBootMenuMode == BIOSBootMenuMode_MessageAndMenu
    24852487        && apicMode == APICMode_APIC
    24862488        && llTimeOffset == 0
    2487         && strLogoImagePath.isEmpty();
     2489        && strLogoImagePath.isEmpty()
     2490        && strNVRAMPath.isEmpty();
    24882491}
    24892492
     
    25012504            && fLogoFadeOut        == d.fLogoFadeOut
    25022505            && fPXEDebugEnabled    == d.fPXEDebugEnabled
     2506            && fNVRAMEnabled       == d.fNVRAMEnabled
    25032507            && ulLogoDisplayTime   == d.ulLogoDisplayTime
    25042508            && biosBootMenuMode    == d.biosBootMenuMode
    25052509            && apicMode            == d.apicMode
    25062510            && llTimeOffset        == d.llTimeOffset
    2507             && strLogoImagePath    == d.strLogoImagePath);
     2511            && strLogoImagePath    == d.strLogoImagePath
     2512            && strNVRAMPath        == d.strNVRAMPath);
    25082513}
    25092514
     
    47214726            if ((pelmBIOSChild = pelmHwChild->findChildElement("TimeOffset")))
    47224727                pelmBIOSChild->getAttributeValue("value", hw.biosSettings.llTimeOffset);
     4728            if ((pelmBIOSChild = pelmHwChild->findChildElement("NVRAM")))
     4729            {
     4730                pelmBIOSChild->getAttributeValue("enabled", hw.biosSettings.fNVRAMEnabled);
     4731                pelmBIOSChild->getAttributeValue("path", hw.biosSettings.strNVRAMPath);
     4732            }
    47234733
    47244734            // legacy BIOS/IDEController (pre 1.7)
     
    61896199        if (hw.biosSettings.fPXEDebugEnabled)
    61906200            pelmBIOS->createChild("PXEDebug")->setAttribute("enabled", hw.biosSettings.fPXEDebugEnabled);
     6201        if (   hw.biosSettings.fNVRAMEnabled
     6202            || !hw.biosSettings.strNVRAMPath.isEmpty())
     6203        {
     6204            xml::ElementNode *pelmNVRAM = pelmBIOS->createChild("NVRAM");
     6205            if (hw.biosSettings.fNVRAMEnabled)
     6206                pelmNVRAM->setAttribute("enabled", hw.biosSettings.fNVRAMEnabled);
     6207            if (!hw.biosSettings.strNVRAMPath.isEmpty())
     6208                pelmNVRAM->setAttribute("path", hw.biosSettings.strNVRAMPath);
     6209        }
    61916210    }
    61926211
     
    74507469    if (m->sv < SettingsVersion_v1_18)
    74517470    {
     7471        if (   hardwareMachine.biosSettings.fNVRAMEnabled
     7472            || !hardwareMachine.biosSettings.strNVRAMPath.isEmpty())
     7473        {
     7474            m->sv = SettingsVersion_v1_18;
     7475            return;
     7476        }
     7477
    74527478        // VirtualBox 6.1 adds a virtio-scsi storage controller.
    74537479        for (StorageControllersList::const_iterator it = hardwareMachine.storage.llStorageControllers.begin();
  • trunk/src/VBox/Main/xml/VirtualBox-settings.xsd

    r80074 r81087  
    715715      <xsd:complexType>
    716716        <xsd:attribute name="enabled" type="xsd:boolean" default="false"/>
     717      </xsd:complexType>
     718    </xsd:element>
     719    <xsd:element name="NVRAM" minOccurs="0">
     720      <xsd:complexType>
     721        <xsd:attribute name="enabled" type="xsd:boolean" default="false"/>
     722        <xsd:attribute name="path" type="xsd:string"/>
    717723      </xsd:complexType>
    718724    </xsd:element>
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