VirtualBox

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

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

VBoxManage: Added audio codec setting support.

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