Changeset 35460 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Jan 10, 2011 2:24:13 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r35429 r35460 5 5 6 6 /* 7 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 10479 10479 } 10480 10480 10481 10482 10481 /** 10483 10482 * @note Locks this object for writing. … … 10513 10512 return S_OK; 10514 10513 } 10514 10515 /** 10516 * @note Locks this object for writing. 10517 */ 10518 STDMETHODIMP SessionMachine::BeginPoweringDown(IProgress **aProgress) 10519 { 10520 LogFlowThisFuncEnter(); 10521 10522 CheckComArgOutPointerValid(aProgress); 10523 10524 AutoCaller autoCaller(this); 10525 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 10526 10527 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 10528 10529 AssertReturn(mConsoleTaskData.mLastState == MachineState_Null, 10530 E_FAIL); 10531 10532 /* create a progress object to track operation completion */ 10533 ComObjPtr<Progress> pProgress; 10534 pProgress.createObject(); 10535 pProgress->init(getVirtualBox(), 10536 static_cast<IMachine *>(this) /* aInitiator */, 10537 Bstr(tr("Stopping the virtual machine")).raw(), 10538 FALSE /* aCancelable */); 10539 10540 /* fill in the console task data */ 10541 mConsoleTaskData.mLastState = mData->mMachineState; 10542 mConsoleTaskData.mProgress = pProgress; 10543 10544 /* set the state to Stopping (this is expected by Console::PowerDown()) */ 10545 setMachineState(MachineState_Stopping); 10546 10547 pProgress.queryInterfaceTo(aProgress); 10548 10549 return S_OK; 10550 } 10551 10552 /** 10553 * @note Locks this object for writing. 10554 */ 10555 STDMETHODIMP SessionMachine::EndPoweringDown(LONG iResult, IN_BSTR aErrMsg) 10556 { 10557 LogFlowThisFuncEnter(); 10558 10559 AutoCaller autoCaller(this); 10560 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 10561 10562 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 10563 10564 AssertReturn( ( (SUCCEEDED(iResult) && mData->mMachineState == MachineState_PoweredOff) 10565 || (FAILED(iResult) && mData->mMachineState == MachineState_Stopping)) 10566 && mConsoleTaskData.mLastState != MachineState_Null, 10567 E_FAIL); 10568 10569 /* 10570 * On failure, set the state to the state we had when BeginPoweringDown() 10571 * was called (this is expected by Console::PowerDown() and the associated 10572 * task). On success the VM process already changed the state to 10573 * MachineState_PoweredOff, so no need to do anything. 10574 */ 10575 if (FAILED(iResult)) 10576 setMachineState(mConsoleTaskData.mLastState); 10577 10578 /* notify the progress object about operation completion */ 10579 Assert(mConsoleTaskData.mProgress); 10580 if (SUCCEEDED(iResult)) 10581 mConsoleTaskData.mProgress->notifyComplete(S_OK); 10582 else 10583 { 10584 Utf8Str strErrMsg(aErrMsg); 10585 if (strErrMsg.length()) 10586 mConsoleTaskData.mProgress->notifyComplete(iResult, 10587 COM_IIDOF(ISession), 10588 getComponentName(), 10589 strErrMsg.c_str()); 10590 else 10591 mConsoleTaskData.mProgress->notifyComplete(iResult); 10592 } 10593 10594 /* clear out the temporary saved state data */ 10595 mConsoleTaskData.mLastState = MachineState_Null; 10596 mConsoleTaskData.mProgress.setNull(); 10597 10598 LogFlowThisFuncLeave(); 10599 return S_OK; 10600 } 10601 10515 10602 10516 10603 /** … … 10779 10866 } 10780 10867 10781 /* fill in the snapshotdata */10868 /* fill in the console task data */ 10782 10869 mConsoleTaskData.mLastState = mData->mMachineState; 10783 10870 mConsoleTaskData.mStateFilePath = stateFilePath; … … 11541 11628 if (aErrMsg.length()) 11542 11629 mConsoleTaskData.mProgress->notifyComplete(aRc, 11543 COM_IIDOF(ISession),11544 getComponentName(),11545 aErrMsg.c_str());11630 COM_IIDOF(ISession), 11631 getComponentName(), 11632 aErrMsg.c_str()); 11546 11633 else 11547 11634 mConsoleTaskData.mProgress->notifyComplete(aRc);
Note:
See TracChangeset
for help on using the changeset viewer.