Changeset 44288 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jan 14, 2013 6:22:18 PM (12 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ProgressImpl.h
r37069 r44288 27 27 28 28 /** 29 * Base component class for progress objects.29 * Class for progress objects. 30 30 */ 31 class ATL_NO_VTABLE Progress Base:31 class ATL_NO_VTABLE Progress : 32 32 public VirtualBoxBase, 33 33 VBOX_SCRIPTABLE_IMPL(IProgress) … … 35 35 protected: 36 36 37 // VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ProgressBase, IProgress) 38 // cannot be added here or Windows will not buuld; as a result, ProgressBase cannot be 39 // instantiated, but we're not doing that anyway (but only its children) 40 41 DECLARE_EMPTY_CTOR_DTOR (ProgressBase) 37 DECLARE_EMPTY_CTOR_DTOR (Progress) 38 39 40 void checkForAutomaticTimeout(void); 41 42 #if !defined (VBOX_COM_INPROC) 43 /** Weak parent. */ 44 VirtualBox * const mParent; 45 #endif 46 47 const ComPtr<IUnknown> mInitiator; 48 49 const Guid mId; 50 const Bstr mDescription; 51 52 uint64_t m_ullTimestamp; // progress object creation timestamp, for ETA computation 53 54 void (*m_pfnCancelCallback)(void *); 55 void *m_pvCancelUserArg; 56 57 /* The fields below are to be properly initialized by subclasses */ 58 59 BOOL mCompleted; 60 BOOL mCancelable; 61 BOOL mCanceled; 62 HRESULT mResultCode; 63 ComPtr<IVirtualBoxErrorInfo> mErrorInfo; 64 65 ULONG m_cOperations; // number of operations (so that progress dialog can display something like 1/3) 66 ULONG m_ulTotalOperationsWeight; // sum of weights of all operations, given to constructor 67 68 ULONG m_ulOperationsCompletedWeight; // summed-up weight of operations that have been completed; initially 0 69 70 ULONG m_ulCurrentOperation; // operations counter, incremented with each setNextOperation() 71 Bstr m_bstrOperationDescription; // name of current operation; initially from constructor, changed with setNextOperation() 72 ULONG m_ulCurrentOperationWeight; // weight of current operation, given to setNextOperation() 73 ULONG m_ulOperationPercent; // percentage of current operation, set with setCurrentOperationProgress() 74 ULONG m_cMsTimeout; /**< Automatic timeout value. 0 means none. */ 75 76 public: 77 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Progress, IProgress) 78 79 DECLARE_NOT_AGGREGATABLE (Progress) 80 81 DECLARE_PROTECT_FINAL_CONSTRUCT() 82 83 BEGIN_COM_MAP (Progress) 84 VBOX_DEFAULT_INTERFACE_ENTRIES (IProgress) 85 END_COM_MAP() 42 86 43 87 HRESULT FinalConstruct(); 44 45 // protected initializer/uninitializer for internal purposes only 46 HRESULT protectedInit(AutoInitSpan &aAutoInitSpan, 88 void FinalRelease(); 89 90 // public initializer/uninitializer for internal purposes only 91 92 /** 93 * Simplified constructor for progress objects that have only one 94 * operation as a task. 95 * @param aParent 96 * @param aInitiator 97 * @param aDescription 98 * @param aCancelable 99 * @param aId 100 * @return 101 */ 102 HRESULT init( 47 103 #if !defined (VBOX_COM_INPROC) 48 104 VirtualBox *aParent, 49 105 #endif 50 106 IUnknown *aInitiator, 51 CBSTR aDescription, OUT_GUID aId = NULL); 52 HRESULT protectedInit(AutoInitSpan &aAutoInitSpan); 53 void protectedUninit(AutoUninitSpan &aAutoUninitSpan); 54 55 public: 107 CBSTR aDescription, 108 BOOL aCancelable, 109 OUT_GUID aId = NULL) 110 { 111 return init( 112 #if !defined (VBOX_COM_INPROC) 113 aParent, 114 #endif 115 aInitiator, 116 aDescription, 117 aCancelable, 118 1, // cOperations 119 1, // ulTotalOperationsWeight 120 aDescription, // bstrFirstOperationDescription 121 1, // ulFirstOperationWeight 122 aId); 123 } 124 125 /** 126 * Not quite so simplified constructor for progress objects that have 127 * more than one operation, but all sub-operations are weighed the same. 128 * @param aParent 129 * @param aInitiator 130 * @param aDescription 131 * @param aCancelable 132 * @param cOperations 133 * @param bstrFirstOperationDescription 134 * @param aId 135 * @return 136 */ 137 HRESULT init( 138 #if !defined (VBOX_COM_INPROC) 139 VirtualBox *aParent, 140 #endif 141 IUnknown *aInitiator, 142 CBSTR aDescription, BOOL aCancelable, 143 ULONG cOperations, 144 CBSTR bstrFirstOperationDescription, 145 OUT_GUID aId = NULL) 146 { 147 return init( 148 #if !defined (VBOX_COM_INPROC) 149 aParent, 150 #endif 151 aInitiator, 152 aDescription, 153 aCancelable, 154 cOperations, // cOperations 155 cOperations, // ulTotalOperationsWeight = cOperations 156 bstrFirstOperationDescription, // bstrFirstOperationDescription 157 1, // ulFirstOperationWeight: weigh them all the same 158 aId); 159 } 160 161 HRESULT init( 162 #if !defined (VBOX_COM_INPROC) 163 VirtualBox *aParent, 164 #endif 165 IUnknown *aInitiator, 166 CBSTR aDescription, 167 BOOL aCancelable, 168 ULONG cOperations, 169 ULONG ulTotalOperationsWeight, 170 CBSTR bstrFirstOperationDescription, 171 ULONG ulFirstOperationWeight, 172 OUT_GUID aId = NULL); 173 174 HRESULT init(BOOL aCancelable, 175 ULONG aOperationCount, 176 CBSTR aOperationDescription); 177 178 // initializer/uninitializer for internal purposes only 179 HRESULT init(AutoInitSpan &aAutoInitSpan, 180 #if !defined (VBOX_COM_INPROC) 181 VirtualBox *aParent, 182 #endif 183 IUnknown *aInitiator, 184 CBSTR aDescription, OUT_GUID aId = NULL); 185 HRESULT init(AutoInitSpan &aAutoInitSpan); 186 void init(AutoUninitSpan &aAutoUninitSpan); 187 void uninit(); 188 void uninit(AutoUninitSpan &aAutoUninitSpan); 189 190 // IProgress methods 191 STDMETHOD(WaitForCompletion)(LONG aTimeout); 192 STDMETHOD(WaitForOperationCompletion)(ULONG aOperation, LONG aTimeout); 193 STDMETHOD(WaitForAsyncProgressCompletion)(IProgress *pProgressAsync); 194 STDMETHOD(Cancel)(); 195 196 STDMETHOD(SetCurrentOperationProgress)(ULONG aPercent); 197 STDMETHOD(SetNextOperation)(IN_BSTR bstrNextOperationDescription, ULONG ulNextOperationsWeight); 198 199 // public methods only for internal purposes 200 201 HRESULT setResultCode(HRESULT aResultCode); 202 203 HRESULT notifyComplete(HRESULT aResultCode); 204 HRESULT notifyComplete(HRESULT aResultCode, 205 const GUID &aIID, 206 const char *pcszComponent, 207 const char *aText, 208 ...); 209 HRESULT notifyCompleteV(HRESULT aResultCode, 210 const GUID &aIID, 211 const char *pcszComponent, 212 const char *aText, 213 va_list va); 214 bool notifyPointOfNoReturn(void); 56 215 57 216 // IProgress properties … … 83 242 // unsafe inline public methods for internal purposes only (ensure there is 84 243 // a caller and a read lock before calling them!) 85 86 244 BOOL getCompleted() const { return mCompleted; } 87 245 HRESULT getResultCode() const { return mResultCode; } 88 246 double calcTotalPercent(); 89 247 90 protected:91 void checkForAutomaticTimeout(void);92 93 #if !defined (VBOX_COM_INPROC)94 /** Weak parent. */95 VirtualBox * const mParent;96 #endif97 98 const ComPtr<IUnknown> mInitiator;99 100 const Guid mId;101 const Bstr mDescription;102 103 uint64_t m_ullTimestamp; // progress object creation timestamp, for ETA computation104 105 void (*m_pfnCancelCallback)(void *);106 void *m_pvCancelUserArg;107 108 /* The fields below are to be properly initialized by subclasses */109 110 BOOL mCompleted;111 BOOL mCancelable;112 BOOL mCanceled;113 HRESULT mResultCode;114 ComPtr<IVirtualBoxErrorInfo> mErrorInfo;115 116 ULONG m_cOperations; // number of operations (so that progress dialog can display something like 1/3)117 ULONG m_ulTotalOperationsWeight; // sum of weights of all operations, given to constructor118 119 ULONG m_ulOperationsCompletedWeight; // summed-up weight of operations that have been completed; initially 0120 121 ULONG m_ulCurrentOperation; // operations counter, incremented with each setNextOperation()122 Bstr m_bstrOperationDescription; // name of current operation; initially from constructor, changed with setNextOperation()123 ULONG m_ulCurrentOperationWeight; // weight of current operation, given to setNextOperation()124 ULONG m_ulOperationPercent; // percentage of current operation, set with setCurrentOperationProgress()125 ULONG m_cMsTimeout; /**< Automatic timeout value. 0 means none. */126 };127 128 ////////////////////////////////////////////////////////////////////////////////129 130 /**131 * Normal progress object.132 */133 class ATL_NO_VTABLE Progress :134 public ProgressBase135 {136 137 public:138 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Progress, IProgress)139 140 DECLARE_NOT_AGGREGATABLE (Progress)141 142 DECLARE_PROTECT_FINAL_CONSTRUCT()143 144 BEGIN_COM_MAP (Progress)145 VBOX_DEFAULT_INTERFACE_ENTRIES (IProgress)146 END_COM_MAP()147 148 HRESULT FinalConstruct();149 void FinalRelease();150 151 // public initializer/uninitializer for internal purposes only152 153 /**154 * Simplified constructor for progress objects that have only one155 * operation as a task.156 * @param aParent157 * @param aInitiator158 * @param aDescription159 * @param aCancelable160 * @param aId161 * @return162 */163 HRESULT init(164 #if !defined (VBOX_COM_INPROC)165 VirtualBox *aParent,166 #endif167 IUnknown *aInitiator,168 CBSTR aDescription,169 BOOL aCancelable,170 OUT_GUID aId = NULL)171 {172 return init(173 #if !defined (VBOX_COM_INPROC)174 aParent,175 #endif176 aInitiator,177 aDescription,178 aCancelable,179 1, // cOperations180 1, // ulTotalOperationsWeight181 aDescription, // bstrFirstOperationDescription182 1, // ulFirstOperationWeight183 aId);184 }185 186 /**187 * Not quite so simplified constructor for progress objects that have188 * more than one operation, but all sub-operations are weighed the same.189 * @param aParent190 * @param aInitiator191 * @param aDescription192 * @param aCancelable193 * @param cOperations194 * @param bstrFirstOperationDescription195 * @param aId196 * @return197 */198 HRESULT init(199 #if !defined (VBOX_COM_INPROC)200 VirtualBox *aParent,201 #endif202 IUnknown *aInitiator,203 CBSTR aDescription, BOOL aCancelable,204 ULONG cOperations,205 CBSTR bstrFirstOperationDescription,206 OUT_GUID aId = NULL)207 {208 return init(209 #if !defined (VBOX_COM_INPROC)210 aParent,211 #endif212 aInitiator,213 aDescription,214 aCancelable,215 cOperations, // cOperations216 cOperations, // ulTotalOperationsWeight = cOperations217 bstrFirstOperationDescription, // bstrFirstOperationDescription218 1, // ulFirstOperationWeight: weigh them all the same219 aId);220 }221 222 HRESULT init(223 #if !defined (VBOX_COM_INPROC)224 VirtualBox *aParent,225 #endif226 IUnknown *aInitiator,227 CBSTR aDescription,228 BOOL aCancelable,229 ULONG cOperations,230 ULONG ulTotalOperationsWeight,231 CBSTR bstrFirstOperationDescription,232 ULONG ulFirstOperationWeight,233 OUT_GUID aId = NULL);234 235 HRESULT init(BOOL aCancelable,236 ULONG aOperationCount,237 CBSTR aOperationDescription);238 239 void uninit();240 241 // IProgress methods242 STDMETHOD(WaitForCompletion)(LONG aTimeout);243 STDMETHOD(WaitForOperationCompletion)(ULONG aOperation, LONG aTimeout);244 STDMETHOD(WaitForAsyncProgressCompletion)(IProgress *pProgressAsync);245 STDMETHOD(Cancel)();246 247 STDMETHOD(SetCurrentOperationProgress)(ULONG aPercent);248 STDMETHOD(SetNextOperation)(IN_BSTR bstrNextOperationDescription, ULONG ulNextOperationsWeight);249 250 // public methods only for internal purposes251 252 HRESULT setResultCode(HRESULT aResultCode);253 254 HRESULT notifyComplete(HRESULT aResultCode);255 HRESULT notifyComplete(HRESULT aResultCode,256 const GUID &aIID,257 const char *pcszComponent,258 const char *aText,259 ...);260 HRESULT notifyCompleteV(HRESULT aResultCode,261 const GUID &aIID,262 const char *pcszComponent,263 const char *aText,264 va_list va);265 bool notifyPointOfNoReturn(void);266 267 248 private: 268 249 -
trunk/src/VBox/Main/src-all/ProgressImpl.cpp
r44124 r44288 40 40 #include "AutoCaller.h" 41 41 42 //////////////////////////////////////////////////////////////////////////////// 43 // ProgressBase class 44 //////////////////////////////////////////////////////////////////////////////// 45 46 // constructor / destructor 47 //////////////////////////////////////////////////////////////////////////////// 48 49 ProgressBase::ProgressBase() 42 43 Progress::Progress() 50 44 #if !defined(VBOX_COM_INPROC) 51 45 : mParent(NULL) … … 54 48 } 55 49 56 ProgressBase::~ProgressBase() 57 { 58 } 59 60 61 /** 62 * Subclasses must call this method from their FinalConstruct() implementations. 63 */ 64 HRESULT ProgressBase::FinalConstruct() 65 { 66 mCancelable = FALSE; 67 mCompleted = FALSE; 68 mCanceled = FALSE; 69 mResultCode = S_OK; 70 71 m_cOperations 72 = m_ulTotalOperationsWeight 73 = m_ulOperationsCompletedWeight 74 = m_ulCurrentOperation 75 = m_ulCurrentOperationWeight 76 = m_ulOperationPercent 77 = m_cMsTimeout 78 = 0; 79 80 // get creation timestamp 81 m_ullTimestamp = RTTimeMilliTS(); 82 83 m_pfnCancelCallback = NULL; 84 m_pvCancelUserArg = NULL; 85 86 return BaseFinalConstruct(); 87 } 88 89 // protected initializer/uninitializer for internal purposes only 90 //////////////////////////////////////////////////////////////////////////////// 91 92 /** 93 * Initializes the progress base object. 94 * 95 * Subclasses should call this or any other #protectedInit() method from their 96 * init() implementations. 97 * 98 * @param aAutoInitSpan AutoInitSpan object instantiated by a subclass. 99 * @param aParent Parent object (only for server-side Progress objects). 100 * @param aInitiator Initiator of the task (for server-side objects. Can be 101 * NULL which means initiator = parent, otherwise must not 102 * be NULL). 103 * @param aDescription ask description. 104 * @param aID Address of result GUID structure (optional). 105 * 106 * @return COM result indicator. 107 */ 108 HRESULT ProgressBase::protectedInit(AutoInitSpan &aAutoInitSpan, 109 #if !defined(VBOX_COM_INPROC) 110 VirtualBox *aParent, 111 #endif 112 IUnknown *aInitiator, 113 CBSTR aDescription, 114 OUT_GUID aId /* = NULL */) 115 { 116 /* Guarantees subclasses call this method at the proper time */ 117 NOREF(aAutoInitSpan); 118 119 AutoCaller autoCaller(this); 120 AssertReturn(autoCaller.state() == InInit, E_FAIL); 121 122 #if !defined(VBOX_COM_INPROC) 123 AssertReturn(aParent, E_INVALIDARG); 124 #else 125 AssertReturn(aInitiator, E_INVALIDARG); 126 #endif 127 128 AssertReturn(aDescription, E_INVALIDARG); 129 130 #if !defined(VBOX_COM_INPROC) 131 /* share parent weakly */ 132 unconst(mParent) = aParent; 133 #endif 134 135 #if !defined(VBOX_COM_INPROC) 136 /* assign (and therefore addref) initiator only if it is not VirtualBox 137 * (to avoid cycling); otherwise mInitiator will remain null which means 138 * that it is the same as the parent */ 139 if (aInitiator) 140 { 141 ComObjPtr<VirtualBox> pVirtualBox(mParent); 142 if (!(pVirtualBox == aInitiator)) 143 unconst(mInitiator) = aInitiator; 144 } 145 #else 146 unconst(mInitiator) = aInitiator; 147 #endif 148 149 unconst(mId).create(); 150 if (aId) 151 mId.cloneTo(aId); 152 153 #if !defined(VBOX_COM_INPROC) 154 /* add to the global collection of progress operations (note: after 155 * creating mId) */ 156 mParent->addProgress(this); 157 #endif 158 159 unconst(mDescription) = aDescription; 160 161 return S_OK; 162 } 163 164 /** 165 * Initializes the progress base object. 166 * 167 * This is a special initializer that doesn't initialize any field. Used by one 168 * of the Progress::init() forms to create sub-progress operations combined 169 * together using a CombinedProgress instance, so it doesn't require the parent, 170 * initiator, description and doesn't create an ID. 171 * 172 * Subclasses should call this or any other #protectedInit() method from their 173 * init() implementations. 174 * 175 * @param aAutoInitSpan AutoInitSpan object instantiated by a subclass. 176 */ 177 HRESULT ProgressBase::protectedInit(AutoInitSpan &aAutoInitSpan) 178 { 179 /* Guarantees subclasses call this method at the proper time */ 180 NOREF(aAutoInitSpan); 181 182 return S_OK; 183 } 184 185 /** 186 * Uninitializes the instance. 187 * 188 * Subclasses should call this from their uninit() implementations. 189 * 190 * @param aAutoUninitSpan AutoUninitSpan object instantiated by a subclass. 191 * 192 * @note Using the mParent member after this method returns is forbidden. 193 */ 194 void ProgressBase::protectedUninit(AutoUninitSpan &aAutoUninitSpan) 195 { 196 /* release initiator (effective only if mInitiator has been assigned in 197 * init()) */ 198 unconst(mInitiator).setNull(); 199 200 #if !defined(VBOX_COM_INPROC) 201 if (mParent) 202 { 203 /* remove the added progress on failure to complete the initialization */ 204 if (aAutoUninitSpan.initFailed() && mId.isValid() && !mId.isZero()) 205 mParent->removeProgress(mId.ref()); 206 207 unconst(mParent) = NULL; 208 } 209 #endif 210 } 50 Progress::~Progress() 51 { 52 } 53 211 54 212 55 // IProgress properties 213 56 ///////////////////////////////////////////////////////////////////////////// 214 57 215 STDMETHODIMP Progress Base::COMGETTER(Id)(BSTR *aId)58 STDMETHODIMP Progress::COMGETTER(Id)(BSTR *aId) 216 59 { 217 60 CheckComArgOutPointerValid(aId); … … 226 69 } 227 70 228 STDMETHODIMP Progress Base::COMGETTER(Description)(BSTR *aDescription)71 STDMETHODIMP Progress::COMGETTER(Description)(BSTR *aDescription) 229 72 { 230 73 CheckComArgOutPointerValid(aDescription); … … 239 82 } 240 83 241 STDMETHODIMP Progress Base::COMGETTER(Initiator)(IUnknown **aInitiator)84 STDMETHODIMP Progress::COMGETTER(Initiator)(IUnknown **aInitiator) 242 85 { 243 86 CheckComArgOutPointerValid(aInitiator); … … 263 106 } 264 107 265 STDMETHODIMP Progress Base::COMGETTER(Cancelable)(BOOL *aCancelable)108 STDMETHODIMP Progress::COMGETTER(Cancelable)(BOOL *aCancelable) 266 109 { 267 110 CheckComArgOutPointerValid(aCancelable); … … 286 129 * @return fractional percentage as a double value. 287 130 */ 288 double Progress Base::calcTotalPercent()131 double Progress::calcTotalPercent() 289 132 { 290 133 // avoid division by zero … … 304 147 * The caller should hold the object write lock. 305 148 */ 306 void Progress Base::checkForAutomaticTimeout(void)149 void Progress::checkForAutomaticTimeout(void) 307 150 { 308 151 if ( m_cMsTimeout … … 315 158 316 159 317 STDMETHODIMP Progress Base::COMGETTER(TimeRemaining)(LONG *aTimeRemaining)160 STDMETHODIMP Progress::COMGETTER(TimeRemaining)(LONG *aTimeRemaining) 318 161 { 319 162 CheckComArgOutPointerValid(aTimeRemaining); … … 338 181 uint64_t ullTimeRemaining = ullTimeTotal - ullTimeElapsed; 339 182 340 // Log(("Progress Base::GetTimeRemaining: dPercentDone %RI32, ullTimeNow = %RI64, ullTimeElapsed = %RI64, ullTimeTotal = %RI64, ullTimeRemaining = %RI64\n",183 // Log(("Progress::GetTimeRemaining: dPercentDone %RI32, ullTimeNow = %RI64, ullTimeElapsed = %RI64, ullTimeTotal = %RI64, ullTimeRemaining = %RI64\n", 341 184 // (uint32_t)dPercentDone, ullTimeNow, ullTimeElapsed, ullTimeTotal, ullTimeRemaining)); 342 185 … … 348 191 } 349 192 350 STDMETHODIMP Progress Base::COMGETTER(Percent)(ULONG *aPercent)193 STDMETHODIMP Progress::COMGETTER(Percent)(ULONG *aPercent) 351 194 { 352 195 CheckComArgOutPointerValid(aPercent); … … 381 224 } 382 225 383 STDMETHODIMP Progress Base::COMGETTER(Completed)(BOOL *aCompleted)226 STDMETHODIMP Progress::COMGETTER(Completed)(BOOL *aCompleted) 384 227 { 385 228 CheckComArgOutPointerValid(aCompleted); … … 395 238 } 396 239 397 STDMETHODIMP Progress Base::COMGETTER(Canceled)(BOOL *aCanceled)240 STDMETHODIMP Progress::COMGETTER(Canceled)(BOOL *aCanceled) 398 241 { 399 242 CheckComArgOutPointerValid(aCanceled); … … 409 252 } 410 253 411 STDMETHODIMP Progress Base::COMGETTER(ResultCode)(LONG *aResultCode)254 STDMETHODIMP Progress::COMGETTER(ResultCode)(LONG *aResultCode) 412 255 { 413 256 CheckComArgOutPointerValid(aResultCode); … … 427 270 } 428 271 429 STDMETHODIMP Progress Base::COMGETTER(ErrorInfo)(IVirtualBoxErrorInfo **aErrorInfo)272 STDMETHODIMP Progress::COMGETTER(ErrorInfo)(IVirtualBoxErrorInfo **aErrorInfo) 430 273 { 431 274 CheckComArgOutPointerValid(aErrorInfo); … … 445 288 } 446 289 447 STDMETHODIMP Progress Base::COMGETTER(OperationCount)(ULONG *aOperationCount)290 STDMETHODIMP Progress::COMGETTER(OperationCount)(ULONG *aOperationCount) 448 291 { 449 292 CheckComArgOutPointerValid(aOperationCount); … … 459 302 } 460 303 461 STDMETHODIMP Progress Base::COMGETTER(Operation)(ULONG *aOperation)304 STDMETHODIMP Progress::COMGETTER(Operation)(ULONG *aOperation) 462 305 { 463 306 CheckComArgOutPointerValid(aOperation); … … 473 316 } 474 317 475 STDMETHODIMP Progress Base::COMGETTER(OperationDescription)(BSTR *aOperationDescription)318 STDMETHODIMP Progress::COMGETTER(OperationDescription)(BSTR *aOperationDescription) 476 319 { 477 320 CheckComArgOutPointerValid(aOperationDescription); … … 487 330 } 488 331 489 STDMETHODIMP Progress Base::COMGETTER(OperationPercent)(ULONG *aOperationPercent)332 STDMETHODIMP Progress::COMGETTER(OperationPercent)(ULONG *aOperationPercent) 490 333 { 491 334 CheckComArgOutPointerValid(aOperationPercent); … … 504 347 } 505 348 506 STDMETHODIMP Progress Base::COMGETTER(OperationWeight)(ULONG *aOperationWeight)349 STDMETHODIMP Progress::COMGETTER(OperationWeight)(ULONG *aOperationWeight) 507 350 { 508 351 CheckComArgOutPointerValid(aOperationWeight); … … 518 361 } 519 362 520 STDMETHODIMP Progress Base::COMSETTER(Timeout)(ULONG aTimeout)363 STDMETHODIMP Progress::COMSETTER(Timeout)(ULONG aTimeout) 521 364 { 522 365 AutoCaller autoCaller(this); … … 534 377 } 535 378 536 STDMETHODIMP Progress Base::COMGETTER(Timeout)(ULONG *aTimeout)379 STDMETHODIMP Progress::COMGETTER(Timeout)(ULONG *aTimeout) 537 380 { 538 381 CheckComArgOutPointerValid(aTimeout); … … 561 404 * @param pvUser The callback argument. 562 405 */ 563 bool Progress Base::setCancelCallback(void (*pfnCallback)(void *), void *pvUser)406 bool Progress::setCancelCallback(void (*pfnCallback)(void *), void *pvUser) 564 407 { 565 408 AutoCaller autoCaller(this); … … 577 420 } 578 421 579 ////////////////////////////////////////////////////////////////////////////////580 // Progress class581 ////////////////////////////////////////////////////////////////////////////////582 583 422 HRESULT Progress::FinalConstruct() 584 423 { 585 HRESULT rc = ProgressBase::FinalConstruct(); 424 mCancelable = FALSE; 425 mCompleted = FALSE; 426 mCanceled = FALSE; 427 mResultCode = S_OK; 428 429 m_cOperations 430 = m_ulTotalOperationsWeight 431 = m_ulOperationsCompletedWeight 432 = m_ulCurrentOperation 433 = m_ulCurrentOperationWeight 434 = m_ulOperationPercent 435 = m_cMsTimeout 436 = 0; 437 438 // get creation timestamp 439 m_ullTimestamp = RTTimeMilliTS(); 440 441 m_pfnCancelCallback = NULL; 442 m_pvCancelUserArg = NULL; 443 444 HRESULT rc = Progress::BaseFinalConstruct(); 586 445 if (FAILED(rc)) return rc; 587 446 … … 639 498 * ulTotalOperationsWeight = ulFirstOperationWeight = 1. 640 499 * 641 * @param aParent See Progress Base::init().642 * @param aInitiator See Progress Base::init().643 * @param aDescription See Progress Base::init().500 * @param aParent See Progress::init(). 501 * @param aInitiator See Progress::init(). 502 * @param aDescription See Progress::init(). 644 503 * @param aCancelable Flag whether the task maybe canceled. 645 504 * @param cOperations Number of operations within this task (at least 1). … … 648 507 * @param bstrFirstOperationDescription Description of the first operation. 649 508 * @param ulFirstOperationWeight Weight of first sub-operation. 650 * @param aId See Progress Base::init().509 * @param aId See Progress::init(). 651 510 */ 652 511 HRESULT Progress::init( … … 679 538 HRESULT rc = S_OK; 680 539 681 rc = ProgressBase::protectedInit(autoInitSpan, 540 // rc = Progress::init( 541 //#if !defined(VBOX_COM_INPROC) 542 // aParent, 543 //#endif 544 // aInitiator, aDescription, FALSE, aId); 545 // NA 682 546 #if !defined(VBOX_COM_INPROC) 683 aParent, 547 AssertReturn(aParent, E_INVALIDARG); 548 #else 549 AssertReturn(aInitiator, E_INVALIDARG); 684 550 #endif 685 aInitiator, aDescription, aId); 551 552 AssertReturn(aDescription, E_INVALIDARG); 553 554 #if !defined(VBOX_COM_INPROC) 555 /* share parent weakly */ 556 unconst(mParent) = aParent; 557 #endif 558 559 #if !defined(VBOX_COM_INPROC) 560 /* assign (and therefore addref) initiator only if it is not VirtualBox 561 * * (to avoid cycling); otherwise mInitiator will remain null which means 562 * * that it is the same as the parent */ 563 if (aInitiator) 564 { 565 ComObjPtr<VirtualBox> pVirtualBox(mParent); 566 if (!(pVirtualBox == aInitiator)) 567 unconst(mInitiator) = aInitiator; 568 } 569 #else 570 unconst(mInitiator) = aInitiator; 571 #endif 572 573 unconst(mId).create(); 574 if (aId) 575 mId.cloneTo(aId); 576 577 #if !defined(VBOX_COM_INPROC) 578 /* add to the global collection of progress operations (note: after 579 * * creating mId) */ 580 mParent->addProgress(this); 581 #endif 582 583 unconst(mDescription) = aDescription; 584 585 586 // end of assertion 587 588 686 589 if (FAILED(rc)) return rc; 687 590 … … 713 616 * 714 617 * Objects initialized with this method are then combined together into the 715 * single task using a CombinedProgress instance, so it doesn't require the618 * single task using a Progress instance, so it doesn't require the 716 619 * parent, initiator, description and doesn't create an ID. Note that calling 717 620 * respective getter methods on an object initialized with this method is … … 734 637 735 638 HRESULT rc = S_OK; 736 737 rc = ProgressBase::protectedInit(autoInitSpan); 639 /* Guarantees subclasses call this method at the proper time */ 640 NOREF(autoInitSpan); 641 738 642 if (FAILED(rc)) return rc; 739 643 … … 762 666 } 763 667 668 764 669 /** 765 670 * Uninitializes the instance and sets the ready flag to FALSE. … … 786 691 RTSemEventMultiDestroy(mCompletedSem); 787 692 788 ProgressBase::protectedUninit(autoUninitSpan); 789 } 693 /* release initiator (effective only if mInitiator has been assigned in 694 * * init()) */ 695 unconst(mInitiator).setNull(); 696 697 #if !defined(VBOX_COM_INPROC) 698 if (mParent) 699 { 700 /* remove the added progress on failure to complete the initialization */ 701 if (autoUninitSpan.initFailed() && mId.isValid() && !mId.isZero()) 702 mParent->removeProgress(mId.ref()); 703 704 unconst(mParent) = NULL; 705 } 706 #endif 707 } 708 790 709 791 710 // IProgress properties -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r44191 r44288 5962 5962 AutoCaller autoCaller(this); 5963 5963 AssertComRCReturnVoid(autoCaller.rc()); 5964 5965 5964 fireStateChangedEvent(mEventSource, machineState); 5966 5965 } … … 6329 6328 HRESULT Console::powerUp(IProgress **aProgress, bool aPaused) 6330 6329 { 6330 6331 6331 LogFlowThisFuncEnter(); 6332 6332 LogFlowThisFunc(("mMachineState=%d\n", mMachineState)); … … 6343 6343 bool fBeganPoweringUp = false; 6344 6344 6345 LONG cOperations = 1; 6346 LONG ulTotalOperationsWeight = 1; 6347 6345 6348 try 6346 6349 { 6350 6347 6351 if (Global::IsOnlineOrTransient(mMachineState)) 6348 6352 throw setError(VBOX_E_INVALID_VM_STATE, … … 6361 6365 if (FAILED(rc)) 6362 6366 throw rc; 6367 6363 6368 #if 0 /** @todo we should save it afterwards, but that isn't necessarily a good idea. Find a better place for this (VBoxSVC). */ 6364 6369 if (fTeleporterEnabled) … … 6391 6396 else 6392 6397 progressDesc = tr("Starting virtual machine"); 6393 if ( mMachineState == MachineState_Saved 6398 6399 /* Check all types of shared folders and compose a single list */ 6400 SharedFolderDataMap sharedFolders; 6401 { 6402 /* first, insert global folders */ 6403 for (SharedFolderDataMap::const_iterator it = m_mapGlobalSharedFolders.begin(); 6404 it != m_mapGlobalSharedFolders.end(); 6405 ++it) 6406 { 6407 const SharedFolderData &d = it->second; 6408 sharedFolders[it->first] = d; 6409 } 6410 6411 /* second, insert machine folders */ 6412 for (SharedFolderDataMap::const_iterator it = m_mapMachineSharedFolders.begin(); 6413 it != m_mapMachineSharedFolders.end(); 6414 ++it) 6415 { 6416 const SharedFolderData &d = it->second; 6417 sharedFolders[it->first] = d; 6418 } 6419 6420 /* third, insert console folders */ 6421 for (SharedFolderMap::const_iterator it = m_mapSharedFolders.begin(); 6422 it != m_mapSharedFolders.end(); 6423 ++it) 6424 { 6425 SharedFolder *pSF = it->second; 6426 AutoCaller sfCaller(pSF); 6427 AutoReadLock sfLock(pSF COMMA_LOCKVAL_SRC_POS); 6428 sharedFolders[it->first] = SharedFolderData(pSF->getHostPath(), 6429 pSF->isWritable(), 6430 pSF->isAutoMounted()); 6431 } 6432 } 6433 6434 Bstr savedStateFile; 6435 6436 /* 6437 * Saved VMs will have to prove that their saved states seem kosher. 6438 */ 6439 if (mMachineState == MachineState_Saved) 6440 { 6441 rc = mMachine->COMGETTER(StateFilePath)(savedStateFile.asOutParam()); 6442 if (FAILED(rc)) 6443 throw rc; 6444 ComAssertRet(!savedStateFile.isEmpty(), E_FAIL); 6445 int vrc = SSMR3ValidateFile(Utf8Str(savedStateFile).c_str(), false /* fChecksumIt */); 6446 if (RT_FAILURE(vrc)) 6447 throw setError(VBOX_E_FILE_ERROR, 6448 tr("VM cannot start because the saved state file '%ls' is invalid (%Rrc). Delete the saved state prior to starting the VM"), 6449 savedStateFile.raw(), vrc); 6450 } 6451 6452 /* Setup task object and thread to carry out the operaton 6453 * Asycnhronously */ 6454 std::auto_ptr<VMPowerUpTask> task(new VMPowerUpTask(this, pPowerupProgress)); 6455 ComAssertComRCRetRC(task->rc()); 6456 6457 task->mConfigConstructor = configConstructor; 6458 task->mSharedFolders = sharedFolders; 6459 task->mStartPaused = aPaused; 6460 if (mMachineState == MachineState_Saved) 6461 task->mSavedStateFile = savedStateFile; 6462 task->mTeleporterEnabled = fTeleporterEnabled; 6463 task->mEnmFaultToleranceState = enmFaultToleranceState; 6464 6465 /* Reset differencing hard disks for which autoReset is true, 6466 * but only if the machine has no snapshots OR the current snapshot 6467 * is an OFFLINE snapshot; otherwise we would reset the current 6468 * differencing image of an ONLINE snapshot which contains the disk 6469 * state of the machine while it was previously running, but without 6470 * the corresponding machine state, which is equivalent to powering 6471 * off a running machine and not good idea 6472 */ 6473 ComPtr<ISnapshot> pCurrentSnapshot; 6474 rc = mMachine->COMGETTER(CurrentSnapshot)(pCurrentSnapshot.asOutParam()); 6475 if (FAILED(rc)) 6476 throw rc; 6477 6478 BOOL fCurrentSnapshotIsOnline = false; 6479 if (pCurrentSnapshot) 6480 { 6481 rc = pCurrentSnapshot->COMGETTER(Online)(&fCurrentSnapshotIsOnline); 6482 if (FAILED(rc)) 6483 throw rc; 6484 } 6485 6486 if (!fCurrentSnapshotIsOnline) 6487 { 6488 LogFlowThisFunc(("Looking for immutable images to reset\n")); 6489 6490 com::SafeIfaceArray<IMediumAttachment> atts; 6491 rc = mMachine->COMGETTER(MediumAttachments)(ComSafeArrayAsOutParam(atts)); 6492 if (FAILED(rc)) 6493 throw rc; 6494 6495 for (size_t i = 0; 6496 i < atts.size(); 6497 ++i) 6498 { 6499 DeviceType_T devType; 6500 rc = atts[i]->COMGETTER(Type)(&devType); 6501 /** @todo later applies to floppies as well */ 6502 if (devType == DeviceType_HardDisk) 6503 { 6504 ComPtr<IMedium> pMedium; 6505 rc = atts[i]->COMGETTER(Medium)(pMedium.asOutParam()); 6506 if (FAILED(rc)) 6507 throw rc; 6508 6509 /* needs autoreset? */ 6510 BOOL autoReset = FALSE; 6511 rc = pMedium->COMGETTER(AutoReset)(&autoReset); 6512 if (FAILED(rc)) 6513 throw rc; 6514 6515 if (autoReset) 6516 { 6517 ComPtr<IProgress> pResetProgress; 6518 rc = pMedium->Reset(pResetProgress.asOutParam()); 6519 if (FAILED(rc)) 6520 throw rc; 6521 6522 /* save for later use on the powerup thread */ 6523 task->hardDiskProgresses.push_back(pResetProgress); 6524 } 6525 } 6526 } 6527 } 6528 else 6529 LogFlowThisFunc(("Machine has a current snapshot which is online, skipping immutable images reset\n")); 6530 6531 /* setup task object and thread to carry out the operation 6532 * asynchronously */ 6533 6534 #ifdef VBOX_WITH_EXTPACK 6535 mptrExtPackManager->dumpAllToReleaseLog(); 6536 #endif 6537 6538 #ifdef RT_OS_SOLARIS 6539 /* setup host core dumper for the VM */ 6540 Bstr value; 6541 HRESULT hrc = mMachine->GetExtraData(Bstr("VBoxInternal2/CoreDumpEnabled").raw(), value.asOutParam()); 6542 if (SUCCEEDED(hrc) && value == "1") 6543 { 6544 Bstr coreDumpDir, coreDumpReplaceSys, coreDumpLive; 6545 mMachine->GetExtraData(Bstr("VBoxInternal2/CoreDumpDir").raw(), coreDumpDir.asOutParam()); 6546 mMachine->GetExtraData(Bstr("VBoxInternal2/CoreDumpReplaceSystemDump").raw(), coreDumpReplaceSys.asOutParam()); 6547 mMachine->GetExtraData(Bstr("VBoxInternal2/CoreDumpLive").raw(), coreDumpLive.asOutParam()); 6548 6549 uint32_t fCoreFlags = 0; 6550 if ( coreDumpReplaceSys.isEmpty() == false 6551 && Utf8Str(coreDumpReplaceSys).toUInt32() == 1) 6552 fCoreFlags |= RTCOREDUMPER_FLAGS_REPLACE_SYSTEM_DUMP; 6553 6554 if ( coreDumpLive.isEmpty() == false 6555 && Utf8Str(coreDumpLive).toUInt32() == 1) 6556 fCoreFlags |= RTCOREDUMPER_FLAGS_LIVE_CORE; 6557 6558 Utf8Str strDumpDir(coreDumpDir); 6559 const char *pszDumpDir = strDumpDir.c_str(); 6560 if ( pszDumpDir 6561 && *pszDumpDir == '\0') 6562 pszDumpDir = NULL; 6563 6564 int vrc; 6565 if ( pszDumpDir 6566 && !RTDirExists(pszDumpDir)) 6567 { 6568 /* 6569 * Try create the directory. 6570 */ 6571 vrc = RTDirCreateFullPath(pszDumpDir, 0700); 6572 if (RT_FAILURE(vrc)) 6573 throw setError(E_FAIL, "Failed to setup CoreDumper. Couldn't create dump directory '%s' (%Rrc)\n", pszDumpDir, vrc); 6574 } 6575 6576 vrc = RTCoreDumperSetup(pszDumpDir, fCoreFlags); 6577 if (RT_FAILURE(vrc)) 6578 throw setError(E_FAIL, "Failed to setup CoreDumper (%Rrc)", vrc); 6579 else 6580 LogRel(("CoreDumper setup successful. pszDumpDir=%s fFlags=%#x\n", pszDumpDir ? pszDumpDir : ".", fCoreFlags)); 6581 } 6582 #endif 6583 6584 6585 // If there is immutable drive the process that. 6586 VMPowerUpTask::ProgressList progresses(task->hardDiskProgresses); 6587 if (aProgress && progresses.size() > 0){ 6588 6589 for (VMPowerUpTask::ProgressList::const_iterator it = progresses.begin(); it != progresses.end(); ++it) 6590 { 6591 ++cOperations; 6592 ulTotalOperationsWeight += 1; 6593 } 6594 rc = pPowerupProgress->init(static_cast<IConsole *>(this), 6595 progressDesc.raw(), 6596 TRUE, // Cancelable 6597 cOperations, 6598 ulTotalOperationsWeight, 6599 Bstr(tr("Starting Hard Disk operations")).raw(), 6600 1, 6601 NULL); 6602 AssertComRCReturnRC(rc); 6603 } 6604 else if ( mMachineState == MachineState_Saved 6394 6605 || (!fTeleporterEnabled && !fFaultToleranceSyncEnabled)) 6606 { 6395 6607 rc = pPowerupProgress->init(static_cast<IConsole *>(this), 6396 6608 progressDesc.raw(), 6397 6609 FALSE /* aCancelable */); 6398 else 6399 if (fTeleporterEnabled) 6610 } 6611 else if (fTeleporterEnabled) 6612 { 6400 6613 rc = pPowerupProgress->init(static_cast<IConsole *>(this), 6401 6614 progressDesc.raw(), … … 6406 6619 1 /* ulFirstOperationWeight */, 6407 6620 NULL); 6408 else 6409 if (fFaultToleranceSyncEnabled) 6621 } 6622 else if (fFaultToleranceSyncEnabled) 6623 { 6410 6624 rc = pPowerupProgress->init(static_cast<IConsole *>(this), 6411 6625 progressDesc.raw(), … … 6416 6630 1 /* ulFirstOperationWeight */, 6417 6631 NULL); 6632 } 6418 6633 6419 6634 if (FAILED(rc)) … … 6430 6645 } 6431 6646 fBeganPoweringUp = true; 6647 6648 LogFlowThisFunc(("Checking if canceled...\n")); 6649 BOOL fCanceled; 6650 rc = pPowerupProgress->COMGETTER(Canceled)(&fCanceled); 6651 if (FAILED(rc)) 6652 throw rc; 6653 6654 if (fCanceled) 6655 { 6656 LogFlowThisFunc(("Canceled in BeginPowerUp\n")); 6657 throw setError(E_FAIL, tr("Powerup was canceled")); 6658 } 6659 LogFlowThisFunc(("Not canceled yet.\n")); 6432 6660 6433 6661 /** @todo this code prevents starting a VM with unavailable bridged … … 6490 6718 throw rc; 6491 6719 6492 /* Check all types of shared folders and compose a single list */6493 SharedFolderDataMap sharedFolders;6494 {6495 /* first, insert global folders */6496 for (SharedFolderDataMap::const_iterator it = m_mapGlobalSharedFolders.begin();6497 it != m_mapGlobalSharedFolders.end();6498 ++it)6499 {6500 const SharedFolderData &d = it->second;6501 sharedFolders[it->first] = d;6502 }6503 6504 /* second, insert machine folders */6505 for (SharedFolderDataMap::const_iterator it = m_mapMachineSharedFolders.begin();6506 it != m_mapMachineSharedFolders.end();6507 ++it)6508 {6509 const SharedFolderData &d = it->second;6510 sharedFolders[it->first] = d;6511 }6512 6513 /* third, insert console folders */6514 for (SharedFolderMap::const_iterator it = m_mapSharedFolders.begin();6515 it != m_mapSharedFolders.end();6516 ++it)6517 {6518 SharedFolder *pSF = it->second;6519 AutoCaller sfCaller(pSF);6520 AutoReadLock sfLock(pSF COMMA_LOCKVAL_SRC_POS);6521 sharedFolders[it->first] = SharedFolderData(pSF->getHostPath(),6522 pSF->isWritable(),6523 pSF->isAutoMounted());6524 }6525 }6526 6527 Bstr savedStateFile;6528 6529 /*6530 * Saved VMs will have to prove that their saved states seem kosher.6531 */6532 if (mMachineState == MachineState_Saved)6533 {6534 rc = mMachine->COMGETTER(StateFilePath)(savedStateFile.asOutParam());6535 if (FAILED(rc))6536 throw rc;6537 ComAssertRet(!savedStateFile.isEmpty(), E_FAIL);6538 int vrc = SSMR3ValidateFile(Utf8Str(savedStateFile).c_str(), false /* fChecksumIt */);6539 if (RT_FAILURE(vrc))6540 throw setError(VBOX_E_FILE_ERROR,6541 tr("VM cannot start because the saved state file '%ls' is invalid (%Rrc). Delete the saved state prior to starting the VM"),6542 savedStateFile.raw(), vrc);6543 }6544 6545 LogFlowThisFunc(("Checking if canceled...\n"));6546 BOOL fCanceled;6547 rc = pPowerupProgress->COMGETTER(Canceled)(&fCanceled);6548 if (FAILED(rc))6549 throw rc;6550 if (fCanceled)6551 {6552 LogFlowThisFunc(("Canceled in BeginPowerUp\n"));6553 throw setError(E_FAIL, tr("Powerup was canceled"));6554 }6555 LogFlowThisFunc(("Not canceled yet.\n"));6556 6557 6720 /* setup task object and thread to carry out the operation 6558 6721 * asynchronously */ 6559 6560 std::auto_ptr<VMPowerUpTask> task(new VMPowerUpTask(this, pPowerupProgress)); 6561 ComAssertComRCRetRC(task->rc()); 6562 6563 task->mConfigConstructor = configConstructor; 6564 task->mSharedFolders = sharedFolders; 6565 task->mStartPaused = aPaused; 6566 if (mMachineState == MachineState_Saved) 6567 task->mSavedStateFile = savedStateFile; 6568 task->mTeleporterEnabled = fTeleporterEnabled; 6569 task->mEnmFaultToleranceState = enmFaultToleranceState; 6570 6571 /* Reset differencing hard disks for which autoReset is true, 6572 * but only if the machine has no snapshots OR the current snapshot 6573 * is an OFFLINE snapshot; otherwise we would reset the current 6574 * differencing image of an ONLINE snapshot which contains the disk 6575 * state of the machine while it was previously running, but without 6576 * the corresponding machine state, which is equivalent to powering 6577 * off a running machine and not good idea 6578 */ 6579 ComPtr<ISnapshot> pCurrentSnapshot; 6580 rc = mMachine->COMGETTER(CurrentSnapshot)(pCurrentSnapshot.asOutParam()); 6581 if (FAILED(rc)) 6582 throw rc; 6583 6584 BOOL fCurrentSnapshotIsOnline = false; 6585 if (pCurrentSnapshot) 6586 { 6587 rc = pCurrentSnapshot->COMGETTER(Online)(&fCurrentSnapshotIsOnline); 6588 if (FAILED(rc)) 6589 throw rc; 6590 } 6591 6592 if (!fCurrentSnapshotIsOnline) 6593 { 6594 LogFlowThisFunc(("Looking for immutable images to reset\n")); 6595 6596 com::SafeIfaceArray<IMediumAttachment> atts; 6597 rc = mMachine->COMGETTER(MediumAttachments)(ComSafeArrayAsOutParam(atts)); 6598 if (FAILED(rc)) 6599 throw rc; 6600 6601 for (size_t i = 0; 6602 i < atts.size(); 6603 ++i) 6604 { 6605 DeviceType_T devType; 6606 rc = atts[i]->COMGETTER(Type)(&devType); 6607 /** @todo later applies to floppies as well */ 6608 if (devType == DeviceType_HardDisk) 6609 { 6610 ComPtr<IMedium> pMedium; 6611 rc = atts[i]->COMGETTER(Medium)(pMedium.asOutParam()); 6612 if (FAILED(rc)) 6613 throw rc; 6614 6615 /* needs autoreset? */ 6616 BOOL autoReset = FALSE; 6617 rc = pMedium->COMGETTER(AutoReset)(&autoReset); 6618 if (FAILED(rc)) 6619 throw rc; 6620 6621 if (autoReset) 6622 { 6623 ComPtr<IProgress> pResetProgress; 6624 rc = pMedium->Reset(pResetProgress.asOutParam()); 6625 if (FAILED(rc)) 6626 throw rc; 6627 6628 /* save for later use on the powerup thread */ 6629 task->hardDiskProgresses.push_back(pResetProgress); 6630 } 6631 } 6632 } 6633 } 6634 else 6635 LogFlowThisFunc(("Machine has a current snapshot which is online, skipping immutable images reset\n")); 6636 6637 #ifdef VBOX_WITH_EXTPACK 6638 mptrExtPackManager->dumpAllToReleaseLog(); 6639 #endif 6640 6641 #ifdef RT_OS_SOLARIS 6642 /* setup host core dumper for the VM */ 6643 Bstr value; 6644 HRESULT hrc = mMachine->GetExtraData(Bstr("VBoxInternal2/CoreDumpEnabled").raw(), value.asOutParam()); 6645 if (SUCCEEDED(hrc) && value == "1") 6646 { 6647 Bstr coreDumpDir, coreDumpReplaceSys, coreDumpLive; 6648 mMachine->GetExtraData(Bstr("VBoxInternal2/CoreDumpDir").raw(), coreDumpDir.asOutParam()); 6649 mMachine->GetExtraData(Bstr("VBoxInternal2/CoreDumpReplaceSystemDump").raw(), coreDumpReplaceSys.asOutParam()); 6650 mMachine->GetExtraData(Bstr("VBoxInternal2/CoreDumpLive").raw(), coreDumpLive.asOutParam()); 6651 6652 uint32_t fCoreFlags = 0; 6653 if ( coreDumpReplaceSys.isEmpty() == false 6654 && Utf8Str(coreDumpReplaceSys).toUInt32() == 1) 6655 { 6656 fCoreFlags |= RTCOREDUMPER_FLAGS_REPLACE_SYSTEM_DUMP; 6657 } 6658 6659 if ( coreDumpLive.isEmpty() == false 6660 && Utf8Str(coreDumpLive).toUInt32() == 1) 6661 { 6662 fCoreFlags |= RTCOREDUMPER_FLAGS_LIVE_CORE; 6663 } 6664 6665 Utf8Str strDumpDir(coreDumpDir); 6666 const char *pszDumpDir = strDumpDir.c_str(); 6667 if ( pszDumpDir 6668 && *pszDumpDir == '\0') 6669 pszDumpDir = NULL; 6670 6671 int vrc; 6672 if ( pszDumpDir 6673 && !RTDirExists(pszDumpDir)) 6674 { 6675 /* 6676 * Try create the directory. 6677 */ 6678 vrc = RTDirCreateFullPath(pszDumpDir, 0700); 6679 if (RT_FAILURE(vrc)) 6680 throw setError(E_FAIL, "Failed to setup CoreDumper. Couldn't create dump directory '%s' (%Rrc)\n", pszDumpDir, vrc); 6681 } 6682 6683 vrc = RTCoreDumperSetup(pszDumpDir, fCoreFlags); 6684 if (RT_FAILURE(vrc)) 6685 throw setError(E_FAIL, "Failed to setup CoreDumper (%Rrc)", vrc); 6686 else 6687 LogRel(("CoreDumper setup successful. pszDumpDir=%s fFlags=%#x\n", pszDumpDir ? pszDumpDir : ".", fCoreFlags)); 6688 } 6689 #endif 6690 6691 /* pass the progress object to the caller if requested */ 6692 if (aProgress) 6693 { 6694 if (task->hardDiskProgresses.size() == 0) 6695 { 6696 /* there are no other operations to track, return the powerup 6697 * progress only */ 6698 pPowerupProgress.queryInterfaceTo(aProgress); 6699 } 6700 else 6701 { 6702 // Create a simple progress object 6703 ComObjPtr<Progress> pProgress; 6704 pProgress.createObject(); 6705 6706 // Assign hard disk progresses to the progresses list 6707 VMPowerUpTask::ProgressList progresses(task->hardDiskProgresses); 6708 6709 // Setup params to be used to initialize Progress object properties. 6710 ULONG cOperations = 1; 6711 ULONG ulTotalOperationsWeight = 1; 6712 6713 // Go round them and set number of operations and weight. 6714 for (VMPowerUpTask::ProgressList::const_iterator it = progresses.begin(); it != progresses.end(); ++it) 6715 { 6716 ++cOperations; 6717 ulTotalOperationsWeight += 1; 6718 } 6719 6720 rc = pProgress->init(static_cast<IConsole *>(this), 6721 progressDesc.raw(), 6722 TRUE, // Cancelable 6723 cOperations, 6724 ulTotalOperationsWeight, 6725 Bstr(tr("Starting Hard Disk operations")).raw(), // first sub-op decription 6726 1 ); 6727 AssertComRCReturnRC(rc); 6728 6729 // Perform all the necessary operations. 6730 for (VMPowerUpTask::ProgressList::const_iterator it = progresses.begin(); it != progresses.end(); ++it) 6731 { 6732 rc = pProgress->SetNextOperation(BstrFmt(tr("Disk Image Reset Operation - Immutable Image")).raw(), 1); 6733 AssertComRCReturnRC(rc); 6734 rc = pProgress.queryInterfaceTo(aProgress); 6735 AssertComRCReturnRC(rc); 6736 } 6737 6738 // Now do the power up. 6722 if (aProgress){ 6739 6723 rc = pPowerupProgress.queryInterfaceTo(aProgress); 6740 6724 AssertComRCReturnRC(rc); 6741 }6742 6725 } 6743 6726 … … 6757 6740 setMachineState(MachineState_Restoring); 6758 6741 else if (fTeleporterEnabled) 6759 6742 setMachineState(MachineState_TeleportingIn); 6760 6743 else if (enmFaultToleranceState == FaultToleranceState_Standby) 6761 6744 setMachineState(MachineState_FaultTolerantSyncing); … … 8812 8795 HRESULT rc2 = (*it)->WaitForCompletion(-1); 8813 8796 AssertComRC(rc2); 8797 8798 rc = task->mProgress->SetNextOperation(BstrFmt(tr("Disk Image Reset Operation - Immutable Image")).raw(), 1); 8799 AssertComRCReturnRC(rc); 8814 8800 } 8815 8801
Note:
See TracChangeset
for help on using the changeset viewer.