Changeset 23801 in vbox for trunk/src/VBox/Main/ConsoleImplTeleporter.cpp
- Timestamp:
- Oct 15, 2009 3:00:47 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 53543
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImplTeleporter.cpp
r23793 r23801 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Console COM Class implementation, The Live MigrationPart.3 * VBox Console COM Class implementation, The Teleporter Part. 4 4 */ 5 5 … … 45 45 *******************************************************************************/ 46 46 /** 47 * Base class for the migrationstate.47 * Base class for the teleporter state. 48 48 * 49 49 * These classes are used as advanced structs, not as proper classes. 50 50 */ 51 class MigrationState51 class TeleporterState 52 52 { 53 53 public: … … 67 67 /** @} */ 68 68 69 MigrationState(Console *pConsole, PVM pVM, bool fIsSource)69 TeleporterState(Console *pConsole, PVM pVM, bool fIsSource) 70 70 : mptrConsole(pConsole) 71 71 , mpVM(pVM) … … 83 83 84 84 /** 85 * Migrationstate used by the source side.86 */ 87 class MigrationStateSrc : public MigrationState85 * Teleporter state used by the source side. 86 */ 87 class TeleporterStateSrc : public TeleporterState 88 88 { 89 89 public: … … 92 92 uint32_t muPort; 93 93 94 MigrationStateSrc(Console *pConsole, PVM pVM)95 : MigrationState(pConsole, pVM, true /*fIsSource*/)94 TeleporterStateSrc(Console *pConsole, PVM pVM) 95 : TeleporterState(pConsole, pVM, true /*fIsSource*/) 96 96 , muPort(UINT32_MAX) 97 97 { … … 101 101 102 102 /** 103 * Migrationstate used by the destiation side.104 */ 105 class MigrationStateDst : public MigrationState103 * Teleporter state used by the destiation side. 104 */ 105 class TeleporterStateTrg : public TeleporterState 106 106 { 107 107 public: … … 112 112 int mRc; 113 113 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*/) 116 116 , mpMachine(pMachine) 117 117 , mpvVMCallbackTask(NULL) … … 130 130 * stream ends. 131 131 */ 132 typedef struct MIGRATIONTCPHDR132 typedef struct TELEPORTERTCPHDR 133 133 { 134 134 /** Magic value. */ … … 137 137 * 0 indicates the end of the stream. */ 138 138 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) 142 142 /** The max block size. */ 143 #define MIGRATIONTCPHDR_MAX_SIZE UINT32_C(0x00fffff8)143 #define TELEPORTERTCPHDR_MAX_SIZE UINT32_C(0x00fffff8) 144 144 145 145 … … 147 147 * Global Variables * 148 148 *******************************************************************************/ 149 static const char g_szWelcome[] = "VirtualBox- LiveMigration-1.0\n";149 static const char g_szWelcome[] = "VirtualBox-Teleporter-1.0\n"; 150 150 151 151 … … 155 155 * @returns VBox status code. 156 156 * 157 * @param pState The live migrationstate structure.157 * @param pState The teleporter state structure. 158 158 * @param pszBuf The output buffer. 159 159 * @param cchBuf The size of the output buffer. 160 160 * 161 161 */ 162 static int migrationTcpReadLine(MigrationState *pState, char *pszBuf, size_t cchBuf)162 static int teleporterTcpReadLine(TeleporterState *pState, char *pszBuf, size_t cchBuf) 163 163 { 164 164 char *pszStart = pszBuf; … … 175 175 if (RT_FAILURE(rc)) 176 176 { 177 LogRel((" Migration: RTTcpRead -> %Rrc while reading string ('%s')\n", rc, pszStart));177 LogRel(("Teleporter: RTTcpRead -> %Rrc while reading string ('%s')\n", rc, pszStart)); 178 178 return rc; 179 179 } … … 183 183 if (cchBuf <= 1) 184 184 { 185 LogRel((" Migration: String buffer overflow: '%s'\n", pszStart));185 LogRel(("Teleporter: String buffer overflow: '%s'\n", pszStart)); 186 186 return VERR_BUFFER_OVERFLOW; 187 187 } … … 197 197 * 198 198 * @returns S_OK on ACK, E_FAIL+setError() on failure or NACK. 199 * @param pState The live migrationsource state.199 * @param pState The teleporter source state. 200 200 * @param pszWhich Which ACK is this this? 201 201 * @param pszNAckMsg Optional NACK message. … … 204 204 */ 205 205 HRESULT 206 Console:: migrationSrcReadACK(MigrationStateSrc *pState, const char *pszWhich,206 Console::teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich, 207 207 const char *pszNAckMsg /*= NULL*/) 208 208 { 209 209 char szMsg[128]; 210 int vrc = migrationTcpReadLine(pState, szMsg, sizeof(szMsg));210 int vrc = teleporterTcpReadLine(pState, szMsg, sizeof(szMsg)); 211 211 if (RT_FAILURE(vrc)) 212 212 return setError(E_FAIL, tr("Failed reading ACK(%s): %Rrc"), pszWhich, vrc); … … 221 221 if (pszNAckMsg) 222 222 { 223 LogRel((" Migration: %s: NACK=%Rrc (%d)\n", pszWhich, vrc2, vrc2));223 LogRel(("Teleporter: %s: NACK=%Rrc (%d)\n", pszWhich, vrc2, vrc2)); 224 224 return setError(E_FAIL, pszNAckMsg); 225 225 } … … 238 238 * @returns S_OK on ACKed command, E_FAIL+setError() on failure. 239 239 * 240 * @param pState The live migrationsource state.240 * @param pState The teleporter source state. 241 241 * @param pszCommand The command. 242 242 * … … 244 244 */ 245 245 HRESULT 246 Console:: migrationSrcSubmitCommand(MigrationStateSrc *pState, const char *pszCommand)246 Console::teleporterSrcSubmitCommand(TeleporterStateSrc *pState, const char *pszCommand) 247 247 { 248 248 size_t cchCommand = strlen(pszCommand); … … 254 254 if (RT_FAILURE(vrc)) 255 255 return setError(E_FAIL, tr("Failed writing command '%s': %Rrc"), pszCommand, vrc); 256 return migrationSrcReadACK(pState, pszCommand);256 return teleporterSrcReadACK(pState, pszCommand); 257 257 } 258 258 … … 261 261 * @copydoc SSMSTRMOPS::pfnWrite 262 262 */ 263 static DECLCALLBACK(int) migrationTcpOpWrite(void *pvUser, uint64_t offStream, const void *pvBuf, size_t cbToWrite)264 { 265 MigrationState *pState = (MigrationState *)pvUser;263 static DECLCALLBACK(int) teleporterTcpOpWrite(void *pvUser, uint64_t offStream, const void *pvBuf, size_t cbToWrite) 264 { 265 TeleporterState *pState = (TeleporterState *)pvUser; 266 266 267 267 AssertReturn(cbToWrite > 0, VINF_SUCCESS); … … 271 271 { 272 272 /* 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); 276 276 int rc = RTTcpWrite(pState->mhSocket, &Hdr, sizeof(Hdr)); 277 277 if (RT_FAILURE(rc)) 278 278 { 279 LogRel((" Migration/TCP: Header write error: %Rrc\n", rc));279 LogRel(("Teleporter/TCP: Header write error: %Rrc\n", rc)); 280 280 return rc; 281 281 } … … 285 285 if (RT_FAILURE(rc)) 286 286 { 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)); 288 288 return rc; 289 289 } … … 308 308 * @returns VBox status code. 309 309 * 310 * @param pState The migrationstate data.311 */ 312 static int migrationTcpReadSelect(MigrationState *pState)310 * @param pState The teleporter state data. 311 */ 312 static int teleporterTcpReadSelect(TeleporterState *pState) 313 313 { 314 314 int rc; … … 319 319 { 320 320 pState->mfIOError = true; 321 LogRel((" Migration/TCP: Header select error: %Rrc\n", rc));321 LogRel(("Teleporter/TCP: Header select error: %Rrc\n", rc)); 322 322 break; 323 323 } … … 335 335 * @copydoc SSMSTRMOPS::pfnRead 336 336 */ 337 static DECLCALLBACK(int) migrationTcpOpRead(void *pvUser, uint64_t offStream, void *pvBuf, size_t cbToRead, size_t *pcbRead)338 { 339 MigrationState *pState = (MigrationState *)pvUser;337 static DECLCALLBACK(int) teleporterTcpOpRead(void *pvUser, uint64_t offStream, void *pvBuf, size_t cbToRead, size_t *pcbRead) 338 { 339 TeleporterState *pState = (TeleporterState *)pvUser; 340 340 AssertReturn(!pState->mfIsSource, VERR_INVALID_HANDLE); 341 341 … … 360 360 if (!pState->mcbReadBlock) 361 361 { 362 rc = migrationTcpReadSelect(pState);362 rc = teleporterTcpReadSelect(pState); 363 363 if (RT_FAILURE(rc)) 364 364 return rc; 365 MIGRATIONTCPHDR Hdr;365 TELEPORTERTCPHDR Hdr; 366 366 rc = RTTcpRead(pState->mhSocket, &Hdr, sizeof(Hdr), NULL); 367 367 if (RT_FAILURE(rc)) 368 368 { 369 369 pState->mfIOError = true; 370 LogRel((" Migration/TCP: Header read error: %Rrc\n", rc));370 LogRel(("Teleporter/TCP: Header read error: %Rrc\n", rc)); 371 371 return rc; 372 372 } 373 if ( Hdr.u32Magic != MIGRATIONTCPHDR_MAGIC374 || Hdr.cb > MIGRATIONTCPHDR_MAX_SIZE)373 if ( Hdr.u32Magic != TELEPORTERTCPHDR_MAGIC 374 || Hdr.cb > TELEPORTERTCPHDR_MAX_SIZE) 375 375 { 376 376 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)); 378 378 return VERR_IO_GEN_FAILURE; 379 379 } … … 393 393 * Read more data. 394 394 */ 395 rc = migrationTcpReadSelect(pState);395 rc = teleporterTcpReadSelect(pState); 396 396 if (RT_FAILURE(rc)) 397 397 return rc; … … 401 401 { 402 402 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)); 404 404 return rc; 405 405 } … … 425 425 * @copydoc SSMSTRMOPS::pfnSeek 426 426 */ 427 static DECLCALLBACK(int) migrationTcpOpSeek(void *pvUser, int64_t offSeek, unsigned uMethod, uint64_t *poffActual)427 static DECLCALLBACK(int) teleporterTcpOpSeek(void *pvUser, int64_t offSeek, unsigned uMethod, uint64_t *poffActual) 428 428 { 429 429 return VERR_NOT_SUPPORTED; … … 434 434 * @copydoc SSMSTRMOPS::pfnTell 435 435 */ 436 static DECLCALLBACK(uint64_t) migrationTcpOpTell(void *pvUser)437 { 438 MigrationState *pState = (MigrationState *)pvUser;436 static DECLCALLBACK(uint64_t) teleporterTcpOpTell(void *pvUser) 437 { 438 TeleporterState *pState = (TeleporterState *)pvUser; 439 439 return pState->moffStream; 440 440 } … … 444 444 * @copydoc SSMSTRMOPS::pfnSize 445 445 */ 446 static DECLCALLBACK(int) migrationTcpOpSize(void *pvUser, uint64_t *pcb)446 static DECLCALLBACK(int) teleporterTcpOpSize(void *pvUser, uint64_t *pcb) 447 447 { 448 448 return VERR_NOT_SUPPORTED; … … 453 453 * @copydoc SSMSTRMOPS::pfnClose 454 454 */ 455 static DECLCALLBACK(int) migrationTcpOpClose(void *pvUser)456 { 457 MigrationState *pState = (MigrationState *)pvUser;455 static DECLCALLBACK(int) teleporterTcpOpClose(void *pvUser) 456 { 457 TeleporterState *pState = (TeleporterState *)pvUser; 458 458 459 459 if (pState->mfIsSource) 460 460 { 461 MIGRATIONTCPHDR EofHdr = { MIGRATIONTCPHDR_MAGIC, 0 };461 TELEPORTERTCPHDR EofHdr = { TELEPORTERTCPHDR_MAGIC, 0 }; 462 462 int rc = RTTcpWrite(pState->mhSocket, &EofHdr, sizeof(EofHdr)); 463 463 if (RT_SUCCESS(rc)) … … 465 465 if (RT_FAILURE(rc)) 466 466 { 467 LogRel((" Migration/TCP: EOF Header write error: %Rrc\n", rc));467 LogRel(("Teleporter/TCP: EOF Header write error: %Rrc\n", rc)); 468 468 return rc; 469 469 } … … 482 482 * Method table for a TCP based stream. 483 483 */ 484 static SSMSTRMOPS const g_ migrationTcpOps =484 static SSMSTRMOPS const g_teleporterTcpOps = 485 485 { 486 486 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, 493 493 SSMSTRMOPS_VERSION 494 494 }; … … 498 498 * @copydoc FNRTTIMERLR 499 499 */ 500 static DECLCALLBACK(void) migrationTimeout(RTTIMERLR hTimerLR, void *pvUser, uint64_t iTick)500 static DECLCALLBACK(void) teleporterTimeout(RTTIMERLR hTimerLR, void *pvUser, uint64_t iTick) 501 501 { 502 502 /* This is harmless for any open connections. */ … … 506 506 507 507 /** 508 * Do the live migration.508 * Do the teleporter. 509 509 * 510 510 * @returns VBox status code. 511 * @param pState The migrationstate.511 * @param pState The teleporter state. 512 512 */ 513 513 HRESULT 514 Console:: migrationSrc(MigrationStateSrc *pState)514 Console::teleporterSrc(TeleporterStateSrc *pState) 515 515 { 516 516 AutoCaller autoCaller(this); … … 518 518 519 519 /* 520 * Wait for Console:: Migrateto change the state.520 * Wait for Console::Teleport to change the state. 521 521 */ 522 522 { AutoWriteLock autoLock(); } … … 554 554 555 555 /* ACK */ 556 hrc = migrationSrcReadACK(pState, "password", tr("Invalid password"));556 hrc = teleporterSrcReadACK(pState, "password", tr("Invalid password")); 557 557 if (FAILED(hrc)) 558 558 return hrc; … … 566 566 * Start loading the state. 567 567 */ 568 hrc = migrationSrcSubmitCommand(pState, "load");568 hrc = teleporterSrcSubmitCommand(pState, "load"); 569 569 if (FAILED(hrc)) 570 570 return hrc; 571 571 572 void *pvUser = static_cast<void *>(static_cast< MigrationState *>(pState));573 vrc = VMR3 Migrate(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); 574 574 if (vrc) 575 return setError(E_FAIL, tr("VMR3 Migrate-> %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"); 578 578 if (FAILED(hrc)) 579 579 return hrc; … … 582 582 * State fun? Automatic power off? 583 583 */ 584 hrc = migrationSrcSubmitCommand(pState, "done");584 hrc = teleporterSrcSubmitCommand(pState, "done"); 585 585 if (FAILED(hrc)) 586 586 return hrc; … … 595 595 * @returns VINF_SUCCESS (ignored). 596 596 * @param hThread The thread. 597 * @param pvUser Pointer to a MigrationStateSrc instance.597 * @param pvUser Pointer to a TeleporterStateSrc instance. 598 598 */ 599 599 /*static*/ DECLCALLBACK(int) 600 Console:: migrationSrcThreadWrapper(RTTHREAD hThread, void *pvUser)601 { 602 MigrationStateSrc *pState = (MigrationStateSrc *)pvUser;600 Console::teleporterSrcThreadWrapper(RTTHREAD hThread, void *pvUser) 601 { 602 TeleporterStateSrc *pState = (TeleporterStateSrc *)pvUser; 603 603 604 604 AutoVMCaller autoVMCaller(pState->mptrConsole); … … 606 606 607 607 if (SUCCEEDED(hrc)) 608 hrc = pState->mptrConsole-> migrationSrc(pState);608 hrc = pState->mptrConsole->teleporterSrc(pState); 609 609 610 610 pState->mptrProgress->notifyComplete(hrc); … … 665 665 666 666 /** 667 * Start live migrationto the specified target.667 * Start teleporter to the specified target. 668 668 * 669 669 * @returns COM status code. … … 675 675 */ 676 676 STDMETHODIMP 677 Console:: Migrate(IN_BSTR aHostname, ULONG aPort, IN_BSTR aPassword, IProgress **aProgress)677 Console::Teleport(IN_BSTR aHostname, ULONG aPort, IN_BSTR aPassword, IProgress **aProgress) 678 678 { 679 679 /* … … 709 709 * Note! The thread won't start working until we release the lock. 710 710 */ 711 LogFlowThisFunc(("Initiating LIVE MIGRATIONrequest...\n"));712 713 ComObjPtr<Progress> ptr MigrateProgress;714 HRESULT hrc = ptr MigrateProgress.createObject();711 LogFlowThisFunc(("Initiating TELEPORTER request...\n")); 712 713 ComObjPtr<Progress> ptrTelportationProgress; 714 HRESULT hrc = ptrTelportationProgress.createObject(); 715 715 CheckComRCReturnRC(hrc); 716 hrc = ptr MigrateProgress->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*/); 719 719 CheckComRCReturnRC(hrc); 720 720 721 MigrationStateSrc *pState = new MigrationStateSrc(this, mpVM);721 TeleporterStateSrc *pState = new TeleporterStateSrc(this, mpVM); 722 722 pState->mstrPassword = aPassword; 723 723 pState->mstrHostname = aHostname; 724 724 pState->muPort = aPort; 725 pState->mptrProgress = ptr MigrateProgress;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"); 729 729 if (RT_SUCCESS(vrc)) 730 730 { 731 731 hrc = setMachineState(MachineState_Saving); 732 732 if (SUCCEEDED(hrc)) 733 ptr MigrateProgress.queryInterfaceTo(aProgress);733 ptrTelportationProgress.queryInterfaceTo(aProgress); 734 734 else 735 ptr MigrateProgress->Cancel();735 ptrTelportationProgress->Cancel(); 736 736 } 737 737 else … … 747 747 /** 748 748 * Creates a TCP server that listens for the source machine and passes control 749 * over to Console:: migrationDstServeConnection().749 * over to Console::teleporterTrgServeConnection(). 750 750 * 751 751 * @returns VBox status code. … … 758 758 */ 759 759 int 760 Console:: migrationDst(PVM pVM, IMachine *pMachine, bool fStartPaused, void *pvVMCallbackTask)760 Console::teleporterTrg(PVM pVM, IMachine *pMachine, bool fStartPaused, void *pvVMCallbackTask) 761 761 { 762 762 /* … … 764 764 */ 765 765 ULONG uPort; 766 HRESULT hrc = pMachine->COMGETTER( LiveMigrationPort)(&uPort);766 HRESULT hrc = pMachine->COMGETTER(TeleporterPort)(&uPort); 767 767 if (FAILED(hrc)) 768 768 return VERR_GENERAL_FAILURE; 769 769 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 770 777 Bstr bstrPassword; 771 hrc = pMachine->COMGETTER( LiveMigrationPassword)(bstrPassword.asOutParam());778 hrc = pMachine->COMGETTER(TeleporterPassword)(bstrPassword.asOutParam()); 772 779 if (FAILED(hrc)) 773 780 return VERR_GENERAL_FAILURE; … … 775 782 strPassword.append('\n'); /* To simplify password checking. */ 776 783 777 Utf8Str strBind("");778 /** @todo Add a bind address property. */779 const char *pszBindAddress = strBind.isEmpty() ? NULL : strBind.c_str();780 781 782 784 /* 783 785 * Create the TCP server. … … 786 788 PRTTCPSERVER hServer; 787 789 if (uPort) 788 vrc = RTTcpServerCreateEx(psz BindAddress, uPort, &hServer);790 vrc = RTTcpServerCreateEx(pszAddress, uPort, &hServer); 789 791 else 790 792 { … … 792 794 { 793 795 uPort = RTRandU32Ex(cTries >= 8192 ? 49152 : 1024, 65534); 794 vrc = RTTcpServerCreateEx(psz BindAddress, uPort, &hServer);796 vrc = RTTcpServerCreateEx(pszAddress, uPort, &hServer); 795 797 if (vrc != VERR_NET_ADDRESS_IN_USE) 796 798 break; … … 798 800 if (RT_SUCCESS(vrc)) 799 801 { 800 HRESULT hrc = pMachine->COMSETTER( LiveMigrationPort)(uPort);802 HRESULT hrc = pMachine->COMSETTER(TeleporterPort)(uPort); 801 803 if (FAILED(hrc)) 802 804 { … … 804 806 return VERR_GENERAL_FAILURE; 805 807 } 808 /** @todo Should undo this upon return. */ 806 809 } 807 810 } … … 813 816 */ 814 817 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); 816 819 if (RT_SUCCESS(vrc)) 817 820 { … … 822 825 * Do the job, when it returns we're done. 823 826 */ 824 MigrationStateDstState(this, pVM, pMachine, &hTimerLR);827 TeleporterStateTrg State(this, pVM, pMachine, &hTimerLR); 825 828 State.mstrPassword = strPassword; 826 829 State.mhServer = hServer; 827 830 State.mpvVMCallbackTask = pvVMCallbackTask; 828 831 829 vrc = RTTcpServerListen(hServer, Console:: migrationDstServeConnection, &State);832 vrc = RTTcpServerListen(hServer, Console::teleporterTrgServeConnection, &State); 830 833 if (vrc == VERR_TCP_SERVER_STOP) 831 834 vrc = State.mRc; … … 839 842 else 840 843 { 841 LogRel((" Migration: RTTcpServerListen -> %Rrc\n", vrc));844 LogRel(("Teleporter: RTTcpServerListen -> %Rrc\n", vrc)); 842 845 } 843 846 } … … 851 854 852 855 853 static int migrationTcpWriteACK(MigrationStateDst*pState)856 static int teleporterTcpWriteACK(TeleporterStateTrg *pState) 854 857 { 855 858 int rc = RTTcpWrite(pState->mhSocket, "ACK\n", sizeof("ACK\n") - 1); 856 859 if (RT_FAILURE(rc)) 857 LogRel((" Migration: RTTcpWrite(,ACK,) -> %Rrc\n", rc));860 LogRel(("Teleporter: RTTcpWrite(,ACK,) -> %Rrc\n", rc)); 858 861 RTTcpFlush(pState->mhSocket); 859 862 return rc; … … 861 864 862 865 863 static int migrationTcpWriteNACK(MigrationStateDst*pState, int32_t rc2)866 static int teleporterTcpWriteNACK(TeleporterStateTrg *pState, int32_t rc2) 864 867 { 865 868 char szMsg[64]; … … 867 870 int rc = RTTcpWrite(pState->mhSocket, szMsg, cch); 868 871 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)); 870 873 RTTcpFlush(pState->mhSocket); 871 874 return rc; … … 877 880 */ 878 881 /*static*/ DECLCALLBACK(int) 879 Console:: migrationDstServeConnection(RTSOCKET Sock, void *pvUser)880 { 881 MigrationStateDst *pState = (MigrationStateDst*)pvUser;882 Console::teleporterTrgServeConnection(RTSOCKET Sock, void *pvUser) 883 { 884 TeleporterStateTrg *pState = (TeleporterStateTrg *)pvUser; 882 885 pState->mhSocket = Sock; 883 886 … … 888 891 if (RT_FAILURE(vrc)) 889 892 { 890 LogRel((" Migration: Failed to write welcome message: %Rrc\n", vrc));893 LogRel(("Teleporter: Failed to write welcome message: %Rrc\n", vrc)); 891 894 return VINF_SUCCESS; 892 895 } 893 896 894 897 /* 895 * Password (includes '\n', see migrationDst). If it's right, tell898 * Password (includes '\n', see teleporterTrg). If it's right, tell 896 899 * the TCP server to stop listening (frees up host resources and makes sure 897 900 * this is the last connection attempt). … … 907 910 { 908 911 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)); 910 913 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); 913 916 return VINF_SUCCESS; 914 917 } 915 918 off++; 916 919 } 917 vrc = migrationTcpWriteACK(pState);920 vrc = teleporterTcpWriteACK(pState); 918 921 if (RT_FAILURE(vrc)) 919 922 return vrc; … … 929 932 { 930 933 char szCmd[128]; 931 vrc = migrationTcpReadLine(pState, szCmd, sizeof(szCmd));934 vrc = teleporterTcpReadLine(pState, szCmd, sizeof(szCmd)); 932 935 if (RT_FAILURE(vrc)) 933 936 break; … … 935 938 if (!strcmp(szCmd, "load")) 936 939 { 937 vrc = migrationTcpWriteACK(pState);940 vrc = teleporterTcpWriteACK(pState); 938 941 if (RT_FAILURE(vrc)) 939 942 break; 940 943 941 944 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, 944 947 Console::stateProgressCallback, pState->mpvVMCallbackTask); 945 948 if (RT_FAILURE(vrc)) 946 949 { 947 LogRel((" Migration: VMR3LoadFromStream -> %Rrc\n", vrc));948 migrationTcpWriteNACK(pState, vrc);950 LogRel(("Teleporter: VMR3LoadFromStream -> %Rrc\n", vrc)); 951 teleporterTcpWriteNACK(pState, vrc); 949 952 break; 950 953 } … … 953 956 pState->mfStopReading = false; 954 957 size_t cbRead; 955 vrc = migrationTcpOpRead(pvUser, pState->moffStream, szCmd, 1, &cbRead);958 vrc = teleporterTcpOpRead(pvUser, pState->moffStream, szCmd, 1, &cbRead); 956 959 if (vrc != VERR_EOF) 957 960 { 958 LogRel((" Migration: Draining migrationTcpOpRead -> %Rrc\n", vrc));959 migrationTcpWriteNACK(pState, vrc);961 LogRel(("Teleporter: Draining teleporterTcpOpRead -> %Rrc\n", vrc)); 962 teleporterTcpWriteNACK(pState, vrc); 960 963 break; 961 964 } 962 965 963 vrc = migrationTcpWriteACK(pState);966 vrc = teleporterTcpWriteACK(pState); 964 967 if (RT_FAILURE(vrc)) 965 968 break; … … 969 972 else if (!strcmp(szCmd, "done")) 970 973 { 971 vrc = migrationTcpWriteACK(pState);974 vrc = teleporterTcpWriteACK(pState); 972 975 break; 973 976 } 974 977 else 975 978 { 976 LogRel((" Migration: Unknown command '%s' (%.*Rhxs)\n", szCmd, strlen(szCmd), szCmd));979 LogRel(("Teleporter: Unknown command '%s' (%.*Rhxs)\n", szCmd, strlen(szCmd), szCmd)); 977 980 vrc = VERR_NOT_IMPLEMENTED; 978 migrationTcpWriteNACK(pState, vrc);981 teleporterTcpWriteNACK(pState, vrc); 979 982 break; 980 983 }
Note:
See TracChangeset
for help on using the changeset viewer.