VirtualBox

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

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

VBoxManage generated help updates, manual/Makefile.kmk hacking, related stuff.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 67.3 KB
Line 
1/* $Id: VBoxManageHelp.cpp 56533 2015-06-18 18:15:51Z 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 " [--snapshotfolder default|<path>]\n"
854 " [--teleporter on|off]\n"
855 " [--teleporterport <port>]\n"
856 " [--teleporteraddress <address|empty>\n"
857 " [--teleporterpassword <password>]\n"
858 " [--teleporterpasswordfile <file>|stdin]\n"
859 " [--tracing-enabled on|off]\n"
860 " [--tracing-config <config-string>]\n"
861 " [--tracing-allow-vm-access on|off]\n"
862#if 0
863 " [--iocache on|off]\n"
864 " [--iocachesize <I/O cache size in MB>]\n"
865#endif
866#if 0
867 " [--faulttolerance master|standby]\n"
868 " [--faulttoleranceaddress <name>]\n"
869 " [--faulttoleranceport <port>]\n"
870 " [--faulttolerancesyncinterval <msec>]\n"
871 " [--faulttolerancepassword <password>]\n"
872#endif
873#ifdef VBOX_WITH_USB_CARDREADER
874 " [--usbcardreader on|off]\n"
875#endif
876 " [--autostart-enabled on|off]\n"
877 " [--autostart-delay <seconds>]\n"
878#if 0
879 " [--autostop-type disabled|savestate|poweroff|\n"
880 " acpishutdown]\n"
881#endif
882#ifdef VBOX_WITH_VPX
883 " [--videocap on|off]\n"
884 " [--videocapscreens all|<screen ID> [<screen ID> ...]]\n"
885 " [--videocapfile <filename>]\n"
886 " [--videocapres <width> <height>]\n"
887 " [--videocaprate <rate>]\n"
888 " [--videocapfps <fps>]\n"
889 " [--videocapmaxtime <time>]\n"
890 " [--videocapmaxsize <MB>]\n"
891 " [--videocapopts <key=value> [<key=value> ...]]\n"
892#endif
893 " [--defaultfrontend default|<name>]\n"
894 "\n");
895 }
896
897 if (fCategory & USAGE_CLONEVM)
898 RTStrmPrintf(pStrm,
899 "%s clonevm %s <uuid|vmname>\n"
900 " [--snapshot <uuid>|<name>]\n"
901 " [--mode machine|machineandchildren|all]\n"
902 " [--options link|keepallmacs|keepnatmacs|\n"
903 " keepdisknames]\n"
904 " [--name <name>]\n"
905 " [--groups <group>, ...]\n"
906 " [--basefolder <basefolder>]\n"
907 " [--uuid <uuid>]\n"
908 " [--register]\n"
909 "\n", SEP);
910
911 if (fCategory & USAGE_IMPORTAPPLIANCE)
912 RTStrmPrintf(pStrm,
913 "%s import %s <ovfname/ovaname>\n"
914 " [--dry-run|-n]\n"
915 " [--options keepallmacs|keepnatmacs|importtovdi]\n"
916 " [more options]\n"
917 " (run with -n to have options displayed\n"
918 " for a particular OVF)\n\n", SEP);
919
920 if (fCategory & USAGE_EXPORTAPPLIANCE)
921 RTStrmPrintf(pStrm,
922 "%s export %s <machines> --output|-o <name>.<ovf/ova>\n"
923 " [--legacy09|--ovf09|--ovf10|--ovf20]\n"
924 " [--manifest]\n"
925 " [--iso]\n"
926 " [--options manifest|iso|nomacs|nomacsbutnat]\n"
927 " [--vsys <number of virtual system>]\n"
928 " [--product <product name>]\n"
929 " [--producturl <product url>]\n"
930 " [--vendor <vendor name>]\n"
931 " [--vendorurl <vendor url>]\n"
932 " [--version <version info>]\n"
933 " [--description <description info>]\n"
934 " [--eula <license text>]\n"
935 " [--eulafile <filename>]\n"
936 "\n", SEP);
937
938 if (fCategory & USAGE_STARTVM)
939 {
940 RTStrmPrintf(pStrm,
941 "%s startvm %s <uuid|vmname>...\n"
942 " [--type gui", SEP);
943 if (fVBoxSDL)
944 RTStrmPrintf(pStrm, "|sdl");
945 RTStrmPrintf(pStrm, "|headless|separate]\n");
946 RTStrmPrintf(pStrm,
947 "\n");
948 }
949
950 if (fCategory & USAGE_CONTROLVM)
951 {
952 RTStrmPrintf(pStrm,
953 "%s controlvm %s <uuid|vmname>\n"
954 " pause|resume|reset|poweroff|savestate|\n"
955 " acpipowerbutton|acpisleepbutton|\n"
956 " keyboardputscancode <hex> [<hex> ...]|\n"
957 " setlinkstate<1-N> on|off |\n"
958#if defined(VBOX_WITH_NETFLT)
959 " nic<1-N> null|nat|bridged|intnet|hostonly|generic|\n"
960 " natnetwork [<devicename>] |\n"
961#else /* !VBOX_WITH_NETFLT */
962 " nic<1-N> null|nat|bridged|intnet|generic|natnetwork\n"
963 " [<devicename>] |\n"
964#endif /* !VBOX_WITH_NETFLT */
965 " nictrace<1-N> on|off |\n"
966 " nictracefile<1-N> <filename> |\n"
967 " nicproperty<1-N> name=[value] |\n"
968 " nicpromisc<1-N> deny|allow-vms|allow-all |\n"
969 " natpf<1-N> [<rulename>],tcp|udp,[<hostip>],\n"
970 " <hostport>,[<guestip>],<guestport> |\n"
971 " natpf<1-N> delete <rulename> |\n"
972 " guestmemoryballoon <balloonsize in MB> |\n"
973 " usbattach <uuid>|<address>\n"
974 " [--capturefile <filename>] |\n"
975 " usbdetach <uuid>|<address> |\n"
976 " clipboard disabled|hosttoguest|guesttohost|\n"
977 " bidirectional |\n"
978 " draganddrop disabled|hosttoguest |\n"
979 " vrde on|off |\n"
980 " vrdeport <port> |\n"
981 " vrdeproperty <name=[value]> |\n"
982 " vrdevideochannelquality <percent> |\n"
983 " setvideomodehint <xres> <yres> <bpp>\n"
984 " [[<display>] [<enabled:yes|no> |\n"
985 " [<xorigin> <yorigin>]]] |\n"
986 " screenshotpng <file> [display] |\n"
987 " vcpenabled on|off |\n"
988 " vcpscreens all|none|<screen>,[<screen>...] |\n"
989 " setcredentials <username>\n"
990 " --passwordfile <file> | <password>\n"
991 " <domain>\n"
992 " [--allowlocallogon <yes|no>] |\n"
993 " teleport --host <name> --port <port>\n"
994 " [--maxdowntime <msec>]\n"
995 " [--passwordfile <file> |\n"
996 " --password <password>] |\n"
997 " plugcpu <id> |\n"
998 " unplugcpu <id> |\n"
999 " cpuexecutioncap <1-100>\n"
1000 " webcam <attach [path [settings]]> | <detach [path]> | <list>\n"
1001 " addencpassword <id>\n"
1002 " <password file>|-\n"
1003 " [--removeonsuspend <yes|no>]\n"
1004 " removeencpassword <id>\n"
1005 " removeallencpasswords\n"
1006 "\n", SEP);
1007 }
1008
1009 if (fCategory & USAGE_DISCARDSTATE)
1010 RTStrmPrintf(pStrm,
1011 "%s discardstate %s <uuid|vmname>\n"
1012 "\n", SEP);
1013
1014 if (fCategory & USAGE_ADOPTSTATE)
1015 RTStrmPrintf(pStrm,
1016 "%s adoptstate %s <uuid|vmname> <state_file>\n"
1017 "\n", SEP);
1018
1019 if (fCategory & USAGE_SNAPSHOT)
1020 RTStrmPrintf(pStrm,
1021 "%s snapshot %s <uuid|vmname>\n"
1022 " take <name> [--description <desc>] [--live]\n"
1023 " [--uniquename Number,Timestamp,Space,Force] |\n"
1024 " delete <uuid|snapname> |\n"
1025 " restore <uuid|snapname> |\n"
1026 " restorecurrent |\n"
1027 " edit <uuid|snapname>|--current\n"
1028 " [--name <name>]\n"
1029 " [--description <desc>] |\n"
1030 " list [--details|--machinereadable]\n"
1031 " showvminfo <uuid|snapname>\n"
1032 "\n", SEP);
1033
1034 if (fCategory & USAGE_CLOSEMEDIUM)
1035 RTStrmPrintf(pStrm,
1036 "%s closemedium %s [disk|dvd|floppy] <uuid|filename>\n"
1037 " [--delete]\n"
1038 "\n", SEP);
1039
1040 if (fCategory & USAGE_STORAGEATTACH)
1041 RTStrmPrintf(pStrm,
1042 "%s storageattach %s <uuid|vmname>\n"
1043 " --storagectl <name>\n"
1044 " [--port <number>]\n"
1045 " [--device <number>]\n"
1046 " [--type dvddrive|hdd|fdd]\n"
1047 " [--medium none|emptydrive|additions|\n"
1048 " <uuid|filename>|host:<drive>|iscsi]\n"
1049 " [--mtype normal|writethrough|immutable|shareable|\n"
1050 " readonly|multiattach]\n"
1051 " [--comment <text>]\n"
1052 " [--setuuid <uuid>]\n"
1053 " [--setparentuuid <uuid>]\n"
1054 " [--passthrough on|off]\n"
1055 " [--tempeject on|off]\n"
1056 " [--nonrotational on|off]\n"
1057 " [--discard on|off]\n"
1058 " [--hotpluggable on|off]\n"
1059 " [--bandwidthgroup <name>]\n"
1060 " [--forceunmount]\n"
1061 " [--server <name>|<ip>]\n"
1062 " [--target <target>]\n"
1063 " [--tport <port>]\n"
1064 " [--lun <lun>]\n"
1065 " [--encodedlun <lun>]\n"
1066 " [--username <username>]\n"
1067 " [--password <password>]\n"
1068 " [--initiator <initiator>]\n"
1069 " [--intnet]\n"
1070 "\n", SEP);
1071
1072 if (fCategory & USAGE_STORAGECONTROLLER)
1073 RTStrmPrintf(pStrm,
1074 "%s storagectl %s <uuid|vmname>\n"
1075 " --name <name>\n"
1076 " [--add ide|sata|scsi|floppy|sas]\n"
1077 " [--controller LSILogic|LSILogicSAS|BusLogic|\n"
1078 " IntelAHCI|PIIX3|PIIX4|ICH6|I82078]\n"
1079 " [--portcount <1-n>]\n"
1080 " [--hostiocache on|off]\n"
1081 " [--bootable on|off]\n"
1082 " [--remove]\n"
1083 "\n", SEP);
1084
1085 if (fCategory & USAGE_BANDWIDTHCONTROL)
1086 RTStrmPrintf(pStrm,
1087 "%s bandwidthctl %s <uuid|vmname>\n"
1088 " add <name> --type disk|network\n"
1089 " --limit <megabytes per second>[k|m|g|K|M|G] |\n"
1090 " set <name>\n"
1091 " --limit <megabytes per second>[k|m|g|K|M|G] |\n"
1092 " remove <name> |\n"
1093 " list [--machinereadable]\n"
1094 " (limit units: k=kilobit, m=megabit, g=gigabit,\n"
1095 " K=kilobyte, M=megabyte, G=gigabyte)\n"
1096 "\n", SEP);
1097
1098 if (fCategory & USAGE_SHOWMEDIUMINFO)
1099 RTStrmPrintf(pStrm,
1100 "%s showmediuminfo %s [disk|dvd|floppy] <uuid|filename>\n"
1101 "\n", SEP);
1102
1103 if (fCategory & USAGE_CREATEMEDIUM)
1104 RTStrmPrintf(pStrm,
1105 "%s createmedium %s [disk|dvd|floppy] --filename <filename>\n"
1106 " [--size <megabytes>|--sizebyte <bytes>]\n"
1107 " [--diffparent <uuid>|<filename>\n"
1108 " [--format VDI|VMDK|VHD] (default: VDI)\n"
1109 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1110 "\n", SEP);
1111
1112 if (fCategory & USAGE_MODIFYMEDIUM)
1113 RTStrmPrintf(pStrm,
1114 "%s modifymedium %s [disk|dvd|floppy] <uuid|filename>\n"
1115 " [--type normal|writethrough|immutable|shareable|\n"
1116 " readonly|multiattach]\n"
1117 " [--autoreset on|off]\n"
1118 " [--property <name=[value]>]\n"
1119 " [--compact]\n"
1120 " [--resize <megabytes>|--resizebyte <bytes>]\n"
1121 "\n", SEP);
1122
1123 if (fCategory & USAGE_CLONEMEDIUM)
1124 RTStrmPrintf(pStrm,
1125 "%s clonemedium %s [disk|dvd|floppy] <uuid|inputfile> <uuid|outputfile>\n"
1126 " [--format VDI|VMDK|VHD|RAW|<other>]\n"
1127 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1128 " [--existing]\n"
1129 "\n", SEP);
1130
1131 if (fCategory & USAGE_MEDIUMPROPERTY)
1132 RTStrmPrintf(pStrm,
1133 "%s mediumproperty %s [disk|dvd|floppy] set <uuid|filename>\n"
1134 " <property> <value>\n"
1135 "\n"
1136 " [disk|dvd|floppy] get <uuid|filename>\n"
1137 " <property>\n"
1138 "\n"
1139 " [disk|dvd|floppy] delete <uuid|filename>\n"
1140 " <property>\n"
1141 "\n", SEP);
1142
1143 if (fCategory & USAGE_ENCRYPTMEDIUM)
1144 RTStrmPrintf(pStrm,
1145 "%s encryptmedium %s <uuid|filename>\n"
1146 " [--newpassword <file>|-]\n"
1147 " [--oldpassword <file>|-]\n"
1148 " [--cipher <cipher identifier>]\n"
1149 " [--newpasswordid <password identifier>]\n"
1150 "\n", SEP);
1151
1152 if (fCategory & USAGE_MEDIUMENCCHKPWD)
1153 RTStrmPrintf(pStrm,
1154 "%s checkmediumpwd %s <uuid|filename>\n"
1155 " <pwd file>|-\n"
1156 "\n", SEP);
1157
1158 if (fCategory & USAGE_CONVERTFROMRAW)
1159 RTStrmPrintf(pStrm,
1160 "%s convertfromraw %s <filename> <outputfile>\n"
1161 " [--format VDI|VMDK|VHD]\n"
1162 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1163 " [--uuid <uuid>]\n"
1164 "%s convertfromraw %s stdin <outputfile> <bytes>\n"
1165 " [--format VDI|VMDK|VHD]\n"
1166 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1167 " [--uuid <uuid>]\n"
1168 "\n", SEP, SEP);
1169
1170 if (fCategory & USAGE_GETEXTRADATA)
1171 RTStrmPrintf(pStrm,
1172 "%s getextradata %s global|<uuid|vmname>\n"
1173 " <key>|enumerate\n"
1174 "\n", SEP);
1175
1176 if (fCategory & USAGE_SETEXTRADATA)
1177 RTStrmPrintf(pStrm,
1178 "%s setextradata %s global|<uuid|vmname>\n"
1179 " <key>\n"
1180 " [<value>] (no value deletes key)\n"
1181 "\n", SEP);
1182
1183 if (fCategory & USAGE_SETPROPERTY)
1184 RTStrmPrintf(pStrm,
1185 "%s setproperty %s machinefolder default|<folder> |\n"
1186 " hwvirtexclusive on|off |\n"
1187 " vrdeauthlibrary default|<library> |\n"
1188 " websrvauthlibrary default|null|<library> |\n"
1189 " vrdeextpack null|<library> |\n"
1190 " autostartdbpath null|<folder> |\n"
1191 " loghistorycount <value>\n"
1192 " defaultfrontend default|<name>\n"
1193 " logginglevel <log setting>\n"
1194 "\n", SEP);
1195
1196 if (fCategory & USAGE_USBFILTER_ADD)
1197 RTStrmPrintf(pStrm,
1198 "%s usbfilter %s add <index,0-N>\n"
1199 " --target <uuid|vmname>|global\n"
1200 " --name <string>\n"
1201 " --action ignore|hold (global filters only)\n"
1202 " [--active yes|no] (yes)\n"
1203 " [--vendorid <XXXX>] (null)\n"
1204 " [--productid <XXXX>] (null)\n"
1205 " [--revision <IIFF>] (null)\n"
1206 " [--manufacturer <string>] (null)\n"
1207 " [--product <string>] (null)\n"
1208 " [--remote yes|no] (null, VM filters only)\n"
1209 " [--serialnumber <string>] (null)\n"
1210 " [--maskedinterfaces <XXXXXXXX>]\n"
1211 "\n", SEP);
1212
1213 if (fCategory & USAGE_USBFILTER_MODIFY)
1214 RTStrmPrintf(pStrm,
1215 "%s usbfilter %s modify <index,0-N>\n"
1216 " --target <uuid|vmname>|global\n"
1217 " [--name <string>]\n"
1218 " [--action ignore|hold] (global filters only)\n"
1219 " [--active yes|no]\n"
1220 " [--vendorid <XXXX>|\"\"]\n"
1221 " [--productid <XXXX>|\"\"]\n"
1222 " [--revision <IIFF>|\"\"]\n"
1223 " [--manufacturer <string>|\"\"]\n"
1224 " [--product <string>|\"\"]\n"
1225 " [--remote yes|no] (null, VM filters only)\n"
1226 " [--serialnumber <string>|\"\"]\n"
1227 " [--maskedinterfaces <XXXXXXXX>]\n"
1228 "\n", SEP);
1229
1230 if (fCategory & USAGE_USBFILTER_REMOVE)
1231 RTStrmPrintf(pStrm,
1232 "%s usbfilter %s remove <index,0-N>\n"
1233 " --target <uuid|vmname>|global\n"
1234 "\n", SEP);
1235
1236 if (fCategory & USAGE_SHAREDFOLDER_ADD)
1237 RTStrmPrintf(pStrm,
1238 "%s sharedfolder %s add <uuid|vmname>\n"
1239 " --name <name> --hostpath <hostpath>\n"
1240 " [--transient] [--readonly] [--automount]\n"
1241 "\n", SEP);
1242
1243 if (fCategory & USAGE_SHAREDFOLDER_REMOVE)
1244 RTStrmPrintf(pStrm,
1245 "%s sharedfolder %s remove <uuid|vmname>\n"
1246 " --name <name> [--transient]\n"
1247 "\n", SEP);
1248
1249#ifdef VBOX_WITH_GUEST_PROPS
1250 if (fCategory & USAGE_GUESTPROPERTY)
1251 usageGuestProperty(pStrm, SEP);
1252#endif /* VBOX_WITH_GUEST_PROPS defined */
1253
1254#ifdef VBOX_WITH_GUEST_CONTROL
1255 if (fCategory & USAGE_GUESTCONTROL)
1256 usageGuestControl(pStrm, SEP, fSubCategory);
1257#endif /* VBOX_WITH_GUEST_CONTROL defined */
1258
1259 if (fCategory & USAGE_DEBUGVM)
1260 {
1261 RTStrmPrintf(pStrm,
1262 "%s debugvm %s <uuid|vmname>\n"
1263 " dumpguestcore --filename <name> |\n"
1264 " info <item> [args] |\n"
1265 " injectnmi |\n"
1266 " log [--release|--debug] <settings> ...|\n"
1267 " logdest [--release|--debug] <settings> ...|\n"
1268 " logflags [--release|--debug] <settings> ...|\n"
1269 " osdetect |\n"
1270 " osinfo |\n"
1271 " osdmesg [--lines|-n <N>] |\n"
1272 " getregisters [--cpu <id>] <reg>|all ... |\n"
1273 " setregisters [--cpu <id>] <reg>=<value> ... |\n"
1274 " show [--human-readable|--sh-export|--sh-eval|\n"
1275 " --cmd-set] \n"
1276 " <logdbg-settings|logrel-settings>\n"
1277 " [[opt] what ...] |\n"
1278 " statistics [--reset] [--pattern <pattern>]\n"
1279 " [--descriptions]\n"
1280 "\n", SEP);
1281 }
1282 if (fCategory & USAGE_METRICS)
1283 RTStrmPrintf(pStrm,
1284 "%s metrics %s list [*|host|<vmname> [<metric_list>]]\n"
1285 " (comma-separated)\n\n"
1286 "%s metrics %s setup\n"
1287 " [--period <seconds>] (default: 1)\n"
1288 " [--samples <count>] (default: 1)\n"
1289 " [--list]\n"
1290 " [*|host|<vmname> [<metric_list>]]\n\n"
1291 "%s metrics %s query [*|host|<vmname> [<metric_list>]]\n\n"
1292 "%s metrics %s enable\n"
1293 " [--list]\n"
1294 " [*|host|<vmname> [<metric_list>]]\n\n"
1295 "%s metrics %s disable\n"
1296 " [--list]\n"
1297 " [*|host|<vmname> [<metric_list>]]\n\n"
1298 "%s metrics %s collect\n"
1299 " [--period <seconds>] (default: 1)\n"
1300 " [--samples <count>] (default: 1)\n"
1301 " [--list]\n"
1302 " [--detach]\n"
1303 " [*|host|<vmname> [<metric_list>]]\n"
1304 "\n", SEP, SEP, SEP, SEP, SEP, SEP);
1305
1306#if defined(VBOX_WITH_NAT_SERVICE)
1307 if (fCategory & USAGE_NATNETWORK)
1308 {
1309 RTStrmPrintf(pStrm,
1310 "%s natnetwork %s add --netname <name>\n"
1311 " --network <network>\n"
1312 " [--enable|--disable]\n"
1313 " [--dhcp on|off]\n"
1314 " [--port-forward-4 <rule>]\n"
1315 " [--loopback-4 <rule>]\n"
1316 " [--ipv6 on|off]\n"
1317 " [--port-forward-6 <rule>]\n"
1318 " [--loopback-6 <rule>]\n\n"
1319 "%s natnetwork %s remove --netname <name>\n\n"
1320 "%s natnetwork %s modify --netname <name>\n"
1321 " [--network <network>]\n"
1322 " [--enable|--disable]\n"
1323 " [--dhcp on|off]\n"
1324 " [--port-forward-4 <rule>]\n"
1325 " [--loopback-4 <rule>]\n"
1326 " [--ipv6 on|off]\n"
1327 " [--port-forward-6 <rule>]\n"
1328 " [--loopback-6 <rule>]\n\n"
1329 "%s natnetwork %s start --netname <name>\n\n"
1330 "%s natnetwork %s stop --netname <name>\n"
1331 "\n", SEP, SEP, SEP, SEP, SEP);
1332
1333
1334 }
1335#endif
1336
1337#if defined(VBOX_WITH_NETFLT)
1338 if (fCategory & USAGE_HOSTONLYIFS)
1339 {
1340 RTStrmPrintf(pStrm,
1341 "%s hostonlyif %s ipconfig <name>\n"
1342 " [--dhcp |\n"
1343 " --ip<ipv4> [--netmask<ipv4> (def: 255.255.255.0)] |\n"
1344 " --ipv6<ipv6> [--netmasklengthv6<length> (def: 64)]]\n"
1345# if !defined(RT_OS_SOLARIS) || defined(VBOX_ONLY_DOCS)
1346 " create |\n"
1347 " remove <name>\n"
1348# endif
1349 "\n", SEP);
1350 }
1351#endif
1352
1353 if (fCategory & USAGE_DHCPSERVER)
1354 {
1355 RTStrmPrintf(pStrm,
1356 "%s dhcpserver %s add|modify --netname <network_name> |\n"
1357#if defined(VBOX_WITH_NETFLT)
1358 " --ifname <hostonly_if_name>\n"
1359#endif
1360 " [--ip <ip_address>\n"
1361 " --netmask <network_mask>\n"
1362 " --lowerip <lower_ip>\n"
1363 " --upperip <upper_ip>]\n"
1364 " [--enable | --disable]\n\n"
1365 "%s dhcpserver %s remove --netname <network_name> |\n"
1366#if defined(VBOX_WITH_NETFLT)
1367 " --ifname <hostonly_if_name>\n"
1368#endif
1369 "\n", SEP, SEP);
1370 }
1371
1372#ifndef VBOX_ONLY_DOCS /* Converted to man page, not needed. */
1373 if (fCategory == USAGE_ALL)
1374 {
1375 uint32_t cPendingBlankLines = 0;
1376 for (uint32_t i = 0; i < g_cHelpEntries; i++)
1377 {
1378 PCREFENTRY pHelp = g_apHelpEntries[i];
1379 RTStrmPrintf(pStrm, " %c%s:\n", RT_C_TO_UPPER(pHelp->pszBrief[0]), pHelp->pszBrief + 1);
1380 cPendingBlankLines = printStringTable(pStrm, &pHelp->Synopsis, REFENTRYSTR_SCOPE_GLOBAL, cPendingBlankLines);
1381 if (!cPendingBlankLines)
1382 cPendingBlankLines = 1;
1383 }
1384 }
1385
1386#endif
1387}
1388
1389/**
1390 * Print a usage synopsis and the syntax error message.
1391 * @returns RTEXITCODE_SYNTAX.
1392 */
1393RTEXITCODE errorSyntax(USAGECATEGORY fCategory, const char *pszFormat, ...)
1394{
1395 va_list args;
1396 showLogo(g_pStdErr); // show logo even if suppressed
1397#ifndef VBOX_ONLY_DOCS
1398 if (g_fInternalMode)
1399 printUsageInternal(fCategory, g_pStdErr);
1400 else
1401 printUsage(fCategory, ~0U, g_pStdErr);
1402#endif /* !VBOX_ONLY_DOCS */
1403 va_start(args, pszFormat);
1404 RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
1405 va_end(args);
1406 return RTEXITCODE_SYNTAX;
1407}
1408
1409/**
1410 * Print a usage synopsis and the syntax error message.
1411 * @returns RTEXITCODE_SYNTAX.
1412 */
1413RTEXITCODE errorSyntaxEx(USAGECATEGORY fCategory, uint32_t fSubCategory, const char *pszFormat, ...)
1414{
1415 va_list args;
1416 showLogo(g_pStdErr); // show logo even if suppressed
1417#ifndef VBOX_ONLY_DOCS
1418 if (g_fInternalMode)
1419 printUsageInternal(fCategory, g_pStdErr);
1420 else
1421 printUsage(fCategory, fSubCategory, g_pStdErr);
1422#endif /* !VBOX_ONLY_DOCS */
1423 va_start(args, pszFormat);
1424 RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
1425 va_end(args);
1426 return RTEXITCODE_SYNTAX;
1427}
1428
1429/**
1430 * errorSyntax for RTGetOpt users.
1431 *
1432 * @returns RTEXITCODE_SYNTAX.
1433 *
1434 * @param fCategory The usage category of the command.
1435 * @param fSubCategory The usage sub-category of the command.
1436 * @param rc The RTGetOpt return code.
1437 * @param pValueUnion The value union.
1438 */
1439RTEXITCODE errorGetOptEx(USAGECATEGORY fCategory, uint32_t fSubCategory, int rc, union RTGETOPTUNION const *pValueUnion)
1440{
1441 /*
1442 * Check if it is an unhandled standard option.
1443 */
1444 if (rc == 'V')
1445 {
1446 RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision());
1447 return RTEXITCODE_SUCCESS;
1448 }
1449
1450 if (rc == 'h')
1451 {
1452 showLogo(g_pStdErr);
1453#ifndef VBOX_ONLY_DOCS
1454 if (g_fInternalMode)
1455 printUsageInternal(fCategory, g_pStdOut);
1456 else
1457 printUsage(fCategory, fSubCategory, g_pStdOut);
1458#endif
1459 return RTEXITCODE_SUCCESS;
1460 }
1461
1462 /*
1463 * General failure.
1464 */
1465 showLogo(g_pStdErr); // show logo even if suppressed
1466#ifndef VBOX_ONLY_DOCS
1467 if (g_fInternalMode)
1468 printUsageInternal(fCategory, g_pStdErr);
1469 else
1470 printUsage(fCategory, fSubCategory, g_pStdErr);
1471#endif /* !VBOX_ONLY_DOCS */
1472
1473 if (rc == VINF_GETOPT_NOT_OPTION)
1474 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid parameter '%s'", pValueUnion->psz);
1475 if (rc > 0)
1476 {
1477 if (RT_C_IS_PRINT(rc))
1478 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option -%c", rc);
1479 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option case %i", rc);
1480 }
1481 if (rc == VERR_GETOPT_UNKNOWN_OPTION)
1482 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unknown option: %s", pValueUnion->psz);
1483 if (rc == VERR_GETOPT_INVALID_ARGUMENT_FORMAT)
1484 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid argument format: %s", pValueUnion->psz);
1485 if (pValueUnion->pDef)
1486 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%s: %Rrs", pValueUnion->pDef->pszLong, rc);
1487 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%Rrs", rc);
1488}
1489
1490/**
1491 * errorSyntax for RTGetOpt users.
1492 *
1493 * @returns RTEXITCODE_SYNTAX.
1494 *
1495 * @param fUsageCategory The usage category of the command.
1496 * @param rc The RTGetOpt return code.
1497 * @param pValueUnion The value union.
1498 */
1499RTEXITCODE errorGetOpt(USAGECATEGORY fCategory, int rc, union RTGETOPTUNION const *pValueUnion)
1500{
1501 return errorGetOptEx(fCategory, ~0U, rc, pValueUnion);
1502}
1503
1504/**
1505 * Print an error message without the syntax stuff.
1506 *
1507 * @returns RTEXITCODE_SYNTAX.
1508 */
1509RTEXITCODE errorArgument(const char *pszFormat, ...)
1510{
1511 va_list args;
1512 va_start(args, pszFormat);
1513 RTMsgErrorV(pszFormat, args);
1514 va_end(args);
1515 return RTEXITCODE_SYNTAX;
1516}
1517
1518
1519
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