VirtualBox

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

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

VBoxManageHelp.cpp: Some trailing space tweaking.

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