Changeset 52481 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Aug 22, 2014 5:27:48 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 95701
- Location:
- trunk/src/VBox/Main/src-server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r52339 r52481 1861 1861 { 1862 1862 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1863 1863 1864 1864 aVideoCaptureOptions = mHWData->mVideoCaptureOptions; 1865 1865 return S_OK; … … 7207 7207 * Returns the full path to the machine's log file for an given index. 7208 7208 */ 7209 Utf8Str Machine::i_queryLogFilename(ULONG idx) /** @todo r=bird: Misnamed. Should be i_getLogFilename as it cannot fail. See VBox-CodingGuidelines.cpp, Compulsory seciont, line 79. */ 7209 Utf8Str Machine::i_queryLogFilename(ULONG idx) /** @todo r=bird: Misnamed. Should be i_getLogFilename as it cannot fail. 7210 See VBox-CodingGuidelines.cpp, Compulsory seciont, line 79. */ 7210 7211 { 7211 7212 Utf8Str logFolder; … … 7412 7413 Utf8Str strStartupLogDir = strStartupLogFile; 7413 7414 strStartupLogDir.stripFilename(); 7414 RTDirCreateFullPath(strStartupLogDir.c_str(), 0755); /** @todo add a variant for creating the path to a file without stripping the file. */ 7415 RTDirCreateFullPath(strStartupLogDir.c_str(), 0755); /** @todo add a variant for creating the path to a 7416 file without stripping the file. */ 7415 7417 } 7416 7418 strSupStartLogArg.append(strStartupLogFile); … … 10869 10871 { 10870 10872 alock.release(); 10871 rc = mData->mSession.mMachine-> lockMedia();10873 rc = mData->mSession.mMachine->i_lockMedia(); 10872 10874 alock.acquire(); 10873 10875 if (FAILED(rc)) … … 12548 12550 * Passes collected guest statistics to performance collector object 12549 12551 */ 12550 STDMETHODIMP SessionMachine::ReportVmStatistics(ULONG aValidStats, ULONG aCpuUser,12551 12552 12553 12554 12555 12556 12557 12552 HRESULT SessionMachine::reportVmStatistics(ULONG aValidStats, ULONG aCpuUser, 12553 ULONG aCpuKernel, ULONG aCpuIdle, 12554 ULONG aMemTotal, ULONG aMemFree, 12555 ULONG aMemBalloon, ULONG aMemShared, 12556 ULONG aMemCache, ULONG aPageTotal, 12557 ULONG aAllocVMM, ULONG aFreeVMM, 12558 ULONG aBalloonedVMM, ULONG aSharedVMM, 12559 ULONG aVmNetRx, ULONG aVmNetTx) 12558 12560 { 12559 12561 #ifdef VBOX_WITH_RESOURCE_USAGE_API … … 12589 12591 * @note Locks this object for writing. 12590 12592 */ 12591 STDMETHODIMP SessionMachine::SetRemoveSavedStateFile(BOOL aRemove) 12592 { 12593 AutoCaller autoCaller(this); 12594 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 12595 12593 HRESULT SessionMachine::setRemoveSavedStateFile(BOOL aRemove) 12594 { 12596 12595 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 12597 12596 … … 12604 12603 * @note Locks the same as #i_setMachineState() does. 12605 12604 */ 12606 STDMETHODIMP SessionMachine::UpdateState(MachineState_T aMachineState)12607 { 12608 return i_setMachineState(a MachineState);12605 HRESULT SessionMachine::updateState(MachineState_T aState) 12606 { 12607 return i_setMachineState(aState); 12609 12608 } 12610 12609 … … 12612 12611 * @note Locks this object for writing. 12613 12612 */ 12614 STDMETHODIMP SessionMachine::BeginPowerUp(IProgress *aProgress)12615 { 12616 LogFlowThisFunc(("aProgress=%p\n", aProgress));12617 AutoCaller autoCaller(this); 12618 AssertComRCReturn(autoCaller.rc(), autoCaller.rc());12613 HRESULT SessionMachine::beginPowerUp(const ComPtr<IProgress> &aProgress) 12614 { 12615 IProgress* pProgress(aProgress); 12616 12617 LogFlowThisFunc(("aProgress=%p\n", pProgress)); 12619 12618 12620 12619 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 12624 12623 12625 12624 if (!mData->mSession.mProgress.isNull()) 12626 mData->mSession.mProgress->setOtherProgressObject( aProgress);12625 mData->mSession.mProgress->setOtherProgressObject(pProgress); 12627 12626 12628 12627 /* If we didn't reference the NAT network service yet, add a reference to … … 12664 12663 * @note Locks this object for writing. 12665 12664 */ 12666 STDMETHODIMP SessionMachine::EndPowerUp(LONG iResult) 12667 { 12668 AutoCaller autoCaller(this); 12669 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 12670 12665 HRESULT SessionMachine::endPowerUp(LONG aResult) 12666 { 12671 12667 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 12672 12668 … … 12677 12673 if (mData->mSession.mProgress) 12678 12674 { 12679 mData->mSession.mProgress->notifyComplete((HRESULT) iResult);12675 mData->mSession.mProgress->notifyComplete((HRESULT)aResult); 12680 12676 mData->mSession.mProgress.setNull(); 12681 12677 } 12682 12678 12683 if (SUCCEEDED((HRESULT) iResult))12679 if (SUCCEEDED((HRESULT)aResult)) 12684 12680 { 12685 12681 #ifdef VBOX_WITH_RESOURCE_USAGE_API … … 12698 12694 * @note Locks this object for writing. 12699 12695 */ 12700 STDMETHODIMP SessionMachine::BeginPoweringDown(IProgress **aProgress)12696 HRESULT SessionMachine::beginPoweringDown(ComPtr<IProgress> &aProgress) 12701 12697 { 12702 12698 LogFlowThisFuncEnter(); 12703 12704 AutoCaller autoCaller(this);12705 AssertComRCReturn(autoCaller.rc(), autoCaller.rc());12706 12699 12707 12700 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 12725 12718 i_setMachineState(MachineState_Stopping); 12726 12719 12727 pProgress.queryInterfaceTo(aProgress );12720 pProgress.queryInterfaceTo(aProgress.asOutParam()); 12728 12721 12729 12722 return S_OK; … … 12733 12726 * @note Locks this object for writing. 12734 12727 */ 12735 STDMETHODIMP SessionMachine::EndPoweringDown(LONG iResult, IN_BSTR aErrMsg) 12728 HRESULT SessionMachine::endPoweringDown(LONG aResult, 12729 const com::Utf8Str &aErrMsg) 12736 12730 { 12737 12731 LogFlowThisFuncEnter(); 12738 12732 12739 AutoCaller autoCaller(this);12740 AssertComRCReturn(autoCaller.rc(), autoCaller.rc());12741 12742 12733 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 12743 12734 12744 AssertReturn( ( (SUCCEEDED( iResult) && mData->mMachineState == MachineState_PoweredOff)12745 || (FAILED( iResult) && mData->mMachineState == MachineState_Stopping))12735 AssertReturn( ( (SUCCEEDED(aResult) && mData->mMachineState == MachineState_PoweredOff) 12736 || (FAILED(aResult) && mData->mMachineState == MachineState_Stopping)) 12746 12737 && mConsoleTaskData.mLastState != MachineState_Null, 12747 12738 E_FAIL); … … 12753 12744 * MachineState_PoweredOff, so no need to do anything. 12754 12745 */ 12755 if (FAILED( iResult))12746 if (FAILED(aResult)) 12756 12747 i_setMachineState(mConsoleTaskData.mLastState); 12757 12748 12758 12749 /* notify the progress object about operation completion */ 12759 12750 Assert(mConsoleTaskData.mProgress); 12760 if (SUCCEEDED( iResult))12751 if (SUCCEEDED(aResult)) 12761 12752 mConsoleTaskData.mProgress->i_notifyComplete(S_OK); 12762 12753 else 12763 12754 { 12764 Utf8Str strErrMsg(aErrMsg); 12765 if (strErrMsg.length()) 12766 mConsoleTaskData.mProgress->i_notifyComplete(iResult, 12755 if (aErrMsg.length()) 12756 mConsoleTaskData.mProgress->i_notifyComplete(aResult, 12767 12757 COM_IIDOF(ISession), 12768 12758 getComponentName(), 12769 strErrMsg.c_str());12759 aErrMsg.c_str()); 12770 12760 else 12771 mConsoleTaskData.mProgress->i_notifyComplete( iResult);12761 mConsoleTaskData.mProgress->i_notifyComplete(aResult); 12772 12762 } 12773 12763 … … 12787 12777 * @note Locks the same as USBController::hasMatchingFilter() does. 12788 12778 */ 12789 STDMETHODIMP SessionMachine::RunUSBDeviceFilters(IUSBDevice *aUSBDevice,12790 BOOL*aMatched,12791 ULONG *aMaskedIfs)12779 HRESULT SessionMachine::runUSBDeviceFilters(const ComPtr<IUSBDevice> &aDevice, 12780 BOOL *aMatched, 12781 ULONG *aMaskedInterfaces) 12792 12782 { 12793 12783 LogFlowThisFunc(("\n")); 12794 12784 12795 AutoCaller autoCaller(this);12796 AssertComRCReturn(autoCaller.rc(), autoCaller.rc());12797 12798 12785 #ifdef VBOX_WITH_USB 12799 *aMatched = mUSBDeviceFilters->i_hasMatchingFilter(a USBDevice, aMaskedIfs);12786 *aMatched = mUSBDeviceFilters->i_hasMatchingFilter(aDevice, aMaskedInterfaces); 12800 12787 #else 12801 NOREF(a USBDevice);12802 NOREF(aMaskedI fs);12788 NOREF(aDevice); 12789 NOREF(aMaskedInterfaces); 12803 12790 *aMatched = FALSE; 12804 12791 #endif … … 12810 12797 * @note Locks the same as Host::captureUSBDevice() does. 12811 12798 */ 12812 STDMETHODIMP SessionMachine::CaptureUSBDevice(IN_BSTRaId)12799 HRESULT SessionMachine::captureUSBDevice(const com::Guid &aId) 12813 12800 { 12814 12801 LogFlowThisFunc(("\n")); 12815 12816 AutoCaller autoCaller(this);12817 AssertComRCReturnRC(autoCaller.rc());12818 12802 12819 12803 #ifdef VBOX_WITH_USB … … 12825 12809 USBProxyService *service = mParent->i_host()->i_usbProxyService(); 12826 12810 AssertReturn(service, E_FAIL); 12827 return service->captureDeviceForVM(this, Guid(aId).ref());12811 return service->captureDeviceForVM(this, aId.ref()); 12828 12812 #else 12829 12813 NOREF(aId); … … 12835 12819 * @note Locks the same as Host::detachUSBDevice() does. 12836 12820 */ 12837 STDMETHODIMP SessionMachine::DetachUSBDevice(IN_BSTR aId, BOOL aDone) 12821 HRESULT SessionMachine::detachUSBDevice(const com::Guid &aId, 12822 BOOL aDone) 12838 12823 { 12839 12824 LogFlowThisFunc(("\n")); 12840 12841 AutoCaller autoCaller(this);12842 AssertComRCReturn(autoCaller.rc(), autoCaller.rc());12843 12825 12844 12826 #ifdef VBOX_WITH_USB 12845 12827 USBProxyService *service = mParent->i_host()->i_usbProxyService(); 12846 12828 AssertReturn(service, E_FAIL); 12847 return service->detachDeviceFromVM(this, Guid(aId).ref(), !!aDone);12829 return service->detachDeviceFromVM(this, aId.ref(), !!aDone); 12848 12830 #else 12849 12831 NOREF(aId); … … 12861 12843 * @note Locks what called methods lock. 12862 12844 */ 12863 STDMETHODIMP SessionMachine::AutoCaptureUSBDevices()12845 HRESULT SessionMachine::autoCaptureUSBDevices() 12864 12846 { 12865 12847 LogFlowThisFunc(("\n")); 12866 12867 AutoCaller autoCaller(this);12868 AssertComRCReturn(autoCaller.rc(), autoCaller.rc());12869 12848 12870 12849 #ifdef VBOX_WITH_USB … … 12891 12870 * @note Locks what called methods lock. 12892 12871 */ 12893 STDMETHODIMP SessionMachine::DetachAllUSBDevices(BOOL aDone)12872 HRESULT SessionMachine::detachAllUSBDevices(BOOL aDone) 12894 12873 { 12895 12874 LogFlowThisFunc(("\n")); 12896 12897 AutoCaller autoCaller(this);12898 AssertComRCReturn(autoCaller.rc(), autoCaller.rc());12899 12875 12900 12876 #ifdef VBOX_WITH_USB … … 12915 12891 * @note Locks this object for writing. 12916 12892 */ 12917 STDMETHODIMP SessionMachine::OnSessionEnd(ISession *aSession,12918 IProgress **aProgress)12893 HRESULT SessionMachine::onSessionEnd(const ComPtr<ISession> &aSession, 12894 ComPtr<IProgress> &aProgress) 12919 12895 { 12920 12896 LogFlowThisFuncEnter(); 12921 12922 AssertReturn(aSession, E_INVALIDARG);12923 AssertReturn(aProgress, E_INVALIDARG);12924 12925 AutoCaller autoCaller(this);12926 12897 12927 12898 LogFlowThisFunc(("callerstate=%d\n", getObjectState().getState())); … … 12930 12901 * informs us it is closed right after we've been uninitialized -- it's ok. 12931 12902 */ 12932 if (FAILED(autoCaller.rc())) return autoCaller.rc();12933 12903 12934 12904 /* get IInternalSessionControl interface */ … … 12943 12913 if (control == mData->mSession.mDirectControl) 12944 12914 { 12945 ComAssertRet(aProgress, E_POINTER); 12915 IProgress *pProgress = aProgress; 12916 ComAssertRet(pProgress, E_POINTER); 12946 12917 12947 12918 /* The direct session is being normally closed by the client process … … 12980 12951 Bstr(tr("Closing session")).raw(), 12981 12952 FALSE /* aCancelable */); 12982 progress.queryInterfaceTo(aProgress );12953 progress.queryInterfaceTo(aProgress.asOutParam()); 12983 12954 mData->mSession.mProgress = progress; 12984 12955 } … … 13012 12983 * @note Locks this object for writing. 13013 12984 */ 13014 STDMETHODIMP SessionMachine::BeginSavingState(IProgress **aProgress, BSTR *aStateFilePath) 12985 HRESULT SessionMachine::beginSavingState(ComPtr<IProgress> &aProgress, 12986 com::Utf8Str &aStateFilePath) 13015 12987 { 13016 12988 LogFlowThisFuncEnter(); 13017 13018 CheckComArgOutPointerValid(aProgress);13019 CheckComArgOutPointerValid(aStateFilePath);13020 13021 AutoCaller autoCaller(this);13022 AssertComRCReturn(autoCaller.rc(), autoCaller.rc());13023 12989 13024 12990 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 13037 13003 FALSE /* aCancelable */); 13038 13004 13039 Utf8Str strStateFilePath;13040 13005 /* stateFilePath is null when the machine is not running */ 13041 13006 if (mData->mMachineState == MachineState_Paused) 13042 i_composeSavedStateFilename( strStateFilePath);13007 i_composeSavedStateFilename(aStateFilePath); 13043 13008 13044 13009 /* fill in the console task data */ 13045 13010 mConsoleTaskData.mLastState = mData->mMachineState; 13046 mConsoleTaskData.strStateFilePath = strStateFilePath;13011 mConsoleTaskData.strStateFilePath = aStateFilePath; 13047 13012 mConsoleTaskData.mProgress = pProgress; 13048 13013 … … 13050 13015 i_setMachineState(MachineState_Saving); 13051 13016 13052 strStateFilePath.cloneTo(aStateFilePath); 13053 pProgress.queryInterfaceTo(aProgress); 13017 pProgress.queryInterfaceTo(aProgress.asOutParam()); 13054 13018 13055 13019 return S_OK; … … 13059 13023 * @note Locks mParent + this object for writing. 13060 13024 */ 13061 STDMETHODIMP SessionMachine::EndSavingState(LONG iResult, IN_BSTR aErrMsg) 13025 HRESULT SessionMachine::endSavingState(LONG aResult, 13026 const com::Utf8Str &aErrMsg) 13062 13027 { 13063 13028 LogFlowThisFunc(("\n")); 13064 13065 AutoCaller autoCaller(this);13066 AssertComRCReturn(autoCaller.rc(), autoCaller.rc());13067 13029 13068 13030 /* endSavingState() need mParent lock */ 13069 13031 AutoMultiWriteLock2 alock(mParent, this COMMA_LOCKVAL_SRC_POS); 13070 13032 13071 AssertReturn( ( (SUCCEEDED( iResult) && mData->mMachineState == MachineState_Saved)13072 || (FAILED( iResult) && mData->mMachineState == MachineState_Saving))13033 AssertReturn( ( (SUCCEEDED(aResult) && mData->mMachineState == MachineState_Saved) 13034 || (FAILED(aResult) && mData->mMachineState == MachineState_Saving)) 13073 13035 && mConsoleTaskData.mLastState != MachineState_Null 13074 13036 && !mConsoleTaskData.strStateFilePath.isEmpty(), … … 13081 13043 * MachineState_Saved, so no need to do anything. 13082 13044 */ 13083 if (FAILED( iResult))13045 if (FAILED(aResult)) 13084 13046 i_setMachineState(mConsoleTaskData.mLastState); 13085 13047 13086 return endSavingState(iResult, aErrMsg);13048 return i_endSavingState(aResult, aErrMsg); 13087 13049 } 13088 13050 … … 13090 13052 * @note Locks this object for writing. 13091 13053 */ 13092 STDMETHODIMP SessionMachine::AdoptSavedState(IN_BSTRaSavedStateFile)13054 HRESULT SessionMachine::adoptSavedState(const com::Utf8Str &aSavedStateFile) 13093 13055 { 13094 13056 LogFlowThisFunc(("\n")); 13095 13096 CheckComArgStrNotEmptyOrNull(aSavedStateFile);13097 13098 AutoCaller autoCaller(this);13099 AssertComRCReturn(autoCaller.rc(), autoCaller.rc());13100 13057 13101 13058 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 13106 13063 , E_FAIL); /** @todo setError. */ 13107 13064 13108 Utf8Str stateFilePathFull = aSavedStateFile;13109 int vrc = i_calculateFullPath( stateFilePathFull, stateFilePathFull);13065 com::Utf8Str stateFilePathFull = aSavedStateFile; 13066 int vrc = i_calculateFullPath(aSavedStateFile, stateFilePathFull); 13110 13067 if (RT_FAILURE(vrc)) 13111 13068 return setError(VBOX_E_FILE_ERROR, 13112 tr("Invalid saved state file path '% ls' (%Rrc)"),13113 aSavedStateFile,13069 tr("Invalid saved state file path '%s' (%Rrc)"), 13070 stateFilePathFull.c_str(), 13114 13071 vrc); 13115 13072 … … 13122 13079 } 13123 13080 13124 STDMETHODIMP SessionMachine::PullGuestProperties(ComSafeArrayOut(BSTR, aNames),13125 ComSafeArrayOut(BSTR, aValues),13126 ComSafeArrayOut(LONG64, aTimestamps),13127 ComSafeArrayOut(BSTR, aFlags))13081 HRESULT SessionMachine::pullGuestProperties(std::vector<com::Utf8Str> &aNames, 13082 std::vector<com::Utf8Str> &aValues, 13083 std::vector<LONG64> &aTimestamps, 13084 std::vector<com::Utf8Str> &aFlags) 13128 13085 { 13129 13086 LogFlowThisFunc(("\n")); … … 13132 13089 using namespace guestProp; 13133 13090 13134 AutoCaller autoCaller(this);13135 AssertComRCReturn(autoCaller.rc(), autoCaller.rc());13136 13137 13091 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 13138 13092 13139 CheckComArgOutSafeArrayPointerValid(aNames);13140 CheckComArgOutSafeArrayPointerValid(aValues);13141 CheckComArgOutSafeArrayPointerValid(aTimestamps);13142 CheckComArgOutSafeArrayPointerValid(aFlags);13143 13144 13093 size_t cEntries = mHWData->mGuestProperties.size(); 13145 com::SafeArray<BSTR> names(cEntries); 13146 com::SafeArray<BSTR> values(cEntries); 13147 com::SafeArray<LONG64> timestamps(cEntries); 13148 com::SafeArray<BSTR> flags(cEntries); 13149 unsigned i = 0; 13094 aNames.resize(cEntries); 13095 aValues.resize(cEntries); 13096 aTimestamps.resize(cEntries); 13097 aFlags.resize(cEntries); 13098 13099 size_t i = 0; 13150 13100 for (HWData::GuestPropertyMap::iterator it = mHWData->mGuestProperties.begin(); 13151 13101 it != mHWData->mGuestProperties.end(); 13152 ++it )13102 ++it, ++i) 13153 13103 { 13154 13104 char szFlags[MAX_FLAGS_LEN + 1]; 13155 it->first.cloneTo(&names[i]); 13156 it->second.strValue.cloneTo(&values[i]); 13157 timestamps[i] = it->second.mTimestamp; 13105 aNames[i] = it->first; 13106 aValues[i] = it->second.strValue; 13107 aTimestamps[i] = it->second.mTimestamp; 13108 13158 13109 /* If it is NULL, keep it NULL. */ 13159 13110 if (it->second.mFlags) 13160 13111 { 13161 13112 writeFlags(it->second.mFlags, szFlags); 13162 Bstr(szFlags).cloneTo(&flags[i]);13113 aFlags[i] = szFlags; 13163 13114 } 13164 13115 else 13165 flags[i] = NULL; 13166 ++i; 13167 } 13168 names.detachTo(ComSafeArrayOutArg(aNames)); 13169 values.detachTo(ComSafeArrayOutArg(aValues)); 13170 timestamps.detachTo(ComSafeArrayOutArg(aTimestamps)); 13171 flags.detachTo(ComSafeArrayOutArg(aFlags)); 13116 aFlags[i] = ""; 13117 } 13172 13118 return S_OK; 13173 13119 #else … … 13176 13122 } 13177 13123 13178 STDMETHODIMP SessionMachine::PushGuestProperty(IN_BSTRaName,13179 IN_BSTRaValue,13180 LONG64aTimestamp,13181 IN_BSTRaFlags)13124 HRESULT SessionMachine::pushGuestProperty(const com::Utf8Str &aName, 13125 const com::Utf8Str &aValue, 13126 LONG64 aTimestamp, 13127 const com::Utf8Str &aFlags) 13182 13128 { 13183 13129 LogFlowThisFunc(("\n")); … … 13185 13131 #ifdef VBOX_WITH_GUEST_PROPS 13186 13132 using namespace guestProp; 13187 13188 CheckComArgStrNotEmptyOrNull(aName);13189 CheckComArgNotNull(aValue);13190 CheckComArgNotNull(aFlags);13191 13133 13192 13134 try … … 13195 13137 * Convert input up front. 13196 13138 */ 13197 Utf8Str utf8Name(aName);13198 13139 uint32_t fFlags = NILFLAG; 13199 if (aFlags) 13200 { 13201 Utf8Str utf8Flags(aFlags); 13202 int vrc = validateFlags(utf8Flags.c_str(), &fFlags); 13140 if (aFlags.length()) 13141 { 13142 int vrc = validateFlags(aFlags.c_str(), &fFlags); 13203 13143 AssertRCReturn(vrc, E_INVALIDARG); 13204 13144 } … … 13207 13147 * Now grab the object lock, validate the state and do the update. 13208 13148 */ 13209 AutoCaller autoCaller(this);13210 if (FAILED(autoCaller.rc())) return autoCaller.rc();13211 13149 13212 13150 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 13233 13171 mHWData.backup(); 13234 13172 13235 bool fDelete = ! RT_VALID_PTR(aValue) || *(aValue) == '\0';13236 HWData::GuestPropertyMap::iterator it = mHWData->mGuestProperties.find( utf8Name);13173 bool fDelete = !aValue.length(); 13174 HWData::GuestPropertyMap::iterator it = mHWData->mGuestProperties.find(aName); 13237 13175 if (it != mHWData->mGuestProperties.end()) 13238 13176 { … … 13255 13193 prop.mFlags = fFlags; 13256 13194 13257 mHWData->mGuestProperties[ utf8Name] = prop;13195 mHWData->mGuestProperties[aName] = prop; 13258 13196 mData->mGuestPropertiesModified = TRUE; 13259 13197 } … … 13265 13203 || RTStrSimplePatternMultiMatch(mHWData->mGuestPropertyNotificationPatterns.c_str(), 13266 13204 RTSTR_MAX, 13267 utf8Name.c_str(),13205 aName.c_str(), 13268 13206 RTSTR_MAX, NULL) 13269 13207 ) … … 13272 13210 13273 13211 mParent->i_onGuestPropertyChange(mData->mUuid, 13274 aName,13275 aValue,13276 aFlags);13212 Bstr(aName).raw(), 13213 Bstr(aValue).raw(), 13214 Bstr(aFlags).raw()); 13277 13215 } 13278 13216 } … … 13287 13225 } 13288 13226 13289 STDMETHODIMP SessionMachine::LockMedia() 13290 { 13291 AutoCaller autoCaller(this); 13292 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 13293 13227 13228 HRESULT SessionMachine::lockMedia() 13229 { 13294 13230 AutoMultiWriteLock2 alock(this->lockHandle(), 13295 13231 &mParent->i_getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); … … 13301 13237 clearError(); 13302 13238 alock.release(); 13303 return lockMedia();13304 } 13305 13306 STDMETHODIMP SessionMachine::UnlockMedia()13307 { 13308 HRESULT hrc = unlockMedia();13239 return i_lockMedia(); 13240 } 13241 13242 HRESULT SessionMachine::unlockMedia() 13243 { 13244 HRESULT hrc = i_unlockMedia(); 13309 13245 return hrc; 13310 13246 } 13311 13247 13312 STDMETHODIMP SessionMachine::EjectMedium(IMediumAttachment *aAttachment, 13313 IMediumAttachment **aNewAttachment) 13314 { 13315 CheckComArgNotNull(aAttachment); 13316 CheckComArgOutPointerValid(aNewAttachment); 13317 13318 AutoCaller autoCaller(this); 13319 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 13320 13248 HRESULT SessionMachine::ejectMedium(const ComPtr<IMediumAttachment> &aAttachment, 13249 ComPtr<IMediumAttachment> &aNewAttachment) 13250 { 13321 13251 // request the host lock first, since might be calling Host methods for getting host drives; 13322 13252 // next, protect the media tree all the while we're in here, as well as our member variables … … 13325 13255 &mParent->i_getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 13326 13256 13327 ComObjPtr<MediumAttachment> pAttach = static_cast<MediumAttachment *>(aAttachment); 13257 IMediumAttachment *iAttach = aAttachment; 13258 ComObjPtr<MediumAttachment> pAttach = static_cast<MediumAttachment *>(iAttach); 13328 13259 13329 13260 Bstr ctrlName; … … 13332 13263 bool fTempEject; 13333 13264 { 13334 AutoCaller autoAttachCaller(this);13335 if (FAILED(autoAttachCaller.rc())) return autoAttachCaller.rc();13336 13337 13265 AutoReadLock attLock(pAttach COMMA_LOCKVAL_SRC_POS); 13338 13266 … … 13384 13312 } 13385 13313 13386 pAttach.queryInterfaceTo(aNewAttachment );13314 pAttach.queryInterfaceTo(aNewAttachment.asOutParam()); 13387 13315 13388 13316 return S_OK; … … 13975 13903 * @note Locks mParent + this objects for writing. 13976 13904 */ 13977 HRESULT SessionMachine:: endSavingState(HRESULT aRc, const Utf8Str &aErrMsg)13905 HRESULT SessionMachine::i_endSavingState(HRESULT aRc, const Utf8Str &aErrMsg) 13978 13906 { 13979 13907 LogFlowThisFuncEnter(); … … 14074 14002 * no more needed. 14075 14003 */ 14076 HRESULT SessionMachine:: lockMedia()14004 HRESULT SessionMachine::i_lockMedia() 14077 14005 { 14078 14006 AutoCaller autoCaller(this); … … 14151 14079 * Undoes the locks made by by #lockMedia(). 14152 14080 */ 14153 HRESULT SessionMachine:: unlockMedia()14081 HRESULT SessionMachine::i_unlockMedia() 14154 14082 { 14155 14083 AutoCaller autoCaller(this); -
trunk/src/VBox/Main/src-server/SnapshotImpl.cpp
r52168 r52481 1394 1394 * @return 1395 1395 */ 1396 STDMETHODIMP SessionMachine::BeginTakingSnapshot(IConsole *aInitiator,1397 IN_BSTRaName,1398 IN_BSTRaDescription,1399 IProgress *aConsoleProgress,1400 BOOL fTakingSnapshotOnline,1401 BSTR *aStateFilePath)1396 HRESULT SessionMachine::beginTakingSnapshot(const ComPtr<IConsole> &aInitiator, 1397 const com::Utf8Str &aName, 1398 const com::Utf8Str &aDescription, 1399 const ComPtr<IProgress> &aConsoleProgress, 1400 BOOL aFTakingSnapshotOnline, 1401 com::Utf8Str &aStateFilePath) 1402 1402 { 1403 1403 LogFlowThisFuncEnter(); 1404 1404 1405 AssertReturn(aInitiator && aName, E_INVALIDARG); 1406 AssertReturn(aStateFilePath, E_POINTER); 1407 1408 LogFlowThisFunc(("aName='%ls' fTakingSnapshotOnline=%RTbool\n", aName, fTakingSnapshotOnline)); 1409 1410 AutoCaller autoCaller(this); 1411 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 1405 LogFlowThisFunc(("aName='%s' aFTakingSnapshotOnline=%RTbool\n", aName.c_str(), aFTakingSnapshotOnline)); 1412 1406 1413 1407 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 1428 1422 } 1429 1423 1430 if ( ! fTakingSnapshotOnline1424 if ( !aFTakingSnapshotOnline 1431 1425 && mData->mMachineState != MachineState_Saved 1432 1426 ) … … 1444 1438 snapshotId.create(); 1445 1439 1446 Utf8Str strStateFilePath;1447 1440 /* stateFilePath is null when the machine is not online nor saved */ 1448 if ( fTakingSnapshotOnline)1441 if (aFTakingSnapshotOnline) 1449 1442 { 1450 1443 Bstr value; … … 1452 1445 value.asOutParam()); 1453 1446 if (FAILED(rc) || value != "1") 1454 {1455 1447 // creating a new online snapshot: we need a fresh saved state file 1456 i_composeSavedStateFilename(strStateFilePath); 1457 } 1448 i_composeSavedStateFilename(aStateFilePath); 1458 1449 } 1459 1450 else if (mData->mMachineState == MachineState_Saved) 1460 1451 // taking an online snapshot from machine in "saved" state: then use existing state file 1461 strStateFilePath = mSSData->strStateFilePath;1462 1463 if ( strStateFilePath.isNotEmpty())1452 aStateFilePath = mSSData->strStateFilePath; 1453 1454 if (aStateFilePath.isNotEmpty()) 1464 1455 { 1465 1456 // ensure the directory for the saved state file exists 1466 HRESULT rc = VirtualBox::i_ensureFilePathExists( strStateFilePath, true /* fCreate */);1457 HRESULT rc = VirtualBox::i_ensureFilePathExists(aStateFilePath, true /* fCreate */); 1467 1458 if (FAILED(rc)) return rc; 1468 1459 } … … 1471 1462 ComObjPtr<SnapshotMachine> snapshotMachine; 1472 1463 snapshotMachine.createObject(); 1473 HRESULT rc = snapshotMachine->init(this, snapshotId.ref(), strStateFilePath);1464 HRESULT rc = snapshotMachine->init(this, snapshotId.ref(), aStateFilePath); 1474 1465 AssertComRCReturn(rc, rc); 1475 1466 … … 1490 1481 mConsoleTaskData.mLastState = mData->mMachineState; 1491 1482 mConsoleTaskData.mSnapshot = pSnapshot; 1483 1492 1484 /// @todo in the long run the progress object should be moved to 1493 1485 // VBoxSVC to avoid trouble with monitoring the progress object state … … 1498 1490 { 1499 1491 LogFlowThisFunc(("Creating differencing hard disks (online=%d)...\n", 1500 fTakingSnapshotOnline));1492 aFTakingSnapshotOnline)); 1501 1493 1502 1494 // backup the media data so we can recover if things goes wrong along the day; … … 1515 1507 rc = i_createImplicitDiffs(aConsoleProgress, 1516 1508 1, // operation weight; must be the same as in Console::TakeSnapshot() 1517 !! fTakingSnapshotOnline);1509 !!aFTakingSnapshotOnline); 1518 1510 if (FAILED(rc)) 1519 1511 throw rc; … … 1543 1535 } 1544 1536 1545 if (fTakingSnapshotOnline && SUCCEEDED(rc)) 1546 strStateFilePath.cloneTo(aStateFilePath); 1547 else 1548 *aStateFilePath = NULL; 1537 if (!(aFTakingSnapshotOnline && SUCCEEDED(rc))) 1538 aStateFilePath = ""; 1549 1539 1550 1540 LogFlowThisFunc(("LEAVE - %Rhrc [%s]\n", rc, Global::stringifyMachineState(mData->mMachineState) )); … … 1566 1556 * @return 1567 1557 */ 1568 STDMETHODIMP SessionMachine::EndTakingSnapshot(BOOL aSuccess)1558 HRESULT SessionMachine::endTakingSnapshot(BOOL aSuccess) 1569 1559 { 1570 1560 LogFlowThisFunc(("\n")); 1571 1572 AutoCaller autoCaller(this);1573 AssertComRCReturn (autoCaller.rc(), autoCaller.rc());1574 1561 1575 1562 AutoWriteLock machineLock(this COMMA_LOCKVAL_SRC_POS); … … 1693 1680 * @return 1694 1681 */ 1695 STDMETHODIMP SessionMachine::RestoreSnapshot(IConsole *aInitiator,1696 ISnapshot *aSnapshot,1697 1698 IProgress **aProgress)1682 HRESULT SessionMachine::restoreSnapshot(const ComPtr<IConsole> &aInitiator, 1683 const ComPtr<ISnapshot> &aSnapshot, 1684 MachineState_T *aMachineState, 1685 ComPtr<IProgress> &aProgress) 1699 1686 { 1700 1687 LogFlowThisFuncEnter(); 1701 1702 AssertReturn(aInitiator, E_INVALIDARG);1703 AssertReturn(aSnapshot && aMachineState && aProgress, E_POINTER);1704 1705 AutoCaller autoCaller(this);1706 AssertComRCReturn(autoCaller.rc(), autoCaller.rc());1707 1688 1708 1689 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 1712 1693 E_FAIL); 1713 1694 1714 ComObjPtr<Snapshot> pSnapshot(static_cast<Snapshot*>(aSnapshot)); 1695 ISnapshot* iSnapshot = aSnapshot; 1696 ComObjPtr<Snapshot>pSnapshot(static_cast<Snapshot*>(iSnapshot)); 1715 1697 ComObjPtr<SnapshotMachine> pSnapMachine = pSnapshot->i_getSnapshotMachine(); 1716 1698 … … 1769 1751 1770 1752 /* return the progress to the caller */ 1771 pProgress.queryInterfaceTo(aProgress );1753 pProgress.queryInterfaceTo(aProgress.asOutParam()); 1772 1754 1773 1755 /* return the new state to the caller */ … … 2055 2037 2056 2038 /** 2057 * Implementation for IInternalMachineControl:: DeleteSnapshot().2039 * Implementation for IInternalMachineControl::deleteSnapshot(). 2058 2040 * 2059 2041 * Gets called from Console::DeleteSnapshot(), and that's basically the … … 2070 2052 * @note Locks mParent + this + children objects for writing! 2071 2053 */ 2072 STDMETHODIMP SessionMachine::DeleteSnapshot(IConsole *aInitiator,2073 IN_BSTRaStartId,2074 IN_BSTRaEndId,2075 BOOL fDeleteAllChildren,2076 2077 IProgress **aProgress)2054 HRESULT SessionMachine::deleteSnapshot(const ComPtr<IConsole> &aInitiator, 2055 const com::Guid &aStartId, 2056 const com::Guid &aEndId, 2057 BOOL aDeleteAllChildren, 2058 MachineState_T *aMachineState, 2059 ComPtr<IProgress> &aProgress) 2078 2060 { 2079 2061 LogFlowThisFuncEnter(); 2080 2062 2081 Guid startId(aStartId); 2082 Guid endId(aEndId); 2083 2084 AssertReturn(aInitiator && !startId.isZero() && !endId.isZero() && startId.isValid() && endId.isValid(), E_INVALIDARG); 2063 AssertReturn(aInitiator && !aStartId.isZero() && !aEndId.isZero() && aStartId.isValid() && aEndId.isValid(), E_INVALIDARG); 2085 2064 2086 2065 AssertReturn(aMachineState && aProgress, E_POINTER); 2087 2066 2088 2067 /** @todo implement the "and all children" and "range" variants */ 2089 if ( fDeleteAllChildren || startId != endId)2068 if (aDeleteAllChildren || aStartId != aEndId) 2090 2069 ReturnComNotImplemented(); 2091 2092 AutoCaller autoCaller(this);2093 AssertComRCReturn(autoCaller.rc(), autoCaller.rc());2094 2070 2095 2071 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 2108 2084 2109 2085 ComObjPtr<Snapshot> pSnapshot; 2110 HRESULT rc = i_findSnapshotById( startId, pSnapshot, true /* aSetError */);2086 HRESULT rc = i_findSnapshotById(aStartId, pSnapshot, true /* aSetError */); 2111 2087 if (FAILED(rc)) return rc; 2112 2088 … … 2226 2202 2227 2203 /* return the progress to the caller */ 2228 pProgress.queryInterfaceTo(aProgress );2204 pProgress.queryInterfaceTo(aProgress.asOutParam()); 2229 2205 2230 2206 /* return the new state to the caller */ … … 3428 3404 3429 3405 /** 3430 * Implementation for IInternalMachineControl:: FinishOnlineMergeMedium().3406 * Implementation for IInternalMachineControl::finishOnlineMergeMedium(). 3431 3407 * 3432 3408 * Gets called after the successful completion of an online merge from … … 3437 3413 * can continue with the updated state of the medium chain. 3438 3414 */ 3439 STDMETHODIMP SessionMachine::FinishOnlineMergeMedium()3415 HRESULT SessionMachine::finishOnlineMergeMedium() 3440 3416 { 3441 3417 HRESULT rc = S_OK;
Note:
See TracChangeset
for help on using the changeset viewer.