Changeset 55214 in vbox for trunk/src/VBox/Main/include/MachineImpl.h
- Timestamp:
- Apr 13, 2015 3:53:01 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 99520
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/MachineImpl.h
r55168 r55214 125 125 struct Session 126 126 { 127 /** Type of lock which created this session */ 128 LockType_T mLockType; 129 127 130 /** Control of the direct session opened by lockMachine() */ 128 131 ComPtr<IInternalSessionControl> mDirectControl; … … 597 600 } 598 601 599 602 static HRESULT i_setErrorStatic(HRESULT aResultCode, const char *pcszMsg, ...); 600 603 601 604 protected: … … 712 715 bool i_isControllerHotplugCapable(StorageControllerType_T enmCtrlType); 713 716 714 struct DeleteTask;715 static DECLCALLBACK(int) deleteThread(RTTHREAD Thread, void *pvUser);716 HRESULT i_deleteTaskWorker(DeleteTask &task);717 717 Utf8Str i_getExtraData(const Utf8Str &strKey); 718 718 … … 778 778 779 779 uint64_t uRegistryNeedsSaving; 780 781 /** 782 * Abstract base class for all Machine or SessionMachine related 783 * asynchronous tasks. This is necessary since RTThreadCreate cannot call 784 * a (non-static) method as its thread function, so instead we have it call 785 * the static Machine::taskHandler, which then calls the handler() method 786 * in here (implemented by the subclasses). 787 */ 788 struct Task 789 { 790 Task(Machine *m, Progress *p, const Utf8Str &t) 791 : m_pMachine(m), 792 m_machineCaller(m), 793 m_pProgress(p), 794 m_strTaskName(t), 795 m_machineStateBackup(m->mData->mMachineState) // save the current machine state 796 {} 797 798 HRESULT createThread() 799 { 800 int vrc = RTThreadCreate(NULL, 801 taskHandler, 802 (void *)this, 803 0, 804 RTTHREADTYPE_MAIN_WORKER, 805 0, 806 m_strTaskName.c_str()); 807 if (RT_FAILURE(vrc)) 808 { 809 HRESULT rc = Machine::i_setErrorStatic(E_FAIL, Machine::tr("Could not create thread \"%s\" (%Rrc)"), m_strTaskName.c_str(), vrc); 810 delete this; 811 return rc; 812 } 813 return S_OK; 814 } 815 816 void modifyBackedUpState(MachineState_T s) 817 { 818 *const_cast<MachineState_T *>(&m_machineStateBackup) = s; 819 } 820 821 virtual void handler() = 0; 822 823 ComObjPtr<Machine> m_pMachine; 824 AutoCaller m_machineCaller; 825 ComObjPtr<Progress> m_pProgress; 826 Utf8Str m_strTaskName; 827 const MachineState_T m_machineStateBackup; 828 }; 829 830 struct DeleteConfigTask; 831 void i_deleteConfigHandler(DeleteConfigTask &task); 832 833 static DECLCALLBACK(int) taskHandler(RTTHREAD thread, void *pvUser); 780 834 781 835 friend class SessionMachine; … … 1131 1185 const std::vector<CloneOptions_T> &aOptions, 1132 1186 ComPtr<IProgress> &aProgress); 1187 HRESULT saveState(ComPtr<IProgress> &aProgress); 1188 HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile); 1189 HRESULT discardSavedState(BOOL aFRemoveFile); 1190 HRESULT takeSnapshot(const com::Utf8Str &aName, 1191 const com::Utf8Str &aDescription, 1192 BOOL aPause, 1193 ComPtr<IProgress> &aProgress); 1194 HRESULT deleteSnapshot(const com::Guid &aId, 1195 ComPtr<IProgress> &aProgress); 1196 HRESULT deleteSnapshotAndAllChildren(const com::Guid &aId, 1197 ComPtr<IProgress> &aProgress); 1198 HRESULT deleteSnapshotRange(const com::Guid &aStartId, 1199 const com::Guid &aEndId, 1200 ComPtr<IProgress> &aProgress); 1201 HRESULT restoreSnapshot(const ComPtr<ISnapshot> &aSnapshot, 1202 ComPtr<IProgress> &aProgress); 1133 1203 1134 1204 // wrapped IInternalMachineControl properties 1135 1205 1136 1206 // wrapped IInternalMachineControl methods 1137 HRESULT setRemoveSavedStateFile(BOOL aRemove);1138 1207 HRESULT updateState(MachineState_T aState); 1139 1208 HRESULT beginPowerUp(const ComPtr<IProgress> &aProgress); … … 1145 1214 BOOL *aMatched, 1146 1215 ULONG *aMaskedInterfaces); 1147 HRESULT captureUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename); 1216 HRESULT captureUSBDevice(const com::Guid &aId, 1217 const com::Utf8Str &aCaptureFilename); 1148 1218 HRESULT detachUSBDevice(const com::Guid &aId, 1149 1219 BOOL aDone); … … 1152 1222 HRESULT onSessionEnd(const ComPtr<ISession> &aSession, 1153 1223 ComPtr<IProgress> &aProgress); 1154 HRESULT beginSavingState(ComPtr<IProgress> &aProgress,1155 com::Utf8Str &aStateFilePath);1156 HRESULT endSavingState(LONG aResult,1157 const com::Utf8Str &aErrMsg);1158 HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile);1159 HRESULT beginTakingSnapshot(const ComPtr<IConsole> &aInitiator,1160 const com::Utf8Str &aName,1161 const com::Utf8Str &aDescription,1162 const ComPtr<IProgress> &aConsoleProgress,1163 BOOL aFTakingSnapshotOnline,1164 com::Utf8Str &aStateFilePath);1165 HRESULT endTakingSnapshot(BOOL aSuccess);1166 HRESULT deleteSnapshot(const ComPtr<IConsole> &aInitiator,1167 const com::Guid &aStartId,1168 const com::Guid &aEndId,1169 BOOL aDeleteAllChildren,1170 MachineState_T *aMachineState,1171 ComPtr<IProgress> &aProgress);1172 1224 HRESULT finishOnlineMergeMedium(); 1173 HRESULT restoreSnapshot(const ComPtr<IConsole> &aInitiator,1174 const ComPtr<ISnapshot> &aSnapshot,1175 MachineState_T *aMachineState,1176 ComPtr<IProgress> &aProgress);1177 1225 HRESULT pullGuestProperties(std::vector<com::Utf8Str> &aNames, 1178 1226 std::vector<com::Utf8Str> &aValues, … … 1203 1251 ULONG aVmNetRx, 1204 1252 ULONG aVmNetTx); 1205 1206 1207 1208 1209 1253 }; 1210 1254 … … 1302 1346 HRESULT i_unlockMedia(); 1303 1347 1348 HRESULT i_saveStateWithReason(Reason_T aReason, ComPtr<IProgress> &aProgress); 1349 1304 1350 private: 1305 1351 … … 1324 1370 HRESULT onSessionEnd(const ComPtr<ISession> &aSession, 1325 1371 ComPtr<IProgress> &aProgress); 1326 HRESULT beginSavingState(ComPtr<IProgress> &aProgress,1327 com::Utf8Str &aStateFilePath);1328 HRESULT endSavingState(LONG aResult,1329 const com::Utf8Str &aErrMsg);1330 HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile);1331 HRESULT beginTakingSnapshot(const ComPtr<IConsole> &aInitiator,1332 const com::Utf8Str &aName,1333 const com::Utf8Str &aDescription,1334 const ComPtr<IProgress> &aConsoleProgress,1335 BOOL aFTakingSnapshotOnline,1336 com::Utf8Str &aStateFilePath);1337 HRESULT endTakingSnapshot(BOOL aSuccess);1338 HRESULT deleteSnapshot(const ComPtr<IConsole> &aInitiator,1339 const com::Guid &aStartId,1340 const com::Guid &aEndId,1341 BOOL aDeleteAllChildren,1342 MachineState_T *aMachineState,1343 ComPtr<IProgress> &aProgress);1344 1372 HRESULT finishOnlineMergeMedium(); 1345 HRESULT restoreSnapshot(const ComPtr<IConsole> &aInitiator,1346 const ComPtr<ISnapshot> &aSnapshot,1347 MachineState_T *aMachineState,1348 ComPtr<IProgress> &aProgress);1349 1373 HRESULT pullGuestProperties(std::vector<com::Utf8Str> &aNames, 1350 1374 std::vector<com::Utf8Str> &aValues, … … 1380 1404 { 1381 1405 ConsoleTaskData() 1382 : mLastState(MachineState_Null), mDeleteSnapshotInfo(NULL) 1406 : mLastState(MachineState_Null), 1407 mDeleteSnapshotInfo(NULL) 1383 1408 { } 1384 1409 … … 1386 1411 ComObjPtr<Progress> mProgress; 1387 1412 1388 // used when taking snapshot 1389 ComObjPtr<Snapshot> mSnapshot; 1390 1391 // used when deleting online snapshot 1413 // used when deleting online snaphshot 1392 1414 void *mDeleteSnapshotInfo; 1393 1394 // used when saving state (either as part of a snapshot or separate)1395 Utf8Str strStateFilePath;1396 1415 }; 1397 1416 1417 struct SaveStateTask; 1398 1418 struct SnapshotTask; 1419 struct TakeSnapshotTask; 1399 1420 struct DeleteSnapshotTask; 1400 1421 struct RestoreSnapshotTask; 1401 1422 1423 friend struct TakeSnapshotTask; 1402 1424 friend struct DeleteSnapshotTask; 1403 1425 friend struct RestoreSnapshotTask; 1404 1426 1405 HRESULT i_endSavingState(HRESULT aRC, const Utf8Str &aErrMsg); 1427 void i_saveStateHandler(SaveStateTask &aTask); 1428 1429 // Override some functionality for SessionMachine, this is where the 1430 // real action happens (the Machine methods are just dummies). 1431 HRESULT saveState(ComPtr<IProgress> &aProgress); 1432 HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile); 1433 HRESULT discardSavedState(BOOL aFRemoveFile); 1434 HRESULT takeSnapshot(const com::Utf8Str &aName, 1435 const com::Utf8Str &aDescription, 1436 BOOL aPause, 1437 ComPtr<IProgress> &aProgress); 1438 HRESULT deleteSnapshot(const com::Guid &aId, 1439 ComPtr<IProgress> &aProgress); 1440 HRESULT deleteSnapshotAndAllChildren(const com::Guid &aId, 1441 ComPtr<IProgress> &aProgress); 1442 HRESULT deleteSnapshotRange(const com::Guid &aStartId, 1443 const com::Guid &aEndId, 1444 ComPtr<IProgress> &aProgress); 1445 HRESULT restoreSnapshot(const ComPtr<ISnapshot> &aSnapshot, 1446 ComPtr<IProgress> &aProgress); 1447 1406 1448 void i_releaseSavedStateFile(const Utf8Str &strSavedStateFile, Snapshot *pSnapshotToIgnore); 1407 1449 1450 void i_takeSnapshotHandler(TakeSnapshotTask &aTask); 1451 static void i_takeSnapshotProgressCancelCallback(void *pvUser); 1452 HRESULT i_finishTakingSnapshot(TakeSnapshotTask &aTask, AutoWriteLock &alock, bool aSuccess); 1453 HRESULT i_deleteSnapshot(const com::Guid &aStartId, 1454 const com::Guid &aEndId, 1455 BOOL aDeleteAllChildren, 1456 ComPtr<IProgress> &aProgress); 1408 1457 void i_deleteSnapshotHandler(DeleteSnapshotTask &aTask); 1409 1458 void i_restoreSnapshotHandler(RestoreSnapshotTask &aTask); … … 1451 1500 1452 1501 int miNATNetworksStarted; 1453 1454 static DECLCALLBACK(int) taskHandler(RTTHREAD thread, void *pvUser);1455 1502 }; 1456 1503
Note:
See TracChangeset
for help on using the changeset viewer.