VirtualBox

Changeset 5390 in vbox for trunk/src


Ignore:
Timestamp:
Oct 19, 2007 4:47:52 PM (17 years ago)
Author:
vboxsync
Message:

Main: Implemented IConsole::AdoptSavedState(); Prototyped IVirtualBox::WaitForPropertyChange().

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

Legend:

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

    r5272 r5390  
    17841784    LogFlowThisFuncLeave();
    17851785    return rc;
     1786}
     1787
     1788STDMETHODIMP Console::AdoptSavedState (INPTR BSTR aSavedStateFile)
     1789{
     1790    if (!aSavedStateFile)
     1791        return E_INVALIDARG;
     1792
     1793    AutoCaller autoCaller (this);
     1794    CheckComRCReturnRC (autoCaller.rc());
     1795
     1796    AutoLock alock (this);
     1797
     1798    if (mMachineState != MachineState_PoweredOff &&
     1799        mMachineState != MachineState_Aborted)
     1800        return setError (E_FAIL,
     1801            tr ("Cannot adopt the saved machine state as the machine is "
     1802                "not in Powered Off or Aborted state (machine state: %d)"),
     1803            mMachineState);
     1804
     1805    return mControl->AdoptSavedState (aSavedStateFile);
    17861806}
    17871807
  • trunk/src/VBox/Main/MachineImpl.cpp

    r5361 r5390  
    68746874        {
    68756875            if (mSSData->mStateFilePath)
    6876                 CFGLDRSetBSTR (machineNode, "stateFile", mSSData->mStateFilePath);
     6876            {
     6877                /* try to make the file name relative to the settings file dir */
     6878                Utf8Str stateFilePath = mSSData->mStateFilePath;
     6879                calculateRelativePath (stateFilePath, stateFilePath);
     6880                CFGLDRSetString (machineNode, "stateFile", stateFilePath);
     6881            }
    68776882            else
    68786883                CFGLDRDeleteAttribute (machineNode, "stateFile");
     
    87288733
    87298734/**
     8735 *  @note Locks this objects for writing.
     8736 */
     8737STDMETHODIMP SessionMachine::AdoptSavedState (INPTR BSTR aSavedStateFile)
     8738{
     8739    LogFlowThisFunc (("\n"));
     8740
     8741    AssertReturn (aSavedStateFile, E_INVALIDARG);
     8742
     8743    AutoCaller autoCaller (this);
     8744    AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     8745
     8746    AutoLock alock (this);
     8747
     8748    AssertReturn (mData->mMachineState == MachineState_PoweredOff ||
     8749                  mData->mMachineState == MachineState_Aborted,
     8750                  E_FAIL);
     8751
     8752    Utf8Str stateFilePathFull = aSavedStateFile;
     8753    int vrc = calculateFullPath (stateFilePathFull, stateFilePathFull);
     8754    if (VBOX_FAILURE (vrc))
     8755        return setError (E_FAIL,
     8756            tr ("Invalid saved state file path: '%ls' (%Vrc)"),
     8757                aSavedStateFile, vrc);
     8758
     8759    mSSData->mStateFilePath = stateFilePathFull;
     8760
     8761    /* The below setMachineState() will detect the state transition and will
     8762     * update the settings file */
     8763
     8764    return setMachineState (MachineState_Saved);
     8765}
     8766
     8767/**
    87308768 *  @note Locks mParent + this objects for writing.
    87318769 */
     
    1054310581        aMachineState == MachineState_Saved)
    1054410582    {
     10583        /* the machine has stopped execution
     10584         * (or the saved state file was adopted) */
    1054510585        stsFlags |= SaveSTS_StateTimeStamp;
     10586    }
     10587
     10588    if ((oldMachineState == MachineState_PoweredOff ||
     10589         oldMachineState == MachineState_Aborted) &&
     10590        aMachineState == MachineState_Saved)
     10591    {
     10592        /* the saved state file was adopted */
     10593        Assert (!mSSData->mStateFilePath.isNull());
     10594        stsFlags |= SaveSTS_StateFilePath;
    1054610595    }
    1054710596
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r5292 r5390  
    20202020
    20212021/**
    2022  *  Registers a new client callback on this instance. The methods of the
    2023  *  callback interface will be called by this instance when the appropriate
    2024  *  event occurs.
    2025  *
    20262022 *  @note Locks this object for writing.
    20272023 */
    2028 STDMETHODIMP VirtualBox::RegisterCallback (IVirtualBoxCallback *callback)
    2029 {
    2030     LogFlowMember (("VirtualBox::RegisterCallback(): callback=%p\n", callback));
    2031 
    2032     if (!callback)
     2024STDMETHODIMP VirtualBox::RegisterCallback (IVirtualBoxCallback *aCallback)
     2025{
     2026    LogFlowThisFunc (("aCallback=%p\n", aCallback));
     2027
     2028    if (!aCallback)
    20332029        return E_INVALIDARG;
    20342030
     
    20372033
    20382034    AutoLock alock (this);
    2039     mData.mCallbacks.push_back (CallbackList::value_type (callback));
     2035    mData.mCallbacks.push_back (CallbackList::value_type (aCallback));
    20402036
    20412037    return S_OK;
     
    20432039
    20442040/**
    2045  *  Unregisters the previously registered client callback.
    2046  *
    20472041 *  @note Locks this object for writing.
    20482042 */
    2049 STDMETHODIMP VirtualBox::UnregisterCallback (IVirtualBoxCallback *callback)
    2050 {
    2051     if (!callback)
     2043STDMETHODIMP VirtualBox::UnregisterCallback (IVirtualBoxCallback *aCallback)
     2044{
     2045    if (!aCallback)
    20522046        return E_INVALIDARG;
    20532047
     
    20622056    it = std::find (mData.mCallbacks.begin(),
    20632057                    mData.mCallbacks.end(),
    2064                     CallbackList::value_type (callback));
     2058                    CallbackList::value_type (aCallback));
    20652059    if (it == mData.mCallbacks.end())
    20662060        rc = E_INVALIDARG;
     
    20682062        mData.mCallbacks.erase (it);
    20692063
    2070     LogFlowMember (("VirtualBox::UnregisterCallback(): callback=%p, rc=%08X\n",
    2071                     callback, rc));
    2072     return rc;
     2064    LogFlowThisFunc (("aCallback=%p, rc=%08X\n", aCallback, rc));
     2065    return rc;
     2066}
     2067
     2068STDMETHODIMP VirtualBox::WaitForPropertyChange (INPTR BSTR aWhat, ULONG aTimeout,
     2069                                                BSTR *aChanged, BSTR *aValues)
     2070{
     2071    return E_NOTIMPL;
    20732072}
    20742073
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r5385 r5390  
    809809  <interface
    810810     name="IVirtualBox" extends="$dispatched"
    811      uuid="e1606565-8954-4703-b22a-620941b85a1c"
     811     uuid="64f652cb-7fdf-482d-ae19-4dbb289a5ca0"
    812812     wsmap="managed"
    813813     >
     
    17741774
    17751775    <method name="registerCallback">
    1776       <param name="callback" type="IVirtualBoxCallback" dir="in"/>
     1776      <desc>
     1777        Registers a new global VirtualBox callback. The methods of the given
     1778        callback object will be called by VirtualBox when an appropriate
     1779        event occurs.
     1780      </desc>
     1781      <param name="callback" type="IVirtualBoxCallback" dir="in">
     1782        <desc>Callback object to register.</desc>
     1783      </param>
    17771784    </method>
    17781785
    17791786    <method name="unregisterCallback">
    1780       <param name="callback" type="IVirtualBoxCallback" dir="in"/>
     1787      <desc>
     1788        Unregisters the previously registered global VirtualBox callback.
     1789      </desc>
     1790      <param name="callback" type="IVirtualBoxCallback" dir="in">
     1791        <desc>Callback object to unregister.</desc>
     1792      </param>
     1793    </method>
     1794
     1795    <method name="waitForPropertyChange">
     1796      <desc>
     1797        Blocks the caller until any of the properties represented by the @a
     1798        what argument changes the value or until the given timeout interval
     1799        expires.
     1800
     1801        The @a what argument is a comma separated list of propertiy masks that
     1802        describe properties the caller is interested in. The property mask is
     1803        a string in the following format:
     1804
     1805        @code
     1806        [[group.]subgroup.]name
     1807        @endcode
     1808
     1809        where @c name is the property name and @c group, @c subgroup are zero
     1810        or or more property group specifiers. Each element (group or name) in
     1811        the property mask may be either a latin string or an asterisk symbol
     1812        (@c "*") which is used to match any string for the given element. A
     1813        property mask that doesn't contain asterisk symbols represents a
     1814        single fully qualified property name.
     1815
     1816        Groups in the fully qualified property name go from more generic (the
     1817        left-most part) to more specific (the right-most part). The first
     1818        element is usually a name of the object the property belongs to.  The
     1819        second element may be either a property name, or a child object name,
     1820        or an index if the preceeding element names an object which is one of
     1821        many objects of the same type. This way, property names form a
     1822        hierarchy of properties.  Here are some examples of property names:
     1823
     1824        <table>
     1825          <tr>
     1826            <td><tt>VirtualBox.version</tt></td>
     1827            <td><link to="IVirtualBox::version"/> property</td>
     1828          </tr>
     1829          <tr>
     1830            <td><tt>Machine.&lt;UUID&gt;.name</tt></td>
     1831            <td><link to="IMachine::name"/> property of the machine with the
     1832            given UUID</td>
     1833            </tr>
     1834        </table>
     1835
     1836        Most property names directly correspond to the properties of objects
     1837        (components) provided by the VirtualBox library and may be used to
     1838        track changes to these properties. However, there may be
     1839        pseudo-property names that don't correspond to any existing object's
     1840        property directly, as well as there may be object properties that
     1841        don't have a corresponding property name that is understood by this
     1842        method, and therefore changes to such properties cannot be
     1843        tracked. See individual object's property descrcriptions to get a
     1844        fully qualified property name that can be used with this method (if
     1845        any).
     1846
     1847        There is a special property mask @c "*" (i.e. a string consisting of a
     1848        single asterisk symbol) that can be used to match all properties.
     1849        Below are more examples of property masks:
     1850
     1851        <table>
     1852          <tr>
     1853            <td><tt>VirtualBox.*</tt></td>
     1854            <td>Track all properties of the VirtualBox object</td>
     1855          </tr>
     1856          <tr>
     1857            <td><tt>Machine.*.name</tt></td>
     1858            <td>Track changes to the <link to="IMachine::name"/> property of
     1859            all registered virtual machines</td>
     1860          </tr>
     1861        </table>
     1862
     1863      </desc>
     1864      <param name="what" type="wstring" dir="in">
     1865        <desc>Comma separated list of property masks.</desc>
     1866      </param>
     1867      <param name="timeout" type="unsigned long" dir="in">
     1868        <desc>
     1869          Wait timeout in milliseconds.
     1870          Specify -1 for an indefinite wait.
     1871        </desc>
     1872      </param>
     1873      <param name="changed" type="wstring" dir="out">
     1874        <desc>
     1875          Comma separated list of properties that have been changed and caused
     1876          this method to return to the caller.
     1877        </desc>
     1878      </param>
     1879      <param name="values" type="wstring" dir="out">
     1880        <desc>Reserved, not currently used.</desc>
     1881      </param>
    17811882    </method>
    17821883
     
    18011902  <interface
    18021903     name="IInternalMachineControl" extends="$unknown"
    1803      uuid="83c4e00c-be0b-4c10-a48e-7bf832615f7b"
     1904     uuid="f33740bf-53b2-4519-b950-104260c6a189"
    18041905     internal="yes"
    18051906     wsmap="suppress"
     
    19322033      <param name="success" type="boolean" dir="in">
    19332034        <desc><tt>true</tt> to indicate success and <tt>false</tt> otherwise</desc>
     2035      </param>
     2036    </method>
     2037
     2038    <method name="adoptSavedState">
     2039      <desc>
     2040        Gets called by IConsole::adoptSavedState.
     2041      </desc>
     2042      <param name="savedStateFile" type="wstring" dir="in">
     2043        <desc>Path to the saved state file to adopt.</desc>
    19342044      </param>
    19352045    </method>
     
    33803490  <interface
    33813491     name="IConsole" extends="$unknown"
    3382      uuid="1DEA5C4B-0753-4193-B909-22330F64EC45"
     3492     uuid="d5a1cbda-f5d7-4824-9afe-d640c94c7dcf"
    33833493     wsmap="managed"
    33843494     >
     
    35643674      <param name="progress" type="IProgress" dir="return">
    35653675        <desc>Progress object to track the operation completion.</desc>
     3676      </param>
     3677    </method>
     3678
     3679    <method name="adoptSavedState">
     3680      <desc>
     3681        Associates the given saved state file to the virtual machine.
     3682
     3683        On success, the machine will go to the Saved state. Next time it is
     3684        powered up, it will be restored from the adopted saved state and
     3685        continue execution from the place where the saved state file was
     3686        created.
     3687
     3688        The specified saved state file path may be full or relative to the
     3689        folder the VM normally saves the state to (usually,
     3690        <link to="IMachine::snapshotFolder"/>).
     3691
     3692        <note>
     3693          It's a caller's responsibility to make sure the given saved state
     3694          file is compatible with the settings of this virtual machine that
     3695          represent its virtual hardware (memory size, hard disk configuration
     3696          etc.). If there is a mismatch, the behavior of the virtual machine
     3697          is undefined.
     3698        </note>
     3699      </desc>
     3700      <param name="savedStateFile" type="wstring" dir="in">
     3701        <desc>Path to the saved state file to adopt.</desc>
    35663702      </param>
    35673703    </method>
     
    37853921      <desc>
    37863922        This operation is similar to <link to="#discardSnapshot()"/> but
    3787         affects the current machine state. This means that the state stored
    3788         in the current snapshot will become a new current state, and
    3789         all current settings of the machine and changes stored in
    3790         differencing hard disks will be lost.
    3791 
    3792         After this operation is successfully completed, new empty
    3793         differencing hard disks are created for all normal hard disks
    3794         of the machine.
    3795 
    3796         If the current snapshot of the machine is an online snapshot,
    3797         the machine will go to the <link to="MachineState::Saved">
    3798           saved state</link>, so that the next time it is powered on,
    3799         the execution state will be restored from the current snapshot.
    3800 
    3801         <note>The machine must not be running, otherwise the operation
    3802           will fail.</note>
    3803 
    3804         <note>If the machine state is <link
    3805                                          to="MachineState::Saved">Saved</link> prior to this operation,
    3806           the saved state file will be implicitly discarded (as if <link
    3807                                                                       to="IConsole::discardSavedState()"/> were called).</note>
     3923        affects the current machine state. This means that the state stored in
     3924        the current snapshot will become a new current state, and all current
     3925        settings of the machine and changes stored in differencing hard disks
     3926        will be lost.
     3927
     3928        After this operation is successfully completed, new empty differencing
     3929        hard disks are created for all normal hard disks of the machine.
     3930
     3931        If the current snapshot of the machine is an online snapshot, the
     3932        machine will go to the <link to="MachineState::Saved"> saved
     3933        state</link>, so that the next time it is powered on, the execution
     3934        state will be restored from the current snapshot.
     3935
     3936        <note>
     3937          The machine must not be running, otherwise the operation will fail.
     3938        </note>
     3939
     3940        <note>
     3941          If the machine state is <link to="MachineState::Saved">Saved</link>
     3942          prior to this operation, the saved state file will be implicitly
     3943          discarded (as if <link to="IConsole::discardSavedState()"/> were
     3944          called).
     3945        </note>
    38083946
    38093947      </desc>
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r4404 r5390  
    127127    STDMETHOD(PowerButton)();
    128128    STDMETHOD(SaveState) (IProgress **aProgress);
     129    STDMETHOD(AdoptSavedState) (INPTR BSTR aSavedStateFile);
    129130    STDMETHOD(DiscardSavedState)();
    130131    STDMETHOD(GetDeviceActivity) (DeviceType_T aDeviceType,
  • trunk/src/VBox/Main/include/MachineImpl.h

    r5218 r5390  
    758758    STDMETHOD(BeginSavingState) (IProgress *aProgress, BSTR *aStateFilePath);
    759759    STDMETHOD(EndSavingState) (BOOL aSuccess);
     760    STDMETHOD(AdoptSavedState) (INPTR BSTR aSavedStateFile);
    760761    STDMETHOD(BeginTakingSnapshot) (IConsole *aInitiator,
    761762                                    INPTR BSTR aName, INPTR BSTR aDescription,
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r5292 r5390  
    173173                                  IProgress **aProgress);
    174174    STDMETHOD(OpenExistingSession) (ISession *aSession, INPTR GUIDPARAM aMachineId);
    175     STDMETHOD(RegisterCallback) (IVirtualBoxCallback *callback);
    176     STDMETHOD(UnregisterCallback) (IVirtualBoxCallback *callback);
     175
     176    STDMETHOD(RegisterCallback) (IVirtualBoxCallback *aCallback);
     177    STDMETHOD(UnregisterCallback) (IVirtualBoxCallback *aCallback);
     178
     179    STDMETHOD(WaitForPropertyChange) (INPTR BSTR aWhat, ULONG aTimeout,
     180                                      BSTR *aChanged, BSTR *aValues);
    177181
    178182    /* public methods only for internal purposes */
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