- Timestamp:
- Nov 24, 2009 2:22:47 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/Makefile.kmk
r24903 r24907 69 69 VBoxManageList.cpp \ 70 70 VBoxManageMetrics.cpp \ 71 VBoxManageMisc.cpp \ 71 72 VBoxManageModifyVM.cpp \ 72 73 VBoxManageSnapshot.cpp \ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r24903 r24907 25 25 *******************************************************************************/ 26 26 #ifndef VBOX_ONLY_DOCS 27 # include <VBox/com/com.h>28 # include <VBox/com/string.h>29 # include <VBox/com/Guid.h>30 # include <VBox/com/array.h>31 # include <VBox/com/ErrorInfo.h>32 # include <VBox/com/errorprint.h>33 # include <VBox/com/EventQueue.h>34 35 # include <VBox/com/VirtualBox.h>36 37 # include <vector>38 # include <list>27 # include <VBox/com/com.h> 28 # include <VBox/com/string.h> 29 # include <VBox/com/Guid.h> 30 # include <VBox/com/array.h> 31 # include <VBox/com/ErrorInfo.h> 32 # include <VBox/com/errorprint.h> 33 # include <VBox/com/EventQueue.h> 34 35 # include <VBox/com/VirtualBox.h> 36 37 # include <vector> 38 # include <list> 39 39 #endif /* !VBOX_ONLY_DOCS */ 40 40 41 #include <iprt/asm.h> 41 #include <VBox/err.h> 42 #include <VBox/version.h> 43 42 44 #include <iprt/buildconfig.h> 43 #include <iprt/cidr.h>44 #include <iprt/ctype.h>45 #include <iprt/dir.h>46 45 #include <iprt/env.h> 47 #include <VBox/err.h>48 #include <iprt/file.h>49 46 #include <iprt/initterm.h> 50 #include <iprt/param.h>51 #include <iprt/path.h>52 47 #include <iprt/stream.h> 53 48 #include <iprt/string.h> 54 #include <iprt/stdarg.h>55 #include <iprt/thread.h>56 #include <iprt/uuid.h>57 #include <iprt/getopt.h>58 #include <iprt/ctype.h>59 #include <VBox/version.h>60 #include <VBox/log.h>61 49 62 50 #include "VBoxManage.h" 63 51 64 #ifndef VBOX_ONLY_DOCS65 using namespace com;66 #endif /* !VBOX_ONLY_DOCS */67 52 68 53 /******************************************************************************* … … 71 56 /*extern*/ bool g_fDetailedProgress = false; 72 57 73 ////////////////////////////////////////////////////////////////////////////////74 //75 // functions76 //77 ////////////////////////////////////////////////////////////////////////////////78 58 79 59 #ifndef VBOX_ONLY_DOCS … … 83 63 HRESULT showProgress(ComPtr<IProgress> progress) 84 64 { 65 using namespace com; 66 85 67 BOOL fCompleted; 86 68 ULONG ulCurrentPercent; … … 169 151 return iRc; 170 152 } 171 172 static int handleRegisterVM(HandlerArg *a)173 {174 HRESULT rc;175 176 if (a->argc != 1)177 return errorSyntax(USAGE_REGISTERVM, "Incorrect number of parameters");178 179 ComPtr<IMachine> machine;180 /** @todo Ugly hack to get both the API interpretation of relative paths181 * and the client's interpretation of relative paths. Remove after the API182 * has been redesigned. */183 rc = a->virtualBox->OpenMachine(Bstr(a->argv[0]), machine.asOutParam());184 if (rc == VBOX_E_FILE_ERROR)185 {186 char szVMFileAbs[RTPATH_MAX] = "";187 int vrc = RTPathAbs(a->argv[0], szVMFileAbs, sizeof(szVMFileAbs));188 if (RT_FAILURE(vrc))189 {190 RTPrintf("Cannot convert filename \"%s\" to absolute path\n", a->argv[0]);191 return 1;192 }193 CHECK_ERROR(a->virtualBox, OpenMachine(Bstr(szVMFileAbs), machine.asOutParam()));194 }195 else if (FAILED(rc))196 CHECK_ERROR(a->virtualBox, OpenMachine(Bstr(a->argv[0]), machine.asOutParam()));197 if (SUCCEEDED(rc))198 {199 ASSERT(machine);200 CHECK_ERROR(a->virtualBox, RegisterMachine(machine));201 }202 return SUCCEEDED(rc) ? 0 : 1;203 }204 205 static const RTGETOPTDEF g_aUnregisterVMOptions[] =206 {207 { "--delete", 'd', RTGETOPT_REQ_NOTHING },208 { "-delete", 'd', RTGETOPT_REQ_NOTHING }, // deprecated209 };210 211 static int handleUnregisterVM(HandlerArg *a)212 {213 HRESULT rc;214 const char *VMName = NULL;215 bool fDelete = false;216 217 int c;218 RTGETOPTUNION ValueUnion;219 RTGETOPTSTATE GetState;220 // start at 0 because main() has hacked both the argc and argv given to us221 RTGetOptInit(&GetState, a->argc, a->argv, g_aUnregisterVMOptions, RT_ELEMENTS(g_aUnregisterVMOptions), 0, 0 /* fFlags */);222 while ((c = RTGetOpt(&GetState, &ValueUnion)))223 {224 switch (c)225 {226 case 'd': // --delete227 fDelete = true;228 break;229 230 case VINF_GETOPT_NOT_OPTION:231 if (!VMName)232 VMName = ValueUnion.psz;233 else234 return errorSyntax(USAGE_UNREGISTERVM, "Invalid parameter '%s'", ValueUnion.psz);235 break;236 237 default:238 if (c > 0)239 {240 if (RT_C_IS_PRINT(c))241 return errorSyntax(USAGE_UNREGISTERVM, "Invalid option -%c", c);242 else243 return errorSyntax(USAGE_UNREGISTERVM, "Invalid option case %i", c);244 }245 else if (c == VERR_GETOPT_UNKNOWN_OPTION)246 return errorSyntax(USAGE_UNREGISTERVM, "unknown option: %s\n", ValueUnion.psz);247 else if (ValueUnion.pDef)248 return errorSyntax(USAGE_UNREGISTERVM, "%s: %Rrs", ValueUnion.pDef->pszLong, c);249 else250 return errorSyntax(USAGE_UNREGISTERVM, "error: %Rrs", c);251 }252 }253 254 /* check for required options */255 if (!VMName)256 return errorSyntax(USAGE_UNREGISTERVM, "VM name required");257 258 ComPtr<IMachine> machine;259 /* assume it's a UUID */260 rc = a->virtualBox->GetMachine(Guid(VMName).toUtf16(), machine.asOutParam());261 if (FAILED(rc) || !machine)262 {263 /* must be a name */264 CHECK_ERROR(a->virtualBox, FindMachine(Bstr(VMName), machine.asOutParam()));265 }266 if (machine)267 {268 Bstr uuid;269 machine->COMGETTER(Id)(uuid.asOutParam());270 machine = NULL;271 CHECK_ERROR(a->virtualBox, UnregisterMachine(uuid, machine.asOutParam()));272 if (SUCCEEDED(rc) && machine && fDelete)273 CHECK_ERROR(machine, DeleteSettings());274 }275 return SUCCEEDED(rc) ? 0 : 1;276 }277 278 static int handleCreateVM(HandlerArg *a)279 {280 HRESULT rc;281 Bstr baseFolder;282 Bstr settingsFile;283 Bstr name;284 Bstr osTypeId;285 RTUUID id;286 bool fRegister = false;287 288 RTUuidClear(&id);289 for (int i = 0; i < a->argc; i++)290 {291 if ( !strcmp(a->argv[i], "--basefolder")292 || !strcmp(a->argv[i], "-basefolder"))293 {294 if (a->argc <= i + 1)295 return errorArgument("Missing argument to '%s'", a->argv[i]);296 i++;297 baseFolder = a->argv[i];298 }299 else if ( !strcmp(a->argv[i], "--settingsfile")300 || !strcmp(a->argv[i], "-settingsfile"))301 {302 if (a->argc <= i + 1)303 return errorArgument("Missing argument to '%s'", a->argv[i]);304 i++;305 settingsFile = a->argv[i];306 }307 else if ( !strcmp(a->argv[i], "--name")308 || !strcmp(a->argv[i], "-name"))309 {310 if (a->argc <= i + 1)311 return errorArgument("Missing argument to '%s'", a->argv[i]);312 i++;313 name = a->argv[i];314 }315 else if ( !strcmp(a->argv[i], "--ostype")316 || !strcmp(a->argv[i], "-ostype"))317 {318 if (a->argc <= i + 1)319 return errorArgument("Missing argument to '%s'", a->argv[i]);320 i++;321 osTypeId = a->argv[i];322 }323 else if ( !strcmp(a->argv[i], "--uuid")324 || !strcmp(a->argv[i], "-uuid"))325 {326 if (a->argc <= i + 1)327 return errorArgument("Missing argument to '%s'", a->argv[i]);328 i++;329 if (RT_FAILURE(RTUuidFromStr(&id, a->argv[i])))330 return errorArgument("Invalid UUID format %s\n", a->argv[i]);331 }332 else if ( !strcmp(a->argv[i], "--register")333 || !strcmp(a->argv[i], "-register"))334 {335 fRegister = true;336 }337 else338 return errorSyntax(USAGE_CREATEVM, "Invalid parameter '%s'", Utf8Str(a->argv[i]).raw());339 }340 if (!name)341 return errorSyntax(USAGE_CREATEVM, "Parameter --name is required");342 343 if (!!baseFolder && !!settingsFile)344 return errorSyntax(USAGE_CREATEVM, "Either --basefolder or --settingsfile must be specified");345 346 do347 {348 ComPtr<IMachine> machine;349 350 if (!settingsFile)351 CHECK_ERROR_BREAK(a->virtualBox,352 CreateMachine(name, osTypeId, baseFolder, Guid(id).toUtf16(), machine.asOutParam()));353 else354 CHECK_ERROR_BREAK(a->virtualBox,355 CreateLegacyMachine(name, osTypeId, settingsFile, Guid(id).toUtf16(), machine.asOutParam()));356 357 CHECK_ERROR_BREAK(machine, SaveSettings());358 if (fRegister)359 {360 CHECK_ERROR_BREAK(a->virtualBox, RegisterMachine(machine));361 }362 Bstr uuid;363 CHECK_ERROR_BREAK(machine, COMGETTER(Id)(uuid.asOutParam()));364 CHECK_ERROR_BREAK(machine, COMGETTER(SettingsFilePath)(settingsFile.asOutParam()));365 RTPrintf("Virtual machine '%ls' is created%s.\n"366 "UUID: %s\n"367 "Settings file: '%ls'\n",368 name.raw(), fRegister ? " and registered" : "",369 Utf8Str(uuid).raw(), settingsFile.raw());370 }371 while (0);372 373 return SUCCEEDED(rc) ? 0 : 1;374 }375 376 static int handleStartVM(HandlerArg *a)377 {378 HRESULT rc;379 const char *VMName = NULL;380 Bstr sessionType = "gui";381 382 static const RTGETOPTDEF s_aStartVMOptions[] =383 {384 { "--type", 't', RTGETOPT_REQ_STRING },385 { "-type", 't', RTGETOPT_REQ_STRING }, // deprecated386 };387 int c;388 RTGETOPTUNION ValueUnion;389 RTGETOPTSTATE GetState;390 // start at 0 because main() has hacked both the argc and argv given to us391 RTGetOptInit(&GetState, a->argc, a->argv, s_aStartVMOptions, RT_ELEMENTS(s_aStartVMOptions), 0, 0 /* fFlags */);392 while ((c = RTGetOpt(&GetState, &ValueUnion)))393 {394 switch (c)395 {396 case 't': // --type397 if (!RTStrICmp(ValueUnion.psz, "gui"))398 {399 sessionType = "gui";400 }401 #ifdef VBOX_WITH_VBOXSDL402 else if (!RTStrICmp(ValueUnion.psz, "sdl"))403 {404 sessionType = "sdl";405 }406 #endif407 #ifdef VBOX_WITH_VRDP408 else if (!RTStrICmp(ValueUnion.psz, "vrdp"))409 {410 sessionType = "vrdp";411 }412 #endif413 #ifdef VBOX_WITH_HEADLESS414 else if (!RTStrICmp(ValueUnion.psz, "capture"))415 {416 sessionType = "capture";417 }418 else if (!RTStrICmp(ValueUnion.psz, "headless"))419 {420 sessionType = "headless";421 }422 #endif423 else424 return errorArgument("Invalid session type '%s'", ValueUnion.psz);425 break;426 427 case VINF_GETOPT_NOT_OPTION:428 if (!VMName)429 VMName = ValueUnion.psz;430 else431 return errorSyntax(USAGE_STARTVM, "Invalid parameter '%s'", ValueUnion.psz);432 break;433 434 default:435 if (c > 0)436 {437 if (RT_C_IS_PRINT(c))438 return errorSyntax(USAGE_STARTVM, "Invalid option -%c", c);439 else440 return errorSyntax(USAGE_STARTVM, "Invalid option case %i", c);441 }442 else if (c == VERR_GETOPT_UNKNOWN_OPTION)443 return errorSyntax(USAGE_STARTVM, "unknown option: %s\n", ValueUnion.psz);444 else if (ValueUnion.pDef)445 return errorSyntax(USAGE_STARTVM, "%s: %Rrs", ValueUnion.pDef->pszLong, c);446 else447 return errorSyntax(USAGE_STARTVM, "error: %Rrs", c);448 }449 }450 451 /* check for required options */452 if (!VMName)453 return errorSyntax(USAGE_STARTVM, "VM name required");454 455 ComPtr<IMachine> machine;456 /* assume it's a UUID */457 rc = a->virtualBox->GetMachine(Guid(VMName).toUtf16(), machine.asOutParam());458 if (FAILED(rc) || !machine)459 {460 /* must be a name */461 CHECK_ERROR(a->virtualBox, FindMachine(Bstr(VMName), machine.asOutParam()));462 }463 if (machine)464 {465 Bstr uuid;466 machine->COMGETTER(Id)(uuid.asOutParam());467 468 469 Bstr env;470 #if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)471 /* make sure the VM process will start on the same display as VBoxManage */472 Utf8Str str;473 const char *pszDisplay = RTEnvGet("DISPLAY");474 if (pszDisplay)475 str = Utf8StrFmt("DISPLAY=%s\n", pszDisplay);476 const char *pszXAuth = RTEnvGet("XAUTHORITY");477 if (pszXAuth)478 str.append(Utf8StrFmt("XAUTHORITY=%s\n", pszXAuth));479 env = str;480 #endif481 ComPtr<IProgress> progress;482 CHECK_ERROR_RET(a->virtualBox, OpenRemoteSession(a->session, uuid, sessionType,483 env, progress.asOutParam()), rc);484 RTPrintf("Waiting for the remote session to open...\n");485 CHECK_ERROR_RET(progress, WaitForCompletion (-1), 1);486 487 BOOL completed;488 CHECK_ERROR_RET(progress, COMGETTER(Completed)(&completed), rc);489 ASSERT(completed);490 491 LONG iRc;492 CHECK_ERROR_RET(progress, COMGETTER(ResultCode)(&iRc), rc);493 if (FAILED(iRc))494 {495 ComPtr <IVirtualBoxErrorInfo> errorInfo;496 CHECK_ERROR_RET(progress, COMGETTER(ErrorInfo)(errorInfo.asOutParam()), 1);497 ErrorInfo info (errorInfo);498 com::GluePrintErrorInfo(info);499 }500 else501 {502 RTPrintf("Remote session has been successfully opened.\n");503 }504 }505 506 /* it's important to always close sessions */507 a->session->Close();508 509 return SUCCEEDED(rc) ? 0 : 1;510 }511 512 static int handleDiscardState(HandlerArg *a)513 {514 HRESULT rc;515 516 if (a->argc != 1)517 return errorSyntax(USAGE_DISCARDSTATE, "Incorrect number of parameters");518 519 ComPtr<IMachine> machine;520 /* assume it's a UUID */521 rc = a->virtualBox->GetMachine(Bstr(a->argv[0]), machine.asOutParam());522 if (FAILED(rc) || !machine)523 {524 /* must be a name */525 CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()));526 }527 if (machine)528 {529 do530 {531 /* we have to open a session for this task */532 Bstr guid;533 machine->COMGETTER(Id)(guid.asOutParam());534 CHECK_ERROR_BREAK(a->virtualBox, OpenSession(a->session, guid));535 do536 {537 ComPtr<IConsole> console;538 CHECK_ERROR_BREAK(a->session, COMGETTER(Console)(console.asOutParam()));539 CHECK_ERROR_BREAK(console, ForgetSavedState(true));540 } while (0);541 CHECK_ERROR_BREAK(a->session, Close());542 } while (0);543 }544 545 return SUCCEEDED(rc) ? 0 : 1;546 }547 548 static int handleAdoptdState(HandlerArg *a)549 {550 HRESULT rc;551 552 if (a->argc != 2)553 return errorSyntax(USAGE_ADOPTSTATE, "Incorrect number of parameters");554 555 ComPtr<IMachine> machine;556 /* assume it's a UUID */557 rc = a->virtualBox->GetMachine(Bstr(a->argv[0]), machine.asOutParam());558 if (FAILED(rc) || !machine)559 {560 /* must be a name */561 CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()));562 }563 if (machine)564 {565 do566 {567 /* we have to open a session for this task */568 Bstr guid;569 machine->COMGETTER(Id)(guid.asOutParam());570 CHECK_ERROR_BREAK(a->virtualBox, OpenSession(a->session, guid));571 do572 {573 ComPtr<IConsole> console;574 CHECK_ERROR_BREAK(a->session, COMGETTER(Console)(console.asOutParam()));575 CHECK_ERROR_BREAK(console, AdoptSavedState(Bstr(a->argv[1])));576 } while (0);577 CHECK_ERROR_BREAK(a->session, Close());578 } while (0);579 }580 581 return SUCCEEDED(rc) ? 0 : 1;582 }583 584 static int handleGetExtraData(HandlerArg *a)585 {586 HRESULT rc = S_OK;587 588 if (a->argc != 2)589 return errorSyntax(USAGE_GETEXTRADATA, "Incorrect number of parameters");590 591 /* global data? */592 if (!strcmp(a->argv[0], "global"))593 {594 /* enumeration? */595 if (!strcmp(a->argv[1], "enumerate"))596 {597 SafeArray<BSTR> aKeys;598 CHECK_ERROR(a->virtualBox, GetExtraDataKeys(ComSafeArrayAsOutParam(aKeys)));599 600 for (size_t i = 0;601 i < aKeys.size();602 ++i)603 {604 Bstr bstrKey(aKeys[i]);605 Bstr bstrValue;606 CHECK_ERROR(a->virtualBox, GetExtraData(bstrKey, bstrValue.asOutParam()));607 608 RTPrintf("Key: %lS, Value: %lS\n", bstrKey.raw(), bstrValue.raw());609 }610 }611 else612 {613 Bstr value;614 CHECK_ERROR(a->virtualBox, GetExtraData(Bstr(a->argv[1]), value.asOutParam()));615 if (!value.isEmpty())616 RTPrintf("Value: %lS\n", value.raw());617 else618 RTPrintf("No value set!\n");619 }620 }621 else622 {623 ComPtr<IMachine> machine;624 /* assume it's a UUID */625 rc = a->virtualBox->GetMachine(Bstr(a->argv[0]), machine.asOutParam());626 if (FAILED(rc) || !machine)627 {628 /* must be a name */629 CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()));630 }631 if (machine)632 {633 /* enumeration? */634 if (!strcmp(a->argv[1], "enumerate"))635 {636 SafeArray<BSTR> aKeys;637 CHECK_ERROR(machine, GetExtraDataKeys(ComSafeArrayAsOutParam(aKeys)));638 639 for (size_t i = 0;640 i < aKeys.size();641 ++i)642 {643 Bstr bstrKey(aKeys[i]);644 Bstr bstrValue;645 CHECK_ERROR(machine, GetExtraData(bstrKey, bstrValue.asOutParam()));646 647 RTPrintf("Key: %lS, Value: %lS\n", bstrKey.raw(), bstrValue.raw());648 }649 }650 else651 {652 Bstr value;653 CHECK_ERROR(machine, GetExtraData(Bstr(a->argv[1]), value.asOutParam()));654 if (!value.isEmpty())655 RTPrintf("Value: %lS\n", value.raw());656 else657 RTPrintf("No value set!\n");658 }659 }660 }661 return SUCCEEDED(rc) ? 0 : 1;662 }663 664 static int handleSetExtraData(HandlerArg *a)665 {666 HRESULT rc = S_OK;667 668 if (a->argc < 2)669 return errorSyntax(USAGE_SETEXTRADATA, "Not enough parameters");670 671 /* global data? */672 if (!strcmp(a->argv[0], "global"))673 {674 if (a->argc < 3)675 CHECK_ERROR(a->virtualBox, SetExtraData(Bstr(a->argv[1]), NULL));676 else if (a->argc == 3)677 CHECK_ERROR(a->virtualBox, SetExtraData(Bstr(a->argv[1]), Bstr(a->argv[2])));678 else679 return errorSyntax(USAGE_SETEXTRADATA, "Too many parameters");680 }681 else682 {683 ComPtr<IMachine> machine;684 /* assume it's a UUID */685 rc = a->virtualBox->GetMachine(Bstr(a->argv[0]), machine.asOutParam());686 if (FAILED(rc) || !machine)687 {688 /* must be a name */689 CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()));690 }691 if (machine)692 {693 if (a->argc < 3)694 CHECK_ERROR(machine, SetExtraData(Bstr(a->argv[1]), NULL));695 else if (a->argc == 3)696 CHECK_ERROR(machine, SetExtraData(Bstr(a->argv[1]), Bstr(a->argv[2])));697 else698 return errorSyntax(USAGE_SETEXTRADATA, "Too many parameters");699 }700 }701 return SUCCEEDED(rc) ? 0 : 1;702 }703 704 static int handleSetProperty(HandlerArg *a)705 {706 HRESULT rc;707 708 /* there must be two arguments: property name and value */709 if (a->argc != 2)710 return errorSyntax(USAGE_SETPROPERTY, "Incorrect number of parameters");711 712 ComPtr<ISystemProperties> systemProperties;713 a->virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());714 715 if (!strcmp(a->argv[0], "hdfolder"))716 {717 /* reset to default? */718 if (!strcmp(a->argv[1], "default"))719 CHECK_ERROR(systemProperties, COMSETTER(DefaultHardDiskFolder)(NULL));720 else721 CHECK_ERROR(systemProperties, COMSETTER(DefaultHardDiskFolder)(Bstr(a->argv[1])));722 }723 else if (!strcmp(a->argv[0], "machinefolder"))724 {725 /* reset to default? */726 if (!strcmp(a->argv[1], "default"))727 CHECK_ERROR(systemProperties, COMSETTER(DefaultMachineFolder)(NULL));728 else729 CHECK_ERROR(systemProperties, COMSETTER(DefaultMachineFolder)(Bstr(a->argv[1])));730 }731 else if (!strcmp(a->argv[0], "vrdpauthlibrary"))732 {733 /* reset to default? */734 if (!strcmp(a->argv[1], "default"))735 CHECK_ERROR(systemProperties, COMSETTER(RemoteDisplayAuthLibrary)(NULL));736 else737 CHECK_ERROR(systemProperties, COMSETTER(RemoteDisplayAuthLibrary)(Bstr(a->argv[1])));738 }739 else if (!strcmp(a->argv[0], "websrvauthlibrary"))740 {741 /* reset to default? */742 if (!strcmp(a->argv[1], "default"))743 CHECK_ERROR(systemProperties, COMSETTER(WebServiceAuthLibrary)(NULL));744 else745 CHECK_ERROR(systemProperties, COMSETTER(WebServiceAuthLibrary)(Bstr(a->argv[1])));746 }747 else if (!strcmp(a->argv[0], "loghistorycount"))748 {749 uint32_t uVal;750 int vrc;751 vrc = RTStrToUInt32Ex(a->argv[1], NULL, 0, &uVal);752 if (vrc != VINF_SUCCESS)753 return errorArgument("Error parsing Log history count '%s'", a->argv[1]);754 CHECK_ERROR(systemProperties, COMSETTER(LogHistoryCount)(uVal));755 }756 else757 return errorSyntax(USAGE_SETPROPERTY, "Invalid parameter '%s'", a->argv[0]);758 759 return SUCCEEDED(rc) ? 0 : 1;760 }761 762 static int handleSharedFolder(HandlerArg *a)763 {764 HRESULT rc;765 766 /* we need at least a command and target */767 if (a->argc < 2)768 return errorSyntax(USAGE_SHAREDFOLDER, "Not enough parameters");769 770 ComPtr<IMachine> machine;771 /* assume it's a UUID */772 rc = a->virtualBox->GetMachine(Bstr(a->argv[1]), machine.asOutParam());773 if (FAILED(rc) || !machine)774 {775 /* must be a name */776 CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[1]), machine.asOutParam()));777 }778 if (!machine)779 return 1;780 Bstr uuid;781 machine->COMGETTER(Id)(uuid.asOutParam());782 783 if (!strcmp(a->argv[0], "add"))784 {785 /* we need at least four more parameters */786 if (a->argc < 5)787 return errorSyntax(USAGE_SHAREDFOLDER_ADD, "Not enough parameters");788 789 char *name = NULL;790 char *hostpath = NULL;791 bool fTransient = false;792 bool fWritable = true;793 794 for (int i = 2; i < a->argc; i++)795 {796 if ( !strcmp(a->argv[i], "--name")797 || !strcmp(a->argv[i], "-name"))798 {799 if (a->argc <= i + 1 || !*a->argv[i+1])800 return errorArgument("Missing argument to '%s'", a->argv[i]);801 i++;802 name = a->argv[i];803 }804 else if ( !strcmp(a->argv[i], "--hostpath")805 || !strcmp(a->argv[i], "-hostpath"))806 {807 if (a->argc <= i + 1 || !*a->argv[i+1])808 return errorArgument("Missing argument to '%s'", a->argv[i]);809 i++;810 hostpath = a->argv[i];811 }812 else if ( !strcmp(a->argv[i], "--readonly")813 || !strcmp(a->argv[i], "-readonly"))814 {815 fWritable = false;816 }817 else if ( !strcmp(a->argv[i], "--transient")818 || !strcmp(a->argv[i], "-transient"))819 {820 fTransient = true;821 }822 else823 return errorSyntax(USAGE_SHAREDFOLDER_ADD, "Invalid parameter '%s'", Utf8Str(a->argv[i]).raw());824 }825 826 if (NULL != strstr(name, " "))827 return errorSyntax(USAGE_SHAREDFOLDER_ADD, "No spaces allowed in parameter '-name'!");828 829 /* required arguments */830 if (!name || !hostpath)831 {832 return errorSyntax(USAGE_SHAREDFOLDER_ADD, "Parameters --name and --hostpath are required");833 }834 835 if (fTransient)836 {837 ComPtr <IConsole> console;838 839 /* open an existing session for the VM */840 CHECK_ERROR_RET(a->virtualBox, OpenExistingSession(a->session, uuid), 1);841 /* get the session machine */842 CHECK_ERROR_RET(a->session, COMGETTER(Machine)(machine.asOutParam()), 1);843 /* get the session console */844 CHECK_ERROR_RET(a->session, COMGETTER(Console)(console.asOutParam()), 1);845 846 CHECK_ERROR(console, CreateSharedFolder(Bstr(name), Bstr(hostpath), fWritable));847 848 if (console)849 a->session->Close();850 }851 else852 {853 /* open a session for the VM */854 CHECK_ERROR_RET(a->virtualBox, OpenSession(a->session, uuid), 1);855 856 /* get the mutable session machine */857 a->session->COMGETTER(Machine)(machine.asOutParam());858 859 CHECK_ERROR(machine, CreateSharedFolder(Bstr(name), Bstr(hostpath), fWritable));860 861 if (SUCCEEDED(rc))862 CHECK_ERROR(machine, SaveSettings());863 864 a->session->Close();865 }866 }867 else if (!strcmp(a->argv[0], "remove"))868 {869 /* we need at least two more parameters */870 if (a->argc < 3)871 return errorSyntax(USAGE_SHAREDFOLDER_REMOVE, "Not enough parameters");872 873 char *name = NULL;874 bool fTransient = false;875 876 for (int i = 2; i < a->argc; i++)877 {878 if ( !strcmp(a->argv[i], "--name")879 || !strcmp(a->argv[i], "-name"))880 {881 if (a->argc <= i + 1 || !*a->argv[i+1])882 return errorArgument("Missing argument to '%s'", a->argv[i]);883 i++;884 name = a->argv[i];885 }886 else if ( !strcmp(a->argv[i], "--transient")887 || !strcmp(a->argv[i], "-transient"))888 {889 fTransient = true;890 }891 else892 return errorSyntax(USAGE_SHAREDFOLDER_REMOVE, "Invalid parameter '%s'", Utf8Str(a->argv[i]).raw());893 }894 895 /* required arguments */896 if (!name)897 return errorSyntax(USAGE_SHAREDFOLDER_REMOVE, "Parameter --name is required");898 899 if (fTransient)900 {901 ComPtr <IConsole> console;902 903 /* open an existing session for the VM */904 CHECK_ERROR_RET(a->virtualBox, OpenExistingSession(a->session, uuid), 1);905 /* get the session machine */906 CHECK_ERROR_RET(a->session, COMGETTER(Machine)(machine.asOutParam()), 1);907 /* get the session console */908 CHECK_ERROR_RET(a->session, COMGETTER(Console)(console.asOutParam()), 1);909 910 CHECK_ERROR(console, RemoveSharedFolder(Bstr(name)));911 912 if (console)913 a->session->Close();914 }915 else916 {917 /* open a session for the VM */918 CHECK_ERROR_RET(a->virtualBox, OpenSession(a->session, uuid), 1);919 920 /* get the mutable session machine */921 a->session->COMGETTER(Machine)(machine.asOutParam());922 923 CHECK_ERROR(machine, RemoveSharedFolder(Bstr(name)));924 925 /* commit and close the session */926 CHECK_ERROR(machine, SaveSettings());927 a->session->Close();928 }929 }930 else931 return errorSyntax(USAGE_SETPROPERTY, "Invalid parameter '%s'", Utf8Str(a->argv[0]).raw());932 933 return 0;934 }935 936 static int handleVMStatistics(HandlerArg *a)937 {938 HRESULT rc;939 940 /* at least one option: the UUID or name of the VM */941 if (a->argc < 1)942 return errorSyntax(USAGE_VM_STATISTICS, "Incorrect number of parameters");943 944 /* try to find the given machine */945 ComPtr <IMachine> machine;946 Bstr uuid (a->argv[0]);947 if (!Guid (a->argv[0]).isEmpty())948 CHECK_ERROR(a->virtualBox, GetMachine(uuid, machine.asOutParam()));949 else950 {951 CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()));952 if (SUCCEEDED (rc))953 machine->COMGETTER(Id)(uuid.asOutParam());954 }955 if (FAILED(rc))956 return 1;957 958 /* parse arguments. */959 bool fReset = false;960 bool fWithDescriptions = false;961 const char *pszPattern = NULL; /* all */962 for (int i = 1; i < a->argc; i++)963 {964 if ( !strcmp(a->argv[i], "--pattern")965 || !strcmp(a->argv[i], "-pattern"))966 {967 if (pszPattern)968 return errorSyntax(USAGE_VM_STATISTICS, "Multiple --patterns options is not permitted");969 if (i + 1 >= a->argc)970 return errorArgument("Missing argument to '%s'", a->argv[i]);971 pszPattern = a->argv[++i];972 }973 else if ( !strcmp(a->argv[i], "--descriptions")974 || !strcmp(a->argv[i], "-descriptions"))975 fWithDescriptions = true;976 /* add: --file <filename> and --formatted */977 else if ( !strcmp(a->argv[i], "--reset")978 || !strcmp(a->argv[i], "-reset"))979 fReset = true;980 else981 return errorSyntax(USAGE_VM_STATISTICS, "Unknown option '%s'", a->argv[i]);982 }983 if (fReset && fWithDescriptions)984 return errorSyntax(USAGE_VM_STATISTICS, "The --reset and --descriptions options does not mix");985 986 987 /* open an existing session for the VM. */988 CHECK_ERROR(a->virtualBox, OpenExistingSession(a->session, uuid));989 if (SUCCEEDED(rc))990 {991 /* get the session console. */992 ComPtr <IConsole> console;993 CHECK_ERROR(a->session, COMGETTER(Console)(console.asOutParam()));994 if (SUCCEEDED(rc))995 {996 /* get the machine debugger. */997 ComPtr <IMachineDebugger> debugger;998 CHECK_ERROR(console, COMGETTER(Debugger)(debugger.asOutParam()));999 if (SUCCEEDED(rc))1000 {1001 if (fReset)1002 CHECK_ERROR(debugger, ResetStats(Bstr(pszPattern)));1003 else1004 {1005 Bstr stats;1006 CHECK_ERROR(debugger, GetStats(Bstr(pszPattern), fWithDescriptions, stats.asOutParam()));1007 if (SUCCEEDED(rc))1008 {1009 /* if (fFormatted)1010 { big mess }1011 else1012 */1013 RTPrintf("%ls\n", stats.raw());1014 }1015 }1016 }1017 a->session->Close();1018 }1019 }1020 1021 return SUCCEEDED(rc) ? 0 : 1;1022 }1023 153 #endif /* !VBOX_ONLY_DOCS */ 1024 154 1025 // main1026 ///////////////////////////////////////////////////////////////////////////////1027 155 1028 156 int main(int argc, char *argv[]) … … 1095 223 int rc = 0; 1096 224 #else /* !VBOX_ONLY_DOCS */ 225 using namespace com; 1097 226 HRESULT rc = 0; 1098 227 … … 1252 381 return rc != 0; 1253 382 } 383 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r24903 r24907 187 187 int handleMetrics(HandlerArg *a); 188 188 189 /* VBoxManageMisc.cpp */ 190 int handleRegisterVM(HandlerArg *a); 191 int handleUnregisterVM(HandlerArg *a); 192 int handleCreateVM(HandlerArg *a); 193 int handleStartVM(HandlerArg *a); 194 int handleDiscardState(HandlerArg *a); 195 int handleAdoptdState(HandlerArg *a); 196 int handleGetExtraData(HandlerArg *a); 197 int handleSetExtraData(HandlerArg *a); 198 int handleSetProperty(HandlerArg *a); 199 int handleSharedFolder(HandlerArg *a); 200 int handleVMStatistics(HandlerArg *a); 201 189 202 /* VBoxManageDisk.cpp */ 190 203 int handleCreateHardDisk(HandlerArg *a); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r24903 r24907 62 62 #include "VBoxManage.h" 63 63 64 #ifndef VBOX_ONLY_DOCS65 64 using namespace com; 66 #endif /* !VBOX_ONLY_DOCS */ 67 68 /******************************************************************************* 69 * Global Variables * 70 *******************************************************************************/ 71 /*extern*/ bool g_fDetailedProgress = false; 72 73 //////////////////////////////////////////////////////////////////////////////// 74 // 75 // functions 76 // 77 //////////////////////////////////////////////////////////////////////////////// 78 79 #ifndef VBOX_ONLY_DOCS 80 /** 81 * Print out progress on the console 82 */ 83 HRESULT showProgress(ComPtr<IProgress> progress) 84 { 85 BOOL fCompleted; 86 ULONG ulCurrentPercent; 87 ULONG ulLastPercent = 0; 88 89 ULONG ulCurrentOperationPercent; 90 ULONG ulLastOperationPercent = (ULONG)-1; 91 92 ULONG ulLastOperation = (ULONG)-1; 93 Bstr bstrOperationDescription; 94 95 ULONG cOperations; 96 progress->COMGETTER(OperationCount)(&cOperations); 97 98 if (!g_fDetailedProgress) 99 { 100 RTPrintf("0%%..."); 101 RTStrmFlush(g_pStdOut); 102 } 103 104 while (SUCCEEDED(progress->COMGETTER(Completed(&fCompleted)))) 105 { 106 ULONG ulOperation; 107 progress->COMGETTER(Operation)(&ulOperation); 108 109 progress->COMGETTER(Percent(&ulCurrentPercent)); 110 progress->COMGETTER(OperationPercent(&ulCurrentOperationPercent)); 111 112 if (g_fDetailedProgress) 113 { 114 if (ulLastOperation != ulOperation) 115 { 116 progress->COMGETTER(OperationDescription(bstrOperationDescription.asOutParam())); 117 ulLastPercent = (ULONG)-1; // force print 118 ulLastOperation = ulOperation; 119 } 120 121 if ( (ulCurrentPercent != ulLastPercent) 122 || (ulCurrentOperationPercent != ulLastOperationPercent) 123 ) 124 { 125 LONG lSecsRem; 126 progress->COMGETTER(TimeRemaining)(&lSecsRem); 127 128 RTPrintf("(%ld/%ld) %ls %ld%% => %ld%% (%d s remaining)\n", ulOperation + 1, cOperations, bstrOperationDescription.raw(), ulCurrentOperationPercent, ulCurrentPercent, lSecsRem); 129 ulLastPercent = ulCurrentPercent; 130 ulLastOperationPercent = ulCurrentOperationPercent; 131 } 132 } 133 else 134 { 135 /* did we cross a 10% mark? */ 136 if (((ulCurrentPercent / 10) > (ulLastPercent / 10))) 137 { 138 /* make sure to also print out missed steps */ 139 for (ULONG curVal = (ulLastPercent / 10) * 10 + 10; curVal <= (ulCurrentPercent / 10) * 10; curVal += 10) 140 { 141 if (curVal < 100) 142 { 143 RTPrintf("%ld%%...", curVal); 144 RTStrmFlush(g_pStdOut); 145 } 146 } 147 ulLastPercent = (ulCurrentPercent / 10) * 10; 148 } 149 } 150 if (fCompleted) 151 break; 152 153 /* make sure the loop is not too tight */ 154 progress->WaitForCompletion(100); 155 } 156 157 /* complete the line. */ 158 LONG iRc = E_FAIL; 159 if (SUCCEEDED(progress->COMGETTER(ResultCode)(&iRc))) 160 { 161 if (SUCCEEDED(iRc)) 162 RTPrintf("100%%\n"); 163 else 164 RTPrintf("FAILED\n"); 165 } 166 else 167 RTPrintf("\n"); 168 RTStrmFlush(g_pStdOut); 169 return iRc; 170 } 171 172 static int handleRegisterVM(HandlerArg *a) 65 66 67 68 int handleRegisterVM(HandlerArg *a) 173 69 { 174 70 HRESULT rc; … … 209 105 }; 210 106 211 staticint handleUnregisterVM(HandlerArg *a)107 int handleUnregisterVM(HandlerArg *a) 212 108 { 213 109 HRESULT rc; … … 276 172 } 277 173 278 staticint handleCreateVM(HandlerArg *a)174 int handleCreateVM(HandlerArg *a) 279 175 { 280 176 HRESULT rc; … … 374 270 } 375 271 376 staticint handleStartVM(HandlerArg *a)272 int handleStartVM(HandlerArg *a) 377 273 { 378 274 HRESULT rc; … … 510 406 } 511 407 512 staticint handleDiscardState(HandlerArg *a)408 int handleDiscardState(HandlerArg *a) 513 409 { 514 410 HRESULT rc; … … 546 442 } 547 443 548 staticint handleAdoptdState(HandlerArg *a)444 int handleAdoptdState(HandlerArg *a) 549 445 { 550 446 HRESULT rc; … … 582 478 } 583 479 584 staticint handleGetExtraData(HandlerArg *a)480 int handleGetExtraData(HandlerArg *a) 585 481 { 586 482 HRESULT rc = S_OK; … … 662 558 } 663 559 664 staticint handleSetExtraData(HandlerArg *a)560 int handleSetExtraData(HandlerArg *a) 665 561 { 666 562 HRESULT rc = S_OK; … … 702 598 } 703 599 704 staticint handleSetProperty(HandlerArg *a)600 int handleSetProperty(HandlerArg *a) 705 601 { 706 602 HRESULT rc; … … 760 656 } 761 657 762 staticint handleSharedFolder(HandlerArg *a)658 int handleSharedFolder(HandlerArg *a) 763 659 { 764 660 HRESULT rc; … … 934 830 } 935 831 936 staticint handleVMStatistics(HandlerArg *a)832 int handleVMStatistics(HandlerArg *a) 937 833 { 938 834 HRESULT rc; … … 1021 917 return SUCCEEDED(rc) ? 0 : 1; 1022 918 } 1023 #endif /* !VBOX_ONLY_DOCS */ 1024 1025 // main 1026 /////////////////////////////////////////////////////////////////////////////// 1027 1028 int main(int argc, char *argv[]) 1029 { 1030 /* 1031 * Before we do anything, init the runtime without loading 1032 * the support driver. 1033 */ 1034 RTR3Init(); 1035 1036 bool fShowLogo = true; 1037 int iCmd = 1; 1038 int iCmdArg; 1039 1040 /* global options */ 1041 for (int i = 1; i < argc || argc <= iCmd; i++) 1042 { 1043 if ( argc <= iCmd 1044 || !strcmp(argv[i], "help") 1045 || !strcmp(argv[i], "-?") 1046 || !strcmp(argv[i], "-h") 1047 || !strcmp(argv[i], "-help") 1048 || !strcmp(argv[i], "--help")) 1049 { 1050 showLogo(); 1051 printUsage(USAGE_ALL); 1052 return 0; 1053 } 1054 1055 if ( !strcmp(argv[i], "-v") 1056 || !strcmp(argv[i], "-version") 1057 || !strcmp(argv[i], "-Version") 1058 || !strcmp(argv[i], "--version")) 1059 { 1060 /* Print version number, and do nothing else. */ 1061 RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision()); 1062 return 0; 1063 } 1064 1065 if ( !strcmp(argv[i], "--dumpopts") 1066 || !strcmp(argv[i], "-dumpopts")) 1067 { 1068 /* Special option to dump really all commands, 1069 * even the ones not understood on this platform. */ 1070 printUsage(USAGE_DUMPOPTS); 1071 return 0; 1072 } 1073 1074 if ( !strcmp(argv[i], "--nologo") 1075 || !strcmp(argv[i], "-nologo") 1076 || !strcmp(argv[i], "-q")) 1077 { 1078 /* suppress the logo */ 1079 fShowLogo = false; 1080 iCmd++; 1081 } 1082 else 1083 { 1084 break; 1085 } 1086 } 1087 1088 iCmdArg = iCmd + 1; 1089 1090 if (fShowLogo) 1091 showLogo(); 1092 1093 1094 #ifdef VBOX_ONLY_DOCS 1095 int rc = 0; 1096 #else /* !VBOX_ONLY_DOCS */ 1097 HRESULT rc = 0; 1098 1099 rc = com::Initialize(); 1100 if (FAILED(rc)) 1101 { 1102 RTPrintf("ERROR: failed to initialize COM!\n"); 1103 return rc; 1104 } 1105 1106 /* 1107 * The input is in the host OS'es codepage (NT guarantees ACP). 1108 * For VBox we use UTF-8 and convert to UCS-2 when calling (XP)COM APIs. 1109 * For simplicity, just convert the argv[] array here. 1110 */ 1111 for (int i = iCmdArg; i < argc; i++) 1112 { 1113 char *converted; 1114 RTStrCurrentCPToUtf8(&converted, argv[i]); 1115 argv[i] = converted; 1116 } 1117 1118 do 1119 { 1120 // scopes all the stuff till shutdown 1121 //////////////////////////////////////////////////////////////////////////// 1122 1123 /* convertfromraw: does not need a VirtualBox instantiation. */ 1124 if (argc >= iCmdArg && ( !strcmp(argv[iCmd], "convertfromraw") 1125 || !strcmp(argv[iCmd], "convertdd"))) 1126 { 1127 rc = handleConvertFromRaw(argc - iCmdArg, argv + iCmdArg); 1128 break; 1129 } 1130 1131 ComPtr<IVirtualBox> virtualBox; 1132 ComPtr<ISession> session; 1133 1134 rc = virtualBox.createLocalObject(CLSID_VirtualBox); 1135 if (FAILED(rc)) 1136 RTPrintf("ERROR: failed to create the VirtualBox object!\n"); 1137 else 1138 { 1139 rc = session.createInprocObject(CLSID_Session); 1140 if (FAILED(rc)) 1141 RTPrintf("ERROR: failed to create a session object!\n"); 1142 } 1143 1144 if (FAILED(rc)) 1145 { 1146 com::ErrorInfo info; 1147 if (!info.isFullAvailable() && !info.isBasicAvailable()) 1148 { 1149 com::GluePrintRCMessage(rc); 1150 RTPrintf("Most likely, the VirtualBox COM server is not running or failed to start.\n"); 1151 } 1152 else 1153 com::GluePrintErrorInfo(info); 1154 break; 1155 } 1156 1157 HandlerArg handlerArg = { 0, NULL, virtualBox, session }; 1158 1159 /* 1160 * All registered command handlers 1161 */ 1162 static const struct 1163 { 1164 const char *command; 1165 int (*handler)(HandlerArg *a); 1166 } s_commandHandlers[] = 1167 { 1168 { "internalcommands", handleInternalCommands }, 1169 { "list", handleList }, 1170 { "showvminfo", handleShowVMInfo }, 1171 { "registervm", handleRegisterVM }, 1172 { "unregistervm", handleUnregisterVM }, 1173 { "createhd", handleCreateHardDisk }, 1174 { "createvdi", handleCreateHardDisk }, /* backward compatiblity */ 1175 { "modifyhd", handleModifyHardDisk }, 1176 { "modifyvdi", handleModifyHardDisk }, /* backward compatiblity */ 1177 { "clonehd", handleCloneHardDisk }, 1178 { "clonevdi", handleCloneHardDisk }, /* backward compatiblity */ 1179 { "addiscsidisk", handleAddiSCSIDisk }, 1180 { "createvm", handleCreateVM }, 1181 { "modifyvm", handleModifyVM }, 1182 { "startvm", handleStartVM }, 1183 { "controlvm", handleControlVM }, 1184 { "discardstate", handleDiscardState }, 1185 { "adoptstate", handleAdoptdState }, 1186 { "snapshot", handleSnapshot }, 1187 { "openmedium", handleOpenMedium }, 1188 { "registerimage", handleOpenMedium }, /* backward compatiblity */ 1189 { "closemedium", handleCloseMedium }, 1190 { "unregisterimage", handleCloseMedium }, /* backward compatiblity */ 1191 { "storageattach", handleStorageAttach }, 1192 { "storagectl", handleStorageController }, 1193 { "showhdinfo", handleShowHardDiskInfo }, 1194 { "showvdiinfo", handleShowHardDiskInfo }, /* backward compatiblity */ 1195 { "getextradata", handleGetExtraData }, 1196 { "setextradata", handleSetExtraData }, 1197 { "setproperty", handleSetProperty }, 1198 { "usbfilter", handleUSBFilter }, 1199 { "sharedfolder", handleSharedFolder }, 1200 { "vmstatistics", handleVMStatistics }, 1201 #ifdef VBOX_WITH_GUEST_PROPS 1202 { "guestproperty", handleGuestProperty }, 1203 #endif 1204 { "metrics", handleMetrics }, 1205 { "import", handleImportAppliance }, 1206 { "export", handleExportAppliance }, 1207 #ifdef VBOX_WITH_NETFLT 1208 { "hostonlyif", handleHostonlyIf }, 1209 #endif 1210 { "dhcpserver", handleDHCPServer}, 1211 { NULL, NULL } 1212 }; 1213 1214 int commandIndex; 1215 for (commandIndex = 0; s_commandHandlers[commandIndex].command != NULL; commandIndex++) 1216 { 1217 if (!strcmp(s_commandHandlers[commandIndex].command, argv[iCmd])) 1218 { 1219 handlerArg.argc = argc - iCmdArg; 1220 handlerArg.argv = &argv[iCmdArg]; 1221 1222 rc = s_commandHandlers[commandIndex].handler(&handlerArg); 1223 break; 1224 } 1225 } 1226 if (!s_commandHandlers[commandIndex].command) 1227 { 1228 rc = errorSyntax(USAGE_ALL, "Invalid command '%s'", Utf8Str(argv[iCmd]).raw()); 1229 } 1230 1231 /* Although all handlers should always close the session if they open it, 1232 * we do it here just in case if some of the handlers contains a bug -- 1233 * leaving the direct session not closed will turn the machine state to 1234 * Aborted which may have unwanted side effects like killing the saved 1235 * state file (if the machine was in the Saved state before). */ 1236 session->Close(); 1237 1238 EventQueue::getMainEventQueue()->processEventQueue(0); 1239 // end "all-stuff" scope 1240 //////////////////////////////////////////////////////////////////////////// 1241 } while (0); 1242 1243 com::Shutdown(); 1244 #endif /* !VBOX_ONLY_DOCS */ 1245 1246 /* 1247 * Free converted argument vector 1248 */ 1249 for (int i = iCmdArg; i < argc; i++) 1250 RTStrFree(argv[i]); 1251 1252 return rc != 0; 1253 } 919
Note:
See TracChangeset
for help on using the changeset viewer.