VirtualBox

Changeset 15582 in vbox for trunk/src/VBox


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'.

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

Legend:

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

    r15574 r15582  
    17021702    afPciDeviceNo[4] = true;
    17031703    rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo",        0);                     RC_CHECK();
     1704    Bstr hwVersion;
     1705    hrc = pMachine->COMGETTER(HardwareVersion)(hwVersion.asOutParam());             H();
     1706    if (hwVersion.compare(Bstr("1")) == 0) /* <= 2.0.x */
     1707    {
     1708        CFGMR3InsertInteger(pCfg, "HeapEnabled", 0);                                RC_CHECK();
     1709    }
    17041710
    17051711    /* the VMM device's Main driver */
  • 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) */
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r15570 r15582  
    31263126  <interface
    31273127     name="IMachine" extends="$unknown"
    3128      uuid="a744b229-3457-422f-8550-649c40346c55"
     3128     uuid="ea6fb7ea-1993-4642-b113-f29eb39e0df0"
    31293129     wsmap="managed"
    31303130     >
     
    33083308        </note>
    33093309      </desc>
     3310    </attribute>
     3311
     3312    <attribute name="HardwareVersion" type="wstring">
     3313      <desc>Hardware version identifier. Internal use only for now.</desc>
    33103314    </attribute>
    33113315
  • trunk/src/VBox/Main/include/MachineImpl.h

    r15051 r15582  
    250250        bool operator== (const HWData &that) const;
    251251
     252        Bstr           mHWVersion;
    252253        ULONG          mMemorySize;
    253254        ULONG          mMemoryBalloonSize;
     
    475476    STDMETHOD(COMGETTER(OSTypeId)) (BSTR *aOSTypeId);
    476477    STDMETHOD(COMSETTER(OSTypeId)) (IN_BSTR aOSTypeId);
     478    STDMETHOD(COMGETTER(HardwareVersion))(BSTR *aVersion);
     479    STDMETHOD(COMSETTER(HardwareVersion))(IN_BSTR aVersion);
    477480    STDMETHOD(COMGETTER(MemorySize))(ULONG *memorySize);
    478481    STDMETHOD(COMSETTER(MemorySize))(ULONG memorySize);
  • trunk/src/VBox/Main/xml/SettingsConverter.xsl

    r15473 r15582  
    667667-->
    668668
     669  <xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3']/
     670                     vb:Machine/vb:Hardware"
     671              mode="v1.4">
     672  <!-- add version attribute to Hardware if parent Machine has a stateFile attribute -->
     673  <xsl:copy>
     674    <xsl:if test="../@stateFile">
     675      <xsl:attribute name="version">1</xsl:attribute>
     676    </xsl:if>
     677    <xsl:apply-templates select="node()" mode="v1.4"/>
     678  </xsl:copy>
     679</xsl:template>
     680
     681
    669682<!--
    670683 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • trunk/src/VBox/Main/xml/VirtualBox-settings-common.xsd

    r15069 r15582  
    763763    </xsd:element>
    764764  </xsd:all>
     765  <xsd:attribute name="version" type="xsd:string" default="2"/>
    765766</xsd:complexType>
    766767
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