VirtualBox

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

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

VBoxManage: adapted the video capture options in 'controlvm' to 'modifyvm'

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 67.8 KB
Line 
1/* $Id: VBoxManageHelp.cpp 56831 2015-07-07 09:54:32Z 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.215389.xyz. 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 <ms>]\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 " videocap on|off |\n"
988 " videocapscreens all|none|<screen>,[<screen>...] |\n"
989 " videocapfile <file>\n"
990 " videocapres <width>x<height>\n"
991 " videocaprate <rate>\n"
992 " videocapfps <fps>\n"
993 " videocapmaxtime <ms>\n"
994 " videocapmaxsize <MB>\n"
995 " setcredentials <username>\n"
996 " --passwordfile <file> | <password>\n"
997 " <domain>\n"
998 " [--allowlocallogon <yes|no>] |\n"
999 " teleport --host <name> --port <port>\n"
1000 " [--maxdowntime <msec>]\n"
1001 " [--passwordfile <file> |\n"
1002 " --password <password>] |\n"
1003 " plugcpu <id> |\n"
1004 " unplugcpu <id> |\n"
1005 " cpuexecutioncap <1-100>\n"
1006 " webcam <attach [path [settings]]> | <detach [path]> | <list>\n"
1007 " addencpassword <id>\n"
1008 " <password file>|-\n"
1009 " [--removeonsuspend <yes|no>]\n"
1010 " removeencpassword <id>\n"
1011 " removeallencpasswords\n"
1012 "\n", SEP);
1013 }
1014
1015 if (fCategory & USAGE_DISCARDSTATE)
1016 RTStrmPrintf(pStrm,
1017 "%s discardstate %s <uuid|vmname>\n"
1018 "\n", SEP);
1019
1020 if (fCategory & USAGE_ADOPTSTATE)
1021 RTStrmPrintf(pStrm,
1022 "%s adoptstate %s <uuid|vmname> <state_file>\n"
1023 "\n", SEP);
1024
1025 if (fCategory & USAGE_SNAPSHOT)
1026 RTStrmPrintf(pStrm,
1027 "%s snapshot %s <uuid|vmname>\n"
1028 " take <name> [--description <desc>] [--live]\n"
1029 " [--uniquename Number,Timestamp,Space,Force] |\n"
1030 " delete <uuid|snapname> |\n"
1031 " restore <uuid|snapname> |\n"
1032 " restorecurrent |\n"
1033 " edit <uuid|snapname>|--current\n"
1034 " [--name <name>]\n"
1035 " [--description <desc>] |\n"
1036 " list [--details|--machinereadable]\n"
1037 " showvminfo <uuid|snapname>\n"
1038 "\n", SEP);
1039
1040 if (fCategory & USAGE_CLOSEMEDIUM)
1041 RTStrmPrintf(pStrm,
1042 "%s closemedium %s [disk|dvd|floppy] <uuid|filename>\n"
1043 " [--delete]\n"
1044 "\n", SEP);
1045
1046 if (fCategory & USAGE_STORAGEATTACH)
1047 RTStrmPrintf(pStrm,
1048 "%s storageattach %s <uuid|vmname>\n"
1049 " --storagectl <name>\n"
1050 " [--port <number>]\n"
1051 " [--device <number>]\n"
1052 " [--type dvddrive|hdd|fdd]\n"
1053 " [--medium none|emptydrive|additions|\n"
1054 " <uuid|filename>|host:<drive>|iscsi]\n"
1055 " [--mtype normal|writethrough|immutable|shareable|\n"
1056 " readonly|multiattach]\n"
1057 " [--comment <text>]\n"
1058 " [--setuuid <uuid>]\n"
1059 " [--setparentuuid <uuid>]\n"
1060 " [--passthrough on|off]\n"
1061 " [--tempeject on|off]\n"
1062 " [--nonrotational on|off]\n"
1063 " [--discard on|off]\n"
1064 " [--hotpluggable on|off]\n"
1065 " [--bandwidthgroup <name>]\n"
1066 " [--forceunmount]\n"
1067 " [--server <name>|<ip>]\n"
1068 " [--target <target>]\n"
1069 " [--tport <port>]\n"
1070 " [--lun <lun>]\n"
1071 " [--encodedlun <lun>]\n"
1072 " [--username <username>]\n"
1073 " [--password <password>]\n"
1074 " [--initiator <initiator>]\n"
1075 " [--intnet]\n"
1076 "\n", SEP);
1077
1078 if (fCategory & USAGE_STORAGECONTROLLER)
1079 RTStrmPrintf(pStrm,
1080 "%s storagectl %s <uuid|vmname>\n"
1081 " --name <name>\n"
1082 " [--add ide|sata|scsi|floppy|sas]\n"
1083 " [--controller LSILogic|LSILogicSAS|BusLogic|\n"
1084 " IntelAHCI|PIIX3|PIIX4|ICH6|I82078]\n"
1085 " [--portcount <1-n>]\n"
1086 " [--hostiocache on|off]\n"
1087 " [--bootable on|off]\n"
1088 " [--rename <name>]\n"
1089 " [--remove]\n"
1090 "\n", SEP);
1091
1092 if (fCategory & USAGE_BANDWIDTHCONTROL)
1093 RTStrmPrintf(pStrm,
1094 "%s bandwidthctl %s <uuid|vmname>\n"
1095 " add <name> --type disk|network\n"
1096 " --limit <megabytes per second>[k|m|g|K|M|G] |\n"
1097 " set <name>\n"
1098 " --limit <megabytes per second>[k|m|g|K|M|G] |\n"
1099 " remove <name> |\n"
1100 " list [--machinereadable]\n"
1101 " (limit units: k=kilobit, m=megabit, g=gigabit,\n"
1102 " K=kilobyte, M=megabyte, G=gigabyte)\n"
1103 "\n", SEP);
1104
1105 if (fCategory & USAGE_SHOWMEDIUMINFO)
1106 RTStrmPrintf(pStrm,
1107 "%s showmediuminfo %s [disk|dvd|floppy] <uuid|filename>\n"
1108 "\n", SEP);
1109
1110 if (fCategory & USAGE_CREATEMEDIUM)
1111 RTStrmPrintf(pStrm,
1112 "%s createmedium %s [disk|dvd|floppy] --filename <filename>\n"
1113 " [--size <megabytes>|--sizebyte <bytes>]\n"
1114 " [--diffparent <uuid>|<filename>\n"
1115 " [--format VDI|VMDK|VHD] (default: VDI)\n"
1116 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1117 "\n", SEP);
1118
1119 if (fCategory & USAGE_MODIFYMEDIUM)
1120 RTStrmPrintf(pStrm,
1121 "%s modifymedium %s [disk|dvd|floppy] <uuid|filename>\n"
1122 " [--type normal|writethrough|immutable|shareable|\n"
1123 " readonly|multiattach]\n"
1124 " [--autoreset on|off]\n"
1125 " [--property <name=[value]>]\n"
1126 " [--compact]\n"
1127 " [--resize <megabytes>|--resizebyte <bytes>]\n"
1128 "\n", SEP);
1129
1130 if (fCategory & USAGE_CLONEMEDIUM)
1131 RTStrmPrintf(pStrm,
1132 "%s clonemedium %s [disk|dvd|floppy] <uuid|inputfile> <uuid|outputfile>\n"
1133 " [--format VDI|VMDK|VHD|RAW|<other>]\n"
1134 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1135 " [--existing]\n"
1136 "\n", SEP);
1137
1138 if (fCategory & USAGE_MEDIUMPROPERTY)
1139 RTStrmPrintf(pStrm,
1140 "%s mediumproperty %s [disk|dvd|floppy] set <uuid|filename>\n"
1141 " <property> <value>\n"
1142 "\n"
1143 " [disk|dvd|floppy] get <uuid|filename>\n"
1144 " <property>\n"
1145 "\n"
1146 " [disk|dvd|floppy] delete <uuid|filename>\n"
1147 " <property>\n"
1148 "\n", SEP);
1149
1150 if (fCategory & USAGE_ENCRYPTMEDIUM)
1151 RTStrmPrintf(pStrm,
1152 "%s encryptmedium %s <uuid|filename>\n"
1153 " [--newpassword <file>|-]\n"
1154 " [--oldpassword <file>|-]\n"
1155 " [--cipher <cipher identifier>]\n"
1156 " [--newpasswordid <password identifier>]\n"
1157 "\n", SEP);
1158
1159 if (fCategory & USAGE_MEDIUMENCCHKPWD)
1160 RTStrmPrintf(pStrm,
1161 "%s checkmediumpwd %s <uuid|filename>\n"
1162 " <pwd file>|-\n"
1163 "\n", SEP);
1164
1165 if (fCategory & USAGE_CONVERTFROMRAW)
1166 RTStrmPrintf(pStrm,
1167 "%s convertfromraw %s <filename> <outputfile>\n"
1168 " [--format VDI|VMDK|VHD]\n"
1169 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1170 " [--uuid <uuid>]\n"
1171 "%s convertfromraw %s stdin <outputfile> <bytes>\n"
1172 " [--format VDI|VMDK|VHD]\n"
1173 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1174 " [--uuid <uuid>]\n"
1175 "\n", SEP, SEP);
1176
1177 if (fCategory & USAGE_GETEXTRADATA)
1178 RTStrmPrintf(pStrm,
1179 "%s getextradata %s global|<uuid|vmname>\n"
1180 " <key>|enumerate\n"
1181 "\n", SEP);
1182
1183 if (fCategory & USAGE_SETEXTRADATA)
1184 RTStrmPrintf(pStrm,
1185 "%s setextradata %s global|<uuid|vmname>\n"
1186 " <key>\n"
1187 " [<value>] (no value deletes key)\n"
1188 "\n", SEP);
1189
1190 if (fCategory & USAGE_SETPROPERTY)
1191 RTStrmPrintf(pStrm,
1192 "%s setproperty %s machinefolder default|<folder> |\n"
1193 " hwvirtexclusive on|off |\n"
1194 " vrdeauthlibrary default|<library> |\n"
1195 " websrvauthlibrary default|null|<library> |\n"
1196 " vrdeextpack null|<library> |\n"
1197 " autostartdbpath null|<folder> |\n"
1198 " loghistorycount <value>\n"
1199 " defaultfrontend default|<name>\n"
1200 " logginglevel <log setting>\n"
1201 "\n", SEP);
1202
1203 if (fCategory & USAGE_USBFILTER_ADD)
1204 RTStrmPrintf(pStrm,
1205 "%s usbfilter %s add <index,0-N>\n"
1206 " --target <uuid|vmname>|global\n"
1207 " --name <string>\n"
1208 " --action ignore|hold (global filters only)\n"
1209 " [--active yes|no] (yes)\n"
1210 " [--vendorid <XXXX>] (null)\n"
1211 " [--productid <XXXX>] (null)\n"
1212 " [--revision <IIFF>] (null)\n"
1213 " [--manufacturer <string>] (null)\n"
1214 " [--product <string>] (null)\n"
1215 " [--remote yes|no] (null, VM filters only)\n"
1216 " [--serialnumber <string>] (null)\n"
1217 " [--maskedinterfaces <XXXXXXXX>]\n"
1218 "\n", SEP);
1219
1220 if (fCategory & USAGE_USBFILTER_MODIFY)
1221 RTStrmPrintf(pStrm,
1222 "%s usbfilter %s modify <index,0-N>\n"
1223 " --target <uuid|vmname>|global\n"
1224 " [--name <string>]\n"
1225 " [--action ignore|hold] (global filters only)\n"
1226 " [--active yes|no]\n"
1227 " [--vendorid <XXXX>|\"\"]\n"
1228 " [--productid <XXXX>|\"\"]\n"
1229 " [--revision <IIFF>|\"\"]\n"
1230 " [--manufacturer <string>|\"\"]\n"
1231 " [--product <string>|\"\"]\n"
1232 " [--remote yes|no] (null, VM filters only)\n"
1233 " [--serialnumber <string>|\"\"]\n"
1234 " [--maskedinterfaces <XXXXXXXX>]\n"
1235 "\n", SEP);
1236
1237 if (fCategory & USAGE_USBFILTER_REMOVE)
1238 RTStrmPrintf(pStrm,
1239 "%s usbfilter %s remove <index,0-N>\n"
1240 " --target <uuid|vmname>|global\n"
1241 "\n", SEP);
1242
1243 if (fCategory & USAGE_SHAREDFOLDER_ADD)
1244 RTStrmPrintf(pStrm,
1245 "%s sharedfolder %s add <uuid|vmname>\n"
1246 " --name <name> --hostpath <hostpath>\n"
1247 " [--transient] [--readonly] [--automount]\n"
1248 "\n", SEP);
1249
1250 if (fCategory & USAGE_SHAREDFOLDER_REMOVE)
1251 RTStrmPrintf(pStrm,
1252 "%s sharedfolder %s remove <uuid|vmname>\n"
1253 " --name <name> [--transient]\n"
1254 "\n", SEP);
1255
1256#ifdef VBOX_WITH_GUEST_PROPS
1257 if (fCategory & USAGE_GUESTPROPERTY)
1258 usageGuestProperty(pStrm, SEP);
1259#endif /* VBOX_WITH_GUEST_PROPS defined */
1260
1261#ifdef VBOX_WITH_GUEST_CONTROL
1262 if (fCategory & USAGE_GUESTCONTROL)
1263 usageGuestControl(pStrm, SEP, fSubCategory);
1264#endif /* VBOX_WITH_GUEST_CONTROL defined */
1265
1266 if (fCategory & USAGE_DEBUGVM)
1267 {
1268 RTStrmPrintf(pStrm,
1269 "%s debugvm %s <uuid|vmname>\n"
1270 " dumpguestcore --filename <name> |\n"
1271 " info <item> [args] |\n"
1272 " injectnmi |\n"
1273 " log [--release|--debug] <settings> ...|\n"
1274 " logdest [--release|--debug] <settings> ...|\n"
1275 " logflags [--release|--debug] <settings> ...|\n"
1276 " osdetect |\n"
1277 " osinfo |\n"
1278 " osdmesg [--lines|-n <N>] |\n"
1279 " getregisters [--cpu <id>] <reg>|all ... |\n"
1280 " setregisters [--cpu <id>] <reg>=<value> ... |\n"
1281 " show [--human-readable|--sh-export|--sh-eval|\n"
1282 " --cmd-set] \n"
1283 " <logdbg-settings|logrel-settings>\n"
1284 " [[opt] what ...] |\n"
1285 " statistics [--reset] [--pattern <pattern>]\n"
1286 " [--descriptions]\n"
1287 "\n", SEP);
1288 }
1289 if (fCategory & USAGE_METRICS)
1290 RTStrmPrintf(pStrm,
1291 "%s metrics %s list [*|host|<vmname> [<metric_list>]]\n"
1292 " (comma-separated)\n\n"
1293 "%s metrics %s setup\n"
1294 " [--period <seconds>] (default: 1)\n"
1295 " [--samples <count>] (default: 1)\n"
1296 " [--list]\n"
1297 " [*|host|<vmname> [<metric_list>]]\n\n"
1298 "%s metrics %s query [*|host|<vmname> [<metric_list>]]\n\n"
1299 "%s metrics %s enable\n"
1300 " [--list]\n"
1301 " [*|host|<vmname> [<metric_list>]]\n\n"
1302 "%s metrics %s disable\n"
1303 " [--list]\n"
1304 " [*|host|<vmname> [<metric_list>]]\n\n"
1305 "%s metrics %s collect\n"
1306 " [--period <seconds>] (default: 1)\n"
1307 " [--samples <count>] (default: 1)\n"
1308 " [--list]\n"
1309 " [--detach]\n"
1310 " [*|host|<vmname> [<metric_list>]]\n"
1311 "\n", SEP, SEP, SEP, SEP, SEP, SEP);
1312
1313#if defined(VBOX_WITH_NAT_SERVICE)
1314 if (fCategory & USAGE_NATNETWORK)
1315 {
1316 RTStrmPrintf(pStrm,
1317 "%s natnetwork %s add --netname <name>\n"
1318 " --network <network>\n"
1319 " [--enable|--disable]\n"
1320 " [--dhcp on|off]\n"
1321 " [--port-forward-4 <rule>]\n"
1322 " [--loopback-4 <rule>]\n"
1323 " [--ipv6 on|off]\n"
1324 " [--port-forward-6 <rule>]\n"
1325 " [--loopback-6 <rule>]\n\n"
1326 "%s natnetwork %s remove --netname <name>\n\n"
1327 "%s natnetwork %s modify --netname <name>\n"
1328 " [--network <network>]\n"
1329 " [--enable|--disable]\n"
1330 " [--dhcp on|off]\n"
1331 " [--port-forward-4 <rule>]\n"
1332 " [--loopback-4 <rule>]\n"
1333 " [--ipv6 on|off]\n"
1334 " [--port-forward-6 <rule>]\n"
1335 " [--loopback-6 <rule>]\n\n"
1336 "%s natnetwork %s start --netname <name>\n\n"
1337 "%s natnetwork %s stop --netname <name>\n"
1338 "\n", SEP, SEP, SEP, SEP, SEP);
1339
1340
1341 }
1342#endif
1343
1344#if defined(VBOX_WITH_NETFLT)
1345 if (fCategory & USAGE_HOSTONLYIFS)
1346 {
1347 RTStrmPrintf(pStrm,
1348 "%s hostonlyif %s ipconfig <name>\n"
1349 " [--dhcp |\n"
1350 " --ip<ipv4> [--netmask<ipv4> (def: 255.255.255.0)] |\n"
1351 " --ipv6<ipv6> [--netmasklengthv6<length> (def: 64)]]\n"
1352# if !defined(RT_OS_SOLARIS) || defined(VBOX_ONLY_DOCS)
1353 " create |\n"
1354 " remove <name>\n"
1355# endif
1356 "\n", SEP);
1357 }
1358#endif
1359
1360 if (fCategory & USAGE_DHCPSERVER)
1361 {
1362 RTStrmPrintf(pStrm,
1363 "%s dhcpserver %s add|modify --netname <network_name> |\n"
1364#if defined(VBOX_WITH_NETFLT)
1365 " --ifname <hostonly_if_name>\n"
1366#endif
1367 " [--ip <ip_address>\n"
1368 " --netmask <network_mask>\n"
1369 " --lowerip <lower_ip>\n"
1370 " --upperip <upper_ip>]\n"
1371 " [--enable | --disable]\n\n"
1372 "%s dhcpserver %s remove --netname <network_name> |\n"
1373#if defined(VBOX_WITH_NETFLT)
1374 " --ifname <hostonly_if_name>\n"
1375#endif
1376 "\n", SEP, SEP);
1377 }
1378
1379#ifndef VBOX_ONLY_DOCS /* Converted to man page, not needed. */
1380 if (fCategory == USAGE_ALL)
1381 {
1382 uint32_t cPendingBlankLines = 0;
1383 for (uint32_t i = 0; i < g_cHelpEntries; i++)
1384 {
1385 PCREFENTRY pHelp = g_apHelpEntries[i];
1386 RTStrmPrintf(pStrm, " %c%s:\n", RT_C_TO_UPPER(pHelp->pszBrief[0]), pHelp->pszBrief + 1);
1387 cPendingBlankLines = printStringTable(pStrm, &pHelp->Synopsis, REFENTRYSTR_SCOPE_GLOBAL, cPendingBlankLines);
1388 if (!cPendingBlankLines)
1389 cPendingBlankLines = 1;
1390 }
1391 }
1392
1393#endif
1394}
1395
1396/**
1397 * Print a usage synopsis and the syntax error message.
1398 * @returns RTEXITCODE_SYNTAX.
1399 */
1400RTEXITCODE errorSyntax(USAGECATEGORY fCategory, const char *pszFormat, ...)
1401{
1402 va_list args;
1403 showLogo(g_pStdErr); // show logo even if suppressed
1404#ifndef VBOX_ONLY_DOCS
1405 if (g_fInternalMode)
1406 printUsageInternal(fCategory, g_pStdErr);
1407 else
1408 printUsage(fCategory, ~0U, g_pStdErr);
1409#endif /* !VBOX_ONLY_DOCS */
1410 va_start(args, pszFormat);
1411 RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
1412 va_end(args);
1413 return RTEXITCODE_SYNTAX;
1414}
1415
1416/**
1417 * Print a usage synopsis and the syntax error message.
1418 * @returns RTEXITCODE_SYNTAX.
1419 */
1420RTEXITCODE errorSyntaxEx(USAGECATEGORY fCategory, uint32_t fSubCategory, const char *pszFormat, ...)
1421{
1422 va_list args;
1423 showLogo(g_pStdErr); // show logo even if suppressed
1424#ifndef VBOX_ONLY_DOCS
1425 if (g_fInternalMode)
1426 printUsageInternal(fCategory, g_pStdErr);
1427 else
1428 printUsage(fCategory, fSubCategory, g_pStdErr);
1429#endif /* !VBOX_ONLY_DOCS */
1430 va_start(args, pszFormat);
1431 RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
1432 va_end(args);
1433 return RTEXITCODE_SYNTAX;
1434}
1435
1436/**
1437 * errorSyntax for RTGetOpt users.
1438 *
1439 * @returns RTEXITCODE_SYNTAX.
1440 *
1441 * @param fCategory The usage category of the command.
1442 * @param fSubCategory The usage sub-category of the command.
1443 * @param rc The RTGetOpt return code.
1444 * @param pValueUnion The value union.
1445 */
1446RTEXITCODE errorGetOptEx(USAGECATEGORY fCategory, uint32_t fSubCategory, int rc, union RTGETOPTUNION const *pValueUnion)
1447{
1448 /*
1449 * Check if it is an unhandled standard option.
1450 */
1451 if (rc == 'V')
1452 {
1453 RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision());
1454 return RTEXITCODE_SUCCESS;
1455 }
1456
1457 if (rc == 'h')
1458 {
1459 showLogo(g_pStdErr);
1460#ifndef VBOX_ONLY_DOCS
1461 if (g_fInternalMode)
1462 printUsageInternal(fCategory, g_pStdOut);
1463 else
1464 printUsage(fCategory, fSubCategory, g_pStdOut);
1465#endif
1466 return RTEXITCODE_SUCCESS;
1467 }
1468
1469 /*
1470 * General failure.
1471 */
1472 showLogo(g_pStdErr); // show logo even if suppressed
1473#ifndef VBOX_ONLY_DOCS
1474 if (g_fInternalMode)
1475 printUsageInternal(fCategory, g_pStdErr);
1476 else
1477 printUsage(fCategory, fSubCategory, g_pStdErr);
1478#endif /* !VBOX_ONLY_DOCS */
1479
1480 if (rc == VINF_GETOPT_NOT_OPTION)
1481 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid parameter '%s'", pValueUnion->psz);
1482 if (rc > 0)
1483 {
1484 if (RT_C_IS_PRINT(rc))
1485 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option -%c", rc);
1486 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option case %i", rc);
1487 }
1488 if (rc == VERR_GETOPT_UNKNOWN_OPTION)
1489 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unknown option: %s", pValueUnion->psz);
1490 if (rc == VERR_GETOPT_INVALID_ARGUMENT_FORMAT)
1491 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid argument format: %s", pValueUnion->psz);
1492 if (pValueUnion->pDef)
1493 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%s: %Rrs", pValueUnion->pDef->pszLong, rc);
1494 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%Rrs", rc);
1495}
1496
1497/**
1498 * errorSyntax for RTGetOpt users.
1499 *
1500 * @returns RTEXITCODE_SYNTAX.
1501 *
1502 * @param fUsageCategory The usage category of the command.
1503 * @param rc The RTGetOpt return code.
1504 * @param pValueUnion The value union.
1505 */
1506RTEXITCODE errorGetOpt(USAGECATEGORY fCategory, int rc, union RTGETOPTUNION const *pValueUnion)
1507{
1508 return errorGetOptEx(fCategory, ~0U, rc, pValueUnion);
1509}
1510
1511/**
1512 * Print an error message without the syntax stuff.
1513 *
1514 * @returns RTEXITCODE_SYNTAX.
1515 */
1516RTEXITCODE errorArgument(const char *pszFormat, ...)
1517{
1518 va_list args;
1519 va_start(args, pszFormat);
1520 RTMsgErrorV(pszFormat, args);
1521 va_end(args);
1522 return RTEXITCODE_SYNTAX;
1523}
1524
1525
1526
Note: See TracBrowser for help on using the repository browser.

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