VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp@ 56099

Last change on this file since 56099 was 56099, checked in by vboxsync, 10 years ago

VBoxManage: Don't use g_ for local variables, duh.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.4 KB
Line 
1/* $Id: VBoxManage.cpp 56099 2015-05-27 13:12:03Z vboxsync $ */
2/** @file
3 * VBoxManage - VirtualBox's command-line interface.
4 */
5
6/*
7 * Copyright (C) 2006-2015 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#ifndef VBOX_ONLY_DOCS
23# include <VBox/com/com.h>
24# include <VBox/com/string.h>
25# include <VBox/com/Guid.h>
26# include <VBox/com/array.h>
27# include <VBox/com/ErrorInfo.h>
28# include <VBox/com/errorprint.h>
29# include <VBox/com/NativeEventQueue.h>
30
31# include <VBox/com/VirtualBox.h>
32#endif /* !VBOX_ONLY_DOCS */
33
34#include <VBox/err.h>
35#include <VBox/version.h>
36
37#include <iprt/asm.h>
38#include <iprt/buildconfig.h>
39#include <iprt/ctype.h>
40#include <iprt/initterm.h>
41#include <iprt/path.h>
42#include <iprt/stream.h>
43#include <iprt/string.h>
44
45#include <signal.h>
46
47#include "VBoxManage.h"
48
49
50/*******************************************************************************
51* Global Variables *
52*******************************************************************************/
53/*extern*/ bool g_fDetailedProgress = false;
54
55#ifndef VBOX_ONLY_DOCS
56/** Set by the signal handler. */
57static volatile bool g_fCanceled = false;
58
59
60/**
61 * Signal handler that sets g_fCanceled.
62 *
63 * This can be executed on any thread in the process, on Windows it may even be
64 * a thread dedicated to delivering this signal. Do not doing anything
65 * unnecessary here.
66 */
67static void showProgressSignalHandler(int iSignal)
68{
69 NOREF(iSignal);
70 ASMAtomicWriteBool(&g_fCanceled, true);
71}
72
73/**
74 * Print out progress on the console.
75 *
76 * This runs the main event queue every now and then to prevent piling up
77 * unhandled things (which doesn't cause real problems, just makes things
78 * react a little slower than in the ideal case).
79 */
80HRESULT showProgress(ComPtr<IProgress> progress)
81{
82 using namespace com;
83
84 BOOL fCompleted = FALSE;
85 ULONG ulCurrentPercent = 0;
86 ULONG ulLastPercent = 0;
87
88 ULONG ulLastOperationPercent = (ULONG)-1;
89
90 ULONG ulLastOperation = (ULONG)-1;
91 Bstr bstrOperationDescription;
92
93 NativeEventQueue::getMainEventQueue()->processEventQueue(0);
94
95 ULONG cOperations = 1;
96 HRESULT hrc = progress->COMGETTER(OperationCount)(&cOperations);
97 if (FAILED(hrc))
98 {
99 RTStrmPrintf(g_pStdErr, "Progress object failure: %Rhrc\n", hrc);
100 RTStrmFlush(g_pStdErr);
101 return hrc;
102 }
103
104 /*
105 * Note: Outputting the progress info to stderr (g_pStdErr) is intentional
106 * to not get intermixed with other (raw) stdout data which might get
107 * written in the meanwhile.
108 */
109
110 if (!g_fDetailedProgress)
111 {
112 RTStrmPrintf(g_pStdErr, "0%%...");
113 RTStrmFlush(g_pStdErr);
114 }
115
116 /* setup signal handling if cancelable */
117 bool fCanceledAlready = false;
118 BOOL fCancelable;
119 hrc = progress->COMGETTER(Cancelable)(&fCancelable);
120 if (FAILED(hrc))
121 fCancelable = FALSE;
122 if (fCancelable)
123 {
124 signal(SIGINT, showProgressSignalHandler);
125#ifdef SIGBREAK
126 signal(SIGBREAK, showProgressSignalHandler);
127#endif
128 }
129
130 hrc = progress->COMGETTER(Completed(&fCompleted));
131 while (SUCCEEDED(hrc))
132 {
133 progress->COMGETTER(Percent(&ulCurrentPercent));
134
135 if (g_fDetailedProgress)
136 {
137 ULONG ulOperation = 1;
138 hrc = progress->COMGETTER(Operation)(&ulOperation);
139 if (FAILED(hrc))
140 break;
141 ULONG ulCurrentOperationPercent = 0;
142 hrc = progress->COMGETTER(OperationPercent(&ulCurrentOperationPercent));
143 if (FAILED(hrc))
144 break;
145
146 if (ulLastOperation != ulOperation)
147 {
148 hrc = progress->COMGETTER(OperationDescription(bstrOperationDescription.asOutParam()));
149 if (FAILED(hrc))
150 break;
151 ulLastPercent = (ULONG)-1; // force print
152 ulLastOperation = ulOperation;
153 }
154
155 if ( ulCurrentPercent != ulLastPercent
156 || ulCurrentOperationPercent != ulLastOperationPercent
157 )
158 {
159 LONG lSecsRem = 0;
160 progress->COMGETTER(TimeRemaining)(&lSecsRem);
161
162 RTStrmPrintf(g_pStdErr, "(%u/%u) %ls %02u%% => %02u%% (%d s remaining)\n", ulOperation + 1, cOperations,
163 bstrOperationDescription.raw(), ulCurrentOperationPercent, ulCurrentPercent, lSecsRem);
164 ulLastPercent = ulCurrentPercent;
165 ulLastOperationPercent = ulCurrentOperationPercent;
166 }
167 }
168 else
169 {
170 /* did we cross a 10% mark? */
171 if (ulCurrentPercent / 10 > ulLastPercent / 10)
172 {
173 /* make sure to also print out missed steps */
174 for (ULONG curVal = (ulLastPercent / 10) * 10 + 10; curVal <= (ulCurrentPercent / 10) * 10; curVal += 10)
175 {
176 if (curVal < 100)
177 {
178 RTStrmPrintf(g_pStdErr, "%u%%...", curVal);
179 RTStrmFlush(g_pStdErr);
180 }
181 }
182 ulLastPercent = (ulCurrentPercent / 10) * 10;
183 }
184 }
185 if (fCompleted)
186 break;
187
188 /* process async cancelation */
189 if (g_fCanceled && !fCanceledAlready)
190 {
191 hrc = progress->Cancel();
192 if (SUCCEEDED(hrc))
193 fCanceledAlready = true;
194 else
195 g_fCanceled = false;
196 }
197
198 /* make sure the loop is not too tight */
199 progress->WaitForCompletion(100);
200
201 NativeEventQueue::getMainEventQueue()->processEventQueue(0);
202 hrc = progress->COMGETTER(Completed(&fCompleted));
203 }
204
205 /* undo signal handling */
206 if (fCancelable)
207 {
208 signal(SIGINT, SIG_DFL);
209#ifdef SIGBREAK
210 signal(SIGBREAK, SIG_DFL);
211#endif
212 }
213
214 /* complete the line. */
215 LONG iRc = E_FAIL;
216 hrc = progress->COMGETTER(ResultCode)(&iRc);
217 if (SUCCEEDED(hrc))
218 {
219 if (SUCCEEDED(iRc))
220 RTStrmPrintf(g_pStdErr, "100%%\n");
221 else if (g_fCanceled)
222 RTStrmPrintf(g_pStdErr, "CANCELED\n");
223 else
224 {
225 if (!g_fDetailedProgress)
226 RTStrmPrintf(g_pStdErr, "\n");
227 RTStrmPrintf(g_pStdErr, "Progress state: %Rhrc\n", iRc);
228 }
229 hrc = iRc;
230 }
231 else
232 {
233 if (!g_fDetailedProgress)
234 RTStrmPrintf(g_pStdErr, "\n");
235 RTStrmPrintf(g_pStdErr, "Progress object failure: %Rhrc\n", hrc);
236 }
237 RTStrmFlush(g_pStdErr);
238 return hrc;
239}
240
241#ifdef RT_OS_WINDOWS
242// Required for ATL
243static CComModule _Module;
244#endif
245
246#endif /* !VBOX_ONLY_DOCS */
247
248
249#ifndef VBOX_ONLY_DOCS
250RTEXITCODE readPasswordFile(const char *pszFilename, com::Utf8Str *pPasswd)
251{
252 size_t cbFile;
253 char szPasswd[512];
254 int vrc = VINF_SUCCESS;
255 RTEXITCODE rcExit = RTEXITCODE_SUCCESS;
256 bool fStdIn = !strcmp(pszFilename, "stdin");
257 PRTSTREAM pStrm;
258 if (!fStdIn)
259 vrc = RTStrmOpen(pszFilename, "r", &pStrm);
260 else
261 pStrm = g_pStdIn;
262 if (RT_SUCCESS(vrc))
263 {
264 vrc = RTStrmReadEx(pStrm, szPasswd, sizeof(szPasswd)-1, &cbFile);
265 if (RT_SUCCESS(vrc))
266 {
267 if (cbFile >= sizeof(szPasswd)-1)
268 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Provided password in file '%s' is too long", pszFilename);
269 else
270 {
271 unsigned i;
272 for (i = 0; i < cbFile && !RT_C_IS_CNTRL(szPasswd[i]); i++)
273 ;
274 szPasswd[i] = '\0';
275 *pPasswd = szPasswd;
276 }
277 }
278 else
279 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Cannot read password from file '%s': %Rrc", pszFilename, vrc);
280 if (!fStdIn)
281 RTStrmClose(pStrm);
282 }
283 else
284 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Cannot open password file '%s' (%Rrc)", pszFilename, vrc);
285
286 return rcExit;
287}
288
289static RTEXITCODE settingsPasswordFile(ComPtr<IVirtualBox> virtualBox, const char *pszFilename)
290{
291 com::Utf8Str passwd;
292 RTEXITCODE rcExit = readPasswordFile(pszFilename, &passwd);
293 if (rcExit == RTEXITCODE_SUCCESS)
294 {
295 int rc;
296 CHECK_ERROR(virtualBox, SetSettingsSecret(com::Bstr(passwd).raw()));
297 if (FAILED(rc))
298 rcExit = RTEXITCODE_FAILURE;
299 }
300
301 return rcExit;
302}
303
304RTEXITCODE readPasswordFromConsole(com::Utf8Str *pPassword, const char *pszPrompt, ...)
305{
306 RTEXITCODE rcExit = RTEXITCODE_SUCCESS;
307 char aszPwdInput[_1K] = { 0 };
308 va_list vaArgs;
309
310 va_start(vaArgs, pszPrompt);
311 int vrc = RTStrmPrintfV(g_pStdOut, pszPrompt, vaArgs);
312 if (RT_SUCCESS(vrc))
313 {
314 bool fEchoOld = false;
315 vrc = RTStrmInputGetEchoChars(g_pStdIn, &fEchoOld);
316 if (RT_SUCCESS(vrc))
317 {
318 vrc = RTStrmInputSetEchoChars(g_pStdIn, false);
319 if (RT_SUCCESS(vrc))
320 {
321 vrc = RTStrmGetLine(g_pStdIn, &aszPwdInput[0], sizeof(aszPwdInput));
322 if (RT_SUCCESS(vrc))
323 *pPassword = aszPwdInput;
324 else
325 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed read password from command line (%Rrc)", vrc);
326
327 int vrc2 = RTStrmInputSetEchoChars(g_pStdIn, fEchoOld);
328 AssertRC(vrc2);
329 }
330 else
331 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to disable echoing typed characters (%Rrc)", vrc);
332 }
333 else
334 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to retrieve echo setting (%Rrc)", vrc);
335
336 RTStrmPutStr(g_pStdOut, "\n");
337 }
338 else
339 rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to print prompt (%Rrc)", vrc);
340 va_end(vaArgs);
341
342 return rcExit;
343}
344
345#endif
346
347int main(int argc, char *argv[])
348{
349 /*
350 * Before we do anything, init the runtime without loading
351 * the support driver.
352 */
353 RTR3InitExe(argc, &argv, 0);
354
355 /*
356 * Parse the global options
357 */
358 bool fShowLogo = false;
359 bool fShowHelp = false;
360 int iCmd = 1;
361 int iCmdArg;
362 const char *pszSettingsPw = NULL;
363 const char *pszSettingsPwFile = NULL;
364
365 for (int i = 1; i < argc || argc <= iCmd; i++)
366 {
367 if ( argc <= iCmd
368 || !strcmp(argv[i], "help")
369 || !strcmp(argv[i], "--help")
370 || !strcmp(argv[i], "-?")
371 || !strcmp(argv[i], "-h")
372 || !strcmp(argv[i], "-help"))
373 {
374 if (i >= argc - 1)
375 {
376 showLogo(g_pStdOut);
377 printUsage(USAGE_ALL, ~0U, g_pStdOut);
378 return 0;
379 }
380 fShowLogo = true;
381 fShowHelp = true;
382 iCmd++;
383 continue;
384 }
385
386 if ( !strcmp(argv[i], "-V")
387 || !strcmp(argv[i], "--version")
388 || !strcmp(argv[i], "-v") /* deprecated */
389 || !strcmp(argv[i], "-version") /* deprecated */
390 || !strcmp(argv[i], "-Version") /* deprecated */)
391 {
392 /* Print version number, and do nothing else. */
393 RTPrintf("%sr%u\n", VBOX_VERSION_STRING, RTBldCfgRevision());
394 return 0;
395 }
396
397 if ( !strcmp(argv[i], "--dumpopts")
398 || !strcmp(argv[i], "-dumpopts") /* deprecated */)
399 {
400 /* Special option to dump really all commands,
401 * even the ones not understood on this platform. */
402 printUsage(USAGE_DUMPOPTS, ~0U, g_pStdOut);
403 return 0;
404 }
405
406 if ( !strcmp(argv[i], "--nologo")
407 || !strcmp(argv[i], "-q")
408 || !strcmp(argv[i], "-nologo") /* deprecated */)
409 {
410 /* suppress the logo */
411 fShowLogo = false;
412 iCmd++;
413 }
414 else if ( !strcmp(argv[i], "--detailed-progress")
415 || !strcmp(argv[i], "-d"))
416 {
417 /* detailed progress report */
418 g_fDetailedProgress = true;
419 iCmd++;
420 }
421 else if (!strcmp(argv[i], "--settingspw"))
422 {
423 if (i >= argc - 1)
424 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Password expected");
425 /* password for certain settings */
426 pszSettingsPw = argv[i + 1];
427 iCmd += 2;
428 }
429 else if (!strcmp(argv[i], "--settingspwfile"))
430 {
431 if (i >= argc-1)
432 return RTMsgErrorExit(RTEXITCODE_FAILURE, "No password file specified");
433 pszSettingsPwFile = argv[i+1];
434 iCmd += 2;
435 }
436 else
437 break;
438 }
439
440 iCmdArg = iCmd + 1;
441
442 if (fShowLogo)
443 showLogo(g_pStdOut);
444
445
446#ifndef VBOX_ONLY_DOCS
447 /*
448 * Initialize COM.
449 */
450 using namespace com;
451 HRESULT hrc = com::Initialize();
452# ifdef VBOX_WITH_XPCOM
453 if (hrc == NS_ERROR_FILE_ACCESS_DENIED)
454 {
455 char szHome[RTPATH_MAX] = "";
456 com::GetVBoxUserHomeDirectory(szHome, sizeof(szHome));
457 return RTMsgErrorExit(RTEXITCODE_FAILURE,
458 "Failed to initialize COM because the global settings directory '%s' is not accessible!", szHome);
459 }
460# endif
461 if (FAILED(hrc))
462 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to initialize COM!");
463
464 RTEXITCODE rcExit = RTEXITCODE_FAILURE;
465 do
466 {
467 ///////////////////////////////////////////////////////////////////////////
468 // scopes all the stuff till shutdown
469 /*
470 * convertfromraw: does not need a VirtualBox instantiation.
471 */
472 if (argc >= iCmdArg && ( !strcmp(argv[iCmd], "convertfromraw")
473 || !strcmp(argv[iCmd], "convertdd")))
474 {
475 rcExit = handleConvertFromRaw(argc - iCmdArg, argv + iCmdArg);
476 break;
477 }
478
479 /*
480 * Get the remote VirtualBox object and create a local session object.
481 */
482 ComPtr<IVirtualBox> virtualBox;
483 ComPtr<ISession> session;
484
485 hrc = virtualBox.createLocalObject(CLSID_VirtualBox);
486 if (FAILED(hrc))
487 RTMsgError("Failed to create the VirtualBox object!");
488 else
489 {
490 hrc = session.createInprocObject(CLSID_Session);
491 if (FAILED(hrc))
492 RTMsgError("Failed to create a session object!");
493 }
494 if (FAILED(hrc))
495 {
496 com::ErrorInfo info;
497 if (!info.isFullAvailable() && !info.isBasicAvailable())
498 {
499 com::GluePrintRCMessage(hrc);
500 RTMsgError("Most likely, the VirtualBox COM server is not running or failed to start.");
501 }
502 else
503 com::GluePrintErrorInfo(info);
504 break;
505 }
506
507 /*
508 * All registered command handlers
509 */
510 static const struct
511 {
512 const char *command;
513 USAGECATEGORY help;
514 int (*handler)(HandlerArg *a);
515 } s_commandHandlers[] =
516 {
517 { "internalcommands", 0, handleInternalCommands },
518 { "list", USAGE_LIST, handleList },
519 { "showvminfo", USAGE_SHOWVMINFO, handleShowVMInfo },
520 { "registervm", USAGE_REGISTERVM, handleRegisterVM },
521 { "unregistervm", USAGE_UNREGISTERVM, handleUnregisterVM },
522 { "clonevm", USAGE_CLONEVM, handleCloneVM },
523 { "mediumproperty", USAGE_MEDIUMPROPERTY, handleMediumProperty },
524 { "hdproperty", USAGE_MEDIUMPROPERTY, handleMediumProperty }, /* backward compatibility */
525 { "createmedium", USAGE_CREATEMEDIUM, handleCreateMedium },
526 { "createhd", USAGE_CREATEMEDIUM, handleCreateMedium }, /* backward compatibility */
527 { "createvdi", USAGE_CREATEMEDIUM, handleCreateMedium }, /* backward compatibility */
528 { "modifymedium", USAGE_MODIFYMEDIUM, handleModifyMedium },
529 { "modifyhd", USAGE_MODIFYMEDIUM, handleModifyMedium }, /* backward compatibility */
530 { "modifyvdi", USAGE_MODIFYMEDIUM, handleModifyMedium }, /* backward compatibility */
531 { "clonemedium", USAGE_CLONEMEDIUM, handleCloneMedium },
532 { "clonehd", USAGE_CLONEMEDIUM, handleCloneMedium }, /* backward compatibility */
533 { "clonevdi", USAGE_CLONEMEDIUM, handleCloneMedium }, /* backward compatibility */
534 { "encryptmedium", USAGE_ENCRYPTMEDIUM, handleEncryptMedium},
535 { "checkmediumpwd", USAGE_MEDIUMENCCHKPWD, handleCheckMediumPassword},
536 { "createvm", USAGE_CREATEVM, handleCreateVM },
537 { "modifyvm", USAGE_MODIFYVM, handleModifyVM },
538 { "startvm", USAGE_STARTVM, handleStartVM },
539 { "controlvm", USAGE_CONTROLVM, handleControlVM },
540 { "discardstate", USAGE_DISCARDSTATE, handleDiscardState },
541 { "adoptstate", USAGE_ADOPTSTATE, handleAdoptState },
542 { "snapshot", USAGE_SNAPSHOT, handleSnapshot },
543 { "closemedium", USAGE_CLOSEMEDIUM, handleCloseMedium },
544 { "storageattach", USAGE_STORAGEATTACH, handleStorageAttach },
545 { "storagectl", USAGE_STORAGECONTROLLER, handleStorageController },
546 { "showmediuminfo", USAGE_SHOWMEDIUMINFO, handleShowMediumInfo },
547 { "showhdinfo", USAGE_SHOWMEDIUMINFO, handleShowMediumInfo }, /* backward compatibility */
548 { "showvdiinfo", USAGE_SHOWMEDIUMINFO, handleShowMediumInfo }, /* backward compatibility */
549 { "getextradata", USAGE_GETEXTRADATA, handleGetExtraData },
550 { "setextradata", USAGE_SETEXTRADATA, handleSetExtraData },
551 { "setproperty", USAGE_SETPROPERTY, handleSetProperty },
552 { "usbfilter", USAGE_USBFILTER, handleUSBFilter },
553 { "sharedfolder", USAGE_SHAREDFOLDER, handleSharedFolder },
554#ifdef VBOX_WITH_GUEST_PROPS
555 { "guestproperty", USAGE_GUESTPROPERTY, handleGuestProperty },
556#endif
557#ifdef VBOX_WITH_GUEST_CONTROL
558 { "guestcontrol", USAGE_GUESTCONTROL, handleGuestControl },
559#endif
560 { "metrics", USAGE_METRICS, handleMetrics },
561 { "import", USAGE_IMPORTAPPLIANCE, handleImportAppliance },
562 { "export", USAGE_EXPORTAPPLIANCE, handleExportAppliance },
563#ifdef VBOX_WITH_NETFLT
564 { "hostonlyif", USAGE_HOSTONLYIFS, handleHostonlyIf },
565#endif
566 { "dhcpserver", USAGE_DHCPSERVER, handleDHCPServer},
567#ifdef VBOX_WITH_NAT_SERVICE
568 { "natnetwork", USAGE_NATNETWORK, handleNATNetwork},
569#endif
570 { "extpack", USAGE_EXTPACK, handleExtPack},
571 { "bandwidthctl", USAGE_BANDWIDTHCONTROL, handleBandwidthControl},
572 { "debugvm", USAGE_DEBUGVM, handleDebugVM},
573 { NULL, 0, NULL }
574 };
575
576 if (pszSettingsPw)
577 {
578 int rc;
579 CHECK_ERROR(virtualBox, SetSettingsSecret(Bstr(pszSettingsPw).raw()));
580 if (FAILED(rc))
581 {
582 rcExit = RTEXITCODE_FAILURE;
583 break;
584 }
585 }
586 else if (pszSettingsPwFile)
587 {
588 rcExit = settingsPasswordFile(virtualBox, pszSettingsPwFile);
589 if (rcExit != RTEXITCODE_SUCCESS)
590 break;
591 }
592
593 HandlerArg handlerArg = { 0, NULL, virtualBox, session };
594 int commandIndex;
595 for (commandIndex = 0; s_commandHandlers[commandIndex].command != NULL; commandIndex++)
596 {
597 if (!strcmp(s_commandHandlers[commandIndex].command, argv[iCmd]))
598 {
599 handlerArg.argc = argc - iCmdArg;
600 handlerArg.argv = &argv[iCmdArg];
601
602 if ( fShowHelp
603 || ( argc - iCmdArg == 0
604 && s_commandHandlers[commandIndex].help))
605 {
606 printUsage(s_commandHandlers[commandIndex].help, ~0U, g_pStdOut);
607 rcExit = RTEXITCODE_FAILURE; /* error */
608 }
609 else
610 rcExit = (RTEXITCODE)s_commandHandlers[commandIndex].handler(&handlerArg); /** @todo Change to return RTEXITCODE. */
611 break;
612 }
613 }
614 if (!s_commandHandlers[commandIndex].command)
615 {
616 /* Help topics. */
617 if (fShowHelp && !strcmp(argv[iCmd], "commands"))
618 {
619 RTPrintf("commands:\n");
620 for (unsigned i = 0; i < RT_ELEMENTS(s_commandHandlers) - 1; i++)
621 if ( i == 0 /* skip backwards compatibility entries */
622 || s_commandHandlers[i].help != s_commandHandlers[i - 1].help)
623 RTPrintf(" %s\n", s_commandHandlers[i].command);
624 }
625 else
626 rcExit = errorSyntax(USAGE_ALL, "Invalid command '%s'", Utf8Str(argv[iCmd]).c_str());
627 }
628
629 /* Although all handlers should always close the session if they open it,
630 * we do it here just in case if some of the handlers contains a bug --
631 * leaving the direct session not closed will turn the machine state to
632 * Aborted which may have unwanted side effects like killing the saved
633 * state file (if the machine was in the Saved state before). */
634 session->UnlockMachine();
635
636 NativeEventQueue::getMainEventQueue()->processEventQueue(0);
637
638 // end "all-stuff" scope
639 ///////////////////////////////////////////////////////////////////////////
640 } while (0);
641
642 com::Shutdown();
643
644 return rcExit;
645#else /* VBOX_ONLY_DOCS */
646 return RTEXITCODE_SUCCESS;
647#endif /* VBOX_ONLY_DOCS */
648}
Note: See TracBrowser for help on using the repository browser.

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