VirtualBox

Ignore:
Timestamp:
Oct 15, 2009 3:00:47 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53543
Message:

Main,VMM,Frontends,++: Teminology. Added a bind address for the (target) teleporter.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleImplTeleporter.cpp

    r23793 r23801  
    11/* $Id$ */
    22/** @file
    3  * VBox Console COM Class implementation, The Live Migration Part.
     3 * VBox Console COM Class implementation, The Teleporter Part.
    44 */
    55
     
    4545*******************************************************************************/
    4646/**
    47  * Base class for the migration state.
     47 * Base class for the teleporter state.
    4848 *
    4949 * These classes are used as advanced structs, not as proper classes.
    5050 */
    51 class MigrationState
     51class TeleporterState
    5252{
    5353public:
     
    6767    /** @} */
    6868
    69     MigrationState(Console *pConsole, PVM pVM, bool fIsSource)
     69    TeleporterState(Console *pConsole, PVM pVM, bool fIsSource)
    7070        : mptrConsole(pConsole)
    7171        , mpVM(pVM)
     
    8383
    8484/**
    85  * Migration state used by the source side.
    86  */
    87 class MigrationStateSrc : public MigrationState
     85 * Teleporter state used by the source side.
     86 */
     87class TeleporterStateSrc : public TeleporterState
    8888{
    8989public:
     
    9292    uint32_t            muPort;
    9393
    94     MigrationStateSrc(Console *pConsole, PVM pVM)
    95         : MigrationState(pConsole, pVM, true /*fIsSource*/)
     94    TeleporterStateSrc(Console *pConsole, PVM pVM)
     95        : TeleporterState(pConsole, pVM, true /*fIsSource*/)
    9696        , muPort(UINT32_MAX)
    9797    {
     
    101101
    102102/**
    103  * Migration state used by the destiation side.
    104  */
    105 class MigrationStateDst : public MigrationState
     103 * Teleporter state used by the destiation side.
     104 */
     105class TeleporterStateTrg : public TeleporterState
    106106{
    107107public:
     
    112112    int                 mRc;
    113113
    114     MigrationStateDst(Console *pConsole, PVM pVM, IMachine *pMachine, PRTTIMERLR phTimerLR)
    115         : MigrationState(pConsole, pVM, false /*fIsSource*/)
     114    TeleporterStateTrg(Console *pConsole, PVM pVM, IMachine *pMachine, PRTTIMERLR phTimerLR)
     115        : TeleporterState(pConsole, pVM, false /*fIsSource*/)
    116116        , mpMachine(pMachine)
    117117        , mpvVMCallbackTask(NULL)
     
    130130 * stream ends.
    131131 */
    132 typedef struct MIGRATIONTCPHDR
     132typedef struct TELEPORTERTCPHDR
    133133{
    134134    /** Magic value. */
     
    137137     * 0 indicates the end of the stream. */
    138138    uint32_t    cb;
    139 } MIGRATIONTCPHDR;
    140 /** Magic value for MIGRATIONTCPHDR::u32Magic. (Egberto Gismonti Amin) */
    141 #define MIGRATIONTCPHDR_MAGIC       UINT32_C(0x19471205)
     139} TELEPORTERTCPHDR;
     140/** Magic value for TELEPORTERTCPHDR::u32Magic. (Egberto Gismonti Amin) */
     141#define TELEPORTERTCPHDR_MAGIC       UINT32_C(0x19471205)
    142142/** The max block size. */
    143 #define MIGRATIONTCPHDR_MAX_SIZE    UINT32_C(0x00fffff8)
     143#define TELEPORTERTCPHDR_MAX_SIZE    UINT32_C(0x00fffff8)
    144144
    145145
     
    147147*   Global Variables                                                           *
    148148*******************************************************************************/
    149 static const char g_szWelcome[] = "VirtualBox-LiveMigration-1.0\n";
     149static const char g_szWelcome[] = "VirtualBox-Teleporter-1.0\n";
    150150
    151151
     
    155155 * @returns VBox status code.
    156156 *
    157  * @param   pState      The live migration state structure.
     157 * @param   pState      The teleporter state structure.
    158158 * @param   pszBuf      The output buffer.
    159159 * @param   cchBuf      The size of the output buffer.
    160160 *
    161161 */
    162 static int migrationTcpReadLine(MigrationState *pState, char *pszBuf, size_t cchBuf)
     162static int teleporterTcpReadLine(TeleporterState *pState, char *pszBuf, size_t cchBuf)
    163163{
    164164    char       *pszStart = pszBuf;
     
    175175        if (RT_FAILURE(rc))
    176176        {
    177             LogRel(("Migration: RTTcpRead -> %Rrc while reading string ('%s')\n", rc, pszStart));
     177            LogRel(("Teleporter: RTTcpRead -> %Rrc while reading string ('%s')\n", rc, pszStart));
    178178            return rc;
    179179        }
     
    183183        if (cchBuf <= 1)
    184184        {
    185             LogRel(("Migration: String buffer overflow: '%s'\n", pszStart));
     185            LogRel(("Teleporter: String buffer overflow: '%s'\n", pszStart));
    186186            return VERR_BUFFER_OVERFLOW;
    187187        }
     
    197197 *
    198198 * @returns S_OK on ACK, E_FAIL+setError() on failure or NACK.
    199  * @param   pState              The live migration source state.
     199 * @param   pState              The teleporter source state.
    200200 * @param   pszWhich            Which ACK is this this?
    201201 * @param   pszNAckMsg          Optional NACK message.
     
    204204 */
    205205HRESULT
    206 Console::migrationSrcReadACK(MigrationStateSrc *pState, const char *pszWhich,
     206Console::teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich,
    207207                             const char *pszNAckMsg /*= NULL*/)
    208208{
    209209    char szMsg[128];
    210     int vrc = migrationTcpReadLine(pState, szMsg, sizeof(szMsg));
     210    int vrc = teleporterTcpReadLine(pState, szMsg, sizeof(szMsg));
    211211    if (RT_FAILURE(vrc))
    212212        return setError(E_FAIL, tr("Failed reading ACK(%s): %Rrc"), pszWhich, vrc);
     
    221221                if (pszNAckMsg)
    222222                {
    223                     LogRel(("Migration: %s: NACK=%Rrc (%d)\n", pszWhich, vrc2, vrc2));
     223                    LogRel(("Teleporter: %s: NACK=%Rrc (%d)\n", pszWhich, vrc2, vrc2));
    224224                    return setError(E_FAIL, pszNAckMsg);
    225225                }
     
    238238 * @returns S_OK on ACKed command, E_FAIL+setError() on failure.
    239239 *
    240  * @param   pState              The live migration source state.
     240 * @param   pState              The teleporter source state.
    241241 * @param   pszCommand          The command.
    242242 *
     
    244244 */
    245245HRESULT
    246 Console::migrationSrcSubmitCommand(MigrationStateSrc *pState, const char *pszCommand)
     246Console::teleporterSrcSubmitCommand(TeleporterStateSrc *pState, const char *pszCommand)
    247247{
    248248    size_t cchCommand = strlen(pszCommand);
     
    254254    if (RT_FAILURE(vrc))
    255255        return setError(E_FAIL, tr("Failed writing command '%s': %Rrc"), pszCommand, vrc);
    256     return migrationSrcReadACK(pState, pszCommand);
     256    return teleporterSrcReadACK(pState, pszCommand);
    257257}
    258258
     
    261261 * @copydoc SSMSTRMOPS::pfnWrite
    262262 */
    263 static DECLCALLBACK(int) migrationTcpOpWrite(void *pvUser, uint64_t offStream, const void *pvBuf, size_t cbToWrite)
    264 {
    265     MigrationState *pState = (MigrationState *)pvUser;
     263static DECLCALLBACK(int) teleporterTcpOpWrite(void *pvUser, uint64_t offStream, const void *pvBuf, size_t cbToWrite)
     264{
     265    TeleporterState *pState = (TeleporterState *)pvUser;
    266266
    267267    AssertReturn(cbToWrite > 0, VINF_SUCCESS);
     
    271271    {
    272272        /* Write block header. */
    273         MIGRATIONTCPHDR Hdr;
    274         Hdr.u32Magic = MIGRATIONTCPHDR_MAGIC;
    275         Hdr.cb       = RT_MIN(cbToWrite, MIGRATIONTCPHDR_MAX_SIZE);
     273        TELEPORTERTCPHDR Hdr;
     274        Hdr.u32Magic = TELEPORTERTCPHDR_MAGIC;
     275        Hdr.cb       = RT_MIN(cbToWrite, TELEPORTERTCPHDR_MAX_SIZE);
    276276        int rc = RTTcpWrite(pState->mhSocket, &Hdr, sizeof(Hdr));
    277277        if (RT_FAILURE(rc))
    278278        {
    279             LogRel(("Migration/TCP: Header write error: %Rrc\n", rc));
     279            LogRel(("Teleporter/TCP: Header write error: %Rrc\n", rc));
    280280            return rc;
    281281        }
     
    285285        if (RT_FAILURE(rc))
    286286        {
    287             LogRel(("Migration/TCP: Data write error: %Rrc (cb=%#x)\n", rc, Hdr.cb));
     287            LogRel(("Teleporter/TCP: Data write error: %Rrc (cb=%#x)\n", rc, Hdr.cb));
    288288            return rc;
    289289        }
     
    308308 * @returns VBox status code.
    309309 *
    310  * @param   pState          The migration state data.
    311  */
    312 static int migrationTcpReadSelect(MigrationState *pState)
     310 * @param   pState          The teleporter state data.
     311 */
     312static int teleporterTcpReadSelect(TeleporterState *pState)
    313313{
    314314    int rc;
     
    319319        {
    320320            pState->mfIOError = true;
    321             LogRel(("Migration/TCP: Header select error: %Rrc\n", rc));
     321            LogRel(("Teleporter/TCP: Header select error: %Rrc\n", rc));
    322322            break;
    323323        }
     
    335335 * @copydoc SSMSTRMOPS::pfnRead
    336336 */
    337 static DECLCALLBACK(int) migrationTcpOpRead(void *pvUser, uint64_t offStream, void *pvBuf, size_t cbToRead, size_t *pcbRead)
    338 {
    339     MigrationState *pState = (MigrationState *)pvUser;
     337static DECLCALLBACK(int) teleporterTcpOpRead(void *pvUser, uint64_t offStream, void *pvBuf, size_t cbToRead, size_t *pcbRead)
     338{
     339    TeleporterState *pState = (TeleporterState *)pvUser;
    340340    AssertReturn(!pState->mfIsSource, VERR_INVALID_HANDLE);
    341341
     
    360360        if (!pState->mcbReadBlock)
    361361        {
    362             rc = migrationTcpReadSelect(pState);
     362            rc = teleporterTcpReadSelect(pState);
    363363            if (RT_FAILURE(rc))
    364364                return rc;
    365             MIGRATIONTCPHDR Hdr;
     365            TELEPORTERTCPHDR Hdr;
    366366            rc = RTTcpRead(pState->mhSocket, &Hdr, sizeof(Hdr), NULL);
    367367            if (RT_FAILURE(rc))
    368368            {
    369369                pState->mfIOError = true;
    370                 LogRel(("Migration/TCP: Header read error: %Rrc\n", rc));
     370                LogRel(("Teleporter/TCP: Header read error: %Rrc\n", rc));
    371371                return rc;
    372372            }
    373             if (   Hdr.u32Magic != MIGRATIONTCPHDR_MAGIC
    374                 || Hdr.cb > MIGRATIONTCPHDR_MAX_SIZE)
     373            if (   Hdr.u32Magic != TELEPORTERTCPHDR_MAGIC
     374                || Hdr.cb > TELEPORTERTCPHDR_MAX_SIZE)
    375375            {
    376376                pState->mfIOError = true;
    377                 LogRel(("Migration/TCP: Invalid block: u32Magic=%#x cb=%#x\n", Hdr.u32Magic, Hdr.cb));
     377                LogRel(("Teleporter/TCP: Invalid block: u32Magic=%#x cb=%#x\n", Hdr.u32Magic, Hdr.cb));
    378378                return VERR_IO_GEN_FAILURE;
    379379            }
     
    393393         * Read more data.
    394394         */
    395         rc = migrationTcpReadSelect(pState);
     395        rc = teleporterTcpReadSelect(pState);
    396396        if (RT_FAILURE(rc))
    397397            return rc;
     
    401401        {
    402402            pState->mfIOError = true;
    403             LogRel(("Migration/TCP: Data read error: %Rrc (cb=%#x)\n", rc, cb));
     403            LogRel(("Teleporter/TCP: Data read error: %Rrc (cb=%#x)\n", rc, cb));
    404404            return rc;
    405405        }
     
    425425 * @copydoc SSMSTRMOPS::pfnSeek
    426426 */
    427 static DECLCALLBACK(int) migrationTcpOpSeek(void *pvUser, int64_t offSeek, unsigned uMethod, uint64_t *poffActual)
     427static DECLCALLBACK(int) teleporterTcpOpSeek(void *pvUser, int64_t offSeek, unsigned uMethod, uint64_t *poffActual)
    428428{
    429429    return VERR_NOT_SUPPORTED;
     
    434434 * @copydoc SSMSTRMOPS::pfnTell
    435435 */
    436 static DECLCALLBACK(uint64_t) migrationTcpOpTell(void *pvUser)
    437 {
    438     MigrationState *pState = (MigrationState *)pvUser;
     436static DECLCALLBACK(uint64_t) teleporterTcpOpTell(void *pvUser)
     437{
     438    TeleporterState *pState = (TeleporterState *)pvUser;
    439439    return pState->moffStream;
    440440}
     
    444444 * @copydoc SSMSTRMOPS::pfnSize
    445445 */
    446 static DECLCALLBACK(int) migrationTcpOpSize(void *pvUser, uint64_t *pcb)
     446static DECLCALLBACK(int) teleporterTcpOpSize(void *pvUser, uint64_t *pcb)
    447447{
    448448    return VERR_NOT_SUPPORTED;
     
    453453 * @copydoc SSMSTRMOPS::pfnClose
    454454 */
    455 static DECLCALLBACK(int) migrationTcpOpClose(void *pvUser)
    456 {
    457     MigrationState *pState = (MigrationState *)pvUser;
     455static DECLCALLBACK(int) teleporterTcpOpClose(void *pvUser)
     456{
     457    TeleporterState *pState = (TeleporterState *)pvUser;
    458458
    459459    if (pState->mfIsSource)
    460460    {
    461         MIGRATIONTCPHDR EofHdr = { MIGRATIONTCPHDR_MAGIC, 0 };
     461        TELEPORTERTCPHDR EofHdr = { TELEPORTERTCPHDR_MAGIC, 0 };
    462462        int rc = RTTcpWrite(pState->mhSocket, &EofHdr, sizeof(EofHdr));
    463463        if (RT_SUCCESS(rc))
     
    465465        if (RT_FAILURE(rc))
    466466        {
    467             LogRel(("Migration/TCP: EOF Header write error: %Rrc\n", rc));
     467            LogRel(("Teleporter/TCP: EOF Header write error: %Rrc\n", rc));
    468468            return rc;
    469469        }
     
    482482 * Method table for a TCP based stream.
    483483 */
    484 static SSMSTRMOPS const g_migrationTcpOps =
     484static SSMSTRMOPS const g_teleporterTcpOps =
    485485{
    486486    SSMSTRMOPS_VERSION,
    487     migrationTcpOpWrite,
    488     migrationTcpOpRead,
    489     migrationTcpOpSeek,
    490     migrationTcpOpTell,
    491     migrationTcpOpSize,
    492     migrationTcpOpClose,
     487    teleporterTcpOpWrite,
     488    teleporterTcpOpRead,
     489    teleporterTcpOpSeek,
     490    teleporterTcpOpTell,
     491    teleporterTcpOpSize,
     492    teleporterTcpOpClose,
    493493    SSMSTRMOPS_VERSION
    494494};
     
    498498 * @copydoc FNRTTIMERLR
    499499 */
    500 static DECLCALLBACK(void) migrationTimeout(RTTIMERLR hTimerLR, void *pvUser, uint64_t iTick)
     500static DECLCALLBACK(void) teleporterTimeout(RTTIMERLR hTimerLR, void *pvUser, uint64_t iTick)
    501501{
    502502    /* This is harmless for any open connections. */
     
    506506
    507507/**
    508  * Do the live migration.
     508 * Do the teleporter.
    509509 *
    510510 * @returns VBox status code.
    511  * @param   pState              The migration state.
     511 * @param   pState              The teleporter state.
    512512 */
    513513HRESULT
    514 Console::migrationSrc(MigrationStateSrc *pState)
     514Console::teleporterSrc(TeleporterStateSrc *pState)
    515515{
    516516    AutoCaller autoCaller(this);
     
    518518
    519519    /*
    520      * Wait for Console::Migrate to change the state.
     520     * Wait for Console::Teleport to change the state.
    521521     */
    522522    { AutoWriteLock autoLock(); }
     
    554554
    555555    /* ACK */
    556     hrc = migrationSrcReadACK(pState, "password", tr("Invalid password"));
     556    hrc = teleporterSrcReadACK(pState, "password", tr("Invalid password"));
    557557    if (FAILED(hrc))
    558558        return hrc;
     
    566566     * Start loading the state.
    567567     */
    568     hrc = migrationSrcSubmitCommand(pState, "load");
     568    hrc = teleporterSrcSubmitCommand(pState, "load");
    569569    if (FAILED(hrc))
    570570        return hrc;
    571571
    572     void *pvUser = static_cast<void *>(static_cast<MigrationState *>(pState));
    573     vrc = VMR3Migrate(pState->mpVM, &g_migrationTcpOps, pvUser, NULL/** @todo progress*/, pvUser);
     572    void *pvUser = static_cast<void *>(static_cast<TeleporterState *>(pState));
     573    vrc = VMR3Teleport(pState->mpVM, &g_teleporterTcpOps, pvUser, NULL/** @todo progress*/, pvUser);
    574574    if (vrc)
    575         return setError(E_FAIL, tr("VMR3Migrate -> %Rrc"), vrc);
    576 
    577     hrc = migrationSrcReadACK(pState, "load-complete");
     575        return setError(E_FAIL, tr("VMR3Teleport -> %Rrc"), vrc);
     576
     577    hrc = teleporterSrcReadACK(pState, "load-complete");
    578578    if (FAILED(hrc))
    579579        return hrc;
     
    582582     * State fun? Automatic power off?
    583583     */
    584     hrc = migrationSrcSubmitCommand(pState, "done");
     584    hrc = teleporterSrcSubmitCommand(pState, "done");
    585585    if (FAILED(hrc))
    586586        return hrc;
     
    595595 * @returns VINF_SUCCESS (ignored).
    596596 * @param   hThread             The thread.
    597  * @param   pvUser              Pointer to a MigrationStateSrc instance.
     597 * @param   pvUser              Pointer to a TeleporterStateSrc instance.
    598598 */
    599599/*static*/ DECLCALLBACK(int)
    600 Console::migrationSrcThreadWrapper(RTTHREAD hThread, void *pvUser)
    601 {
    602     MigrationStateSrc *pState = (MigrationStateSrc *)pvUser;
     600Console::teleporterSrcThreadWrapper(RTTHREAD hThread, void *pvUser)
     601{
     602    TeleporterStateSrc *pState = (TeleporterStateSrc *)pvUser;
    603603
    604604    AutoVMCaller autoVMCaller(pState->mptrConsole);
     
    606606
    607607    if (SUCCEEDED(hrc))
    608         hrc = pState->mptrConsole->migrationSrc(pState);
     608        hrc = pState->mptrConsole->teleporterSrc(pState);
    609609
    610610    pState->mptrProgress->notifyComplete(hrc);
     
    665665
    666666/**
    667  * Start live migration to the specified target.
     667 * Start teleporter to the specified target.
    668668 *
    669669 * @returns COM status code.
     
    675675 */
    676676STDMETHODIMP
    677 Console::Migrate(IN_BSTR aHostname, ULONG aPort, IN_BSTR aPassword, IProgress **aProgress)
     677Console::Teleport(IN_BSTR aHostname, ULONG aPort, IN_BSTR aPassword, IProgress **aProgress)
    678678{
    679679    /*
     
    709709     * Note! The thread won't start working until we release the lock.
    710710     */
    711     LogFlowThisFunc(("Initiating LIVE MIGRATION request...\n"));
    712 
    713     ComObjPtr<Progress> ptrMigrateProgress;
    714     HRESULT hrc = ptrMigrateProgress.createObject();
     711    LogFlowThisFunc(("Initiating TELEPORTER request...\n"));
     712
     713    ComObjPtr<Progress> ptrTelportationProgress;
     714    HRESULT hrc = ptrTelportationProgress.createObject();
    715715    CheckComRCReturnRC(hrc);
    716     hrc = ptrMigrateProgress->init(static_cast<IConsole *>(this),
    717                                    Bstr(tr("Live Migration")),
    718                                    TRUE /*aCancelable*/);
     716    hrc = ptrTelportationProgress->init(static_cast<IConsole *>(this),
     717                                        Bstr(tr("Teleporter")),
     718                                        TRUE /*aCancelable*/);
    719719    CheckComRCReturnRC(hrc);
    720720
    721     MigrationStateSrc *pState = new MigrationStateSrc(this, mpVM);
     721    TeleporterStateSrc *pState = new TeleporterStateSrc(this, mpVM);
    722722    pState->mstrPassword = aPassword;
    723723    pState->mstrHostname = aHostname;
    724724    pState->muPort       = aPort;
    725     pState->mptrProgress = ptrMigrateProgress;
    726 
    727     int vrc = RTThreadCreate(NULL, Console::migrationSrcThreadWrapper, (void *)pState, 0 /*cbStack*/,
    728                              RTTHREADTYPE_EMULATION, 0 /*fFlags*/, "Migrate");
     725    pState->mptrProgress = ptrTelportationProgress;
     726
     727    int vrc = RTThreadCreate(NULL, Console::teleporterSrcThreadWrapper, (void *)pState, 0 /*cbStack*/,
     728                             RTTHREADTYPE_EMULATION, 0 /*fFlags*/, "Teleport");
    729729    if (RT_SUCCESS(vrc))
    730730    {
    731731        hrc = setMachineState(MachineState_Saving);
    732732        if (SUCCEEDED(hrc))
    733             ptrMigrateProgress.queryInterfaceTo(aProgress);
     733            ptrTelportationProgress.queryInterfaceTo(aProgress);
    734734        else
    735             ptrMigrateProgress->Cancel();
     735            ptrTelportationProgress->Cancel();
    736736    }
    737737    else
     
    747747/**
    748748 * Creates a TCP server that listens for the source machine and passes control
    749  * over to Console::migrationDstServeConnection().
     749 * over to Console::teleporterTrgServeConnection().
    750750 *
    751751 * @returns VBox status code.
     
    758758 */
    759759int
    760 Console::migrationDst(PVM pVM, IMachine *pMachine, bool fStartPaused, void *pvVMCallbackTask)
     760Console::teleporterTrg(PVM pVM, IMachine *pMachine, bool fStartPaused, void *pvVMCallbackTask)
    761761{
    762762    /*
     
    764764     */
    765765    ULONG uPort;
    766     HRESULT hrc = pMachine->COMGETTER(LiveMigrationPort)(&uPort);
     766    HRESULT hrc = pMachine->COMGETTER(TeleporterPort)(&uPort);
    767767    if (FAILED(hrc))
    768768        return VERR_GENERAL_FAILURE;
    769769
     770    Bstr bstrAddress;
     771    hrc = pMachine->COMGETTER(TeleporterAddress)(bstrAddress.asOutParam());
     772    if (FAILED(hrc))
     773        return VERR_GENERAL_FAILURE;
     774    Utf8Str strAddress(bstrAddress);
     775    const char *pszAddress = strAddress.isEmpty() ? NULL : strAddress.c_str();
     776
    770777    Bstr bstrPassword;
    771     hrc = pMachine->COMGETTER(LiveMigrationPassword)(bstrPassword.asOutParam());
     778    hrc = pMachine->COMGETTER(TeleporterPassword)(bstrPassword.asOutParam());
    772779    if (FAILED(hrc))
    773780        return VERR_GENERAL_FAILURE;
     
    775782    strPassword.append('\n');           /* To simplify password checking. */
    776783
    777     Utf8Str strBind("");
    778     /** @todo Add a bind address property. */
    779     const char *pszBindAddress = strBind.isEmpty() ? NULL : strBind.c_str();
    780 
    781 
    782784    /*
    783785     * Create the TCP server.
     
    786788    PRTTCPSERVER hServer;
    787789    if (uPort)
    788         vrc = RTTcpServerCreateEx(pszBindAddress, uPort, &hServer);
     790        vrc = RTTcpServerCreateEx(pszAddress, uPort, &hServer);
    789791    else
    790792    {
     
    792794        {
    793795            uPort = RTRandU32Ex(cTries >= 8192 ? 49152 : 1024, 65534);
    794             vrc = RTTcpServerCreateEx(pszBindAddress, uPort, &hServer);
     796            vrc = RTTcpServerCreateEx(pszAddress, uPort, &hServer);
    795797            if (vrc != VERR_NET_ADDRESS_IN_USE)
    796798                break;
     
    798800        if (RT_SUCCESS(vrc))
    799801        {
    800             HRESULT hrc = pMachine->COMSETTER(LiveMigrationPort)(uPort);
     802            HRESULT hrc = pMachine->COMSETTER(TeleporterPort)(uPort);
    801803            if (FAILED(hrc))
    802804            {
     
    804806                return VERR_GENERAL_FAILURE;
    805807            }
     808/** @todo Should undo this upon return. */
    806809        }
    807810    }
     
    813816     */
    814817    RTTIMERLR hTimerLR;
    815     vrc = RTTimerLRCreateEx(&hTimerLR, 0 /*ns*/, RTTIMER_FLAGS_CPU_ANY, migrationTimeout, hServer);
     818    vrc = RTTimerLRCreateEx(&hTimerLR, 0 /*ns*/, RTTIMER_FLAGS_CPU_ANY, teleporterTimeout, hServer);
    816819    if (RT_SUCCESS(vrc))
    817820    {
     
    822825             * Do the job, when it returns we're done.
    823826             */
    824             MigrationStateDst State(this, pVM, pMachine, &hTimerLR);
     827            TeleporterStateTrg State(this, pVM, pMachine, &hTimerLR);
    825828            State.mstrPassword      = strPassword;
    826829            State.mhServer          = hServer;
    827830            State.mpvVMCallbackTask = pvVMCallbackTask;
    828831
    829             vrc = RTTcpServerListen(hServer, Console::migrationDstServeConnection, &State);
     832            vrc = RTTcpServerListen(hServer, Console::teleporterTrgServeConnection, &State);
    830833            if (vrc == VERR_TCP_SERVER_STOP)
    831834                vrc = State.mRc;
     
    839842            else
    840843            {
    841                 LogRel(("Migration: RTTcpServerListen -> %Rrc\n", vrc));
     844                LogRel(("Teleporter: RTTcpServerListen -> %Rrc\n", vrc));
    842845            }
    843846        }
     
    851854
    852855
    853 static int migrationTcpWriteACK(MigrationStateDst *pState)
     856static int teleporterTcpWriteACK(TeleporterStateTrg *pState)
    854857{
    855858    int rc = RTTcpWrite(pState->mhSocket, "ACK\n", sizeof("ACK\n") - 1);
    856859    if (RT_FAILURE(rc))
    857         LogRel(("Migration: RTTcpWrite(,ACK,) -> %Rrc\n", rc));
     860        LogRel(("Teleporter: RTTcpWrite(,ACK,) -> %Rrc\n", rc));
    858861    RTTcpFlush(pState->mhSocket);
    859862    return rc;
     
    861864
    862865
    863 static int migrationTcpWriteNACK(MigrationStateDst *pState, int32_t rc2)
     866static int teleporterTcpWriteNACK(TeleporterStateTrg *pState, int32_t rc2)
    864867{
    865868    char    szMsg[64];
     
    867870    int rc = RTTcpWrite(pState->mhSocket, szMsg, cch);
    868871    if (RT_FAILURE(rc))
    869         LogRel(("Migration: RTTcpWrite(,%s,%zu) -> %Rrc\n", szMsg, cch, rc));
     872        LogRel(("Teleporter: RTTcpWrite(,%s,%zu) -> %Rrc\n", szMsg, cch, rc));
    870873    RTTcpFlush(pState->mhSocket);
    871874    return rc;
     
    877880 */
    878881/*static*/ DECLCALLBACK(int)
    879 Console::migrationDstServeConnection(RTSOCKET Sock, void *pvUser)
    880 {
    881     MigrationStateDst *pState = (MigrationStateDst *)pvUser;
     882Console::teleporterTrgServeConnection(RTSOCKET Sock, void *pvUser)
     883{
     884    TeleporterStateTrg *pState = (TeleporterStateTrg *)pvUser;
    882885    pState->mhSocket = Sock;
    883886
     
    888891    if (RT_FAILURE(vrc))
    889892    {
    890         LogRel(("Migration: Failed to write welcome message: %Rrc\n", vrc));
     893        LogRel(("Teleporter: Failed to write welcome message: %Rrc\n", vrc));
    891894        return VINF_SUCCESS;
    892895    }
    893896
    894897    /*
    895      * Password (includes '\n', see migrationDst).  If it's right, tell
     898     * Password (includes '\n', see teleporterTrg).  If it's right, tell
    896899     * the TCP server to stop listening (frees up host resources and makes sure
    897900     * this is the last connection attempt).
     
    907910        {
    908911            if (RT_FAILURE(vrc))
    909                 LogRel(("Migration: Password read failure (off=%u): %Rrc\n", off, vrc));
     912                LogRel(("Teleporter: Password read failure (off=%u): %Rrc\n", off, vrc));
    910913            else
    911                 LogRel(("Migration: Invalid password (off=%u)\n", off));
    912             migrationTcpWriteNACK(pState, VERR_AUTHENTICATION_FAILURE);
     914                LogRel(("Teleporter: Invalid password (off=%u)\n", off));
     915            teleporterTcpWriteNACK(pState, VERR_AUTHENTICATION_FAILURE);
    913916            return VINF_SUCCESS;
    914917        }
    915918        off++;
    916919    }
    917     vrc = migrationTcpWriteACK(pState);
     920    vrc = teleporterTcpWriteACK(pState);
    918921    if (RT_FAILURE(vrc))
    919922        return vrc;
     
    929932    {
    930933        char szCmd[128];
    931         vrc = migrationTcpReadLine(pState, szCmd, sizeof(szCmd));
     934        vrc = teleporterTcpReadLine(pState, szCmd, sizeof(szCmd));
    932935        if (RT_FAILURE(vrc))
    933936            break;
     
    935938        if (!strcmp(szCmd, "load"))
    936939        {
    937             vrc = migrationTcpWriteACK(pState);
     940            vrc = teleporterTcpWriteACK(pState);
    938941            if (RT_FAILURE(vrc))
    939942                break;
    940943
    941944            pState->moffStream = 0;
    942             void *pvUser = static_cast<void *>(static_cast<MigrationState *>(pState));
    943             vrc = VMR3LoadFromStream(pState->mpVM, &g_migrationTcpOps, pvUser,
     945            void *pvUser = static_cast<void *>(static_cast<TeleporterState *>(pState));
     946            vrc = VMR3LoadFromStream(pState->mpVM, &g_teleporterTcpOps, pvUser,
    944947                                     Console::stateProgressCallback, pState->mpvVMCallbackTask);
    945948            if (RT_FAILURE(vrc))
    946949            {
    947                 LogRel(("Migration: VMR3LoadFromStream -> %Rrc\n", vrc));
    948                 migrationTcpWriteNACK(pState, vrc);
     950                LogRel(("Teleporter: VMR3LoadFromStream -> %Rrc\n", vrc));
     951                teleporterTcpWriteNACK(pState, vrc);
    949952                break;
    950953            }
     
    953956            pState->mfStopReading = false;
    954957            size_t cbRead;
    955             vrc = migrationTcpOpRead(pvUser, pState->moffStream, szCmd, 1, &cbRead);
     958            vrc = teleporterTcpOpRead(pvUser, pState->moffStream, szCmd, 1, &cbRead);
    956959            if (vrc != VERR_EOF)
    957960            {
    958                 LogRel(("Migration: Draining migrationTcpOpRead -> %Rrc\n", vrc));
    959                 migrationTcpWriteNACK(pState, vrc);
     961                LogRel(("Teleporter: Draining teleporterTcpOpRead -> %Rrc\n", vrc));
     962                teleporterTcpWriteNACK(pState, vrc);
    960963                break;
    961964            }
    962965
    963             vrc = migrationTcpWriteACK(pState);
     966            vrc = teleporterTcpWriteACK(pState);
    964967            if (RT_FAILURE(vrc))
    965968                break;
     
    969972        else if (!strcmp(szCmd, "done"))
    970973        {
    971             vrc = migrationTcpWriteACK(pState);
     974            vrc = teleporterTcpWriteACK(pState);
    972975            break;
    973976        }
    974977        else
    975978        {
    976             LogRel(("Migration: Unknown command '%s' (%.*Rhxs)\n", szCmd, strlen(szCmd), szCmd));
     979            LogRel(("Teleporter: Unknown command '%s' (%.*Rhxs)\n", szCmd, strlen(szCmd), szCmd));
    977980            vrc = VERR_NOT_IMPLEMENTED;
    978             migrationTcpWriteNACK(pState, vrc);
     981            teleporterTcpWriteNACK(pState, vrc);
    979982            break;
    980983        }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette