VirtualBox

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

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

VBoxManage: Let main() set the current command and made 'VBoxManage help extpack' work.

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

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