Changeset 24558 in vbox for trunk/src/VBox/Main
- Timestamp:
- Nov 10, 2009 3:59:07 PM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl.cpp
r24552 r24558 6686 6686 } 6687 6687 6688 /* lock attached media. This method will also check their 6689 * accessibility. Note that the media will be unlocked automatically 6690 * by SessionMachine::setMachineState() when the VM is powered down. */ 6691 rc = console->mControl->LockMedia(); 6692 CheckComRCThrowRC(rc); 6688 /* 6689 * Lock attached media. This method will also check their accessibility. 6690 * If we're a teleporter, we'll have to postpone this action so we can 6691 * migrate between local processes. 6692 * 6693 * Note! The media will be unlocked automatically by 6694 * SessionMachine::setMachineState() when the VM is powered down. 6695 */ 6696 if (!task->mTeleporterEnabled) 6697 { 6698 rc = console->mControl->LockMedia(); 6699 CheckComRCThrowRC(rc); 6700 } 6693 6701 6694 6702 #ifdef VBOX_WITH_VRDP -
trunk/src/VBox/Main/ConsoleImplTeleporter.cpp
r24365 r24558 94 94 MachineState_T menmOldMachineState; 95 95 bool mfSuspendedByUs; 96 bool mfUnlockedMedia; 96 97 97 98 TeleporterStateSrc(Console *pConsole, PVM pVM, Progress *pProgress, MachineState_T enmOldMachineState) … … 100 101 , menmOldMachineState(enmOldMachineState) 101 102 , mfSuspendedByUs(false) 103 , mfUnlockedMedia(false) 102 104 { 103 105 } … … 111 113 { 112 114 public: 113 IMachine *mpMachine; 114 PRTTCPSERVER mhServer; 115 PRTTIMERLR mphTimerLR; 116 bool mfStartPaused; 117 int mRc; 115 IMachine *mpMachine; 116 IInternalMachineControl *mpControl; 117 PRTTCPSERVER mhServer; 118 PRTTIMERLR mphTimerLR; 119 bool mfStartPaused; 120 bool mfLockedMedia; 121 int mRc; 118 122 119 123 TeleporterStateTrg(Console *pConsole, PVM pVM, Progress *pProgress, 120 IMachine *pMachine, PRTTIMERLR phTimerLR, bool fStartPaused) 124 IMachine *pMachine, IInternalMachineControl *pControl, 125 PRTTIMERLR phTimerLR, bool fStartPaused) 121 126 : TeleporterState(pConsole, pVM, pProgress, false /*fIsSource*/) 122 127 , mpMachine(pMachine) 128 , mpControl(pControl) 123 129 , mhServer(NULL) 124 130 , mphTimerLR(phTimerLR) 125 131 , mfStartPaused(false) 132 , mfLockedMedia(false) 126 133 , mRc(VINF_SUCCESS) 127 134 { … … 651 658 return E_FAIL; 652 659 } 660 661 /* 662 * The last thing we do is to hand over any media we might have locked. 663 */ 664 /** @todo Maybe we should only do this if it's a local teleportation... */ 665 hrc = mControl->UnlockMedia(); 666 if (FAILED(hrc)) 667 return hrc; 668 pState->mfUnlockedMedia = true; 669 670 hrc = teleporterSrcSubmitCommand(pState, "lock-media"); 671 if (FAILED(hrc)) 672 return hrc; 673 653 674 hrc = teleporterSrcSubmitCommand(pState, "done"); 654 675 if (FAILED(hrc)) … … 727 748 ) 728 749 { 750 if (pState->mfUnlockedMedia) 751 { 752 ErrorInfoKeeper Oak; 753 HRESULT hrc2 = pState->mptrConsole->mControl->LockMedia(); 754 if (FAILED(hrc2)) 755 { 756 uint64_t StartMS = RTTimeMilliTS(); 757 do 758 { 759 RTThreadSleep(2); 760 hrc2 = pState->mptrConsole->mControl->LockMedia(); 761 } while ( FAILED(hrc2) 762 && RTTimeMilliTS() - StartMS < 2000); 763 } 764 if (SUCCEEDED(hrc2)) 765 pState->mfUnlockedMedia = true; 766 else 767 LogRel(("FATAL ERROR: Failed to re-take the media locks. hrc2=%Rhrc\n", hrc2)); 768 } 769 729 770 switch (enmVMState) 730 771 { … … 738 779 case VMSTATE_RESETTING_LS: 739 780 Assert(!pState->mfSuspendedByUs); 781 Assert(!pState->mfUnlockedMedia); 740 782 pState->mptrConsole->setMachineState(MachineState_Running); 741 783 break; … … 758 800 case VMSTATE_SUSPENDING_LS: 759 801 case VMSTATE_SUSPENDING_EXT_LS: 760 pState->mptrConsole->setMachineState(MachineState_Paused); 761 if (pState->mfSuspendedByUs) 802 if (!pState->mfUnlockedMedia) 762 803 { 763 autoLock.leave(); 764 int rc = VMR3Resume(pState->mpVM); 765 AssertLogRelMsgRC(rc, ("VMR3Resume -> %Rrc\n", rc)); 766 autoLock.enter(); 804 pState->mptrConsole->setMachineState(MachineState_Paused); 805 if (pState->mfSuspendedByUs) 806 { 807 autoLock.leave(); 808 int rc = VMR3Resume(pState->mpVM); 809 AssertLogRelMsgRC(rc, ("VMR3Resume -> %Rrc\n", rc)); 810 autoLock.enter(); 811 } 812 } 813 else 814 { 815 /* Faking a guru meditation is the best I can think of doing here... */ 816 pState->mptrConsole->setMachineState(MachineState_Stuck); 767 817 } 768 818 break; … … 956 1006 * Do the job, when it returns we're done. 957 1007 */ 958 TeleporterStateTrg State(this, pVM, pProgress, pMachine, &hTimerLR, fStartPaused);1008 TeleporterStateTrg State(this, pVM, pProgress, pMachine, mControl, &hTimerLR, fStartPaused); 959 1009 State.mstrPassword = strPassword; 960 1010 State.mhServer = hServer; … … 1036 1086 1037 1087 1088 /** 1089 * Unlock the media. 1090 * 1091 * This is used in error paths. 1092 * 1093 * @param pState The teleporter state. 1094 */ 1095 static void teleporterTrgUnlockMedia(TeleporterStateTrg *pState) 1096 { 1097 if (pState->mfLockedMedia) 1098 { 1099 pState->mpControl->UnlockMedia(); 1100 pState->mfLockedMedia = false; 1101 } 1102 } 1103 1104 1038 1105 static int teleporterTcpWriteACK(TeleporterStateTrg *pState) 1039 1106 { 1040 1107 int rc = RTTcpWrite(pState->mhSocket, "ACK\n", sizeof("ACK\n") - 1); 1041 1108 if (RT_FAILURE(rc)) 1109 { 1042 1110 LogRel(("Teleporter: RTTcpWrite(,ACK,) -> %Rrc\n", rc)); 1111 teleporterTrgUnlockMedia(pState); 1112 } 1043 1113 RTTcpFlush(pState->mhSocket); 1044 1114 return rc; … … 1048 1118 static int teleporterTcpWriteNACK(TeleporterStateTrg *pState, int32_t rc2) 1049 1119 { 1120 /* 1121 * Unlock media sending the NACK. That way the other doesn't have to spin 1122 * waiting to regain the locks. 1123 */ 1124 teleporterTrgUnlockMedia(pState); 1125 1050 1126 char szMsg[64]; 1051 1127 size_t cch = RTStrPrintf(szMsg, sizeof(szMsg), "NACK=%d\n", rc2); … … 1117 1193 * Command processing loop. 1118 1194 */ 1195 bool fDone = false; 1119 1196 for (;;) 1120 1197 { … … 1154 1231 vrc = teleporterTcpWriteACK(pState); 1155 1232 } 1156 /** @todo implement config verification and hardware compatability checks. Or1157 * maybe leave part of these to the saved state machinery?1158 * Update: We're doing as much as possible in the first SSM pass. */1159 1233 else if (!strcmp(szCmd, "cancel")) 1160 1234 { … … 1168 1242 vrc = teleporterTcpWriteACK(pState); 1169 1243 } 1244 else if (!strcmp(szCmd, "lock-media")) 1245 { 1246 HRESULT hrc = pState->mpControl->LockMedia(); 1247 if (SUCCEEDED(hrc)) 1248 { 1249 pState->mfLockedMedia = true; 1250 vrc = teleporterTcpWriteACK(pState); 1251 } 1252 else 1253 { 1254 vrc = VERR_FILE_LOCK_FAILED; 1255 teleporterTcpWriteNACK(pState, vrc); 1256 } 1257 } 1170 1258 else if (!strcmp(szCmd, "done")) 1171 1259 { … … 1173 1261 * The ACK is the point of no return. 1174 1262 */ 1175 if (pState->mptrProgress->notifyPointOfNoReturn()) 1263 if ( pState->mptrProgress->notifyPointOfNoReturn() 1264 && pState->mfLockedMedia) 1176 1265 vrc = teleporterTcpWriteACK(pState); 1177 1266 else 1178 1267 { 1179 vrc = VERR_SSM_CANCELLED;1268 vrc = pState->mfLockedMedia ? VERR_WRONG_ORDER : VERR_SSM_CANCELLED; 1180 1269 teleporterTcpWriteNACK(pState, vrc); 1181 1270 } 1271 fDone = true; 1182 1272 break; 1183 1273 } … … 1194 1284 } 1195 1285 1286 if (RT_SUCCESS(vrc) && !fDone) 1287 vrc = VERR_WRONG_ORDER; 1288 if (RT_FAILURE(vrc)) 1289 teleporterTrgUnlockMedia(pState); 1290 1196 1291 pState->mRc = vrc; 1197 1292 pState->mhSocket = NIL_RTSOCKET; -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r24539 r24558 3682 3682 <interface 3683 3683 name="IInternalMachineControl" extends="$unknown" 3684 uuid=" 4e2b8f0f-6575-49d2-bb19-5cd15a6ca2f0"3684 uuid="35d8d838-d066-447d-927a-fd93afdbec90" 3685 3685 internal="yes" 3686 3686 wsmap="suppress" … … 4040 4040 Restoring state. The locked media will be automatically unlocked when 4041 4041 the machine is powered off or crashed. 4042 </desc> 4043 </method> 4044 <method name="unlockMedia"> 4045 <desc> 4046 Unlocks all media previously locked using 4047 <link to="IInternalMachineControl::lockMedia"/>. 4048 4049 This method is intended to be used with teleportation so that it is 4050 possible to teleport between processes on the same machine. 4042 4051 </desc> 4043 4052 </method> … … 5803 5812 <desc> 5804 5813 How to order bytes in the pixel. A pixel consists of 4 bytes. If this parameter is true, then 5805 bytes order is: B, G, R, 0xFF. If this parameter is false, then bytes order is: R, G, B, 0xFF. 5814 bytes order is: B, G, R, 0xFF. If this parameter is false, then bytes order is: R, G, B, 0xFF. 5806 5815 </desc> 5807 5816 </param> -
trunk/src/VBox/Main/include/MachineImpl.h
r24539 r24558 998 998 STDMETHOD(PushGuestProperty)(IN_BSTR aName, IN_BSTR aValue, 999 999 ULONG64 aTimestamp, IN_BSTR aFlags); 1000 STDMETHOD(LockMedia)() { return lockMedia(); } 1000 STDMETHOD(LockMedia)() { return lockMedia(); } 1001 STDMETHOD(UnlockMedia)() { unlockMedia(); return S_OK; } 1001 1002 1002 1003 // public methods only for internal purposes
Note:
See TracChangeset
for help on using the changeset viewer.