Changeset 31218 in vbox
- Timestamp:
- Jul 29, 2010 3:07:48 PM (14 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 8 edited
-
Frontends/VBoxManage/VBoxManageMisc.cpp (modified) (2 diffs)
-
Frontends/VBoxSDL/VBoxSDL.cpp (modified) (1 diff)
-
Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp (modified) (1 diff)
-
Main/ConsoleImpl.cpp (modified) (2 diffs)
-
Main/MachineImpl.cpp (modified) (10 diffs)
-
Main/idl/VirtualBox.xidl (modified) (7 diffs)
-
Main/include/ConsoleImpl.h (modified) (1 diff)
-
Main/include/MachineImpl.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r31070 r31218 160 160 { 161 161 SafeArray<BSTR> abstrFiles; 162 CHECK_ERROR(machine, Unregister(f alse /* fDetachMedia*/,162 CHECK_ERROR(machine, Unregister(fDelete /* fAutoCleanup */, 163 163 ComSafeArrayAsOutParam(abstrFiles))); 164 if (SUCCEEDED(rc) && fDelete) 165 CHECK_ERROR(machine, Delete()); 164 if (SUCCEEDED(rc)) 165 { 166 for (size_t u = 0; 167 u < abstrFiles.size(); 168 ++u) 169 { 170 Utf8Str strFile(abstrFiles[u]); 171 if (fDelete) 172 { 173 RTPrintf("Deleting '%s'\n", strFile.c_str()); 174 RTFileDelete(strFile.c_str()); 175 } 176 else 177 RTPrintf("File '%s' is now obsolete and can be deleted\n", strFile.c_str()); 178 } 179 180 if (fDelete) 181 { 182 CHECK_ERROR(machine, Delete()); 183 } 184 } 166 185 } 167 186 return SUCCEEDED(rc) ? 0 : 1; … … 423 442 ComPtr<IConsole> console; 424 443 CHECK_ERROR_BREAK(a->session, COMGETTER(Console)(console.asOutParam())); 425 CHECK_ERROR_BREAK(console, ForgetSavedState( true));444 CHECK_ERROR_BREAK(console, ForgetSavedState()); 426 445 } while (0); 427 446 CHECK_ERROR_BREAK(a->session, UnlockMachine()); -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r31070 r31218 1652 1652 if (machineState == MachineState_Saved) 1653 1653 { 1654 CHECK_ERROR(gConsole, ForgetSavedState( true));1654 CHECK_ERROR(gConsole, ForgetSavedState()); 1655 1655 } 1656 1656 /* -
trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp
r31070 r31218 805 805 806 806 CConsole console = session.GetConsole(); 807 console.ForgetSavedState( true);807 console.ForgetSavedState(); 808 808 if (!console.isOk()) 809 809 vboxProblem().cannotDiscardSavedState (console); -
trunk/src/VBox/Main/ConsoleImpl.cpp
r31008 r31218 2387 2387 } 2388 2388 2389 STDMETHODIMP Console::ForgetSavedState( BOOL aRemove)2389 STDMETHODIMP Console::ForgetSavedState() 2390 2390 { 2391 2391 AutoCaller autoCaller(this); … … 2400 2400 2401 2401 HRESULT rc = S_OK; 2402 2403 rc = mControl->SetRemoveSavedState(aRemove);2404 if (FAILED(rc)) return rc;2405 2402 2406 2403 /* -
trunk/src/VBox/Main/MachineImpl.cpp
r31070 r31218 4062 4062 4063 4063 /** @note Locks objects! */ 4064 STDMETHODIMP Machine::Unregister(BOOL f CloseMedia,4064 STDMETHODIMP Machine::Unregister(BOOL fAutoCleanup, 4065 4065 ComSafeArrayOut(BSTR, aFiles)) 4066 4066 { … … 4076 4076 mUserData->mName.raw()); 4077 4077 4078 // @todo optionally discard saved state 4078 // this list collects the files that should be reported 4079 // as to be deleted to the caller in aFiles 4080 std::list<Bstr> llFilesForCaller; 4081 4082 // discard saved state 4079 4083 if (mData->mMachineState == MachineState_Saved) 4080 return setError(VBOX_E_INVALID_VM_STATE, 4081 tr("Cannot unregister the machine '%ls' because it is in the Saved state"), 4082 mUserData->mName.raw()); 4084 { 4085 // add the saved state file to the list of files the caller should delete 4086 Assert(!mSSData->mStateFilePath.isEmpty()); 4087 llFilesForCaller.push_back(Bstr(mSSData->mStateFilePath)); 4088 4089 mSSData->mStateFilePath.setNull(); 4090 4091 // unconditionally set the machine state to powered off, we now 4092 // know no session has locked the machine 4093 mData->mMachineState = MachineState_PoweredOff; 4094 } 4083 4095 4084 4096 // @todo optionally nuke snapshots … … 4089 4101 return setError(VBOX_E_INVALID_OBJECT_STATE, 4090 4102 tr("Cannot unregister the machine '%ls' because it has %d snapshots"), 4091 mUserData->mName.raw(), snapshotCount);4103 mUserData->mName.raw(), snapshotCount); 4092 4104 4093 4105 if ( !mMediaData.isNull() // can be NULL if machine is inaccessible … … 4096 4108 { 4097 4109 // we have media attachments: 4098 if (f CloseMedia)4110 if (fAutoCleanup) 4099 4111 { 4100 4112 // caller wants automatic detachment: then do that and report all media to the array … … 4122 4134 return setError(VBOX_E_INVALID_OBJECT_STATE, 4123 4135 tr("Cannot unregister the machine '%ls' because it has %d media attachments"), 4124 mMediaData->mAttachments.size());4136 mUserData->mName.raw(), mMediaData->mAttachments.size()); 4125 4137 } 4126 4138 … … 4133 4145 alock.release(); 4134 4146 4135 if (f CloseMedia)4147 if (fAutoCleanup) 4136 4148 { 4137 4149 // now go thru the list of attached media reported by prepareUnregister() and close them all 4138 SafeArray<BSTR> sfaFiles(llMedia.size());4139 4150 size_t u = 0; 4140 4151 for (MediaList::const_iterator it = llMedia.begin(); … … 4153 4164 4154 4165 // report the path to the caller 4155 bstrFile.detachTo(&sfaFiles[u]);4166 llFilesForCaller.push_back(bstrFile); 4156 4167 ++u; 4157 4168 } 4158 // report all paths to the caller 4159 sfaFiles.detachTo(ComSafeArrayOutArg(aFiles)); 4160 } 4169 } 4170 4171 // report all paths to the caller 4172 SafeArray<BSTR> sfaFiles(llFilesForCaller.size()); 4173 size_t i = 0; 4174 for (std::list<Bstr>::iterator it = llFilesForCaller.begin(); 4175 it != llFilesForCaller.end(); 4176 ++it) 4177 it->detachTo(&sfaFiles[i++]); 4178 sfaFiles.detachTo(ComSafeArrayOutArg(aFiles)); 4161 4179 4162 4180 mParent->unregisterMachine(this); 4181 // calls VirtualBox::saveSettings() 4163 4182 4164 4183 return S_OK; … … 9637 9656 } 9638 9657 9639 /* default is to delete saved state on Saved -> PoweredOff transition */9640 mRemoveSavedState = true;9641 9642 9658 /* Confirm a successful initialization when it's the case */ 9643 9659 autoInitSpan.setSucceeded(); … … 9933 9949 9934 9950 /** 9935 * @note Locks this object for writing.9936 */9937 STDMETHODIMP SessionMachine::SetRemoveSavedState(BOOL aRemove)9938 {9939 AutoCaller autoCaller(this);9940 AssertComRCReturn(autoCaller.rc(), autoCaller.rc());9941 9942 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);9943 9944 mRemoveSavedState = aRemove;9945 9946 return S_OK;9947 }9948 9949 /**9950 9951 * @note Locks the same as #setMachineState() does. 9951 9952 */ … … 11236 11237 if (deleteSavedState) 11237 11238 { 11238 if (mRemoveSavedState) 11239 { 11240 Assert(!mSSData->mStateFilePath.isEmpty()); 11241 RTFileDelete(mSSData->mStateFilePath.c_str()); 11242 } 11239 Assert(!mSSData->mStateFilePath.isEmpty()); 11240 RTFileDelete(mSSData->mStateFilePath.c_str()); 11243 11241 mSSData->mStateFilePath.setNull(); 11244 11242 stsFlags |= SaveSTS_StateFilePath; -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r31217 r31218 3192 3192 <interface 3193 3193 name="IInternalMachineControl" extends="$unknown" 3194 uuid=" 26604a54-8628-491b-a0ea-e1392a16d13b"3194 uuid="e2da8b1a-2ad1-490e-b29e-c33a144791b6" 3195 3195 internal="yes" 3196 3196 wsmap="suppress" 3197 3197 > 3198 <method name="setRemoveSavedState">3199 <desc>3200 Updates the flag whether saved state is removed on a machine state3201 change from Saved to PoweredOff.3202 </desc>3203 <param name="aRemove" type="boolean" dir="in"/>3204 </method>3205 3206 3198 <method name="updateState"> 3207 3199 <desc> … … 5190 5182 <desc> 5191 5183 Unregisters the machine, which must have been previously registered using 5192 <link to="IVirtualBox::registerMachine"/>. After successful method invocation, 5184 <link to="IVirtualBox::registerMachine"/>. 5185 5186 This method will succeed even if the machine currently has media attachments or 5187 is in the <link to="MachineState::Saved">Saved</link> state. In those cases, 5188 the caller receives the names of all files that have been made obsolete by the 5189 call in the @a aFiles array parameter. This list will consist of the saved 5190 state file and all storage files by media that were detached from the machine. 5191 5192 <note> 5193 The @a fAutoCleanup parameter is temporary to avoid substantial changes to the 5194 frontends in SVN trunk.It will go away before the 3.3 release and 5195 always be true then. If fAutoCleanup is false, the API currently behaves like 5196 the old VirtualBox::UnregisterMachine API. Cleaning up snapshots does not work 5197 yet, so the method will still fail if the machine has snapshots. 5198 </note> 5199 5200 The settings XML file of the machine object itself will not be included in that 5201 list; call <link to="#delete" /> for that. 5202 5203 The call will fail if the machine is currently locked (see <link to="ISession" />). 5204 It implicitly calls <link to="#saveSettings"/> to save all current machine settings 5205 before unregistering it. 5206 5207 After successful method invocation, 5193 5208 the <link to="IMachineRegisteredEvent"/> event is fired. 5194 5195 <note>5196 The specified machine must not be in the Saved state nor have an open5197 (or a spawning) direct session associated with it.5198 </note>5199 5200 <note>5201 This method implicitly calls <link to="#saveSettings"/> to5202 save all current machine settings before unregistering it.5203 </note>5204 5209 5205 5210 <note> … … 5210 5215 </note> 5211 5216 5212 <result name="VBOX_E_OBJECT_NOT_FOUND">5213 Could not find registered machine matching @a id.5214 </result>5215 <result name="VBOX_E_INVALID_VM_STATE">5216 Machine is in Saved state.5217 </result>5218 5217 <result name="VBOX_E_INVALID_OBJECT_STATE"> 5219 Machine has snapshot or open session or medium attached.5220 </result> 5221 </desc> 5222 5223 <param name="f CloseMedia" type="boolean" dir="in">5218 Machine has snapshot or is locked. 5219 </result> 5220 </desc> 5221 5222 <param name="fAutoCleanup" type="boolean" dir="in"> 5224 5223 <desc>If true, the method will automatically detach all media from the 5225 5224 machine and its snapshots, call <link to="IMedium::close" /> on each … … 5227 5226 the caller in the @a aFiles array so the caller can then delete the 5228 5227 image files. 5229 If false, the method will fail if media attachments are present.</desc> 5228 If false, the method will fail if media attachments are present. 5229 </desc> 5230 5230 </param> 5231 5231 <param name="aFiles" type="wstring" safearray="yes" dir="return"> … … 5933 5933 <interface 5934 5934 name="IConsole" extends="$unknown" 5935 uuid=" 9e467cff-98fc-4f5b-83aa-048d903694c9"5935 uuid="3a7bb20e-bbee-47f2-a5ee-b158555f2c79" 5936 5936 wsmap="managed" 5937 5937 > … … 6301 6301 <method name="forgetSavedState"> 6302 6302 <desc> 6303 Forgets the saved state of the virtual machine previously created6304 by <link to="#saveState"/>. Next time the machine is powered up, a6305 clean boot will occur. If @a remove is @c true the saved state file6306 is deleted.6303 Forgets the saved state of the virtual machine if it is currently 6304 in the "Saved" state (previously created by <link to="#saveState"/>) 6305 and deletes the file into which the machine state was saved. 6306 Next time the machine is powered up, a clean boot will occur. 6307 6307 <note> 6308 6308 This operation is equivalent to resetting or powering off … … 6313 6313 </result> 6314 6314 </desc> 6315 <param name="removeFile" type="boolean" dir="in">6316 <desc>If @c true remove the saved state file.</desc>6317 </param>6318 6315 </method> 6319 6316 -
trunk/src/VBox/Main/include/ConsoleImpl.h
r31002 r31218 138 138 STDMETHOD(SaveState)(IProgress **aProgress); 139 139 STDMETHOD(AdoptSavedState)(IN_BSTR aSavedStateFile); 140 STDMETHOD(ForgetSavedState)( BOOL aRemove);140 STDMETHOD(ForgetSavedState)(); 141 141 STDMETHOD(GetDeviceActivity)(DeviceType_T aDeviceType, 142 142 DeviceActivity_T *aDeviceActivity); -
trunk/src/VBox/Main/include/MachineImpl.h
r31019 r31218 484 484 STDMETHOD(SaveSettings)(); 485 485 STDMETHOD(DiscardSettings)(); 486 STDMETHOD(Unregister) (BOOL f CloseMedia, ComSafeArrayOut(BSTR, aFiles));486 STDMETHOD(Unregister) (BOOL fAutoCleanup, ComSafeArrayOut(BSTR, aFiles)); 487 487 STDMETHOD(Delete)(); 488 488 STDMETHOD(Export)(IAppliance *aAppliance, IVirtualSystemDescription **aDescription); … … 888 888 889 889 // IInternalMachineControl methods 890 STDMETHOD(SetRemoveSavedState)(BOOL aRemove);891 890 STDMETHOD(UpdateState)(MachineState_T machineState); 892 891 STDMETHOD(GetIPCId)(BSTR *id); … … 1025 1024 HRESULT updateMachineStateOnClient(); 1026 1025 1027 HRESULT mRemoveSavedState;1028 1029 1026 SnapshotData mSnapshotData; 1030 1027
Note:
See TracChangeset
for help on using the changeset viewer.

