- Timestamp:
- May 25, 2019 8:39:19 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r78683 r78750 2192 2192 MachineState_T lastMachineState = mMachineState; 2193 2193 2194 HRESULT rc = S_OK;2195 bool fBeganPowerDown = false;2196 VMPowerDownTask* task = NULL;2197 2198 do2199 {2200 ComPtr<IProgress> pProgress;2201 2202 2194 #ifdef VBOX_WITH_GUEST_PROPS 2203 alock.release();2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2195 alock.release(); /** @todo r=bird: This code introduces a race condition wrt to the state. This must be done elsewhere! */ 2196 2197 if (i_isResetTurnedIntoPowerOff()) 2198 { 2199 mMachine->DeleteGuestProperty(Bstr("/VirtualBox/HostInfo/VMPowerOffReason").raw()); 2200 mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/VMPowerOffReason").raw(), 2201 Bstr("PowerOff").raw(), Bstr("RDONLYGUEST").raw()); 2202 mMachine->SaveSettings(); 2203 } 2204 2205 alock.acquire(); 2214 2206 #endif 2215 2207 2208 /* 2209 * Request a progress object from the server (this will set the machine state 2210 * to Stopping on the server to block others from accessing this machine). 2211 */ 2212 ComPtr<IProgress> ptrProgress; 2213 HRESULT hrc = mControl->BeginPoweringDown(ptrProgress.asOutParam()); 2214 if (SUCCEEDED(hrc)) 2215 { 2216 /* Sync the state with the server: */ 2217 i_setMachineStateLocally(MachineState_Stopping); 2218 2219 /* Create the power down task: */ 2220 VMPowerDownTask *pTask = NULL; 2221 try 2222 { 2223 pTask = new VMPowerDownTask(this, ptrProgress); 2224 if (!pTask->isOk()) 2225 { 2226 hrc = setError(FAILED(hrc) ? hrc : E_FAIL, "Could not create VMPowerDownTask object\n"); 2227 delete(pTask); 2228 pTask = NULL; 2229 } 2230 } 2231 catch (std::bad_alloc &) 2232 { 2233 hrc = E_OUTOFMEMORY; 2234 } 2235 if (SUCCEEDED(hrc)) 2236 { 2237 hrc = pTask->createThread(); 2238 if (SUCCEEDED(hrc)) 2239 { 2240 ptrProgress.queryInterfaceTo(aProgress.asOutParam()); 2241 LogFlowThisFunc(("LEAVE: hrc=%Rhrc\n", hrc)); 2242 return hrc; 2243 } 2244 } 2245 2216 2246 /* 2217 * request a progress object from the server2218 * (this will set the machine state to Stopping on the server to block2219 * others from accessing this machine)2247 * Cancel the requested power down procedure. 2248 * This will reset the machine state to the state it had right 2249 * before calling mControl->BeginPoweringDown(). 2220 2250 */ 2221 rc = mControl->BeginPoweringDown(pProgress.asOutParam());2222 if (FAILED(rc))2223 break;2224 2225 fBeganPowerDown = true;2226 2227 /* sync the state with the server */2228 i_setMachineStateLocally(MachineState_Stopping);2229 try2230 {2231 task = new VMPowerDownTask(this, pProgress);2232 if (!task->isOk())2233 {2234 throw E_FAIL;2235 }2236 }2237 catch(...)2238 {2239 delete task;2240 rc = setError(E_FAIL, "Could not create VMPowerDownTask object\n");2241 break;2242 }2243 2244 rc = task->createThread();2245 2246 /* pass the progress to the caller */2247 pProgress.queryInterfaceTo(aProgress.asOutParam());2248 }2249 while (0);2250 2251 if (FAILED(rc))2252 {2253 /* preserve existing error info */2254 2251 ErrorInfoKeeper eik; 2255 2256 if (fBeganPowerDown) 2257 { 2258 /* 2259 * cancel the requested power down procedure. 2260 * This will reset the machine state to the state it had right 2261 * before calling mControl->BeginPoweringDown(). 2262 */ 2263 mControl->EndPoweringDown(eik.getResultCode(), eik.getText().raw()); } 2264 2252 mControl->EndPoweringDown(eik.getResultCode(), eik.getText().raw()); 2265 2253 i_setMachineStateLocally(lastMachineState); 2266 2254 } 2267 2268 LogFlowThisFunc(("rc=%Rhrc\n", rc)); 2269 LogFlowThisFuncLeave(); 2270 2271 return rc; 2255 LogFlowThisFunc(("LEAVE: hrc=%Rhrc\n", hrc)); 2256 return hrc; 2272 2257 } 2273 2258
Note:
See TracChangeset
for help on using the changeset viewer.