- Timestamp:
- May 25, 2019 2:21:47 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestCtrlImpl.cpp
r77116 r78744 492 492 return setError(E_INVALIDARG, tr("Unknown flags (%#x)"), fFlags); 493 493 494 int vrc = VINF_SUCCESS; 495 494 495 /* Copy arguments into aArgs: */ 496 496 ProcessArguments aArgs; 497 aArgs.resize(0); 498 499 if (aArguments.size()) 500 { 501 try 502 { 503 for (size_t i = 0; i < aArguments.size(); ++i) 504 aArgs.push_back(aArguments[i]); 505 } 506 catch(std::bad_alloc &) 507 { 508 vrc = VERR_NO_MEMORY; 509 } 510 } 511 512 HRESULT hr = S_OK; 497 try 498 { 499 aArgs.resize(0); 500 for (size_t i = 0; i < aArguments.size(); ++i) 501 aArgs.push_back(aArguments[i]); 502 } 503 catch (std::bad_alloc &) 504 { 505 return E_OUTOFMEMORY; 506 } 507 513 508 514 509 /* … … 522 517 RT_ZERO(guestCreds); 523 518 519 HRESULT hrc; 524 520 ComObjPtr<GuestSession> pSession; 521 int vrc = i_sessionCreate(startupInfo, guestCreds, pSession); 525 522 if (RT_SUCCESS(vrc)) 526 vrc = i_sessionCreate(startupInfo, guestCreds, pSession);527 if (RT_FAILURE(vrc))528 {529 switch (vrc)530 {531 case VERR_MAX_PROCS_REACHED:532 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Maximum number of concurrent guest sessions (%d) reached"),533 VBOX_GUESTCTRL_MAX_SESSIONS);534 break;535 536 /** @todo Add more errors here. */537 538 default:539 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Could not create guest session: %Rrc"), vrc);540 break;541 }542 }543 else544 523 { 545 524 Assert(!pSession.isNull()); 546 int rcGuest; 525 526 int rcGuest = VERR_GSTCTL_GUEST_ERROR; 547 527 vrc = pSession->i_startSession(&rcGuest); 548 if (RT_FAILURE(vrc)) 549 { 550 /** @todo Handle rcGuest! */ 551 552 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Could not open guest session: %Rrc"), vrc); 553 } 554 else 555 { 556 557 ComObjPtr<Progress> pProgress; 528 if (RT_SUCCESS(vrc)) 529 { 530 /* 531 * Create the update task. 532 */ 558 533 GuestSessionTaskUpdateAdditions *pTask = NULL; 559 534 try 560 535 { 536 pTask = new GuestSessionTaskUpdateAdditions(pSession /* GuestSession */, aSource, aArgs, fFlags); 537 hrc = S_OK; 538 } 539 catch (std::bad_alloc &) 540 { 541 hrc = setError(E_OUTOFMEMORY, tr("Failed to create SessionTaskUpdateAdditions object")); 542 } 543 if (SUCCEEDED(hrc)) 544 { 561 545 try 562 546 { 563 pTask = new GuestSessionTaskUpdateAdditions(pSession /* GuestSession */, aSource, aArgs, fFlags);547 hrc = pTask->Init(Utf8StrFmt(tr("Updating Guest Additions"))); 564 548 } 565 catch (...)549 catch (std::bad_alloc &) 566 550 { 567 hr = setError(E_OUTOFMEMORY, tr("Failed to create SessionTaskUpdateAdditions object ")); 568 throw; 551 hrc = E_OUTOFMEMORY; 569 552 } 570 571 572 hr = pTask->Init(Utf8StrFmt(tr("Updating Guest Additions"))); 573 if (FAILED(hr)) 553 if (SUCCEEDED(hrc)) 574 554 { 575 delete pTask; 576 hr = setError(hr, tr("Creating progress object for SessionTaskUpdateAdditions object failed")); 577 throw hr; 578 } 579 580 hr = pTask->createThreadWithType(RTTHREADTYPE_MAIN_HEAVY_WORKER); 581 582 if (SUCCEEDED(hr)) 583 { 584 /* Return progress to the caller. */ 585 pProgress = pTask->GetProgressObject(); 586 hr = pProgress.queryInterfaceTo(aProgress.asOutParam()); 555 ComPtr<Progress> ptrProgress = pTask->GetProgressObject(); 556 557 /* 558 * Kick off the thread. Note! consumes pTask! 559 */ 560 hrc = pTask->createThreadWithType(RTTHREADTYPE_MAIN_HEAVY_WORKER); 561 pTask = NULL; 562 if (SUCCEEDED(hrc)) 563 hrc = ptrProgress.queryInterfaceTo(aProgress.asOutParam()); 564 else 565 hrc = setError(hrc, tr("Starting thread for updating Guest Additions on the guest failed")); 587 566 } 588 567 else 589 hr = setError(hr, tr("Starting thread for updating Guest Additions on the guest failed ")); 568 { 569 hrc = setError(hrc, tr("Failed to initialize SessionTaskUpdateAdditions object")); 570 delete pTask; 571 } 590 572 } 591 catch(std::bad_alloc &) 592 { 593 hr = E_OUTOFMEMORY; 594 } 595 catch(...) 596 { 597 LogFlowThisFunc(("Exception was caught in the function\n")); 598 } 599 } 600 } 601 602 LogFlowFunc(("Returning hr=%Rhrc\n", hr)); 603 return hr; 573 } 574 else 575 { 576 if (vrc == VERR_GSTCTL_GUEST_ERROR) 577 vrc = rcGuest; 578 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Could not open guest session: %Rrc"), vrc); 579 } 580 } 581 else 582 { 583 switch (vrc) 584 { 585 case VERR_MAX_PROCS_REACHED: 586 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Maximum number of concurrent guest sessions (%d) reached"), 587 VBOX_GUESTCTRL_MAX_SESSIONS); 588 break; 589 590 /** @todo Add more errors here. */ 591 592 default: 593 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Could not create guest session: %Rrc"), vrc); 594 break; 595 } 596 } 597 598 LogFlowFunc(("Returning hrc=%Rhrc\n", hrc)); 599 return hrc; 604 600 #endif /* VBOX_WITH_GUEST_CONTROL */ 605 601 }
Note:
See TracChangeset
for help on using the changeset viewer.