VirtualBox

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

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

bugfix

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