VirtualBox

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

Last change on this file since 56843 was 56843, checked in by vboxsync, 9 years ago

Frontends/VBoxManage: Add a modifyvm option to rename USB controllers, use "xHCI" as the default xHCI controller name, and remove USB controllers by type, not by hardcoded name.
Frontends/VirtualBox: Use "xHCI" as the default xHCI controller name, and remove USB controllers by type, not by hardcoded name.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 67.9 KB
Line 
1/* $Id: VBoxManageHelp.cpp 56843 2015-07-07 16:03:53Z vboxsync $ */
2/** @file
3 * VBoxManage - help and other message output.
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#include <VBox/version.h>
23
24#include <iprt/buildconfig.h>
25#include <iprt/ctype.h>
26#include <iprt/err.h>
27#include <iprt/getopt.h>
28#include <iprt/stream.h>
29
30#include "VBoxManage.h"
31
32/*******************************************************************************
33* Defined Constants And Macros *
34*******************************************************************************/
35/** If the usage is the given number of length long or longer, the error is
36 * repeated so the user can actually see it. */
37#define ERROR_REPEAT_AFTER_USAGE_LENGTH 16
38
39
40/*******************************************************************************
41* Global Variables *
42*******************************************************************************/
43#ifndef VBOX_ONLY_DOCS
44enum HELP_CMD_VBOXMANAGE g_enmCurCommand = HELP_CMD_VBOXMANAGE_INVALID;
45/** The scope maskt for the current subcommand. */
46uint64_t g_fCurSubcommandScope = REFENTRYSTR_SCOPE_GLOBAL;
47/** String of spaces that can be used for indentation. */
48static const char g_szSpaces[] = " ";
49
50/**
51 * Sets the current command.
52 *
53 * This affects future calls to error and help functions.
54 *
55 * @param enmCommand The command.
56 */
57void setCurrentCommand(enum HELP_CMD_VBOXMANAGE enmCommand)
58{
59 Assert(g_enmCurCommand == HELP_CMD_VBOXMANAGE_INVALID);
60 g_enmCurCommand = enmCommand;
61 g_fCurSubcommandScope = REFENTRYSTR_SCOPE_GLOBAL;
62}
63
64
65/**
66 * Sets the current subcommand.
67 *
68 * This affects future calls to error and help functions.
69 *
70 * @param fSubcommandScope The subcommand scope.
71 */
72void setCurrentSubcommand(uint64_t fSubcommandScope)
73{
74 g_fCurSubcommandScope = fSubcommandScope;
75}
76
77
78
79/**
80 * Retruns the width for the given handle.
81 *
82 * @returns Screen width.
83 * @param pStrm The stream, g_pStdErr or g_pStdOut.
84 */
85static uint32_t getScreenWidth(PRTSTREAM pStrm)
86{
87 static uint32_t s_acch[2] = { 0, 0};
88 uint32_t iWhich = pStrm == g_pStdErr ? 1 : 0;
89 uint32_t cch = s_acch[iWhich];
90 if (cch)
91 return cch;
92
93 cch = 80; /** @todo screen width IPRT API. */
94 s_acch[iWhich] = cch;
95 return cch;
96}
97
98
99/**
100 * Prints a string table string (paragraph), performing non-breaking-space
101 * replacement and wrapping.
102 *
103 * @returns Number of lines written.
104 * @param pStrm The output stream.
105 * @param psz The string table string to print.
106 * @param cchMaxWidth The maximum output width.
107 * @param fFlags String flags that may affect formatting.
108 */
109static uint32_t printString(PRTSTREAM pStrm, const char *psz, uint32_t cchMaxWidth, uint64_t fFlags)
110{
111 uint32_t cLinesWritten;
112 size_t cch = strlen(psz);
113 const char *pszNbsp = strchr(psz, REFENTRY_NBSP);
114
115 /*
116 * No-wrap case is simpler, so handle that separately.
117 */
118 if (cch <= cchMaxWidth)
119 {
120 if (!pszNbsp)
121 RTStrmWrite(pStrm, psz, cch);
122 else
123 {
124 do
125 {
126 RTStrmWrite(pStrm, psz, pszNbsp - psz);
127 RTStrmPutCh(pStrm, ' ');
128 psz = pszNbsp + 1;
129 pszNbsp = strchr(psz, REFENTRY_NBSP);
130 } while (pszNbsp);
131 RTStrmWrite(pStrm, psz, strlen(psz));
132 }
133 RTStrmPutCh(pStrm, '\n');
134 cLinesWritten = 1;
135 }
136 /*
137 * We need to wrap stuff, too bad.
138 */
139 else
140 {
141 /* Figure the paragraph indent level first. */
142 const char * const pszIndent = psz;
143 uint32_t cchIndent = 0;
144 while (*psz == ' ')
145 cchIndent++, psz++;
146 Assert(cchIndent + 4 + 1 <= RT_ELEMENTS(g_szSpaces));
147
148 if (cchIndent + 8 >= cchMaxWidth)
149 cchMaxWidth += cchIndent + 8;
150
151 /* Work our way thru the string, line by line. */
152 uint32_t cchHangingIndent = 0;
153 cLinesWritten = 0;
154 do
155 {
156 RTStrmWrite(pStrm, g_szSpaces, cchIndent + cchHangingIndent);
157 size_t offLine = cchIndent + cchHangingIndent;
158 bool fPendingSpace = false;
159 do
160 {
161 const char *pszSpace = strchr(psz, ' ');
162 size_t cchWord = pszSpace ? pszSpace - psz : strlen(psz);
163 if ( offLine + cchWord + fPendingSpace > cchMaxWidth
164 && offLine != cchIndent)
165 break;
166
167 pszNbsp = (const char *)memchr(psz, REFENTRY_NBSP, cchWord);
168 while (pszNbsp)
169 {
170 size_t cchSubWord = pszNbsp - psz;
171 if (fPendingSpace)
172 RTStrmPutCh(pStrm, ' ');
173 RTStrmWrite(pStrm, psz, cchSubWord);
174 offLine += cchSubWord + fPendingSpace;
175 psz += cchSubWord + 1;
176 cchWord -= cchSubWord + 1;
177 pszNbsp = (const char *)memchr(psz, REFENTRY_NBSP, cchWord);
178 fPendingSpace = true;
179 }
180
181 if (fPendingSpace)
182 RTStrmPutCh(pStrm, ' ');
183 RTStrmWrite(pStrm, psz, cchWord);
184 offLine += cchWord + fPendingSpace;
185 psz = pszSpace ? pszSpace + 1 : strchr(psz, '\0');
186 fPendingSpace = true;
187 } while (offLine < cchMaxWidth && *psz != '\0');
188 RTStrmPutCh(pStrm, '\n');
189 cLinesWritten++;
190
191 /* Set up hanging indent if relevant. */
192 if (fFlags & REFENTRYSTR_FLAGS_SYNOPSIS)
193 cchHangingIndent = 4;
194 } while (*psz != '\0');
195 }
196 return cLinesWritten;
197}
198
199
200/**
201 * Checks if the given string is empty (only spaces).
202 * @returns true if empty, false if not.
203 * @param psz The string to examine.
204 */
205DECLINLINE(bool) isEmptyString(const char *psz)
206{
207 char ch;
208 while ((ch = *psz) == ' ')
209 psz++;
210 return ch == '\0';
211}
212
213
214/**
215 * Prints a string table.
216 *
217 * @returns Current number of pending blank lines.
218 * @param pStrm The output stream.
219 * @param pStrTab The string table.
220 * @param fScope The selection scope.
221 * @param cPendingBlankLines Pending blank lines from previous string table.
222 * @param pcLinesWritten Pointer to variable that should be incremented
223 * by the number of lines written. Optional.
224 */
225static uint32_t printStringTable(PRTSTREAM pStrm, PCREFENTRYSTRTAB pStrTab, uint64_t fScope, uint32_t cPendingBlankLines,
226 uint32_t *pcLinesWritten = NULL)
227{
228 uint32_t cLinesWritten = 0;
229 uint32_t cchWidth = getScreenWidth(pStrm);
230 uint64_t fPrevScope = fScope;
231 for (uint32_t i = 0; i < pStrTab->cStrings; i++)
232 {
233 uint64_t fCurScope = pStrTab->paStrings[i].fScope;
234 if ((fCurScope & REFENTRYSTR_SCOPE_MASK) == REFENTRYSTR_SCOPE_SAME)
235 {
236 fCurScope &= ~REFENTRYSTR_SCOPE_MASK;
237 fCurScope |= (fPrevScope & REFENTRYSTR_SCOPE_MASK);
238 }
239 if (fCurScope & REFENTRYSTR_SCOPE_MASK & fScope)
240 {
241 const char *psz = pStrTab->paStrings[i].psz;
242 if (psz && !isEmptyString(psz))
243 {
244 while (cPendingBlankLines > 0)
245 {
246 cPendingBlankLines--;
247 RTStrmPutCh(pStrm, '\n');
248 cLinesWritten++;
249 }
250 cLinesWritten += printString(pStrm, psz, cchWidth, fCurScope & REFENTRYSTR_FLAGS_MASK);
251 }
252 else
253 cPendingBlankLines++;
254 }
255 fPrevScope = fCurScope;
256 }
257
258 if (pcLinesWritten)
259 *pcLinesWritten += cLinesWritten;
260 return cPendingBlankLines;
261}
262
263
264/**
265 * Prints brief help for a command or subcommand.
266 *
267 * @returns Number of lines written.
268 * @param enmCommand The command.
269 * @param fSubcommandScope The subcommand scope, REFENTRYSTR_SCOPE_GLOBAL
270 * for all.
271 * @param pStrm The output stream.
272 */
273static uint32_t printBriefCommandOrSubcommandHelp(enum HELP_CMD_VBOXMANAGE enmCommand, uint64_t fSubcommandScope, PRTSTREAM pStrm)
274{
275 uint32_t cLinesWritten = 0;
276 uint32_t cPendingBlankLines = 0;
277 uint32_t cFound = 0;
278 for (uint32_t i = 0; i < g_cHelpEntries; i++)
279 {
280 PCREFENTRY pHelp = g_apHelpEntries[i];
281 if (pHelp->idInternal == (int64_t)enmCommand)
282 {
283 cFound++;
284 if (cFound == 1)
285 {
286 if (fSubcommandScope == REFENTRYSTR_SCOPE_GLOBAL)
287 RTStrmPrintf(pStrm, "Usage - %c%s:\n", RT_C_TO_UPPER(pHelp->pszBrief[0]), pHelp->pszBrief + 1);
288 else
289 RTStrmPrintf(pStrm, "Usage:\n");
290 }
291 cPendingBlankLines = printStringTable(pStrm, &pHelp->Synopsis, fSubcommandScope, cPendingBlankLines, &cLinesWritten);
292 if (!cPendingBlankLines)
293 cPendingBlankLines = 1;
294 }
295 }
296 Assert(cFound > 0);
297 return cLinesWritten;
298}
299
300
301/**
302 * Prints the brief usage information for the current (sub)command.
303 *
304 * @param pStrm The output stream.
305 */
306void printUsage(PRTSTREAM pStrm)
307{
308 printBriefCommandOrSubcommandHelp(g_enmCurCommand, g_fCurSubcommandScope, pStrm);
309}
310
311
312/**
313 * Prints full help for a command or subcommand.
314 *
315 * @param enmCommand The command.
316 * @param fSubcommandScope The subcommand scope, REFENTRYSTR_SCOPE_GLOBAL
317 * for all.
318 * @param pStrm The output stream.
319 */
320static void printFullCommandOrSubcommandHelp(enum HELP_CMD_VBOXMANAGE enmCommand, uint64_t fSubcommandScope, PRTSTREAM pStrm)
321{
322 uint32_t cPendingBlankLines = 0;
323 uint32_t cFound = 0;
324 for (uint32_t i = 0; i < g_cHelpEntries; i++)
325 {
326 PCREFENTRY pHelp = g_apHelpEntries[i];
327 if ( pHelp->idInternal == (int64_t)enmCommand
328 || enmCommand == HELP_CMD_VBOXMANAGE_INVALID)
329 {
330 cFound++;
331 cPendingBlankLines = printStringTable(pStrm, &pHelp->Help, fSubcommandScope, cPendingBlankLines);
332 if (cPendingBlankLines < 2)
333 cPendingBlankLines = 2;
334 }
335 }
336 Assert(cFound > 0);
337}
338
339
340/**
341 * Prints the full help for the current (sub)command.
342 *
343 * @param pStrm The output stream.
344 */
345void printHelp(PRTSTREAM pStrm)
346{
347 printFullCommandOrSubcommandHelp(g_enmCurCommand, g_fCurSubcommandScope, pStrm);
348}
349
350
351/**
352 * Display no subcommand error message and current command usage.
353 *
354 * @returns RTEXITCODE_SYNTAX.
355 */
356RTEXITCODE errorNoSubcommand(void)
357{
358 Assert(g_enmCurCommand != HELP_CMD_VBOXMANAGE_INVALID);
359 Assert(g_fCurSubcommandScope == REFENTRYSTR_SCOPE_GLOBAL);
360
361 return errorSyntax("No subcommand specified");
362}
363
364
365/**
366 * Display unknown subcommand error message and current command usage.
367 *
368 * May show full command help instead if the subcommand is a common help option.
369 *
370 * @returns RTEXITCODE_SYNTAX, or RTEXITCODE_SUCCESS if common help option.
371 * @param pszSubcommand The name of the alleged subcommand.
372 */
373RTEXITCODE errorUnknownSubcommand(const char *pszSubcommand)
374{
375 Assert(g_enmCurCommand != HELP_CMD_VBOXMANAGE_INVALID);
376 Assert(g_fCurSubcommandScope == REFENTRYSTR_SCOPE_GLOBAL);
377
378 /* check if help was requested. */
379 if ( strcmp(pszSubcommand, "--help") == 0
380 || strcmp(pszSubcommand, "-h") == 0
381 || strcmp(pszSubcommand, "-?") == 0)
382 {
383 printFullCommandOrSubcommandHelp(g_enmCurCommand, g_fCurSubcommandScope, g_pStdOut);
384 return RTEXITCODE_SUCCESS;
385 }
386
387 return errorSyntax("Unknown subcommand: %s", pszSubcommand);
388}
389
390
391/**
392 * Display too many parameters error message and current command usage.
393 *
394 * May show full command help instead if the subcommand is a common help option.
395 *
396 * @returns RTEXITCODE_SYNTAX, or RTEXITCODE_SUCCESS if common help option.
397 * @param papszArgs The first unwanted parameter. Terminated by
398 * NULL entry.
399 */
400RTEXITCODE errorTooManyParameters(char **papszArgs)
401{
402 Assert(g_enmCurCommand != HELP_CMD_VBOXMANAGE_INVALID);
403 Assert(g_fCurSubcommandScope != REFENTRYSTR_SCOPE_GLOBAL);
404
405 /* check if help was requested. */
406 if (papszArgs)
407 for (uint32_t i = 0; papszArgs[i]; i++)
408 if ( strcmp(papszArgs[i], "--help") == 0
409 || strcmp(papszArgs[i], "-h") == 0
410 || strcmp(papszArgs[i], "-?") == 0)
411 {
412 printFullCommandOrSubcommandHelp(g_enmCurCommand, g_fCurSubcommandScope, g_pStdOut);
413 return RTEXITCODE_SUCCESS;
414 }
415 else if (!strcmp(papszArgs[i], "--"))
416 break;
417
418 return errorSyntax("Too many parameters");
419}
420
421
422/**
423 * Display current (sub)command usage and the custom error message.
424 *
425 * @returns RTEXITCODE_SYNTAX.
426 * @param pszFormat Custom error message format string.
427 * @param ... Format arguments.
428 */
429RTEXITCODE errorSyntax(const char *pszFormat, ...)
430{
431 Assert(g_enmCurCommand != HELP_CMD_VBOXMANAGE_INVALID);
432
433 showLogo(g_pStdErr);
434
435 va_list va;
436 va_start(va, pszFormat);
437 RTMsgErrorV(pszFormat, va);
438 va_end(va);
439
440 RTStrmPutCh(g_pStdErr, '\n');
441 if ( printBriefCommandOrSubcommandHelp(g_enmCurCommand, g_fCurSubcommandScope, g_pStdErr)
442 >= ERROR_REPEAT_AFTER_USAGE_LENGTH)
443 {
444 /* Usage was very long, repeat the error message. */
445 RTStrmPutCh(g_pStdErr, '\n');
446 va_start(va, pszFormat);
447 RTMsgErrorV(pszFormat, va);
448 va_end(va);
449 }
450 return RTEXITCODE_SYNTAX;
451}
452
453
454/**
455 * Worker for errorGetOpt.
456 *
457 * @param rcGetOpt The RTGetOpt return value.
458 * @param pValueUnion The value union returned by RTGetOpt.
459 */
460static void errorGetOptWorker(int rcGetOpt, union RTGETOPTUNION const *pValueUnion)
461{
462 if (rcGetOpt == VINF_GETOPT_NOT_OPTION)
463 RTMsgError("Invalid parameter '%s'", pValueUnion->psz);
464 else if (rcGetOpt > 0)
465 {
466 if (RT_C_IS_PRINT(rcGetOpt))
467 RTMsgError("Invalid option -%c", rcGetOpt);
468 else
469 RTMsgError("Invalid option case %i", rcGetOpt);
470 }
471 else if (rcGetOpt == VERR_GETOPT_UNKNOWN_OPTION)
472 RTMsgError("Unknown option: %s", pValueUnion->psz);
473 else if (rcGetOpt == VERR_GETOPT_INVALID_ARGUMENT_FORMAT)
474 RTMsgError("Invalid argument format: %s", pValueUnion->psz);
475 else if (pValueUnion->pDef)
476 RTMsgError("%s: %Rrs", pValueUnion->pDef->pszLong, rcGetOpt);
477 else
478 RTMsgError("%Rrs", rcGetOpt);
479}
480
481
482/**
483 * Handled an RTGetOpt error or common option.
484 *
485 * This implements the 'V' and 'h' cases. It reports appropriate syntax errors
486 * for other @a rcGetOpt values.
487 *
488 * @retval RTEXITCODE_SUCCESS if help or version request.
489 * @retval RTEXITCODE_SYNTAX if not help or version request.
490 * @param rcGetOpt The RTGetOpt return value.
491 * @param pValueUnion The value union returned by RTGetOpt.
492 */
493RTEXITCODE errorGetOpt(int rcGetOpt, union RTGETOPTUNION const *pValueUnion)
494{
495 Assert(g_enmCurCommand != HELP_CMD_VBOXMANAGE_INVALID);
496
497 /*
498 * Check if it is an unhandled standard option.
499 */
500 if (rcGetOpt == 'V')
501 {
502 RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision());
503 return RTEXITCODE_SUCCESS;
504 }
505
506 if (rcGetOpt == 'h')
507 {
508 printFullCommandOrSubcommandHelp(g_enmCurCommand, g_fCurSubcommandScope, g_pStdOut);
509 return RTEXITCODE_SUCCESS;
510 }
511
512 /*
513 * We failed.
514 */
515 showLogo(g_pStdErr);
516 errorGetOptWorker(rcGetOpt, pValueUnion);
517 if ( printBriefCommandOrSubcommandHelp(g_enmCurCommand, g_fCurSubcommandScope, g_pStdErr)
518 >= ERROR_REPEAT_AFTER_USAGE_LENGTH)
519 {
520 /* Usage was very long, repeat the error message. */
521 RTStrmPutCh(g_pStdErr, '\n');
522 errorGetOptWorker(rcGetOpt, pValueUnion);
523 }
524 return RTEXITCODE_SYNTAX;
525}
526
527#endif /* VBOX_ONLY_DOCS */
528
529
530
531void showLogo(PRTSTREAM pStrm)
532{
533 static bool s_fShown; /* show only once */
534
535 if (!s_fShown)
536 {
537 RTStrmPrintf(pStrm, VBOX_PRODUCT " Command Line Management Interface Version "
538 VBOX_VERSION_STRING "\n"
539 "(C) 2005-" VBOX_C_YEAR " " VBOX_VENDOR "\n"
540 "All rights reserved.\n"
541 "\n");
542 s_fShown = true;
543 }
544}
545
546
547
548
549void printUsage(USAGECATEGORY fCategory, uint32_t fSubCategory, PRTSTREAM pStrm)
550{
551 bool fDumpOpts = false;
552#ifdef RT_OS_LINUX
553 bool fLinux = true;
554#else
555 bool fLinux = false;
556#endif
557#ifdef RT_OS_WINDOWS
558 bool fWin = true;
559#else
560 bool fWin = false;
561#endif
562#ifdef RT_OS_SOLARIS
563 bool fSolaris = true;
564#else
565 bool fSolaris = false;
566#endif
567#ifdef RT_OS_FREEBSD
568 bool fFreeBSD = true;
569#else
570 bool fFreeBSD = false;
571#endif
572#ifdef RT_OS_DARWIN
573 bool fDarwin = true;
574#else
575 bool fDarwin = false;
576#endif
577#ifdef VBOX_WITH_VBOXSDL
578 bool fVBoxSDL = true;
579#else
580 bool fVBoxSDL = false;
581#endif
582
583 if (fCategory == USAGE_DUMPOPTS)
584 {
585 fDumpOpts = true;
586 fLinux = true;
587 fWin = true;
588 fSolaris = true;
589 fFreeBSD = true;
590 fDarwin = true;
591 fVBoxSDL = true;
592 fCategory = USAGE_ALL;
593 }
594
595 RTStrmPrintf(pStrm,
596 "Usage:\n"
597 "\n");
598
599 if (fCategory == USAGE_ALL)
600 RTStrmPrintf(pStrm,
601 " VBoxManage [<general option>] <command>\n"
602 " \n \n"
603 "General Options:\n \n"
604 " [-v|--version] print version number and exit\n"
605 " [-q|--nologo] suppress the logo\n"
606 " [--settingspw <pw>] provide the settings password\n"
607 " [--settingspwfile <file>] provide a file containing the settings password\n"
608 " \n \n"
609 "Commands:\n \n");
610
611 const char *pcszSep1 = " ";
612 const char *pcszSep2 = " ";
613 if (fCategory != USAGE_ALL)
614 {
615 pcszSep1 = "VBoxManage";
616 pcszSep2 = "";
617 }
618
619#define SEP pcszSep1, pcszSep2
620
621 if (fCategory & USAGE_LIST)
622 RTStrmPrintf(pStrm,
623 "%s list [--long|-l]%s vms|runningvms|ostypes|hostdvds|hostfloppies|\n"
624#if defined(VBOX_WITH_NETFLT)
625 " intnets|bridgedifs|hostonlyifs|natnets|dhcpservers|\n"
626#else
627 " intnets|bridgedifs|natnets|dhcpservers|hostinfo|\n"
628#endif
629 " hostinfo|hostcpuids|hddbackends|hdds|dvds|floppies|\n"
630 " usbhost|usbfilters|systemproperties|extpacks|\n"
631 " groups|webcams|screenshotformats\n"
632 "\n", SEP);
633
634 if (fCategory & USAGE_SHOWVMINFO)
635 RTStrmPrintf(pStrm,
636 "%s showvminfo %s <uuid|vmname> [--details]\n"
637 " [--machinereadable]\n"
638 "%s showvminfo %s <uuid|vmname> --log <idx>\n"
639 "\n", SEP, SEP);
640
641 if (fCategory & USAGE_REGISTERVM)
642 RTStrmPrintf(pStrm,
643 "%s registervm %s <filename>\n"
644 "\n", SEP);
645
646 if (fCategory & USAGE_UNREGISTERVM)
647 RTStrmPrintf(pStrm,
648 "%s unregistervm %s <uuid|vmname> [--delete]\n"
649 "\n", SEP);
650
651 if (fCategory & USAGE_CREATEVM)
652 RTStrmPrintf(pStrm,
653 "%s createvm %s --name <name>\n"
654 " [--groups <group>, ...]\n"
655 " [--ostype <ostype>]\n"
656 " [--register]\n"
657 " [--basefolder <path>]\n"
658 " [--uuid <uuid>]\n"
659 "\n", SEP);
660
661 if (fCategory & USAGE_MODIFYVM)
662 {
663 RTStrmPrintf(pStrm,
664 "%s modifyvm %s <uuid|vmname>\n"
665 " [--name <name>]\n"
666 " [--groups <group>, ...]\n"
667 " [--description <desc>]\n"
668 " [--ostype <ostype>]\n"
669 " [--iconfile <filename>]\n"
670 " [--memory <memorysize in MB>]\n"
671 " [--pagefusion on|off]\n"
672 " [--vram <vramsize in MB>]\n"
673 " [--acpi on|off]\n"
674#ifdef VBOX_WITH_PCI_PASSTHROUGH
675 " [--pciattach 03:04.0]\n"
676 " [--pciattach 03:04.0@02:01.0]\n"
677 " [--pcidetach 03:04.0]\n"
678#endif
679 " [--ioapic on|off]\n"
680 " [--hpet on|off]\n"
681 " [--triplefaultreset on|off]\n"
682 " [--paravirtprovider none|default|legacy|minimal|\n"
683 " hyperv|kvm]\n"
684 " [--hwvirtex on|off]\n"
685 " [--nestedpaging on|off]\n"
686 " [--largepages on|off]\n"
687 " [--vtxvpid on|off]\n"
688 " [--vtxux on|off]\n"
689 " [--pae on|off]\n"
690 " [--longmode on|off]\n"
691 " [--cpuid-portability-level <0..3>\n"
692 " [--cpuidset <leaf> <eax> <ebx> <ecx> <edx>]\n"
693 " [--cpuidremove <leaf>]\n"
694 " [--cpuidremoveall]\n"
695 " [--hardwareuuid <uuid>]\n"
696 " [--cpus <number>]\n"
697 " [--cpuhotplug on|off]\n"
698 " [--plugcpu <id>]\n"
699 " [--unplugcpu <id>]\n"
700 " [--cpuexecutioncap <1-100>]\n"
701 " [--rtcuseutc on|off]\n"
702#ifdef VBOX_WITH_VMSVGA
703 " [--graphicscontroller none|vboxvga|vmsvga]\n"
704#else
705 " [--graphicscontroller none|vboxvga]\n"
706#endif
707 " [--monitorcount <number>]\n"
708 " [--accelerate3d on|off]\n"
709#ifdef VBOX_WITH_VIDEOHWACCEL
710 " [--accelerate2dvideo on|off]\n"
711#endif
712 " [--firmware bios|efi|efi32|efi64]\n"
713 " [--chipset ich9|piix3]\n"
714 " [--bioslogofadein on|off]\n"
715 " [--bioslogofadeout on|off]\n"
716 " [--bioslogodisplaytime <msec>]\n"
717 " [--bioslogoimagepath <imagepath>]\n"
718 " [--biosbootmenu disabled|menuonly|messageandmenu]\n"
719 " [--biossystemtimeoffset <msec>]\n"
720 " [--biospxedebug on|off]\n"
721 " [--boot<1-4> none|floppy|dvd|disk|net>]\n"
722 " [--nic<1-N> none|null|nat|bridged|intnet"
723#if defined(VBOX_WITH_NETFLT)
724 "|hostonly"
725#endif
726 "|\n"
727 " generic|natnetwork"
728 "]\n"
729 " [--nictype<1-N> Am79C970A|Am79C973"
730#ifdef VBOX_WITH_E1000
731 "|\n 82540EM|82543GC|82545EM"
732#endif
733#ifdef VBOX_WITH_VIRTIO
734 "|\n virtio"
735#endif /* VBOX_WITH_VIRTIO */
736 "]\n"
737 " [--cableconnected<1-N> on|off]\n"
738 " [--nictrace<1-N> on|off]\n"
739 " [--nictracefile<1-N> <filename>]\n"
740 " [--nicproperty<1-N> name=[value]]\n"
741 " [--nicspeed<1-N> <kbps>]\n"
742 " [--nicbootprio<1-N> <priority>]\n"
743 " [--nicpromisc<1-N> deny|allow-vms|allow-all]\n"
744 " [--nicbandwidthgroup<1-N> none|<name>]\n"
745 " [--bridgeadapter<1-N> none|<devicename>]\n"
746#if defined(VBOX_WITH_NETFLT)
747 " [--hostonlyadapter<1-N> none|<devicename>]\n"
748#endif
749 " [--intnet<1-N> <network name>]\n"
750 " [--nat-network<1-N> <network name>]\n"
751 " [--nicgenericdrv<1-N> <driver>\n"
752 " [--natnet<1-N> <network>|default]\n"
753 " [--natsettings<1-N> [<mtu>],[<socksnd>],\n"
754 " [<sockrcv>],[<tcpsnd>],\n"
755 " [<tcprcv>]]\n"
756 " [--natpf<1-N> [<rulename>],tcp|udp,[<hostip>],\n"
757 " <hostport>,[<guestip>],<guestport>]\n"
758 " [--natpf<1-N> delete <rulename>]\n"
759 " [--nattftpprefix<1-N> <prefix>]\n"
760 " [--nattftpfile<1-N> <file>]\n"
761 " [--nattftpserver<1-N> <ip>]\n"
762 " [--natbindip<1-N> <ip>\n"
763 " [--natdnspassdomain<1-N> on|off]\n"
764 " [--natdnsproxy<1-N> on|off]\n"
765 " [--natdnshostresolver<1-N> on|off]\n"
766 " [--nataliasmode<1-N> default|[log],[proxyonly],\n"
767 " [sameports]]\n"
768 " [--macaddress<1-N> auto|<mac>]\n"
769 " [--mouse ps2|usb|usbtablet|usbmultitouch]\n"
770 " [--keyboard ps2|usb\n"
771 " [--uart<1-N> off|<I/O base> <IRQ>]\n"
772 " [--uartmode<1-N> disconnected|\n"
773 " server <pipe>|\n"
774 " client <pipe>|\n"
775 " tcpserver <port>|\n"
776 " tcpclient <hostname:port>|\n"
777 " file <file>|\n"
778 " <devicename>]\n"
779#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
780 " [--lpt<1-N> off|<I/O base> <IRQ>]\n"
781 " [--lptmode<1-N> <devicename>]\n"
782#endif
783 " [--guestmemoryballoon <balloonsize in MB>]\n"
784 " [--audio none|null", SEP);
785 if (fWin)
786 {
787#ifdef VBOX_WITH_WINMM
788 RTStrmPrintf(pStrm, "|winmm|dsound");
789#else
790 RTStrmPrintf(pStrm, "|dsound");
791#endif
792 }
793 if (fSolaris)
794 {
795 RTStrmPrintf(pStrm, "|solaudio"
796#ifdef VBOX_WITH_SOLARIS_OSS
797 "|oss"
798#endif
799 );
800 }
801 if (fLinux)
802 {
803 RTStrmPrintf(pStrm, "|oss"
804#ifdef VBOX_WITH_ALSA
805 "|alsa"
806#endif
807#ifdef VBOX_WITH_PULSE
808 "|pulse"
809#endif
810 );
811 }
812 if (fFreeBSD)
813 {
814 /* Get the line break sorted when dumping all option variants. */
815 if (fDumpOpts)
816 {
817 RTStrmPrintf(pStrm, "|\n"
818 " oss");
819 }
820 else
821 RTStrmPrintf(pStrm, "|oss");
822#ifdef VBOX_WITH_PULSE
823 RTStrmPrintf(pStrm, "|pulse");
824#endif
825 }
826 if (fDarwin)
827 {
828 RTStrmPrintf(pStrm, "|coreaudio");
829 }
830 RTStrmPrintf(pStrm, "]\n");
831 RTStrmPrintf(pStrm,
832 " [--audiocontroller ac97|hda|sb16]\n"
833 " [--audiocodec stac9700|ad1980|stac9221|sb16]\n"
834 " [--clipboard disabled|hosttoguest|guesttohost|\n"
835 " bidirectional]\n"
836 " [--draganddrop disabled|hosttoguest]\n");
837 RTStrmPrintf(pStrm,
838 " [--vrde on|off]\n"
839 " [--vrdeextpack default|<name>\n"
840 " [--vrdeproperty <name=[value]>]\n"
841 " [--vrdeport <hostport>]\n"
842 " [--vrdeaddress <hostip>]\n"
843 " [--vrdeauthtype null|external|guest]\n"
844 " [--vrdeauthlibrary default|<name>\n"
845 " [--vrdemulticon on|off]\n"
846 " [--vrdereusecon on|off]\n"
847 " [--vrdevideochannel on|off]\n"
848 " [--vrdevideochannelquality <percent>]\n");
849 RTStrmPrintf(pStrm,
850 " [--usb on|off]\n"
851 " [--usbehci on|off]\n"
852 " [--usbxhci on|off]\n"
853 " [--usbrename <oldname> <newname>]\n"
854 " [--snapshotfolder default|<path>]\n"
855 " [--teleporter on|off]\n"
856 " [--teleporterport <port>]\n"
857 " [--teleporteraddress <address|empty>\n"
858 " [--teleporterpassword <password>]\n"
859 " [--teleporterpasswordfile <file>|stdin]\n"
860 " [--tracing-enabled on|off]\n"
861 " [--tracing-config <config-string>]\n"
862 " [--tracing-allow-vm-access on|off]\n"
863#if 0
864 " [--iocache on|off]\n"
865 " [--iocachesize <I/O cache size in MB>]\n"
866#endif
867#if 0
868 " [--faulttolerance master|standby]\n"
869 " [--faulttoleranceaddress <name>]\n"
870 " [--faulttoleranceport <port>]\n"
871 " [--faulttolerancesyncinterval <msec>]\n"
872 " [--faulttolerancepassword <password>]\n"
873#endif
874#ifdef VBOX_WITH_USB_CARDREADER
875 " [--usbcardreader on|off]\n"
876#endif
877 " [--autostart-enabled on|off]\n"
878 " [--autostart-delay <seconds>]\n"
879#if 0
880 " [--autostop-type disabled|savestate|poweroff|\n"
881 " acpishutdown]\n"
882#endif
883#ifdef VBOX_WITH_VPX
884 " [--videocap on|off]\n"
885 " [--videocapscreens all|<screen ID> [<screen ID> ...]]\n"
886 " [--videocapfile <filename>]\n"
887 " [--videocapres <width> <height>]\n"
888 " [--videocaprate <rate>]\n"
889 " [--videocapfps <fps>]\n"
890 " [--videocapmaxtime <ms>]\n"
891 " [--videocapmaxsize <MB>]\n"
892 " [--videocapopts <key=value> [<key=value> ...]]\n"
893#endif
894 " [--defaultfrontend default|<name>]\n"
895 "\n");
896 }
897
898 if (fCategory & USAGE_CLONEVM)
899 RTStrmPrintf(pStrm,
900 "%s clonevm %s <uuid|vmname>\n"
901 " [--snapshot <uuid>|<name>]\n"
902 " [--mode machine|machineandchildren|all]\n"
903 " [--options link|keepallmacs|keepnatmacs|\n"
904 " keepdisknames]\n"
905 " [--name <name>]\n"
906 " [--groups <group>, ...]\n"
907 " [--basefolder <basefolder>]\n"
908 " [--uuid <uuid>]\n"
909 " [--register]\n"
910 "\n", SEP);
911
912 if (fCategory & USAGE_IMPORTAPPLIANCE)
913 RTStrmPrintf(pStrm,
914 "%s import %s <ovfname/ovaname>\n"
915 " [--dry-run|-n]\n"
916 " [--options keepallmacs|keepnatmacs|importtovdi]\n"
917 " [more options]\n"
918 " (run with -n to have options displayed\n"
919 " for a particular OVF)\n\n", SEP);
920
921 if (fCategory & USAGE_EXPORTAPPLIANCE)
922 RTStrmPrintf(pStrm,
923 "%s export %s <machines> --output|-o <name>.<ovf/ova>\n"
924 " [--legacy09|--ovf09|--ovf10|--ovf20]\n"
925 " [--manifest]\n"
926 " [--iso]\n"
927 " [--options manifest|iso|nomacs|nomacsbutnat]\n"
928 " [--vsys <number of virtual system>]\n"
929 " [--product <product name>]\n"
930 " [--producturl <product url>]\n"
931 " [--vendor <vendor name>]\n"
932 " [--vendorurl <vendor url>]\n"
933 " [--version <version info>]\n"
934 " [--description <description info>]\n"
935 " [--eula <license text>]\n"
936 " [--eulafile <filename>]\n"
937 "\n", SEP);
938
939 if (fCategory & USAGE_STARTVM)
940 {
941 RTStrmPrintf(pStrm,
942 "%s startvm %s <uuid|vmname>...\n"
943 " [--type gui", SEP);
944 if (fVBoxSDL)
945 RTStrmPrintf(pStrm, "|sdl");
946 RTStrmPrintf(pStrm, "|headless|separate]\n");
947 RTStrmPrintf(pStrm,
948 "\n");
949 }
950
951 if (fCategory & USAGE_CONTROLVM)
952 {
953 RTStrmPrintf(pStrm,
954 "%s controlvm %s <uuid|vmname>\n"
955 " pause|resume|reset|poweroff|savestate|\n"
956 " acpipowerbutton|acpisleepbutton|\n"
957 " keyboardputscancode <hex> [<hex> ...]|\n"
958 " setlinkstate<1-N> on|off |\n"
959#if defined(VBOX_WITH_NETFLT)
960 " nic<1-N> null|nat|bridged|intnet|hostonly|generic|\n"
961 " natnetwork [<devicename>] |\n"
962#else /* !VBOX_WITH_NETFLT */
963 " nic<1-N> null|nat|bridged|intnet|generic|natnetwork\n"
964 " [<devicename>] |\n"
965#endif /* !VBOX_WITH_NETFLT */
966 " nictrace<1-N> on|off |\n"
967 " nictracefile<1-N> <filename> |\n"
968 " nicproperty<1-N> name=[value] |\n"
969 " nicpromisc<1-N> deny|allow-vms|allow-all |\n"
970 " natpf<1-N> [<rulename>],tcp|udp,[<hostip>],\n"
971 " <hostport>,[<guestip>],<guestport> |\n"
972 " natpf<1-N> delete <rulename> |\n"
973 " guestmemoryballoon <balloonsize in MB> |\n"
974 " usbattach <uuid>|<address>\n"
975 " [--capturefile <filename>] |\n"
976 " usbdetach <uuid>|<address> |\n"
977 " clipboard disabled|hosttoguest|guesttohost|\n"
978 " bidirectional |\n"
979 " draganddrop disabled|hosttoguest |\n"
980 " vrde on|off |\n"
981 " vrdeport <port> |\n"
982 " vrdeproperty <name=[value]> |\n"
983 " vrdevideochannelquality <percent> |\n"
984 " setvideomodehint <xres> <yres> <bpp>\n"
985 " [[<display>] [<enabled:yes|no> |\n"
986 " [<xorigin> <yorigin>]]] |\n"
987 " screenshotpng <file> [display] |\n"
988 " videocap on|off |\n"
989 " videocapscreens all|none|<screen>,[<screen>...] |\n"
990 " videocapfile <file>\n"
991 " videocapres <width>x<height>\n"
992 " videocaprate <rate>\n"
993 " videocapfps <fps>\n"
994 " videocapmaxtime <ms>\n"
995 " videocapmaxsize <MB>\n"
996 " setcredentials <username>\n"
997 " --passwordfile <file> | <password>\n"
998 " <domain>\n"
999 " [--allowlocallogon <yes|no>] |\n"
1000 " teleport --host <name> --port <port>\n"
1001 " [--maxdowntime <msec>]\n"
1002 " [--passwordfile <file> |\n"
1003 " --password <password>] |\n"
1004 " plugcpu <id> |\n"
1005 " unplugcpu <id> |\n"
1006 " cpuexecutioncap <1-100>\n"
1007 " webcam <attach [path [settings]]> | <detach [path]> | <list>\n"
1008 " addencpassword <id>\n"
1009 " <password file>|-\n"
1010 " [--removeonsuspend <yes|no>]\n"
1011 " removeencpassword <id>\n"
1012 " removeallencpasswords\n"
1013 "\n", SEP);
1014 }
1015
1016 if (fCategory & USAGE_DISCARDSTATE)
1017 RTStrmPrintf(pStrm,
1018 "%s discardstate %s <uuid|vmname>\n"
1019 "\n", SEP);
1020
1021 if (fCategory & USAGE_ADOPTSTATE)
1022 RTStrmPrintf(pStrm,
1023 "%s adoptstate %s <uuid|vmname> <state_file>\n"
1024 "\n", SEP);
1025
1026 if (fCategory & USAGE_SNAPSHOT)
1027 RTStrmPrintf(pStrm,
1028 "%s snapshot %s <uuid|vmname>\n"
1029 " take <name> [--description <desc>] [--live]\n"
1030 " [--uniquename Number,Timestamp,Space,Force] |\n"
1031 " delete <uuid|snapname> |\n"
1032 " restore <uuid|snapname> |\n"
1033 " restorecurrent |\n"
1034 " edit <uuid|snapname>|--current\n"
1035 " [--name <name>]\n"
1036 " [--description <desc>] |\n"
1037 " list [--details|--machinereadable]\n"
1038 " showvminfo <uuid|snapname>\n"
1039 "\n", SEP);
1040
1041 if (fCategory & USAGE_CLOSEMEDIUM)
1042 RTStrmPrintf(pStrm,
1043 "%s closemedium %s [disk|dvd|floppy] <uuid|filename>\n"
1044 " [--delete]\n"
1045 "\n", SEP);
1046
1047 if (fCategory & USAGE_STORAGEATTACH)
1048 RTStrmPrintf(pStrm,
1049 "%s storageattach %s <uuid|vmname>\n"
1050 " --storagectl <name>\n"
1051 " [--port <number>]\n"
1052 " [--device <number>]\n"
1053 " [--type dvddrive|hdd|fdd]\n"
1054 " [--medium none|emptydrive|additions|\n"
1055 " <uuid|filename>|host:<drive>|iscsi]\n"
1056 " [--mtype normal|writethrough|immutable|shareable|\n"
1057 " readonly|multiattach]\n"
1058 " [--comment <text>]\n"
1059 " [--setuuid <uuid>]\n"
1060 " [--setparentuuid <uuid>]\n"
1061 " [--passthrough on|off]\n"
1062 " [--tempeject on|off]\n"
1063 " [--nonrotational on|off]\n"
1064 " [--discard on|off]\n"
1065 " [--hotpluggable on|off]\n"
1066 " [--bandwidthgroup <name>]\n"
1067 " [--forceunmount]\n"
1068 " [--server <name>|<ip>]\n"
1069 " [--target <target>]\n"
1070 " [--tport <port>]\n"
1071 " [--lun <lun>]\n"
1072 " [--encodedlun <lun>]\n"
1073 " [--username <username>]\n"
1074 " [--password <password>]\n"
1075 " [--initiator <initiator>]\n"
1076 " [--intnet]\n"
1077 "\n", SEP);
1078
1079 if (fCategory & USAGE_STORAGECONTROLLER)
1080 RTStrmPrintf(pStrm,
1081 "%s storagectl %s <uuid|vmname>\n"
1082 " --name <name>\n"
1083 " [--add ide|sata|scsi|floppy|sas]\n"
1084 " [--controller LSILogic|LSILogicSAS|BusLogic|\n"
1085 " IntelAHCI|PIIX3|PIIX4|ICH6|I82078]\n"
1086 " [--portcount <1-n>]\n"
1087 " [--hostiocache on|off]\n"
1088 " [--bootable on|off]\n"
1089 " [--rename <name>]\n"
1090 " [--remove]\n"
1091 "\n", SEP);
1092
1093 if (fCategory & USAGE_BANDWIDTHCONTROL)
1094 RTStrmPrintf(pStrm,
1095 "%s bandwidthctl %s <uuid|vmname>\n"
1096 " add <name> --type disk|network\n"
1097 " --limit <megabytes per second>[k|m|g|K|M|G] |\n"
1098 " set <name>\n"
1099 " --limit <megabytes per second>[k|m|g|K|M|G] |\n"
1100 " remove <name> |\n"
1101 " list [--machinereadable]\n"
1102 " (limit units: k=kilobit, m=megabit, g=gigabit,\n"
1103 " K=kilobyte, M=megabyte, G=gigabyte)\n"
1104 "\n", SEP);
1105
1106 if (fCategory & USAGE_SHOWMEDIUMINFO)
1107 RTStrmPrintf(pStrm,
1108 "%s showmediuminfo %s [disk|dvd|floppy] <uuid|filename>\n"
1109 "\n", SEP);
1110
1111 if (fCategory & USAGE_CREATEMEDIUM)
1112 RTStrmPrintf(pStrm,
1113 "%s createmedium %s [disk|dvd|floppy] --filename <filename>\n"
1114 " [--size <megabytes>|--sizebyte <bytes>]\n"
1115 " [--diffparent <uuid>|<filename>\n"
1116 " [--format VDI|VMDK|VHD] (default: VDI)\n"
1117 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1118 "\n", SEP);
1119
1120 if (fCategory & USAGE_MODIFYMEDIUM)
1121 RTStrmPrintf(pStrm,
1122 "%s modifymedium %s [disk|dvd|floppy] <uuid|filename>\n"
1123 " [--type normal|writethrough|immutable|shareable|\n"
1124 " readonly|multiattach]\n"
1125 " [--autoreset on|off]\n"
1126 " [--property <name=[value]>]\n"
1127 " [--compact]\n"
1128 " [--resize <megabytes>|--resizebyte <bytes>]\n"
1129 "\n", SEP);
1130
1131 if (fCategory & USAGE_CLONEMEDIUM)
1132 RTStrmPrintf(pStrm,
1133 "%s clonemedium %s [disk|dvd|floppy] <uuid|inputfile> <uuid|outputfile>\n"
1134 " [--format VDI|VMDK|VHD|RAW|<other>]\n"
1135 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1136 " [--existing]\n"
1137 "\n", SEP);
1138
1139 if (fCategory & USAGE_MEDIUMPROPERTY)
1140 RTStrmPrintf(pStrm,
1141 "%s mediumproperty %s [disk|dvd|floppy] set <uuid|filename>\n"
1142 " <property> <value>\n"
1143 "\n"
1144 " [disk|dvd|floppy] get <uuid|filename>\n"
1145 " <property>\n"
1146 "\n"
1147 " [disk|dvd|floppy] delete <uuid|filename>\n"
1148 " <property>\n"
1149 "\n", SEP);
1150
1151 if (fCategory & USAGE_ENCRYPTMEDIUM)
1152 RTStrmPrintf(pStrm,
1153 "%s encryptmedium %s <uuid|filename>\n"
1154 " [--newpassword <file>|-]\n"
1155 " [--oldpassword <file>|-]\n"
1156 " [--cipher <cipher identifier>]\n"
1157 " [--newpasswordid <password identifier>]\n"
1158 "\n", SEP);
1159
1160 if (fCategory & USAGE_MEDIUMENCCHKPWD)
1161 RTStrmPrintf(pStrm,
1162 "%s checkmediumpwd %s <uuid|filename>\n"
1163 " <pwd file>|-\n"
1164 "\n", SEP);
1165
1166 if (fCategory & USAGE_CONVERTFROMRAW)
1167 RTStrmPrintf(pStrm,
1168 "%s convertfromraw %s <filename> <outputfile>\n"
1169 " [--format VDI|VMDK|VHD]\n"
1170 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1171 " [--uuid <uuid>]\n"
1172 "%s convertfromraw %s stdin <outputfile> <bytes>\n"
1173 " [--format VDI|VMDK|VHD]\n"
1174 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1175 " [--uuid <uuid>]\n"
1176 "\n", SEP, SEP);
1177
1178 if (fCategory & USAGE_GETEXTRADATA)
1179 RTStrmPrintf(pStrm,
1180 "%s getextradata %s global|<uuid|vmname>\n"
1181 " <key>|enumerate\n"
1182 "\n", SEP);
1183
1184 if (fCategory & USAGE_SETEXTRADATA)
1185 RTStrmPrintf(pStrm,
1186 "%s setextradata %s global|<uuid|vmname>\n"
1187 " <key>\n"
1188 " [<value>] (no value deletes key)\n"
1189 "\n", SEP);
1190
1191 if (fCategory & USAGE_SETPROPERTY)
1192 RTStrmPrintf(pStrm,
1193 "%s setproperty %s machinefolder default|<folder> |\n"
1194 " hwvirtexclusive on|off |\n"
1195 " vrdeauthlibrary default|<library> |\n"
1196 " websrvauthlibrary default|null|<library> |\n"
1197 " vrdeextpack null|<library> |\n"
1198 " autostartdbpath null|<folder> |\n"
1199 " loghistorycount <value>\n"
1200 " defaultfrontend default|<name>\n"
1201 " logginglevel <log setting>\n"
1202 "\n", SEP);
1203
1204 if (fCategory & USAGE_USBFILTER_ADD)
1205 RTStrmPrintf(pStrm,
1206 "%s usbfilter %s add <index,0-N>\n"
1207 " --target <uuid|vmname>|global\n"
1208 " --name <string>\n"
1209 " --action ignore|hold (global filters only)\n"
1210 " [--active yes|no] (yes)\n"
1211 " [--vendorid <XXXX>] (null)\n"
1212 " [--productid <XXXX>] (null)\n"
1213 " [--revision <IIFF>] (null)\n"
1214 " [--manufacturer <string>] (null)\n"
1215 " [--product <string>] (null)\n"
1216 " [--remote yes|no] (null, VM filters only)\n"
1217 " [--serialnumber <string>] (null)\n"
1218 " [--maskedinterfaces <XXXXXXXX>]\n"
1219 "\n", SEP);
1220
1221 if (fCategory & USAGE_USBFILTER_MODIFY)
1222 RTStrmPrintf(pStrm,
1223 "%s usbfilter %s modify <index,0-N>\n"
1224 " --target <uuid|vmname>|global\n"
1225 " [--name <string>]\n"
1226 " [--action ignore|hold] (global filters only)\n"
1227 " [--active yes|no]\n"
1228 " [--vendorid <XXXX>|\"\"]\n"
1229 " [--productid <XXXX>|\"\"]\n"
1230 " [--revision <IIFF>|\"\"]\n"
1231 " [--manufacturer <string>|\"\"]\n"
1232 " [--product <string>|\"\"]\n"
1233 " [--remote yes|no] (null, VM filters only)\n"
1234 " [--serialnumber <string>|\"\"]\n"
1235 " [--maskedinterfaces <XXXXXXXX>]\n"
1236 "\n", SEP);
1237
1238 if (fCategory & USAGE_USBFILTER_REMOVE)
1239 RTStrmPrintf(pStrm,
1240 "%s usbfilter %s remove <index,0-N>\n"
1241 " --target <uuid|vmname>|global\n"
1242 "\n", SEP);
1243
1244 if (fCategory & USAGE_SHAREDFOLDER_ADD)
1245 RTStrmPrintf(pStrm,
1246 "%s sharedfolder %s add <uuid|vmname>\n"
1247 " --name <name> --hostpath <hostpath>\n"
1248 " [--transient] [--readonly] [--automount]\n"
1249 "\n", SEP);
1250
1251 if (fCategory & USAGE_SHAREDFOLDER_REMOVE)
1252 RTStrmPrintf(pStrm,
1253 "%s sharedfolder %s remove <uuid|vmname>\n"
1254 " --name <name> [--transient]\n"
1255 "\n", SEP);
1256
1257#ifdef VBOX_WITH_GUEST_PROPS
1258 if (fCategory & USAGE_GUESTPROPERTY)
1259 usageGuestProperty(pStrm, SEP);
1260#endif /* VBOX_WITH_GUEST_PROPS defined */
1261
1262#ifdef VBOX_WITH_GUEST_CONTROL
1263 if (fCategory & USAGE_GUESTCONTROL)
1264 usageGuestControl(pStrm, SEP, fSubCategory);
1265#endif /* VBOX_WITH_GUEST_CONTROL defined */
1266
1267 if (fCategory & USAGE_DEBUGVM)
1268 {
1269 RTStrmPrintf(pStrm,
1270 "%s debugvm %s <uuid|vmname>\n"
1271 " dumpguestcore --filename <name> |\n"
1272 " info <item> [args] |\n"
1273 " injectnmi |\n"
1274 " log [--release|--debug] <settings> ...|\n"
1275 " logdest [--release|--debug] <settings> ...|\n"
1276 " logflags [--release|--debug] <settings> ...|\n"
1277 " osdetect |\n"
1278 " osinfo |\n"
1279 " osdmesg [--lines|-n <N>] |\n"
1280 " getregisters [--cpu <id>] <reg>|all ... |\n"
1281 " setregisters [--cpu <id>] <reg>=<value> ... |\n"
1282 " show [--human-readable|--sh-export|--sh-eval|\n"
1283 " --cmd-set] \n"
1284 " <logdbg-settings|logrel-settings>\n"
1285 " [[opt] what ...] |\n"
1286 " statistics [--reset] [--pattern <pattern>]\n"
1287 " [--descriptions]\n"
1288 "\n", SEP);
1289 }
1290 if (fCategory & USAGE_METRICS)
1291 RTStrmPrintf(pStrm,
1292 "%s metrics %s list [*|host|<vmname> [<metric_list>]]\n"
1293 " (comma-separated)\n\n"
1294 "%s metrics %s setup\n"
1295 " [--period <seconds>] (default: 1)\n"
1296 " [--samples <count>] (default: 1)\n"
1297 " [--list]\n"
1298 " [*|host|<vmname> [<metric_list>]]\n\n"
1299 "%s metrics %s query [*|host|<vmname> [<metric_list>]]\n\n"
1300 "%s metrics %s enable\n"
1301 " [--list]\n"
1302 " [*|host|<vmname> [<metric_list>]]\n\n"
1303 "%s metrics %s disable\n"
1304 " [--list]\n"
1305 " [*|host|<vmname> [<metric_list>]]\n\n"
1306 "%s metrics %s collect\n"
1307 " [--period <seconds>] (default: 1)\n"
1308 " [--samples <count>] (default: 1)\n"
1309 " [--list]\n"
1310 " [--detach]\n"
1311 " [*|host|<vmname> [<metric_list>]]\n"
1312 "\n", SEP, SEP, SEP, SEP, SEP, SEP);
1313
1314#if defined(VBOX_WITH_NAT_SERVICE)
1315 if (fCategory & USAGE_NATNETWORK)
1316 {
1317 RTStrmPrintf(pStrm,
1318 "%s natnetwork %s add --netname <name>\n"
1319 " --network <network>\n"
1320 " [--enable|--disable]\n"
1321 " [--dhcp on|off]\n"
1322 " [--port-forward-4 <rule>]\n"
1323 " [--loopback-4 <rule>]\n"
1324 " [--ipv6 on|off]\n"
1325 " [--port-forward-6 <rule>]\n"
1326 " [--loopback-6 <rule>]\n\n"
1327 "%s natnetwork %s remove --netname <name>\n\n"
1328 "%s natnetwork %s modify --netname <name>\n"
1329 " [--network <network>]\n"
1330 " [--enable|--disable]\n"
1331 " [--dhcp on|off]\n"
1332 " [--port-forward-4 <rule>]\n"
1333 " [--loopback-4 <rule>]\n"
1334 " [--ipv6 on|off]\n"
1335 " [--port-forward-6 <rule>]\n"
1336 " [--loopback-6 <rule>]\n\n"
1337 "%s natnetwork %s start --netname <name>\n\n"
1338 "%s natnetwork %s stop --netname <name>\n"
1339 "\n", SEP, SEP, SEP, SEP, SEP);
1340
1341
1342 }
1343#endif
1344
1345#if defined(VBOX_WITH_NETFLT)
1346 if (fCategory & USAGE_HOSTONLYIFS)
1347 {
1348 RTStrmPrintf(pStrm,
1349 "%s hostonlyif %s ipconfig <name>\n"
1350 " [--dhcp |\n"
1351 " --ip<ipv4> [--netmask<ipv4> (def: 255.255.255.0)] |\n"
1352 " --ipv6<ipv6> [--netmasklengthv6<length> (def: 64)]]\n"
1353# if !defined(RT_OS_SOLARIS) || defined(VBOX_ONLY_DOCS)
1354 " create |\n"
1355 " remove <name>\n"
1356# endif
1357 "\n", SEP);
1358 }
1359#endif
1360
1361 if (fCategory & USAGE_DHCPSERVER)
1362 {
1363 RTStrmPrintf(pStrm,
1364 "%s dhcpserver %s add|modify --netname <network_name> |\n"
1365#if defined(VBOX_WITH_NETFLT)
1366 " --ifname <hostonly_if_name>\n"
1367#endif
1368 " [--ip <ip_address>\n"
1369 " --netmask <network_mask>\n"
1370 " --lowerip <lower_ip>\n"
1371 " --upperip <upper_ip>]\n"
1372 " [--enable | --disable]\n\n"
1373 "%s dhcpserver %s remove --netname <network_name> |\n"
1374#if defined(VBOX_WITH_NETFLT)
1375 " --ifname <hostonly_if_name>\n"
1376#endif
1377 "\n", SEP, SEP);
1378 }
1379
1380#ifndef VBOX_ONLY_DOCS /* Converted to man page, not needed. */
1381 if (fCategory == USAGE_ALL)
1382 {
1383 uint32_t cPendingBlankLines = 0;
1384 for (uint32_t i = 0; i < g_cHelpEntries; i++)
1385 {
1386 PCREFENTRY pHelp = g_apHelpEntries[i];
1387 RTStrmPrintf(pStrm, " %c%s:\n", RT_C_TO_UPPER(pHelp->pszBrief[0]), pHelp->pszBrief + 1);
1388 cPendingBlankLines = printStringTable(pStrm, &pHelp->Synopsis, REFENTRYSTR_SCOPE_GLOBAL, cPendingBlankLines);
1389 if (!cPendingBlankLines)
1390 cPendingBlankLines = 1;
1391 }
1392 }
1393
1394#endif
1395}
1396
1397/**
1398 * Print a usage synopsis and the syntax error message.
1399 * @returns RTEXITCODE_SYNTAX.
1400 */
1401RTEXITCODE errorSyntax(USAGECATEGORY fCategory, const char *pszFormat, ...)
1402{
1403 va_list args;
1404 showLogo(g_pStdErr); // show logo even if suppressed
1405#ifndef VBOX_ONLY_DOCS
1406 if (g_fInternalMode)
1407 printUsageInternal(fCategory, g_pStdErr);
1408 else
1409 printUsage(fCategory, ~0U, g_pStdErr);
1410#endif /* !VBOX_ONLY_DOCS */
1411 va_start(args, pszFormat);
1412 RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
1413 va_end(args);
1414 return RTEXITCODE_SYNTAX;
1415}
1416
1417/**
1418 * Print a usage synopsis and the syntax error message.
1419 * @returns RTEXITCODE_SYNTAX.
1420 */
1421RTEXITCODE errorSyntaxEx(USAGECATEGORY fCategory, uint32_t fSubCategory, const char *pszFormat, ...)
1422{
1423 va_list args;
1424 showLogo(g_pStdErr); // show logo even if suppressed
1425#ifndef VBOX_ONLY_DOCS
1426 if (g_fInternalMode)
1427 printUsageInternal(fCategory, g_pStdErr);
1428 else
1429 printUsage(fCategory, fSubCategory, g_pStdErr);
1430#endif /* !VBOX_ONLY_DOCS */
1431 va_start(args, pszFormat);
1432 RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
1433 va_end(args);
1434 return RTEXITCODE_SYNTAX;
1435}
1436
1437/**
1438 * errorSyntax for RTGetOpt users.
1439 *
1440 * @returns RTEXITCODE_SYNTAX.
1441 *
1442 * @param fCategory The usage category of the command.
1443 * @param fSubCategory The usage sub-category of the command.
1444 * @param rc The RTGetOpt return code.
1445 * @param pValueUnion The value union.
1446 */
1447RTEXITCODE errorGetOptEx(USAGECATEGORY fCategory, uint32_t fSubCategory, int rc, union RTGETOPTUNION const *pValueUnion)
1448{
1449 /*
1450 * Check if it is an unhandled standard option.
1451 */
1452 if (rc == 'V')
1453 {
1454 RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision());
1455 return RTEXITCODE_SUCCESS;
1456 }
1457
1458 if (rc == 'h')
1459 {
1460 showLogo(g_pStdErr);
1461#ifndef VBOX_ONLY_DOCS
1462 if (g_fInternalMode)
1463 printUsageInternal(fCategory, g_pStdOut);
1464 else
1465 printUsage(fCategory, fSubCategory, g_pStdOut);
1466#endif
1467 return RTEXITCODE_SUCCESS;
1468 }
1469
1470 /*
1471 * General failure.
1472 */
1473 showLogo(g_pStdErr); // show logo even if suppressed
1474#ifndef VBOX_ONLY_DOCS
1475 if (g_fInternalMode)
1476 printUsageInternal(fCategory, g_pStdErr);
1477 else
1478 printUsage(fCategory, fSubCategory, g_pStdErr);
1479#endif /* !VBOX_ONLY_DOCS */
1480
1481 if (rc == VINF_GETOPT_NOT_OPTION)
1482 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid parameter '%s'", pValueUnion->psz);
1483 if (rc > 0)
1484 {
1485 if (RT_C_IS_PRINT(rc))
1486 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option -%c", rc);
1487 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option case %i", rc);
1488 }
1489 if (rc == VERR_GETOPT_UNKNOWN_OPTION)
1490 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unknown option: %s", pValueUnion->psz);
1491 if (rc == VERR_GETOPT_INVALID_ARGUMENT_FORMAT)
1492 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid argument format: %s", pValueUnion->psz);
1493 if (pValueUnion->pDef)
1494 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%s: %Rrs", pValueUnion->pDef->pszLong, rc);
1495 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%Rrs", rc);
1496}
1497
1498/**
1499 * errorSyntax for RTGetOpt users.
1500 *
1501 * @returns RTEXITCODE_SYNTAX.
1502 *
1503 * @param fUsageCategory The usage category of the command.
1504 * @param rc The RTGetOpt return code.
1505 * @param pValueUnion The value union.
1506 */
1507RTEXITCODE errorGetOpt(USAGECATEGORY fCategory, int rc, union RTGETOPTUNION const *pValueUnion)
1508{
1509 return errorGetOptEx(fCategory, ~0U, rc, pValueUnion);
1510}
1511
1512/**
1513 * Print an error message without the syntax stuff.
1514 *
1515 * @returns RTEXITCODE_SYNTAX.
1516 */
1517RTEXITCODE errorArgument(const char *pszFormat, ...)
1518{
1519 va_list args;
1520 va_start(args, pszFormat);
1521 RTMsgErrorV(pszFormat, args);
1522 va_end(args);
1523 return RTEXITCODE_SYNTAX;
1524}
1525
1526
1527
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