Lines Matching refs:pState

182  * @param   pState      The teleporter state structure.
187 static int teleporterTcpReadLine(TeleporterState *pState, char *pszBuf, size_t cchBuf)
190 RTSOCKET Sock = pState->mhSocket;
224 * @param pState The teleporter source state.
231 Console::i_teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich,
235 int vrc = teleporterTcpReadLine(pState, szMsg, sizeof(szMsg));
289 * @param pState The teleporter source state.
295 HRESULT Console::i_teleporterSrcSubmitCommand(TeleporterStateSrc *pState, const char *pszCommand, bool fWaitForAck /*= true*/)
297 int vrc = RTTcpSgWriteL(pState->mhSocket, 2, pszCommand, strlen(pszCommand), "\n", sizeof("\n") - 1);
302 return i_teleporterSrcReadACK(pState, pszCommand);
311 TeleporterState *pState = (TeleporterState *)pvUser;
315 AssertReturn(pState->mfIsSource, VERR_INVALID_HANDLE);
322 int rc = RTTcpSgWriteL(pState->mhSocket, 2, &Hdr, sizeof(Hdr), pvBuf, (size_t)Hdr.cb);
328 pState->moffStream += Hdr.cb;
348 * @param pState The teleporter state data.
350 static int teleporterTcpReadSelect(TeleporterState *pState)
355 rc = RTTcpSelectOne(pState->mhSocket, 1000);
358 pState->mfIOError = true;
362 if (pState->mfStopReading)
377 TeleporterState *pState = (TeleporterState *)pvUser;
378 AssertReturn(!pState->mfIsSource, VERR_INVALID_HANDLE);
387 if (pState->mfEndOfStream)
389 if (pState->mfStopReading)
391 if (pState->mfIOError)
398 if (!pState->mcbReadBlock)
400 rc = teleporterTcpReadSelect(pState);
404 rc = RTTcpRead(pState->mhSocket, &Hdr, sizeof(Hdr), NULL);
407 pState->mfIOError = true;
421 pState->mfEndOfStream = true;
422 pState->mcbReadBlock = 0;
425 pState->mfIOError = true;
430 pState->mcbReadBlock = Hdr.cb;
431 if (pState->mfStopReading)
438 rc = teleporterTcpReadSelect(pState);
441 uint32_t cb = (uint32_t)RT_MIN(pState->mcbReadBlock, cbToRead);
442 rc = RTTcpRead(pState->mhSocket, pvBuf, cb, pcbRead);
445 pState->mfIOError = true;
452 pState->moffStream += cb;
453 pState->mcbReadBlock -= cb;
456 pState->moffStream += cb;
457 pState->mcbReadBlock -= cb;
482 TeleporterState *pState = (TeleporterState *)pvUser;
483 return pState->moffStream;
501 TeleporterState *pState = (TeleporterState *)pvUser;
503 if (pState->mfIsSource)
506 int rc = RTTcpSelectOne(pState->mhSocket, 0);
529 TeleporterState *pState = (TeleporterState *)pvUser;
531 if (pState->mfIsSource)
536 int rc = RTTcpWrite(pState->mhSocket, &EofHdr, sizeof(EofHdr));
545 ASMAtomicWriteBool(&pState->mfStopReading, true);
574 TeleporterState *pState = (TeleporterState *)pvUser;
575 SSMR3Cancel(pState->mpUVM);
576 if (!pState->mfIsSource)
578 TeleporterStateTrg *pStateTrg = (TeleporterStateTrg *)pState;
588 TeleporterState *pState = (TeleporterState *)pvUser;
589 if (pState->mptrProgress)
591 HRESULT hrc = pState->mptrProgress->SetCurrentOperationProgress(uPercent);
596 hrc = pState->mptrProgress->COMGETTER(Canceled)(&fCanceled);
599 SSMR3Cancel(pState->mpUVM);
624 * @param pState The teleporter state.
626 HRESULT Console::i_teleporterSrc(TeleporterStateSrc *pState)
637 HRESULT hrc = pState->mptrProgress->COMGETTER(Canceled)(&fCanceled);
647 int vrc = RTTcpClientConnect(pState->mstrHostname.c_str(), pState->muPort, &pState->mhSocket);
650 pState->muPort, pState->mstrHostname.c_str(), vrc);
651 vrc = RTTcpSetSendCoalescing(pState->mhSocket, false /*fEnable*/);
657 vrc = RTTcpRead(pState->mhSocket, szLine, sizeof(g_szWelcome) - 1, NULL);
664 pState->mstrPassword.append('\n');
665 vrc = RTTcpWrite(pState->mhSocket, pState->mstrPassword.c_str(), pState->mstrPassword.length());
670 hrc = i_teleporterSrcReadACK(pState, "password", tr("Invalid password"));
681 hrc = i_teleporterSrcSubmitCommand(pState, "load");
685 RTSocketRetain(pState->mhSocket);
686 void *pvUser = static_cast<void *>(static_cast<TeleporterState *>(pState));
687 vrc = VMR3Teleport(pState->mpUVM,
688 pState->mcMsMaxDowntime,
691 &pState->mfSuspendedByUs);
692 RTSocketRelease(pState->mhSocket);
696 && RT_SUCCESS(RTTcpSelectOne(pState->mhSocket, 1)))
698 hrc = i_teleporterSrcReadACK(pState, "load-complete");
705 hrc = i_teleporterSrcReadACK(pState, "load-complete");
712 if (!pState->mptrProgress->i_notifyPointOfNoReturn())
714 i_teleporterSrcSubmitCommand(pState, "cancel", false /*fWaitForAck*/);
727 pState->mfUnlockedMedia = true;
729 hrc = i_teleporterSrcSubmitCommand(pState, "lock-media");
737 || pState->menmOldMachineState == MachineState_Paused)
738 hrc = i_teleporterSrcSubmitCommand(pState, "hand-over-paused");
740 hrc = i_teleporterSrcSubmitCommand(pState, "hand-over-resume");
762 TeleporterStateSrc *pState = (TeleporterStateSrc *)pvUser;
768 SafeVMPtr ptrVM(pState->mptrConsole);
772 hrc = pState->mptrConsole->i_teleporterSrc(pState);
775 if (pState->mhSocket != NIL_RTSOCKET)
777 RTTcpClientClose(pState->mhSocket);
778 pState->mhSocket = NIL_RTSOCKET;
784 pState->mptrProgress->i_notifyComplete(hrc);
787 pState->mptrProgress->i_setCancelCallback(NULL, NULL);
793 AutoWriteLock autoLock(pState->mptrConsole COMMA_LOCKVAL_SRC_POS);
794 pState->mptrConsole->mptrCancelableProgress.setNull();
796 VMSTATE const enmVMState = VMR3GetStateU(pState->mpUVM);
797 MachineState_T const enmMachineState = pState->mptrConsole->mMachineState;
812 pState->mptrConsole->mVMIsAlreadyPoweringOff = true; /* (Make sure we stick in the TeleportingPausedVM state.) */
815 hrc = pState->mptrConsole->i_powerDown();
818 pState->mptrConsole->mVMIsAlreadyPoweringOff = false;
820 pState->mptrProgress->i_notifyComplete(hrc);
835 if (pState->mfUnlockedMedia)
838 HRESULT hrc2 = pState->mptrConsole->mControl->LockMedia();
845 hrc2 = pState->mptrConsole->mControl->LockMedia();
850 pState->mfUnlockedMedia = true;
865 Assert(!pState->mfSuspendedByUs);
866 Assert(!pState->mfUnlockedMedia);
867 pState->mptrConsole->i_setMachineState(MachineState_Running);
872 pState->mptrConsole->i_setMachineState(MachineState_Stuck);
877 pState->mptrConsole->i_setMachineState(MachineState_Paused);
887 if (!pState->mfUnlockedMedia)
889 pState->mptrConsole->i_setMachineState(MachineState_Paused);
890 if (pState->mfSuspendedByUs)
893 int rc = VMR3Resume(pState->mpUVM, VMRESUMEREASON_TELEPORT_FAILED);
901 pState->mptrConsole->i_setMachineState(MachineState_Stuck);
912 Assert(pState->mhSocket == NIL_RTSOCKET);
913 delete pState;
979 TeleporterStateSrc *pState = new TeleporterStateSrc(this, mpUVM, ptrProgress, mMachineState);
980 pState->mstrPassword = strPassword;
981 pState->mstrHostname = aHostname;
982 pState->muPort = aTcpport;
983 pState->mcMsMaxDowntime = aMaxDowntime;
985 void *pvUser = static_cast<void *>(static_cast<TeleporterState *>(pState));
988 int vrc = RTThreadCreate(NULL, Console::i_teleporterSrcThreadWrapper, (void *)pState, 0 /*cbStack*/,
1007 delete pState;
1193 * @param pState The teleporter state.
1195 static void teleporterTrgUnlockMedia(TeleporterStateTrg *pState)
1197 if (pState->mfLockedMedia)
1199 pState->mpControl->UnlockMedia();
1200 pState->mfLockedMedia = false;
1205 static int teleporterTcpWriteACK(TeleporterStateTrg *pState, bool fAutomaticUnlock = true)
1207 int rc = RTTcpWrite(pState->mhSocket, "ACK\n", sizeof("ACK\n") - 1);
1212 teleporterTrgUnlockMedia(pState);
1218 static int teleporterTcpWriteNACK(TeleporterStateTrg *pState, int32_t rc2, const char *pszMsgText = NULL)
1224 teleporterTrgUnlockMedia(pState);
1237 int rc = RTTcpWrite(pState->mhSocket, szMsg, cch);
1252 TeleporterStateTrg *pState = (TeleporterStateTrg *)pvUser;
1253 pState->mhSocket = Sock;
1258 int vrc = RTTcpSetSendCoalescing(pState->mhSocket, false /*fEnable*/);
1270 const char *pszPassword = pState->mstrPassword.c_str();
1283 teleporterTcpWriteNACK(pState, VERR_AUTHENTICATION_FAILURE);
1288 vrc = teleporterTcpWriteACK(pState);
1301 hrc = pState->mptrProgress->SetNextOperation(BstrFmt(tr("Teleporting VM from %RTnaddr"), &Addr).raw(), 8);
1306 hrc = pState->mptrProgress->SetNextOperation(Bstr(tr("Teleporting VM")).raw(), 8);
1316 RTTcpServerShutdown(pState->mhServer);
1317 RTTimerLRDestroy(*pState->mphTimerLR);
1318 *pState->mphTimerLR = NIL_RTTIMERLR;
1327 vrc = teleporterTcpReadLine(pState, szCmd, sizeof(szCmd));
1333 vrc = teleporterTcpWriteACK(pState);
1337 int vrc2 = VMR3AtErrorRegister(pState->mpUVM,
1338 Console::i_genericVMSetErrorCallback, &pState->mErrorText); AssertRC(vrc2);
1339 RTSocketRetain(pState->mhSocket); /* For concurrent access by I/O thread and EMT. */
1340 pState->moffStream = 0;
1342 void *pvUser2 = static_cast<void *>(static_cast<TeleporterState *>(pState));
1343 vrc = VMR3LoadFromStream(pState->mpUVM,
1347 RTSocketRelease(pState->mhSocket);
1348 vrc2 = VMR3AtErrorDeregister(pState->mpUVM, Console::i_genericVMSetErrorCallback, &pState->mErrorText);
1354 teleporterTcpWriteNACK(pState, vrc, pState->mErrorText.c_str());
1359 pState->mfStopReading = false;
1361 vrc = teleporterTcpOpRead(pvUser2, pState->moffStream, szCmd, 1, &cbRead);
1365 teleporterTcpWriteNACK(pState, vrc);
1369 vrc = teleporterTcpWriteACK(pState);
1379 hrc = pState->mpControl->LockMedia();
1382 pState->mfLockedMedia = true;
1383 vrc = teleporterTcpWriteACK(pState);
1388 teleporterTcpWriteNACK(pState, vrc);
1405 if ( pState->mptrProgress->i_notifyPointOfNoReturn()
1406 && pState->mfLockedMedia)
1408 vrc = teleporterTcpWriteACK(pState);
1412 vrc = VMR3Resume(pState->mpUVM, VMRESUMEREASON_TELEPORTED);
1414 pState->mptrConsole->i_setMachineState(MachineState_Paused);
1421 vrc = pState->mfLockedMedia ? VERR_WRONG_ORDER : VERR_SSM_CANCELLED;
1422 teleporterTcpWriteNACK(pState, vrc);
1429 teleporterTcpWriteNACK(pState, vrc);
1439 teleporterTrgUnlockMedia(pState);
1441 pState->mRc = vrc;
1442 pState->mhSocket = NIL_RTSOCKET;