VirtualBox

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

Last change on this file since 80907 was 80709, checked in by vboxsync, 5 years ago

OCI: Reorder the list of cloud options for better narration. (Though
with the number of options we have the alphabetical order might be
better here).

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