VirtualBox

Changeset 35602 in vbox for trunk


Ignore:
Timestamp:
Jan 18, 2011 11:27:20 AM (14 years ago)
Author:
vboxsync
Message:

Main: fix and clarify that ISnapshot::SetName and SetDescription automatically save the machine settings; API docs

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

Legend:

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

    r35523 r35602  
    53815381        Returns a snapshot of this machine with the given UUID.
    53825382        A @c null argument can be used to obtain the first snapshot
    5383         taken on this machine. This is useful if you want to traverse
    5384         the whole tree of snapshots starting from the root.
     5383        taken on this machine. To traverse the whole tree of snapshots
     5384        starting from the root, inspect the root snapshot's
     5385        <link to="ISnapshot::children" /> attribute and recurse over those children.
    53855386
    53865387        <result name="VBOX_E_OBJECT_NOT_FOUND">
     
    86678668              only the differencing images need to be deleted.
    86688669
    8669               The current machine state is not changed by taking a snapshot.
    8670               If the machine is running, it will resume execution after the
    8671               snapshot has been taken. After calling this,
    8672               <link to="IMachine::currentSnapshot" /> is set to the snapshot
    8673               just created.
     8670              The current machine state is not changed by taking a snapshot
     8671              except that <link to="IMachine::currentSnapshot" /> is set to
     8672              the newly created snapshot, which is also added to the machine's
     8673              snapshots tree.
    86748674          </li>
    86758675
     
    86808680
    86818681              This destroys the machine's current state. After calling this,
    8682               <link to="IMachine::currentSnapshot" /> is set to the snapshot that was
    8683               restored.
     8682              <link to="IMachine::currentSnapshot" /> points to the snapshot
     8683              that was restored.
    86848684          </li>
    86858685
     
    87028702      </ul>
    87038703
    8704       Each snapshot contains the settings of the virtual machine (hardware
    8705       configuration etc.). In addition, if the machine was running when the
     8704      Each snapshot contains a copy of virtual machine's settings (hardware
     8705      configuration etc.). This copy is contained in an immutable (read-only)
     8706      instance of <link to="IMachine" /> which is available from the snapshot's
     8707      <link to="#machine" /> attribute. When restoring the snapshot, these
     8708      settings are copied back to the original machine.
     8709
     8710      In addition, if the machine was running when the
    87068711      snapshot was taken (<link to="IMachine::state"/> is <link to="MachineState_Running"/>),
    87078712      the current VM state is saved in the snapshot (similarly to what happens
    8708       when a VM's state is saved). The snapshot is then said to
    8709       be <i>online</i> because when restoring it, the VM will be running.
    8710 
    8711       If the machine is saved (<link to="MachineState_Saved"/>), the snapshot
    8712       receives a copy of the execution state file (<link to="IMachine::stateFilePath"/>).
     8713      when a VM's state is saved). The snapshot is then said to be <i>online</i>
     8714      because when restoring it, the VM will be running.
     8715
     8716      If the machine was in <link to="MachineState_Saved">saved</link> saved,
     8717      the snapshot receives a copy of the execution state file
     8718      (<link to="IMachine::stateFilePath"/>).
    87138719
    87148720      Otherwise, if the machine was not running (<link to="MachineState_PoweredOff"/>
     
    87238729
    87248730    <attribute name="name" type="wstring">
    8725       <desc>Short name of the snapshot.</desc>
     8731      <desc>Short name of the snapshot.
     8732      <note>Setting this attribute causes <link to="IMachine::saveSettings" /> to
     8733      be called implicitly.</note>
     8734      </desc>
    87268735    </attribute>
    87278736
    87288737    <attribute name="description" type="wstring">
    8729       <desc>Optional description of the snapshot.</desc>
     8738      <desc>Optional description of the snapshot.
     8739      <note>Setting this attribute causes <link to="IMachine::saveSettings" /> to
     8740      be called implicitly.</note>
     8741      </desc>
    87308742    </attribute>
    87318743
     
    87698781      <desc>
    87708782        Child snapshots (all snapshots having this one as a parent).
     8783        By inspecting this attribute starting with a machine's root snapshot
     8784        (which can be obtained by calling <link to="IMachine::findSnapshot" />
     8785        with a @c null UUID), a machine's snapshots tree can be iterated over.
    87718786      </desc>
    87728787    </attribute>
  • trunk/src/VBox/Main/src-server/SnapshotImpl.cpp

    r35368 r35602  
    346346STDMETHODIMP Snapshot::COMSETTER(Name)(IN_BSTR aName)
    347347{
     348    HRESULT rc = S_OK;
    348349    CheckComArgStrNotEmptyOrNull(aName);
    349350
     
    358359    {
    359360        m->strName = strName;
    360 
    361361        alock.leave(); /* Important! (child->parent locks are forbidden) */
    362 
    363         // flag the machine as dirty or change won't get saved
    364         AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    365         m->pMachine->setModified(Machine::IsModified_Snapshots);
    366         mlock.leave();
    367 
    368         return m->pMachine->onSnapshotChange(this);
    369     }
    370 
    371     return S_OK;
     362        rc = m->pMachine->onSnapshotChange(this);
     363    }
     364
     365    return rc;
    372366}
    373367
     
    387381STDMETHODIMP Snapshot::COMSETTER(Description)(IN_BSTR aDescription)
    388382{
     383    HRESULT rc = S_OK;
    389384    AutoCaller autoCaller(this);
    390385    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     
    397392    {
    398393        m->strDescription = strDescription;
    399 
    400394        alock.leave(); /* Important! (child->parent locks are forbidden) */
    401 
    402         // flag the machine as dirty or change won't get saved
    403         AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    404         m->pMachine->setModified(Machine::IsModified_Snapshots);
    405         mlock.leave();
    406 
    407         return m->pMachine->onSnapshotChange(this);
    408     }
    409 
    410     return S_OK;
     395        rc = m->pMachine->onSnapshotChange(this);
     396    }
     397
     398    return rc;
    411399}
    412400
     
    11931181 *  snapshot data such as name or description is changed.
    11941182 *
    1195  *  @note Locks this object for writing.
     1183 *  @warning Caller must hold no locks when calling this.
    11961184 */
    11971185HRESULT SnapshotMachine::onSnapshotChange(Snapshot *aSnapshot)
    11981186{
    1199     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    1200 
    1201     //     mPeer->saveAllSnapshots();  @todo
     1187    AutoMultiWriteLock2 mlock(this, aSnapshot COMMA_LOCKVAL_SRC_POS);
     1188    Guid uuidMachine(mData->mUuid),
     1189         uuidSnapshot(aSnapshot->getId());
     1190    bool fNeedsGlobalSaveSettings = false;
     1191
     1192    // flag the machine as dirty or change won't get saved
     1193    mPeer->setModified(Machine::IsModified_Snapshots);
     1194    HRESULT rc = mPeer->saveSettings(&fNeedsGlobalSaveSettings,
     1195                                     SaveS_Force);        // we know we need saving, no need to check
     1196    mlock.leave();
     1197
     1198    if (SUCCEEDED(rc) && fNeedsGlobalSaveSettings)
     1199    {
     1200        // save the global settings
     1201        AutoWriteLock vboxlock(mParent COMMA_LOCKVAL_SRC_POS);
     1202        rc = mParent->saveSettings();
     1203    }
    12021204
    12031205    /* inform callbacks */
    1204     mParent->onSnapshotChange(mData->mUuid, aSnapshot->getId());
    1205 
    1206     return S_OK;
     1206    mParent->onSnapshotChange(uuidMachine, uuidSnapshot);
     1207
     1208    return rc;
    12071209}
    12081210
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