Changeset 38191 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Jul 26, 2011 5:02:38 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 73149
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r38099 r38191 371 371 { 372 372 RTStrmPrintf(pStrm, 373 "VBoxManage startvm <uuid>|<name> \n");373 "VBoxManage startvm <uuid>|<name>...\n"); 374 374 RTStrmPrintf(pStrm, 375 375 " [--type gui"); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r38099 r38191 55 55 #include "VBoxManage.h" 56 56 57 #include <list> 58 57 59 using namespace com; 58 60 … … 464 466 { 465 467 HRESULT rc; 466 const char *VMName = NULL;468 std::list<const char *> VMs; 467 469 Bstr sessionType = "gui"; 468 470 … … 508 510 509 511 case VINF_GETOPT_NOT_OPTION: 510 if (!VMName) 511 VMName = ValueUnion.psz; 512 else 513 return errorSyntax(USAGE_STARTVM, "Invalid parameter '%s'", ValueUnion.psz); 512 VMs.push_back(ValueUnion.psz); 514 513 break; 515 514 … … 532 531 533 532 /* check for required options */ 534 if (!VMName) 535 return errorSyntax(USAGE_STARTVM, "VM name required"); 536 537 ComPtr<IMachine> machine; 538 CHECK_ERROR(a->virtualBox, FindMachine(Bstr(VMName).raw(), 539 machine.asOutParam())); 540 if (machine) 541 { 542 Bstr env; 533 if (VMs.empty()) 534 return errorSyntax(USAGE_STARTVM, "at least one VM name or uuid required"); 535 536 for (std::list<const char *>::const_iterator it = VMs.begin(); 537 it != VMs.end(); 538 ++it) 539 { 540 HRESULT rc2 = rc; 541 const char *pszVM = *it; 542 ComPtr<IMachine> machine; 543 CHECK_ERROR(a->virtualBox, FindMachine(Bstr(pszVM).raw(), 544 machine.asOutParam())); 545 if (machine) 546 { 547 Bstr env; 543 548 #if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) 544 /* make sure the VM process will start on the same display as VBoxManage */545 Utf8Str str;546 const char *pszDisplay = RTEnvGet("DISPLAY");547 if (pszDisplay)548 str = Utf8StrFmt("DISPLAY=%s\n", pszDisplay);549 const char *pszXAuth = RTEnvGet("XAUTHORITY");550 if (pszXAuth)551 str.append(Utf8StrFmt("XAUTHORITY=%s\n", pszXAuth));552 env = str;549 /* make sure the VM process will start on the same display as VBoxManage */ 550 Utf8Str str; 551 const char *pszDisplay = RTEnvGet("DISPLAY"); 552 if (pszDisplay) 553 str = Utf8StrFmt("DISPLAY=%s\n", pszDisplay); 554 const char *pszXAuth = RTEnvGet("XAUTHORITY"); 555 if (pszXAuth) 556 str.append(Utf8StrFmt("XAUTHORITY=%s\n", pszXAuth)); 557 env = str; 553 558 #endif 554 ComPtr<IProgress> progress; 555 CHECK_ERROR_RET(machine, LaunchVMProcess(a->session, sessionType.raw(), 556 env.raw(), progress.asOutParam()), rc); 557 if (!progress.isNull()) 558 { 559 RTPrintf("Waiting for the VM to power on...\n"); 560 CHECK_ERROR_RET(progress, WaitForCompletion(-1), 1); 561 562 BOOL completed; 563 CHECK_ERROR_RET(progress, COMGETTER(Completed)(&completed), rc); 564 ASSERT(completed); 565 566 LONG iRc; 567 CHECK_ERROR_RET(progress, COMGETTER(ResultCode)(&iRc), rc); 568 if (FAILED(iRc)) 569 { 570 ProgressErrorInfo info(progress); 571 com::GluePrintErrorInfo(info); 572 } 573 else 574 { 575 RTPrintf("VM has been successfully started.\n"); 576 } 577 } 578 } 579 580 /* it's important to always close sessions */ 581 a->session->UnlockMachine(); 559 ComPtr<IProgress> progress; 560 CHECK_ERROR(machine, LaunchVMProcess(a->session, sessionType.raw(), 561 env.raw(), progress.asOutParam())); 562 if (SUCCEEDED(rc) && !progress.isNull()) 563 { 564 RTPrintf("Waiting for VM \"%s\" to power on...\n", pszVM); 565 CHECK_ERROR(progress, WaitForCompletion(-1)); 566 if (SUCCEEDED(rc)) 567 { 568 BOOL completed = true; 569 CHECK_ERROR(progress, COMGETTER(Completed)(&completed)); 570 if (SUCCEEDED(rc)) 571 { 572 ASSERT(completed); 573 574 LONG iRc; 575 CHECK_ERROR(progress, COMGETTER(ResultCode)(&iRc)); 576 if (SUCCEEDED(rc)) 577 { 578 if (FAILED(iRc)) 579 { 580 ProgressErrorInfo info(progress); 581 com::GluePrintErrorInfo(info); 582 } 583 else 584 { 585 RTPrintf("VM \"%s\" has been successfully started.\n", pszVM); 586 } 587 } 588 } 589 } 590 } 591 } 592 593 /* it's important to always close sessions */ 594 a->session->UnlockMachine(); 595 596 /* make sure that we remember the failed state */ 597 if (FAILED(rc2)) 598 rc = rc2; 599 } 582 600 583 601 return SUCCEEDED(rc) ? 0 : 1;
Note:
See TracChangeset
for help on using the changeset viewer.