VirtualBox

Ignore:
Timestamp:
Dec 16, 2008 1:22:33 PM (16 years ago)
Author:
vboxsync
Message:

#3281: Introduced a 'version' attribute on the <Hardware> element setting it to '1' during conversion if a saved state was found, otherwise using the default of '2'.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/MachineImpl.cpp

    r15496 r15582  
    187187{
    188188    /* default values for a newly created machine */
     189    mHWVersion = "2"; /** @todo get the default from the schema if that is possible. */
    189190    mMemorySize = 128;
    190191    mCPUCount = 1;
     
    220221        return true;
    221222
    222     if (mMemorySize != that.mMemorySize ||
     223    if (mHWVersion != that.mHWVersion ||
     224        mMemorySize != that.mMemorySize ||
    223225        mMemoryBalloonSize != that.mMemoryBalloonSize ||
    224226        mStatisticsUpdateInterval != that.mStatisticsUpdateInterval ||
     
    907909    mUserData.backup();
    908910    mUserData->mOSTypeId = aOSTypeId;
     911
     912    return S_OK;
     913}
     914
     915STDMETHODIMP Machine::COMGETTER(HardwareVersion) (BSTR *aHWVersion)
     916{
     917    if (!aHWVersion)
     918        return E_POINTER;
     919
     920    AutoCaller autoCaller (this);
     921    CheckComRCReturnRC (autoCaller.rc());
     922
     923    AutoReadLock alock (this);
     924
     925    mHWData->mHWVersion.cloneTo (aHWVersion);
     926
     927    return S_OK;
     928}
     929
     930STDMETHODIMP Machine::COMSETTER(HardwareVersion) (IN_BSTR aHWVersion)
     931{
     932    /* check known version */
     933    Utf8Str hwVersion = aHWVersion;
     934    if (    hwVersion.compare ("1") != 0
     935        &&  hwVersion.compare ("2") != 0)
     936        return setError (E_INVALIDARG,
     937            tr ("Invalid hardware version: %ls\n"), aHWVersion);
     938
     939    AutoCaller autoCaller (this);
     940    CheckComRCReturnRC (autoCaller.rc());
     941
     942    AutoWriteLock alock (this);
     943
     944    HRESULT rc = checkStateDependency (MutableStateDep);
     945    CheckComRCReturnRC (rc);
     946
     947    mHWData.backup();
     948    mHWData->mHWVersion = hwVersion;
    909949
    910950    return S_OK;
     
    49695009    HRESULT rc = S_OK;
    49705010
     5011    /* The hardware version attribute (optional). */
     5012    mHWData->mHWVersion = aNode.stringValue ("version");
     5013
    49715014    /* CPU node (currently not required) */
    49725015    {
     
    63576400
    63586401    HRESULT rc = S_OK;
     6402
     6403    /* The hardware version attribute (optional).
     6404       Automatically upgrade from 1 to 2 when there is no saved state. (ugly!) */
     6405    {
     6406        Utf8Str hwVersion = mHWData->mHWVersion;
     6407        if (   hwVersion.compare ("1") == 0
     6408            && mSSData->mStateFilePath.isEmpty())
     6409            mHWData->mHWVersion = hwVersion = "2";  /** @todo Is this safe, to update mHWVersion here? If not some other point needs to be found where this can be done. */
     6410        if (hwVersion.compare ("2") == 0)           /** @todo get the default from the schema if possible. */
     6411            aNode.zapValue ("version");
     6412        else
     6413            aNode.setStringValue ("version", hwVersion.raw());
     6414    }
    63596415
    63606416    /* CPU (optional, but always created atm) */
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