ConsoleImplTeleporter.cpp revision f57617b98487e0aa2cac4364b2449974c575b89c
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * VBox Console COM Class implementation, The Teleporter Part.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Copyright (C) 2009 Oracle Corporation
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * available from http://www.virtualbox.org. This file is free software;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * you can redistribute it and/or modify it under the terms of the GNU
92a27575521748a392dcd1b996fce55b87411a00vboxsync * General Public License (GPL) as published by the Free Software
92a27575521748a392dcd1b996fce55b87411a00vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
92a27575521748a392dcd1b996fce55b87411a00vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
92a27575521748a392dcd1b996fce55b87411a00vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
92a27575521748a392dcd1b996fce55b87411a00vboxsync/*******************************************************************************
92a27575521748a392dcd1b996fce55b87411a00vboxsync* Header Files *
92a27575521748a392dcd1b996fce55b87411a00vboxsync*******************************************************************************/
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync/*******************************************************************************
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync* Structures and Typedefs *
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync*******************************************************************************/
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Base class for the teleporter state.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * These classes are used as advanced structs, not as proper classes.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /** @name stream stuff
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync bool volatile mfStopReading;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync bool volatile mfEndOfStream;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync bool volatile mfIOError;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync TeleporterState(Console *pConsole, PVM pVM, Progress *pProgress, bool fIsSource)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Teleporter state used by the source side.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync TeleporterStateSrc(Console *pConsole, PVM pVM, Progress *pProgress, MachineState_T enmOldMachineState)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync : TeleporterState(pConsole, pVM, pProgress, true /*fIsSource*/)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Teleporter state used by the destiation side.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync TeleporterStateTrg(Console *pConsole, PVM pVM, Progress *pProgress,
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync IMachine *pMachine, IInternalMachineControl *pControl,
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync : TeleporterState(pConsole, pVM, pProgress, false /*fIsSource*/)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * TCP stream header.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * This is an extra layer for fixing the problem with figuring out when the SSM
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * stream ends.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /** Magic value. */
28a02a9abdb21adbaaeeae87339534ca0346f97avboxsync /** The size of the data block following this header.
28a02a9abdb21adbaaeeae87339534ca0346f97avboxsync * 0 indicates the end of the stream, while UINT32_MAX indicates
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * cancelation. */
28a02a9abdb21adbaaeeae87339534ca0346f97avboxsync/** Magic value for TELEPORTERTCPHDR::u32Magic. (Egberto Gismonti Amin) */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync/** The max block size. */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync#define TELEPORTERTCPHDR_MAX_SIZE UINT32_C(0x00fffff8)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync/*******************************************************************************
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync* Global Variables *
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync*******************************************************************************/
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncstatic const char g_szWelcome[] = "VirtualBox-Teleporter-1.0\n";
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Reads a string from the socket.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @returns VBox status code.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param pState The teleporter state structure.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param pszBuf The output buffer.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param cchBuf The size of the output buffer.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncstatic int teleporterTcpReadLine(TeleporterState *pState, char *pszBuf, size_t cchBuf)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /* dead simple approach. */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter: RTTcpRead -> %Rrc while reading string ('%s')\n", rc, pszStart));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter: String buffer overflow: '%s'\n", pszStart));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Reads an ACK or NACK.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @returns S_OK on ACK, E_FAIL+setError() on failure or NACK.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param pState The teleporter source state.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param pszWhich Which ACK is this this?
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param pszNAckMsg Optional NACK message.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @remarks the setError laziness forces this to be a Console member.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncConsole::teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich,
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync int vrc = teleporterTcpReadLine(pState, szMsg, sizeof(szMsg));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync return setError(E_FAIL, tr("Failed reading ACK(%s): %Rrc"), pszWhich, vrc);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync vrc = RTStrToInt32Full(&szMsg[sizeof("NACK=") - 1], 10, &vrc2);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Well formed NACK, transform it into an error.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter: %s: NACK=%Rrc (%d)\n", pszWhich, vrc2, vrc2));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter: %s: NACK=%Rrc (%d) - '%s'\n", pszWhich, vrc2, vrc2, pszMsgText));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync return setError(E_FAIL, "NACK(%s) - %Rrc (%d) '%s'", pszWhich, vrc2, vrc2, pszMsgText);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync return setError(E_FAIL, "NACK(%s) - %Rrc (%d)", pszWhich, vrc2, vrc2);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync return setError(E_FAIL, tr("%s: Expected ACK or NACK, got '%s'"), pszWhich, szMsg);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Submitts a command to the destination and waits for the ACK.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @returns S_OK on ACKed command, E_FAIL+setError() on failure.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param pState The teleporter source state.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param pszCommand The command.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param fWaitForAck Whether to wait for the ACK.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @remarks the setError laziness forces this to be a Console member.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncConsole::teleporterSrcSubmitCommand(TeleporterStateSrc *pState, const char *pszCommand, bool fWaitForAck /*= true*/)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync int vrc = RTTcpSgWriteL(pState->mhSocket, 2, pszCommand, strlen(pszCommand), "\n", sizeof("\n") - 1);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync return setError(E_FAIL, tr("Failed writing command '%s': %Rrc"), pszCommand, vrc);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @copydoc SSMSTRMOPS::pfnWrite
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncstatic DECLCALLBACK(int) teleporterTcpOpWrite(void *pvUser, uint64_t offStream, const void *pvBuf, size_t cbToWrite)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync TeleporterState *pState = (TeleporterState *)pvUser;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync AssertReturn(cbToWrite < UINT32_MAX, VERR_OUT_OF_RANGE);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync AssertReturn(pState->mfIsSource, VERR_INVALID_HANDLE);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync Hdr.cb = RT_MIN((uint32_t)cbToWrite, TELEPORTERTCPHDR_MAX_SIZE);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync int rc = RTTcpSgWriteL(pState->mhSocket, 2, &Hdr, sizeof(Hdr), pvBuf, (size_t)Hdr.cb);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter/TCP: Write error: %Rrc (cb=%#x)\n", rc, Hdr.cb));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /* advance */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Selects and poll for close condition.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * We can use a relatively high poll timeout here since it's only used to get
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * us out of error paths. In the normal cause of events, we'll get a
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * end-of-stream header.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @returns VBox status code.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param pState The teleporter state data.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncstatic int teleporterTcpReadSelect(TeleporterState *pState)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter/TCP: Header select error: %Rrc\n", rc));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @copydoc SSMSTRMOPS::pfnRead
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncstatic DECLCALLBACK(int) teleporterTcpOpRead(void *pvUser, uint64_t offStream, void *pvBuf, size_t cbToRead, size_t *pcbRead)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync TeleporterState *pState = (TeleporterState *)pvUser;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync AssertReturn(!pState->mfIsSource, VERR_INVALID_HANDLE);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Check for various conditions and may have been signalled.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * If there is no more data in the current block, read the next
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * block header.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync rc = RTTcpRead(pState->mhSocket, &Hdr, sizeof(Hdr), NULL);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter/TCP: Header read error: %Rrc\n", rc));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync if (RT_UNLIKELY( Hdr.u32Magic != TELEPORTERTCPHDR_MAGIC
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter/TCP: Invalid block: u32Magic=%#x cb=%#x\n", Hdr.u32Magic, Hdr.cb));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Read more data.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync uint32_t cb = (uint32_t)RT_MIN(pState->mcbReadBlock, cbToRead);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync rc = RTTcpRead(pState->mhSocket, pvBuf, cb, pcbRead);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter/TCP: Data read error: %Rrc (cb=%#x)\n", rc, cb));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /* Advance to the next block. */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @copydoc SSMSTRMOPS::pfnSeek
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncstatic DECLCALLBACK(int) teleporterTcpOpSeek(void *pvUser, int64_t offSeek, unsigned uMethod, uint64_t *poffActual)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @copydoc SSMSTRMOPS::pfnTell
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncstatic DECLCALLBACK(uint64_t) teleporterTcpOpTell(void *pvUser)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync TeleporterState *pState = (TeleporterState *)pvUser;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @copydoc SSMSTRMOPS::pfnSize
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncstatic DECLCALLBACK(int) teleporterTcpOpSize(void *pvUser, uint64_t *pcb)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @copydoc SSMSTRMOPS::pfnIsOk
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncstatic DECLCALLBACK(int) teleporterTcpOpIsOk(void *pvUser)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync TeleporterState *pState = (TeleporterState *)pvUser;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /* Poll for incoming NACKs and errors from the other side */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter/TCP: Incoming data detect by IsOk, assuming it is a cancellation NACK.\n"));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter/TCP: RTTcpSelectOne -> %Rrc (IsOk).\n", rc));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @copydoc SSMSTRMOPS::pfnClose
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncstatic DECLCALLBACK(int) teleporterTcpOpClose(void *pvUser, bool fCancelled)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync TeleporterState *pState = (TeleporterState *)pvUser;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync int rc = RTTcpWrite(pState->mhSocket, &EofHdr, sizeof(EofHdr));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter/TCP: EOF Header write error: %Rrc\n", rc));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Method table for a TCP based stream.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Progress cancelation callback.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncstatic void teleporterProgressCancelCallback(void *pvUser)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync TeleporterState *pState = (TeleporterState *)pvUser;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync TeleporterStateTrg *pStateTrg = (TeleporterStateTrg *)pState;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @copydoc PFNVMPROGRESS
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncstatic DECLCALLBACK(int) teleporterProgressCallback(PVM pVM, unsigned uPercent, void *pvUser)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync TeleporterState *pState = (TeleporterState *)pvUser;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync HRESULT hrc = pState->mptrProgress->SetCurrentOperationProgress(uPercent);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /* check if the failure was caused by cancellation. */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = pState->mptrProgress->COMGETTER(Canceled)(&fCancelled);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @copydoc FNRTTIMERLR
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncstatic DECLCALLBACK(void) teleporterDstTimeout(RTTIMERLR hTimerLR, void *pvUser, uint64_t iTick)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /* This is harmless for any open connections. */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Do the teleporter.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @returns VBox status code.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param pState The teleporter state.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Wait for Console::Teleport to change the state.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync { AutoWriteLock autoLock(this COMMA_LOCKVAL_SRC_POS); }
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync HRESULT hrc = pState->mptrProgress->COMGETTER(Canceled)(&fCancelled);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Try connect to the destination machine.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * (Note. The caller cleans up mhSocket, so we can return without worries.)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync int vrc = RTTcpClientConnect(pState->mstrHostname.c_str(), pState->muPort, &pState->mhSocket);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync return setError(E_FAIL, tr("Failed to connect to port %u on '%s': %Rrc"),
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync pState->muPort, pState->mstrHostname.c_str(), vrc);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /* Read and check the welcome message. */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync vrc = RTTcpRead(pState->mhSocket, szLine, sizeof(g_szWelcome) - 1, NULL);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync return setError(E_FAIL, tr("Failed to read welcome message: %Rrc"), vrc);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync return setError(E_FAIL, tr("Unexpected welcome %.*Rhxs"), sizeof(g_szWelcome) - 1, szLine);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /* password */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync vrc = RTTcpWrite(pState->mhSocket, pState->mstrPassword.c_str(), pState->mstrPassword.length());
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync return setError(E_FAIL, tr("Failed to send password: %Rrc"), vrc);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = teleporterSrcReadACK(pState, "password", tr("Invalid password"));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Start loading the state.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Note! The saved state includes vital configuration data which will be
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * verified against the VM config on the other end. This is all done
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * in the first pass, so we should fail pretty promptly on misconfig.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync void *pvUser = static_cast<void *>(static_cast<TeleporterState *>(pState));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync vrc = VMR3Teleport(pState->mpVM, pState->mcMsMaxDowntime,
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync && RT_SUCCESS(RTTcpSelectOne(pState->mhSocket, 1)))
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = teleporterSrcReadACK(pState, "load-complete");
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync return setError(E_FAIL, tr("VMR3Teleport -> %Rrc"), vrc);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = teleporterSrcReadACK(pState, "load-complete");
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * We're at the point of no return.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync if (!pState->mptrProgress->notifyPointOfNoReturn())
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync teleporterSrcSubmitCommand(pState, "cancel", false /*fWaitForAck*/);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Hand over any media which we might be sharing.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Note! This is only important on localhost teleportations.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /** @todo Maybe we should only do this if it's a local teleportation... */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = teleporterSrcSubmitCommand(pState, "lock-media");
28a02a9abdb21adbaaeeae87339534ca0346f97avboxsync * The FINAL step is giving the target instructions how to proceed with the VM.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync || pState->menmOldMachineState == MachineState_Paused)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = teleporterSrcSubmitCommand(pState, "hand-over-paused");
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = teleporterSrcSubmitCommand(pState, "hand-over-resume");
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * teleporterSrcThreadWrapper will do the automatic power off because it
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * has to release the AutoVMCaller.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Static thread method wrapper.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @returns VINF_SUCCESS (ignored).
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param hThread The thread.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param pvUser Pointer to a TeleporterStateSrc instance.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncConsole::teleporterSrcThreadWrapper(RTTHREAD hThread, void *pvUser)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync TeleporterStateSrc *pState = (TeleporterStateSrc *)pvUser;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Console::teleporterSrc does the work, we just grab onto the VM handle
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * and do the cleanups afterwards.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /* Close the connection ASAP on so that the other side can complete. */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /* Aaarg! setMachineState trashes error info on Windows, so we have to
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync complete things here on failure instead of right before cleanup. */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /* We can no longer be cancelled (success), or it doesn't matter any longer (failure). */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync pState->mptrProgress->setCancelCallback(NULL, NULL);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Write lock the console before resetting mptrCancelableProgress and
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * fixing the state.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync AutoWriteLock autoLock(pState->mptrConsole COMMA_LOCKVAL_SRC_POS);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync pState->mptrConsole->mptrCancelableProgress.setNull();
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync VMSTATE const enmVMState = VMR3GetState(pState->mpVM);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync MachineState_T const enmMachineState = pState->mptrConsole->mMachineState;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Automatically shut down the VM on success.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Note! We have to release the VM caller object or we'll deadlock in
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * powerDown.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync AssertLogRelMsg(enmVMState == VMSTATE_SUSPENDED, ("%s\n", VMR3GetStateName(enmVMState)));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync AssertLogRelMsg(enmMachineState == MachineState_TeleportingPausedVM, ("%s\n", Global::stringifyMachineState(enmMachineState)));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync pState->mptrConsole->mVMIsAlreadyPoweringOff = true; /* (Make sure we stick in the TeleportingPausedVM state.) */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync pState->mptrConsole->mVMIsAlreadyPoweringOff = false;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Work the state machinery on failure.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * If the state is no longer 'Teleporting*', some other operation has
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * canceled us and there is nothing we need to do here. In all other
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * cases, we've failed one way or another.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync || enmMachineState == MachineState_TeleportingPausedVM
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync HRESULT hrc2 = pState->mptrConsole->mControl->LockMedia();
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("FATAL ERROR: Failed to re-take the media locks. hrc2=%Rhrc\n", hrc2));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync pState->mptrConsole->setMachineState(MachineState_Running);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync pState->mptrConsole->setMachineState(MachineState_Stuck);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync pState->mptrConsole->setMachineState(MachineState_Paused);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync AssertMsgFailed(("%s\n", VMR3GetStateName(enmVMState)));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync pState->mptrConsole->setMachineState(MachineState_Paused);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync AssertLogRelMsgRC(rc, ("VMR3Resume -> %Rrc\n", rc));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /* Faking a guru meditation is the best I can think of doing here... */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync pState->mptrConsole->setMachineState(MachineState_Stuck);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Start teleporter to the specified target.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @returns COM status code.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param aHostname The name of the target host.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param aPort The TCP port number.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param aPassword The password.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param aMaxDowntime Max allowed "downtime" in milliseconds.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param aProgress Where to return the progress object.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncConsole::Teleport(IN_BSTR aHostname, ULONG aPort, IN_BSTR aPassword, ULONG aMaxDowntime, IProgress **aProgress)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Validate parameters, check+hold object status, write lock the object
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * and validate the state.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync CheckComArgExprMsg(aPort, aPort > 0 && aPort <= 65535, ("is %u", aPort));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync CheckComArgExprMsg(aMaxDowntime, aMaxDowntime > 0, ("is %u", aMaxDowntime));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync AutoWriteLock autoLock(this COMMA_LOCKVAL_SRC_POS);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogFlowThisFunc(("mMachineState=%d\n", mMachineState));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync tr("Invalid machine state: %s (must be Running or Paused)"),
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Create a progress object, spawn a worker thread and change the state.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Note! The thread won't start working until we release the lock.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogFlowThisFunc(("Initiating TELEPORT request...\n"));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = ptrProgress->init(static_cast<IConsole *>(this), Bstr(tr("Teleporter")), TRUE /*aCancelable*/);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync TeleporterStateSrc *pState = new TeleporterStateSrc(this, mpVM, ptrProgress, mMachineState);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync void *pvUser = static_cast<void *>(static_cast<TeleporterState *>(pState));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync ptrProgress->setCancelCallback(teleporterProgressCancelCallback, pvUser);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync int vrc = RTThreadCreate(NULL, Console::teleporterSrcThreadWrapper, (void *)pState, 0 /*cbStack*/,
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = setMachineState(MachineState_TeleportingPausedVM);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = setError(E_FAIL, tr("RTThreadCreate -> %Rrc"), vrc);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Creates a TCP server that listens for the source machine and passes control
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * over to Console::teleporterTrgServeConnection().
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @returns VBox status code.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param pVM The VM handle
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param pMachine The IMachine for the virtual machine.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param pErrorMsg Pointer to the error string for VMSetError.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param fStartPaused Whether to start it in the Paused (true) or
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Running (false) state,
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param pProgress Pointer to the progress object.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param pfPowerOffOnFailure Whether the caller should power off
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * the VM on failure.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @remarks The caller expects error information to be set on failure.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @todo Check that all the possible failure paths sets error info...
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncConsole::teleporterTrg(PVM pVM, IMachine *pMachine, Utf8Str *pErrorMsg, bool fStartPaused,
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogThisFunc(("pVM=%p pMachine=%p fStartPaused=%RTbool pProgress=%p\n", pVM, pMachine, fStartPaused, pProgress));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Get the config.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync HRESULT hrc = pMachine->COMGETTER(TeleporterPort)(&uPort);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = pMachine->COMGETTER(TeleporterAddress)(bstrAddress.asOutParam());
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync const char *pszAddress = strAddress.isEmpty() ? NULL : strAddress.c_str();
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = pMachine->COMGETTER(TeleporterPassword)(bstrPassword.asOutParam());
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync strPassword.append('\n'); /* To simplify password checking. */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Create the TCP server.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync vrc = RTTcpServerCreateEx(pszAddress, uPort, &hServer);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync uPort = RTRandU32Ex(cTries >= 8192 ? 49152 : 1024, 65534);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync vrc = RTTcpServerCreateEx(pszAddress, uPort, &hServer);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync return setError(E_FAIL, tr("RTTcpServerCreateEx failed with status %Rrc"), vrc);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Create a one-shot timer for timing out after 5 mins.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync vrc = RTTimerLRCreateEx(&hTimerLR, 0 /*ns*/, RTTIMER_FLAGS_CPU_ANY, teleporterDstTimeout, hServer);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync vrc = RTTimerLRStart(hTimerLR, 5*60*UINT64_C(1000000000) /*ns*/);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Do the job, when it returns we're done.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync TeleporterStateTrg theState(this, pVM, pProgress, pMachine, mControl, &hTimerLR, fStartPaused);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync void *pvUser = static_cast<void *>(static_cast<TeleporterState *>(&theState));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync if (pProgress->setCancelCallback(teleporterProgressCancelCallback, pvUser))
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter: Waiting for incoming VM...\n"));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = pProgress->SetNextOperation(Bstr(tr("Waiting for incoming VM")), 1);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync vrc = RTTcpServerListen(hServer, Console::teleporterTrgServeConnection, &theState);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /* Power off the VM on failure unless the state callback
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync already did that. */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync /* Set error. */
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = setError(E_FAIL, tr("Teleporation failed (%Rrc)"), vrc);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = setError(E_FAIL, tr("Teleporting canceled"));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = setError(E_FAIL, tr("Teleporter timed out waiting for incoming connection"));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter: RTTcpServerListen aborted - %Rrc\n", vrc));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = setError(E_FAIL, tr("Unexpected RTTcpServerListen status code %Rrc"), vrc);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter: Unexpected RTTcpServerListen rc: %Rrc\n", vrc));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogThisFunc(("SetNextOperation failed, %Rhrc\n", hrc));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = setError(E_FAIL, tr("Teleporting canceled"));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = setError(E_FAIL, "RTTimerLRStart -> %Rrc", vrc);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = setError(E_FAIL, "RTTimerLRCreate -> %Rrc", vrc);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * If we change TeleporterPort above, set it back to it's original
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * value before returning.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Unlock the media.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * This is used in error paths.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @param pState The teleporter state.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncstatic void teleporterTrgUnlockMedia(TeleporterStateTrg *pState)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncstatic int teleporterTcpWriteACK(TeleporterStateTrg *pState, bool fAutomaticUnlock = true)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync int rc = RTTcpWrite(pState->mhSocket, "ACK\n", sizeof("ACK\n") - 1);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter: RTTcpWrite(,ACK,) -> %Rrc\n", rc));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncstatic int teleporterTcpWriteNACK(TeleporterStateTrg *pState, int32_t rc2, const char *pszMsgText = NULL)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Unlock media sending the NACK. That way the other doesn't have to spin
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * waiting to regain the locks.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync cch = RTStrPrintf(szMsg, sizeof(szMsg), "NACK=%d;%s\n", rc2, pszMsgText);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync cch = RTStrPrintf(szMsg, sizeof(szMsg), "NACK=%d\n", rc2);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter: RTTcpWrite(,%s,%zu) -> %Rrc\n", szMsg, cch, rc));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @copydoc FNRTTCPSERVE
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * @returns VINF_SUCCESS or VERR_TCP_SERVER_STOP.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsyncConsole::teleporterTrgServeConnection(RTSOCKET Sock, void *pvUser)
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync TeleporterStateTrg *pState = (TeleporterStateTrg *)pvUser;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Say hello.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync int vrc = RTTcpWrite(Sock, g_szWelcome, sizeof(g_szWelcome) - 1);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter: Failed to write welcome message: %Rrc\n", vrc));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Password (includes '\n', see teleporterTrg).
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync const char *pszPassword = pState->mstrPassword.c_str();
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync unsigned off = 0;
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter: Password read failure (off=%u): %Rrc\n", off, vrc));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter: Invalid password (off=%u)\n", off));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync teleporterTcpWriteNACK(pState, VERR_AUTHENTICATION_FAILURE);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Update the progress bar, with peer name if available.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync LogRel(("Teleporter: Incoming VM from %RTnaddr!\n", &Addr));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = pState->mptrProgress->SetNextOperation(BstrFmt(tr("Teleporting VM from %RTnaddr"), &Addr), 8);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync hrc = pState->mptrProgress->SetNextOperation(Bstr(tr("Teleporting VM")), 8);
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync AssertMsg(SUCCEEDED(hrc) || hrc == E_FAIL, ("%Rhrc\n", hrc));
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Stop the server and cancel the timeout timer.
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * Note! After this point we must return VERR_TCP_SERVER_STOP, while prior
db3dbd0ed7eb69f804a8921fa23a1267ea01f46evboxsync * to it we must not return that value!
bool fDone = false;
int vrc2 = VMR3AtErrorRegister(pState->mpVM, Console::genericVMSetErrorCallback, &pState->mErrorText); AssertRC(vrc2);
vrc2 = VMR3AtErrorDeregister(pState->mpVM, Console::genericVMSetErrorCallback, &pState->mErrorText); AssertRC(vrc2);
fDone = true;
return VERR_TCP_SERVER_STOP;