VirtualBox

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

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

debugvm manpage, refsect2 titles, bunch of other hacking.

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