Changeset 22624 in vbox
- Timestamp:
- Aug 31, 2009 5:32:17 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 51691
- Location:
- trunk/src/VBox/Main
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl.cpp
r22562 r22624 1823 1823 FALSE /* aCancelable */); 1824 1824 1825 bool beganSavingState = false;1826 bool taskCreationFailed = false;1825 bool fBeganSavingState = false; 1826 bool fTaskCreationFailed = false; 1827 1827 1828 1828 do … … 1839 1839 if (FAILED (rc)) 1840 1840 { 1841 taskCreationFailed = true;1841 fTaskCreationFailed = true; 1842 1842 break; 1843 1843 } … … 1853 1853 CheckComRCBreakRC (rc); 1854 1854 1855 beganSavingState = true;1855 fBeganSavingState = true; 1856 1856 1857 1857 /* sync the state with the server */ … … 1896 1896 while (0); 1897 1897 1898 if (FAILED (rc) && ! taskCreationFailed)1898 if (FAILED (rc) && !fTaskCreationFailed) 1899 1899 { 1900 1900 /* preserve existing error info */ 1901 1901 ErrorInfoKeeper eik; 1902 1902 1903 if ( beganSavingState)1903 if (fBeganSavingState) 1904 1904 { 1905 1905 /* … … 2363 2363 } 2364 2364 2365 STDMETHODIMP Console::TakeSnapshot (IN_BSTR aName, IN_BSTR aDescription, 2366 IProgress **aProgress) 2365 STDMETHODIMP Console::TakeSnapshot(IN_BSTR aName, 2366 IN_BSTR aDescription, 2367 IProgress **aProgress) 2367 2368 { 2368 2369 LogFlowThisFuncEnter(); … … 2377 2378 AutoWriteLock alock(this); 2378 2379 2379 if (Global::IsTransient (mMachineState)) 2380 { 2381 return setError (VBOX_E_INVALID_VM_STATE, 2382 tr ("Cannot take a snapshot of the machine " 2383 "while it is changing the state (machine state: %d)"), 2384 mMachineState); 2385 } 2380 if (Global::IsTransient(mMachineState)) 2381 return setError(VBOX_E_INVALID_VM_STATE, 2382 tr("Cannot take a snapshot of the machine while it is changing the state (machine state: %d)"), 2383 mMachineState); 2386 2384 2387 2385 /* memorize the current machine state */ … … 2396 2394 HRESULT rc = S_OK; 2397 2395 2398 bool takingSnapshotOnline = mMachineState == MachineState_Paused;2396 bool fTakingSnapshotOnline = (mMachineState == MachineState_Paused); 2399 2397 2400 2398 /* … … 2403 2401 */ 2404 2402 ComObjPtr<Progress> saveProgress; 2405 if ( takingSnapshotOnline)2403 if (fTakingSnapshotOnline) 2406 2404 { 2407 2405 saveProgress.createObject(); 2408 rc = saveProgress->init (FALSE, 1, Bstr (tr("Saving the execution state")));2406 rc = saveProgress->init(FALSE, 1, Bstr(tr("Saving the execution state"))); 2409 2407 AssertComRCReturn (rc, rc); 2410 2408 } 2411 2409 2412 bool beganTakingSnapshot = false;2413 bool taskCreationFailed = false;2410 bool fBeganTakingSnapshot = false; 2411 bool fTaskCreationFailed = false; 2414 2412 2415 2413 do 2416 2414 { 2417 2415 /* create a task object early to ensure mpVM protection is successful */ 2418 std::auto_ptr 2419 if ( takingSnapshotOnline)2420 { 2421 task.reset (new VMSaveTask(this, saveProgress));2416 std::auto_ptr<VMSaveTask> task; 2417 if (fTakingSnapshotOnline) 2418 { 2419 task.reset(new VMSaveTask(this, saveProgress)); 2422 2420 rc = task->rc(); 2423 2421 /* … … 2429 2427 if (FAILED (rc)) 2430 2428 { 2431 taskCreationFailed = true;2429 fTaskCreationFailed = true; 2432 2430 break; 2433 2431 } … … 2442 2440 * others from accessing this machine) 2443 2441 */ 2444 rc = mControl->BeginTakingSnapshot (this, aName, aDescription, 2445 saveProgress, stateFilePath.asOutParam(), 2446 serverProgress.asOutParam()); 2442 rc = mControl->BeginTakingSnapshot(this, 2443 aName, 2444 aDescription, 2445 saveProgress, 2446 stateFilePath.asOutParam(), 2447 serverProgress.asOutParam()); 2447 2448 if (FAILED (rc)) 2448 2449 break; … … 2452 2453 * (i.e. creating a snapshot online) 2453 2454 */ 2454 ComAssertBreak ( 2455 (!stateFilePath.isNull() && takingSnapshotOnline) || 2456 (stateFilePath.isNull() && !takingSnapshotOnline), 2457 rc = E_FAIL); 2458 2459 beganTakingSnapshot = true; 2455 ComAssertBreak( (!stateFilePath.isNull() && fTakingSnapshotOnline) 2456 || (stateFilePath.isNull() && !fTakingSnapshotOnline), 2457 rc = E_FAIL); 2458 2459 fBeganTakingSnapshot = true; 2460 2460 2461 2461 /* sync the state with the server */ 2462 setMachineStateLocally 2462 setMachineStateLocally(MachineState_Saving); 2463 2463 2464 2464 /* … … 2467 2467 */ 2468 2468 ComObjPtr<CombinedProgress> combinedProgress; 2469 if ( takingSnapshotOnline)2469 if (fTakingSnapshotOnline) 2470 2470 { 2471 2471 combinedProgress.createObject(); 2472 rc = combinedProgress->init (static_cast <IConsole *> (this), 2473 Bstr (tr ("Taking snapshot of virtual machine")), 2474 serverProgress, saveProgress); 2472 rc = combinedProgress->init(static_cast<IConsole*>(this), 2473 Bstr(tr("Taking snapshot of virtual machine")), 2474 serverProgress, 2475 saveProgress); 2475 2476 AssertComRCBreakRC (rc); 2476 2477 … … 2483 2484 2484 2485 /* create a thread to wait until the VM state is saved */ 2485 int vrc = RTThreadCreate (NULL, Console::saveStateThread, (void *) task.get(), 2486 0, RTTHREADTYPE_MAIN_WORKER, 0, "VMTakeSnap"); 2487 2488 ComAssertMsgRCBreak (vrc, ("Could not create VMTakeSnap thread (%Rrc)", vrc), 2489 rc = E_FAIL); 2486 int vrc = RTThreadCreate(NULL, 2487 Console::saveStateThread, 2488 (void*)task.get(), 2489 0, 2490 RTTHREADTYPE_MAIN_WORKER, 2491 0, 2492 "VMTakeSnap"); 2493 2494 ComAssertMsgRCBreak(vrc, 2495 ("Could not create VMTakeSnap thread (%Rrc)", vrc), 2496 rc = E_FAIL); 2490 2497 2491 2498 /* task is now owned by saveStateThread(), so release it */ … … 2501 2508 serverProgress.queryInterfaceTo(aProgress); 2502 2509 } 2503 } 2504 while (0); 2505 2506 if (FAILED (rc) && !taskCreationFailed) 2510 } while (0); 2511 2512 if (FAILED(rc) && !fTaskCreationFailed) 2507 2513 { 2508 2514 /* preserve existing error info */ 2509 2515 ErrorInfoKeeper eik; 2510 2516 2511 if ( beganTakingSnapshot && takingSnapshotOnline)2517 if (fBeganTakingSnapshot && fTakingSnapshotOnline) 2512 2518 { 2513 2519 /* … … 2517 2523 * before calling mControl->BeginTakingSnapshot(). 2518 2524 */ 2519 mControl->EndTakingSnapshot 2525 mControl->EndTakingSnapshot(FALSE); 2520 2526 } 2521 2527 … … 2523 2529 { 2524 2530 /* restore the paused state if appropriate */ 2525 setMachineStateLocally 2531 setMachineStateLocally(MachineState_Paused); 2526 2532 /* restore the running state if appropriate */ 2527 2533 Resume(); 2528 2534 } 2529 2535 else 2530 setMachineStateLocally 2536 setMachineStateLocally(lastMachineState); 2531 2537 } 2532 2538 … … 2536 2542 } 2537 2543 2538 STDMETHODIMP Console::DiscardSnapshot 2544 STDMETHODIMP Console::DiscardSnapshot(IN_BSTR aId, IProgress **aProgress) 2539 2545 { 2540 2546 CheckComArgExpr(aId, Guid (aId).isEmpty() == false); -
trunk/src/VBox/Main/HardDiskImpl.cpp
r22195 r22624 2544 2544 AssertReturn(mm.type != HardDiskType_Writethrough, E_FAIL); 2545 2545 2546 LogFlowThisFunc(("Hard disk '%s' has media status %d\n", name().raw(), m.state)); 2547 2546 2548 /* Note: MediaState_LockedWrite is ok when taking an online snapshot */ 2547 2549 AssertReturn(m.state == MediaState_LockedRead || … … 2555 2557 /* check that the hard disk is not attached to any VM in the current state*/ 2556 2558 for (BackRefList::const_iterator it = m.backRefs.begin(); 2557 it != m.backRefs.end(); ++ it) 2559 it != m.backRefs.end(); 2560 ++it) 2558 2561 { 2559 2562 if (it->inCurState) … … 2590 2593 { 2591 2594 progress.createObject(); 2592 rc = progress->init (mVirtualBox, static_cast<IHardDisk*> (this), 2593 BstrFmt (tr ("Creating differencing hard disk storage unit '%ls'"), 2594 aTarget->m.locationFull.raw()), 2595 TRUE /* aCancelable */); 2595 rc = progress->init(mVirtualBox, 2596 static_cast<IHardDisk*>(this), 2597 BstrFmt(tr("Creating differencing hard disk storage unit '%ls'"), 2598 aTarget->m.locationFull.raw()), 2599 TRUE /* aCancelable */); 2596 2600 CheckComRCReturnRC(rc); 2597 2601 } … … 2601 2605 * asynchronously */ 2602 2606 2603 std::auto_ptr <Task> task (new Task(this, progress, Task::CreateDiff));2607 std::auto_ptr<Task> task(new Task(this, progress, Task::CreateDiff)); 2604 2608 AssertComRCReturnRC(task->autoCaller.rc()); 2605 2609 … … 2608 2612 2609 2613 /* register a task (it will deregister itself when done) */ 2610 ++ 2614 ++mm.numCreateDiffTasks; 2611 2615 Assert (mm.numCreateDiffTasks != 0); /* overflow? */ 2612 2616 … … 3972 3976 /* deregister the task registered in createDiffStorage() */ 3973 3977 Assert (that->mm.numCreateDiffTasks != 0); 3974 -- 3978 --that->mm.numCreateDiffTasks; 3975 3979 3976 3980 /* Note that in sync mode, it's the caller's responsibility to -
trunk/src/VBox/Main/MachineImpl.cpp
r22560 r22624 5894 5894 5895 5895 data.strNotificationPatterns = mHWData->mGuestPropertyNotificationPatterns; 5896 #endif /* VBOX_WITH_GUEST_PROPS defined */ 5896 5897 } 5897 5898 catch(std::bad_alloc &) … … 5899 5900 return E_OUTOFMEMORY; 5900 5901 } 5901 #endif /* VBOX_WITH_GUEST_PROPS defined */5902 5902 5903 5903 AssertComRC(rc); … … 6114 6114 ComObjPtr<HardDisk> hd = hda->hardDisk(); 6115 6115 6116 rc = hd->LockRead 6116 rc = hd->LockRead(NULL); 6117 6117 CheckComRCThrowRC(rc); 6118 6118 6119 lockedMedia.push_back 6119 lockedMedia.push_back(hd); 6120 6120 } 6121 6121 } … … 6131 6131 * disks and attach them */ 6132 6132 6133 for (HDData::AttachmentList::const_iterator 6134 it = atts.begin(); it != atts.end(); ++ it) 6133 for (HDData::AttachmentList::const_iterator it = atts.begin(); 6134 it != atts.end(); 6135 ++it) 6135 6136 { 6136 6137 ComObjPtr<HardDiskAttachment> hda = *it; … … 6141 6142 { 6142 6143 /* copy the attachment as is */ 6143 6144 Assert (hd->type() == HardDiskType_Writethrough); 6144 Assert(hd->type() == HardDiskType_Writethrough); 6145 6145 6146 6146 rc = aProgress->setNextOperation(BstrFmt(tr("Skipping writethrough hard disk '%s'"), … … 6149 6149 CheckComRCThrowRC(rc); 6150 6150 6151 mHDData->mAttachments.push_back 6151 mHDData->mAttachments.push_back(hda); 6152 6152 continue; 6153 6153 } 6154 6154 6155 6155 /* need a diff */ 6156 6157 6156 rc = aProgress->setNextOperation(BstrFmt(tr("Creating differencing hard disk for '%s'"), 6158 6157 hd->root()->name().raw()), … … 6171 6170 alock.leave(); 6172 6171 6173 rc = hd->createDiffStorageAndWait (diff, HardDiskVariant_Standard, 6174 &aProgress); 6172 LogFlowThisFunc(("Calling createDiffStorageAndWait() on hard disk '%s'\n", hd->root()->name().raw())); 6173 6174 rc = hd->createDiffStorageAndWait(diff, 6175 HardDiskVariant_Standard, 6176 &aProgress); 6175 6177 6176 6178 alock.enter(); … … 6178 6180 CheckComRCThrowRC(rc); 6179 6181 6180 rc = diff->attachTo 6181 AssertComRCThrowRC 6182 rc = diff->attachTo(mData->mUuid); 6183 AssertComRCThrowRC(rc); 6182 6184 6183 6185 /* add a new attachment */ 6184 6186 ComObjPtr<HardDiskAttachment> attachment; 6185 6187 attachment.createObject(); 6186 rc = attachment->init (diff, hda->controller(), hda->port(), 6187 hda->device(), true /* aImplicit */); 6188 rc = attachment->init(diff, 6189 hda->controller(), 6190 hda->port(), 6191 hda->device(), 6192 true /* aImplicit */); 6188 6193 CheckComRCThrowRC(rc); 6189 6194 6190 mHDData->mAttachments.push_back 6195 mHDData->mAttachments.push_back(attachment); 6191 6196 } 6192 6197 } … … 6199 6204 6200 6205 for (LockedMedia::const_iterator it = lockedMedia.begin(); 6201 it != lockedMedia.end(); ++ it) 6202 { 6203 HRESULT rc2 = (*it)->UnlockRead (NULL); 6206 it != lockedMedia.end(); 6207 ++it) 6208 { 6209 HRESULT rc2 = (*it)->UnlockRead(NULL); 6204 6210 AssertComRC(rc2); 6205 6211 } … … 7013 7019 7014 7020 /** Take snapshot task */ 7015 struct SessionMachine::TakeSnapshotTask : public SessionMachine::Task 7016 { 7017 TakeSnapshotTask (SessionMachine *m) 7018 : Task (m, NULL) {} 7019 7020 void handler() { machine->takeSnapshotHandler (*this); } 7021 struct SessionMachine::TakeSnapshotTask 7022 : public SessionMachine::Task 7023 { 7024 TakeSnapshotTask(SessionMachine *m) 7025 : Task(m, NULL) 7026 {} 7027 7028 void handler() 7029 { 7030 machine->takeSnapshotHandler(*this); 7031 } 7021 7032 }; 7022 7033 7023 7034 /** Discard snapshot task */ 7024 struct SessionMachine::DiscardSnapshotTask : public SessionMachine::Task 7025 { 7026 DiscardSnapshotTask (SessionMachine *m, Progress *p, Snapshot *s) 7027 : Task (m, p) 7028 , snapshot (s) {} 7035 struct SessionMachine::DiscardSnapshotTask 7036 : public SessionMachine::Task 7037 { 7038 DiscardSnapshotTask(SessionMachine *m, Progress *p, Snapshot *s) 7039 : Task (m, p), 7040 snapshot (s) 7041 {} 7029 7042 7030 7043 DiscardSnapshotTask (const Task &task, Snapshot *s) 7031 7044 : Task (task) 7032 , snapshot (s) {} 7033 7034 void handler() { machine->discardSnapshotHandler (*this); } 7045 , snapshot (s) 7046 {} 7047 7048 void handler() 7049 { 7050 machine->discardSnapshotHandler(*this); 7051 } 7035 7052 7036 7053 ComObjPtr<Snapshot> snapshot; … … 7038 7055 7039 7056 /** Discard current state task */ 7040 struct SessionMachine::DiscardCurrentStateTask : public SessionMachine::Task 7041 { 7042 DiscardCurrentStateTask (SessionMachine *m, Progress *p, 7043 bool discardCurSnapshot) 7044 : Task (m, p), discardCurrentSnapshot (discardCurSnapshot) {} 7045 7046 void handler() { machine->discardCurrentStateHandler (*this); } 7057 struct SessionMachine::DiscardCurrentStateTask 7058 : public SessionMachine::Task 7059 { 7060 DiscardCurrentStateTask(SessionMachine *m, Progress *p, bool discardCurSnapshot) 7061 : Task(m, p), 7062 discardCurrentSnapshot(discardCurSnapshot) 7063 {} 7064 7065 void handler() 7066 { 7067 machine->discardCurrentStateHandler(*this); 7068 } 7047 7069 7048 7070 const bool discardCurrentSnapshot; … … 7051 7073 //////////////////////////////////////////////////////////////////////////////// 7052 7074 7053 DEFINE_EMPTY_CTOR_DTOR 7075 DEFINE_EMPTY_CTOR_DTOR(SessionMachine) 7054 7076 7055 7077 HRESULT SessionMachine::FinalConstruct() … … 7874 7896 * @note Locks mParent + this object for writing. 7875 7897 */ 7876 STDMETHODIMP SessionMachine::BeginTakingSnapshot ( 7877 IConsole *aInitiator, IN_BSTR aName, IN_BSTR aDescription, 7878 IProgress *aProgress, BSTR *aStateFilePath, 7879 IProgress **aServerProgress) 7898 STDMETHODIMP SessionMachine::BeginTakingSnapshot(IConsole *aInitiator, 7899 IN_BSTR aName, 7900 IN_BSTR aDescription, 7901 IProgress *aProgress, 7902 BSTR *aStateFilePath, 7903 IProgress **aServerProgress) 7880 7904 { 7881 7905 LogFlowThisFuncEnter(); … … 7892 7916 AutoMultiWriteLock2 alock (mParent, this); 7893 7917 7894 AssertReturn((!Global::IsOnlineOrTransient (mData->mMachineState) || 7895 mData->mMachineState == MachineState_Paused) && 7896 mSnapshotData.mLastState == MachineState_Null && 7897 mSnapshotData.mSnapshot.isNull() && 7898 mSnapshotData.mServerProgress.isNull() && 7899 mSnapshotData.mCombinedProgress.isNull(), 7900 E_FAIL); 7901 7902 bool takingSnapshotOnline = mData->mMachineState == MachineState_Paused; 7903 7904 if (!takingSnapshotOnline && mData->mMachineState != MachineState_Saved) 7918 AssertReturn( ( !Global::IsOnlineOrTransient (mData->mMachineState) 7919 || mData->mMachineState == MachineState_Paused 7920 ) 7921 && mSnapshotData.mLastState == MachineState_Null 7922 && mSnapshotData.mSnapshot.isNull() 7923 && mSnapshotData.mServerProgress.isNull() 7924 && mSnapshotData.mCombinedProgress.isNull(), E_FAIL); 7925 7926 bool fTakingSnapshotOnline = (mData->mMachineState == MachineState_Paused); 7927 7928 if ( !fTakingSnapshotOnline 7929 && mData->mMachineState != MachineState_Saved) 7905 7930 { 7906 7931 /* save all current settings to ensure current changes are committed and … … 7929 7954 #endif 7930 7955 7931 AssertReturn(aProgress || ! takingSnapshotOnline, E_FAIL);7956 AssertReturn(aProgress || !fTakingSnapshotOnline, E_FAIL); 7932 7957 7933 7958 /* create an ID for the snapshot */ … … 7937 7962 Bstr stateFilePath; 7938 7963 /* stateFilePath is null when the machine is not online nor saved */ 7939 if (takingSnapshotOnline || mData->mMachineState == MachineState_Saved) 7940 stateFilePath = Utf8StrFmt ("%ls%c{%RTuuid}.sav", 7941 mUserData->mSnapshotFolderFull.raw(), 7942 RTPATH_DELIMITER, 7943 snapshotId.ptr()); 7964 if ( fTakingSnapshotOnline 7965 || mData->mMachineState == MachineState_Saved) 7966 stateFilePath = BstrFmt("%ls%c{%RTuuid}.sav", 7967 mUserData->mSnapshotFolderFull.raw(), 7968 RTPATH_DELIMITER, 7969 snapshotId.ptr()); 7944 7970 7945 7971 /* ensure the directory for the saved state file exists */ … … 7953 7979 ComObjPtr<SnapshotMachine> snapshotMachine; 7954 7980 snapshotMachine.createObject(); 7955 HRESULT rc = snapshotMachine->init 7981 HRESULT rc = snapshotMachine->init(this, snapshotId, stateFilePath); 7956 7982 AssertComRCReturn (rc, rc); 7957 7983 7958 Bstr progressDesc = BstrFmt (tr("Taking snapshot of virtual machine '%ls'"),7959 7960 Bstr firstOpDesc = Bstr (tr("Preparing to take snapshot"));7984 Bstr progressDesc = BstrFmt(tr("Taking snapshot of virtual machine '%ls'"), 7985 mUserData->mName.raw()); 7986 Bstr firstOpDesc = Bstr(tr("Preparing to take snapshot")); 7961 7987 7962 7988 /* create a server-side progress object (it will be descriptionless when we … … 7971 7997 if (mData->mMachineState == MachineState_Saved) 7972 7998 opCount ++; 7973 if ( takingSnapshotOnline)7974 rc = serverProgress->init 7999 if (fTakingSnapshotOnline) 8000 rc = serverProgress->init(FALSE, opCount, firstOpDesc); 7975 8001 else 7976 rc = serverProgress->init 7977 8002 rc = serverProgress->init(mParent, aInitiator, progressDesc, FALSE, 8003 opCount, firstOpDesc); 7978 8004 AssertComRCReturn (rc, rc); 7979 8005 } … … 7981 8007 /* create a combined server-side progress object when necessary */ 7982 8008 ComObjPtr<CombinedProgress> combinedProgress; 7983 if ( takingSnapshotOnline)8009 if (fTakingSnapshotOnline) 7984 8010 { 7985 8011 combinedProgress.createObject(); … … 8004 8030 /* create and start the task on a separate thread (note that it will not 8005 8031 * start working until we release alock) */ 8006 TakeSnapshotTask *task = new TakeSnapshotTask (this); 8007 int vrc = RTThreadCreate (NULL, taskHandler, 8008 (void *) task, 8009 0, RTTHREADTYPE_MAIN_WORKER, 0, "TakeSnapshot"); 8032 TakeSnapshotTask *task = new TakeSnapshotTask(this); 8033 int vrc = RTThreadCreate(NULL, 8034 taskHandler, 8035 (void*)task, 8036 0, 8037 RTTHREADTYPE_MAIN_WORKER, 8038 0, 8039 "TakeSnapshot"); 8010 8040 if (RT_FAILURE(vrc)) 8011 8041 { … … 8022 8052 8023 8053 /* set the state to Saving (this is expected by Console::TakeSnapshot()) */ 8024 setMachineState 8025 8026 if ( takingSnapshotOnline)8054 setMachineState(MachineState_Saving); 8055 8056 if (fTakingSnapshotOnline) 8027 8057 stateFilePath.cloneTo(aStateFilePath); 8028 8058 else … … 8038 8068 * @note Locks this object for writing. 8039 8069 */ 8040 STDMETHODIMP SessionMachine::EndTakingSnapshot 8070 STDMETHODIMP SessionMachine::EndTakingSnapshot(BOOL aSuccess) 8041 8071 { 8042 8072 LogFlowThisFunc(("\n")); … … 8058 8088 * (this is expected by Console::TakeSnapshot() and 8059 8089 * Console::saveStateThread()) */ 8060 setMachineState 8061 8062 return endTakingSnapshot 8090 setMachineState(mSnapshotData.mLastState); 8091 8092 return endTakingSnapshot(aSuccess); 8063 8093 } 8064 8094 … … 8930 8960 /** 8931 8961 * Helper method to finalize taking a snapshot. Gets called to finalize the 8932 * "take snapshot" procedure. 8962 * "take snapshot" procedure, either from the public SessionMachine::EndTakingSnapshot() 8963 * if taking the snapshot failed/was aborted or from the takeSnapshotHandler thread 8964 * when taking the snapshot succeeded. 8933 8965 * 8934 8966 * Expected to be called after completing *all* the tasks related to taking the … … 8939 8971 * @note Locks this objects for writing. 8940 8972 */ 8941 HRESULT SessionMachine::endTakingSnapshot 8973 HRESULT SessionMachine::endTakingSnapshot(BOOL aSuccess) 8942 8974 { 8943 8975 LogFlowThisFuncEnter(); … … 8956 8988 { 8957 8989 /* the server progress must be completed on success */ 8958 Assert 8990 Assert(mSnapshotData.mServerProgress->completed()); 8959 8991 8960 8992 mData->mCurrentSnapshot = mSnapshotData.mSnapshot; … … 8964 8996 mData->mFirstSnapshot = mData->mCurrentSnapshot; 8965 8997 8966 if (!Global::IsOnline 8998 if (!Global::IsOnline(mSnapshotData.mLastState)) 8967 8999 /* the machine was powered off or saved when taking a snapshot, so 8968 9000 * reset the mCurrentStateModified flag */ … … 9018 9050 9019 9051 /** 9020 * Take snapshot task handler. Must be called only by 9021 * TakeSnapshotTask::handler()! 9052 * Take snapshot task handler. 9053 * This gets called from TakeSnapshotTask::handler(), which got created by 9054 * SnapshotMachine::BeginTakingSnapshot(). 9022 9055 * 9023 9056 * The sole purpose of this task is to asynchronously create differencing VDIs … … 9027 9060 * @note Locks this object for writing. 9028 9061 */ 9029 void SessionMachine::takeSnapshotHandler 9062 void SessionMachine::takeSnapshotHandler(TakeSnapshotTask & /* aTask */) 9030 9063 { 9031 9064 LogFlowThisFuncEnter(); … … 9046 9079 HRESULT rc = S_OK; 9047 9080 9048 bool online = Global::IsOnline 9081 bool online = Global::IsOnline(mSnapshotData.mLastState); 9049 9082 9050 9083 LogFlowThisFunc(("Creating differencing hard disks (online=%d)...\n", 9051 9084 online)); 9052 9085 9053 9086 mHDData.backup(); 9054 9087 9055 9088 /* create new differencing hard disks and attach them to this machine */ 9056 rc = createImplicitDiffs (mUserData->mSnapshotFolderFull, 9057 mSnapshotData.mServerProgress, 9058 online); 9059 9060 if (SUCCEEDED(rc) && mSnapshotData.mLastState == MachineState_Saved) 9089 rc = createImplicitDiffs(mUserData->mSnapshotFolderFull, 9090 mSnapshotData.mServerProgress, 9091 online); 9092 9093 if ( SUCCEEDED(rc) 9094 && mSnapshotData.mLastState == MachineState_Saved) 9061 9095 { 9062 9096 Utf8Str stateFrom = mSSData->mStateFilePath; … … 9071 9105 /* Leave the lock before a lengthy operation (mMachineState is 9072 9106 * MachineState_Saving here) */ 9073 9074 9107 alock.leave(); 9075 9108 … … 9101 9134 ErrorInfoKeeper eik; 9102 9135 9103 setMachineState 9136 setMachineState(mSnapshotData.mLastState); 9104 9137 updateMachineStateOnClient(); 9105 9138 } 9106 9139 9107 9140 /* finalize the progress after setting the state, for consistency */ 9108 mSnapshotData.mServerProgress->notifyComplete 9109 9110 endTakingSnapshot 9141 mSnapshotData.mServerProgress->notifyComplete(rc); 9142 9143 endTakingSnapshot(SUCCEEDED(rc)); 9111 9144 } 9112 9145 else … … 9373 9406 catch (HRESULT aRC) { rc = aRC; } 9374 9407 9375 if FAILED(rc)9408 if (FAILED(rc)) 9376 9409 { 9377 9410 HRESULT rc2 = S_OK; -
trunk/src/VBox/Main/MediumImpl.cpp
r22173 r22624 396 396 * in-process calls). 397 397 */ 398 STDMETHODIMP MediumBase::LockWrite 398 STDMETHODIMP MediumBase::LockWrite(MediaState_T *aState) 399 399 { 400 400 AutoCaller autoCaller(this); -
trunk/src/VBox/Main/SnapshotImpl.cpp
r22173 r22624 346 346 } 347 347 348 STDMETHODIMP Snapshot::COMGETTER(Online) 348 STDMETHODIMP Snapshot::COMGETTER(Online)(BOOL *aOnline) 349 349 { 350 350 CheckComArgOutPointerValid(aOnline); -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r22562 r22624 4280 4280 */ 4281 4281 HRESULT VirtualBox::unregisterDHCPServer(DHCPServer *aDHCPServer, 4282 bool aSaveRegistry /*= true*/)4282 bool aSaveRegistry /*= true*/) 4283 4283 { 4284 4284 AssertReturn(aDHCPServer != NULL, E_INVALIDARG); -
trunk/src/VBox/Main/include/MachineImpl.h
r22183 r22624 917 917 NS_DECL_ISUPPORTS 918 918 919 DECLARE_EMPTY_CTOR_DTOR 919 DECLARE_EMPTY_CTOR_DTOR(SessionMachine) 920 920 921 921 HRESULT FinalConstruct(); -
trunk/src/VBox/Main/include/SnapshotImpl.h
r22183 r22624 91 91 // public methods only for internal purposes 92 92 93 const Bstr &stateFilePath() const;93 const Bstr& stateFilePath() const; 94 94 95 95 ComObjPtr<Snapshot> parent() const -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r22305 r22624 79 79 public: 80 80 81 typedef std::list <ComPtr<IVirtualBoxCallback> > CallbackList;82 typedef std::vector <ComPtr<IVirtualBoxCallback> > CallbackVector;83 84 typedef std::vector <ComObjPtr<SessionMachine> > SessionMachineVector;85 typedef std::vector <ComObjPtr<Machine> > MachineVector;86 87 typedef std::vector <ComPtr<IInternalSessionControl> > InternalControlVector;81 typedef std::list< ComPtr<IVirtualBoxCallback> > CallbackList; 82 typedef std::vector< ComPtr<IVirtualBoxCallback> > CallbackVector; 83 84 typedef std::vector< ComObjPtr<SessionMachine> > SessionMachineVector; 85 typedef std::vector< ComObjPtr<Machine> > MachineVector; 86 87 typedef std::vector< ComPtr<IInternalSessionControl> > InternalControlVector; 88 88 89 89 class CallbackEvent; … … 107 107 NS_DECL_ISUPPORTS 108 108 109 / * to postpone generation of the default ctor/dtor */109 // to postpone generation of the default ctor/dtor 110 110 VirtualBox(); 111 111 ~VirtualBox(); … … 389 389 Data mData; 390 390 391 #if defined(RT_OS_WINDOWS) 392 #define UPDATEREQARG NULL 393 #define UPDATEREQTYPE HANDLE 394 #elif defined(RT_OS_OS2) 395 #define UPDATEREQARG NIL_RTSEMEVENT 396 #define UPDATEREQTYPE RTSEMEVENT 397 #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER) 398 #define UPDATEREQARG 399 #define UPDATEREQTYPE RTSEMEVENT 400 #else 401 # error "Port me!" 402 #endif 403 391 404 /** Client watcher thread data structure */ 392 405 struct ClientWatcherData 393 406 { 394 407 ClientWatcherData() 395 #if defined(RT_OS_WINDOWS) 396 : mUpdateReq (NULL) 397 #elif defined(RT_OS_OS2) 398 : mUpdateReq (NIL_RTSEMEVENT) 399 #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER) 400 : mUpdateReq (NIL_RTSEMEVENT) 401 #else 402 # error "Port me!" 403 #endif 404 , mThread (NIL_RTTHREAD) {} 408 : mUpdateReq(UPDATEREQARG), 409 mThread(NIL_RTTHREAD) 410 {} 405 411 406 412 // const objects not requiring locking 407 #if defined(RT_OS_WINDOWS) 408 const HANDLE mUpdateReq; 409 #elif defined(RT_OS_OS2) 410 const RTSEMEVENT mUpdateReq; 411 #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER) 412 const RTSEMEVENT mUpdateReq; 413 #else 414 # error "Port me!" 415 #endif 413 const UPDATEREQTYPE mUpdateReq; 416 414 const RTTHREAD mThread; 417 415
Note:
See TracChangeset
for help on using the changeset viewer.