VirtualBox

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

Last change on this file since 86186 was 85929, checked in by vboxsync, 4 years ago

Main: bugref:9224: Main+VBoxManageDisk+doc part

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 67.3 KB
Line 
1/* $Id: VBoxManageHelp.cpp 85929 2020-08-28 14:40:55Z vboxsync $ */
2/** @file
3 * VBoxManage - help and other message output.
4 */
5
6/*
7 * Copyright (C) 2006-2020 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#if defined(VBOX_WITH_CLOUD_NET)
482 " cloudprofiles|cloudnets|cpu-profiles|hostdrives\n"
483#else
484 " cloudprofiles|cpu-profiles|hostdrives\n"
485#endif
486 "\n", SEP);
487
488 if (enmCommand == USAGE_SHOWVMINFO || enmCommand == USAGE_S_ALL)
489 RTStrmPrintf(pStrm,
490 "%s showvminfo %s <uuid|vmname> [--details]\n"
491 " [--machinereadable]\n"
492 "%s showvminfo %s <uuid|vmname> --log <idx>\n"
493 "\n", SEP, SEP);
494
495 if (enmCommand == USAGE_REGISTERVM || enmCommand == USAGE_S_ALL)
496 RTStrmPrintf(pStrm,
497 "%s registervm %s <filename>\n"
498 "\n", SEP);
499
500 if (enmCommand == USAGE_UNREGISTERVM || enmCommand == USAGE_S_ALL)
501 RTStrmPrintf(pStrm,
502 "%s unregistervm %s <uuid|vmname> [--delete]\n"
503 "\n", SEP);
504
505 if (enmCommand == USAGE_CREATEVM || enmCommand == USAGE_S_ALL)
506 RTStrmPrintf(pStrm,
507 "%s createvm %s --name <name>\n"
508 " [--groups <group>, ...]\n"
509 " [--ostype <ostype>]\n"
510 " [--register]\n"
511 " [--basefolder <path>]\n"
512 " [--uuid <uuid>]\n"
513 " [--default]\n"
514 "\n", SEP);
515
516 if (enmCommand == USAGE_MODIFYVM || enmCommand == USAGE_S_ALL)
517 {
518 RTStrmPrintf(pStrm,
519 "%s modifyvm %s <uuid|vmname>\n"
520 " [--name <name>]\n"
521 " [--groups <group>, ...]\n"
522 " [--description <desc>]\n"
523 " [--ostype <ostype>]\n"
524 " [--iconfile <filename>]\n"
525 " [--memory <memorysize in MB>]\n"
526 " [--pagefusion on|off]\n"
527 " [--vram <vramsize in MB>]\n"
528 " [--acpi on|off]\n"
529#ifdef VBOX_WITH_PCI_PASSTHROUGH
530 " [--pciattach 03:04.0]\n"
531 " [--pciattach 03:04.0@02:01.0]\n"
532 " [--pcidetach 03:04.0]\n"
533#endif
534 " [--ioapic on|off]\n"
535 " [--hpet on|off]\n"
536 " [--triplefaultreset on|off]\n"
537 " [--apic on|off]\n"
538 " [--x2apic on|off]\n"
539 " [--paravirtprovider none|default|legacy|minimal|\n"
540 " hyperv|kvm]\n"
541 " [--paravirtdebug <key=value> [,<key=value> ...]]\n"
542 " [--hwvirtex on|off]\n"
543 " [--nestedpaging on|off]\n"
544 " [--largepages on|off]\n"
545 " [--vtxvpid on|off]\n"
546 " [--vtxux on|off]\n"
547 " [--pae on|off]\n"
548 " [--longmode on|off]\n"
549 " [--ibpb-on-vm-exit on|off]\n"
550 " [--ibpb-on-vm-entry on|off]\n"
551 " [--spec-ctrl on|off]\n"
552 " [--l1d-flush-on-sched on|off]\n"
553 " [--l1d-flush-on-vm-entry on|off]\n"
554 " [--mds-clear-on-sched on|off]\n"
555 " [--mds-clear-on-vm-entry on|off]\n"
556 " [--nested-hw-virt on|off]\n"
557 " [--virt-vmsave-vmload on|off]\n"
558 " [--cpu-profile \"host|Intel 80[86|286|386]\"]\n"
559 " [--cpuid-portability-level <0..3>]\n"
560 " [--cpuid-set <leaf[:subleaf]> <eax> <ebx> <ecx> <edx>]\n"
561 " [--cpuid-remove <leaf[:subleaf]>]\n"
562 " [--cpuidremoveall]\n"
563 " [--hardwareuuid <uuid>]\n"
564 " [--cpus <number>]\n"
565 " [--cpuhotplug on|off]\n"
566 " [--plugcpu <id>]\n"
567 " [--unplugcpu <id>]\n"
568 " [--cpuexecutioncap <1-100>]\n"
569 " [--rtcuseutc on|off]\n"
570#ifdef VBOX_WITH_VMSVGA
571 " [--graphicscontroller none|vboxvga|vmsvga|vboxsvga]\n"
572#else
573 " [--graphicscontroller none|vboxvga]\n"
574#endif
575 " [--monitorcount <number>]\n"
576 " [--accelerate3d on|off]\n"
577#ifdef VBOX_WITH_VIDEOHWACCEL
578 " [--accelerate2dvideo on|off]\n"
579#endif
580 " [--firmware bios|efi|efi32|efi64]\n"
581 " [--chipset ich9|piix3]\n"
582 " [--bioslogofadein on|off]\n"
583 " [--bioslogofadeout on|off]\n"
584 " [--bioslogodisplaytime <msec>]\n"
585 " [--bioslogoimagepath <imagepath>]\n"
586 " [--biosbootmenu disabled|menuonly|messageandmenu]\n"
587 " [--biosapic disabled|apic|x2apic]\n"
588 " [--biossystemtimeoffset <msec>]\n"
589 " [--biospxedebug on|off]\n"
590 " [--system-uuid-le on|off]\n"
591 " [--boot<1-4> none|floppy|dvd|disk|net>]\n"
592 " [--nic<1-N> none|null|nat|bridged|intnet"
593#if defined(VBOX_WITH_NETFLT)
594 "|hostonly"
595#endif
596 "|\n"
597 " generic|natnetwork"
598 "]\n"
599 " [--nictype<1-N> Am79C970A|Am79C973|Am79C960"
600#ifdef VBOX_WITH_E1000
601 "|\n 82540EM|82543GC|82545EM"
602#endif
603#ifdef VBOX_WITH_VIRTIO
604 "|\n virtio"
605#endif /* VBOX_WITH_VIRTIO */
606 "]\n"
607 " [--cableconnected<1-N> on|off]\n"
608 " [--nictrace<1-N> on|off]\n"
609 " [--nictracefile<1-N> <filename>]\n"
610 " [--nicproperty<1-N> name=[value]]\n"
611 " [--nicspeed<1-N> <kbps>]\n"
612 " [--nicbootprio<1-N> <priority>]\n"
613 " [--nicpromisc<1-N> deny|allow-vms|allow-all]\n"
614 " [--nicbandwidthgroup<1-N> none|<name>]\n"
615 " [--bridgeadapter<1-N> none|<devicename>]\n"
616#if defined(VBOX_WITH_NETFLT)
617 " [--hostonlyadapter<1-N> none|<devicename>]\n"
618#endif
619 " [--intnet<1-N> <network name>]\n"
620 " [--nat-network<1-N> <network name>]\n"
621 " [--nicgenericdrv<1-N> <driver>]\n"
622 " [--natnet<1-N> <network>|default]\n"
623 " [--natsettings<1-N> [<mtu>],[<socksnd>],\n"
624 " [<sockrcv>],[<tcpsnd>],\n"
625 " [<tcprcv>]]\n"
626 " [--natpf<1-N> [<rulename>],tcp|udp,[<hostip>],\n"
627 " <hostport>,[<guestip>],<guestport>]\n"
628 " [--natpf<1-N> delete <rulename>]\n"
629 " [--nattftpprefix<1-N> <prefix>]\n"
630 " [--nattftpfile<1-N> <file>]\n"
631 " [--nattftpserver<1-N> <ip>]\n"
632 " [--natbindip<1-N> <ip>]\n"
633 " [--natdnspassdomain<1-N> on|off]\n"
634 " [--natdnsproxy<1-N> on|off]\n"
635 " [--natdnshostresolver<1-N> on|off]\n"
636 " [--nataliasmode<1-N> default|[log],[proxyonly],\n"
637 " [sameports]]\n"
638 " [--macaddress<1-N> auto|<mac>]\n"
639 " [--mouse ps2|usb|usbtablet|usbmultitouch]\n"
640 " [--keyboard ps2|usb]\n"
641 " [--uart<1-N> off|<I/O base> <IRQ>]\n"
642 " [--uartmode<1-N> disconnected|\n"
643 " server <pipe>|\n"
644 " client <pipe>|\n"
645 " tcpserver <port>|\n"
646 " tcpclient <hostname:port>|\n"
647 " file <file>|\n"
648 " <devicename>]\n"
649 " [--uarttype<1-N> 16450|16550A|16750]\n"
650#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
651 " [--lpt<1-N> off|<I/O base> <IRQ>]\n"
652 " [--lptmode<1-N> <devicename>]\n"
653#endif
654 " [--guestmemoryballoon <balloonsize in MB>]\n"
655 " [--vm-process-priority default|flat|low|normal|high]\n"
656 " [--audio none|null", SEP);
657 if (fWin)
658 {
659#ifdef VBOX_WITH_WINMM
660 RTStrmPrintf(pStrm, "|winmm|dsound");
661#else
662 RTStrmPrintf(pStrm, "|dsound");
663#endif
664 }
665 if (fLinux || fSolaris)
666 {
667 RTStrmPrintf(pStrm, ""
668#ifdef VBOX_WITH_AUDIO_OSS
669 "|oss"
670#endif
671#ifdef VBOX_WITH_AUDIO_ALSA
672 "|alsa"
673#endif
674#ifdef VBOX_WITH_AUDIO_PULSE
675 "|pulse"
676#endif
677 );
678 }
679 if (fFreeBSD)
680 {
681#ifdef VBOX_WITH_AUDIO_OSS
682 /* Get the line break sorted when dumping all option variants. */
683 if (fDumpOpts)
684 {
685 RTStrmPrintf(pStrm, "|\n"
686 " oss");
687 }
688 else
689 RTStrmPrintf(pStrm, "|oss");
690#endif
691#ifdef VBOX_WITH_AUDIO_PULSE
692 RTStrmPrintf(pStrm, "|pulse");
693#endif
694 }
695 if (fDarwin)
696 {
697 RTStrmPrintf(pStrm, "|coreaudio");
698 }
699 RTStrmPrintf(pStrm, "]\n");
700 RTStrmPrintf(pStrm,
701 " [--audioin on|off]\n"
702 " [--audioout on|off]\n"
703 " [--audiocontroller ac97|hda|sb16]\n"
704 " [--audiocodec stac9700|ad1980|stac9221|sb16]\n"
705#ifdef VBOX_WITH_SHARED_CLIPBOARD
706 " [--clipboard-mode disabled|hosttoguest|guesttohost|\n"
707 " bidirectional]\n"
708# ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
709 " [--clipboard-file-transfers enabled|disabled]\n"
710# endif
711#endif
712 " [--draganddrop disabled|hosttoguest|guesttohost|\n"
713 " bidirectional]\n");
714 RTStrmPrintf(pStrm,
715 " [--vrde on|off]\n"
716 " [--vrdeextpack default|<name>]\n"
717 " [--vrdeproperty <name=[value]>]\n"
718 " [--vrdeport <hostport>]\n"
719 " [--vrdeaddress <hostip>]\n"
720 " [--vrdeauthtype null|external|guest]\n"
721 " [--vrdeauthlibrary default|<name>]\n"
722 " [--vrdemulticon on|off]\n"
723 " [--vrdereusecon on|off]\n"
724 " [--vrdevideochannel on|off]\n"
725 " [--vrdevideochannelquality <percent>]\n");
726 RTStrmPrintf(pStrm,
727 " [--usbohci on|off]\n"
728 " [--usbehci on|off]\n"
729 " [--usbxhci on|off]\n"
730 " [--usbrename <oldname> <newname>]\n"
731 " [--snapshotfolder default|<path>]\n"
732 " [--teleporter on|off]\n"
733 " [--teleporterport <port>]\n"
734 " [--teleporteraddress <address|empty>]\n"
735 " [--teleporterpassword <password>]\n"
736 " [--teleporterpasswordfile <file>|stdin]\n"
737 " [--tracing-enabled on|off]\n"
738 " [--tracing-config <config-string>]\n"
739 " [--tracing-allow-vm-access on|off]\n"
740#if 0
741 " [--iocache on|off]\n"
742 " [--iocachesize <I/O cache size in MB>]\n"
743#endif
744#ifdef VBOX_WITH_USB_CARDREADER
745 " [--usbcardreader on|off]\n"
746#endif
747 " [--autostart-enabled on|off]\n"
748 " [--autostart-delay <seconds>]\n"
749#if 0
750 " [--autostop-type disabled|savestate|poweroff|\n"
751 " acpishutdown]\n"
752#endif
753#ifdef VBOX_WITH_RECORDING
754 " [--recording on|off]\n"
755 " [--recordingscreens all|<screen ID> [<screen ID> ...]]\n"
756 " [--recordingfile <filename>]\n"
757 " [--recordingvideores <width> <height>]\n"
758 " [--recordingvideorate <rate>]\n"
759 " [--recordingvideofps <fps>]\n"
760 " [--recordingmaxtime <s>]\n"
761 " [--recordingmaxsize <MB>]\n"
762 " [--recordingopts <key=value> [,<key=value> ...]]\n"
763#endif
764 " [--defaultfrontend default|<name>]\n"
765 "\n");
766 }
767
768 if (enmCommand == USAGE_MOVEVM || enmCommand == USAGE_S_ALL)
769 RTStrmPrintf(pStrm,
770 "%s movevm %s <uuid|vmname>\n"
771 " --type basic\n"
772 " [--folder <path>]\n"
773 "\n", SEP);
774
775 if (enmCommand == USAGE_IMPORTAPPLIANCE || enmCommand == USAGE_S_ALL)
776 RTStrmPrintf(pStrm,
777 "%s import %s <ovfname/ovaname>\n"
778 " [--dry-run|-n]\n"
779 " [--options keepallmacs|keepnatmacs|importtovdi]\n"
780 " [--vmname <name>]\n"
781 " [--cloud]\n"
782 " [--cloudprofile <cloud profile name>]\n"
783 " [--cloudinstanceid <instance id>]\n"
784 " [--cloudbucket <bucket name>]\n"
785 " [more options]\n"
786 " (run with -n to have options displayed\n"
787 " for a particular OVF. It doesn't work for the Cloud import.)\n\n", SEP);
788
789 if (enmCommand == USAGE_EXPORTAPPLIANCE || enmCommand == USAGE_S_ALL)
790 RTStrmPrintf(pStrm,
791 "%s export %s <machines> --output|-o <name>.<ovf/ova/tar.gz>\n"
792 " [--legacy09|--ovf09|--ovf10|--ovf20|--opc10]\n"
793 " [--manifest]\n"
794 " [--iso]\n"
795 " [--options manifest|iso|nomacs|nomacsbutnat]\n"
796 " [--vsys <number of virtual system>]\n"
797 " [--vmname <name>]\n"
798 " [--product <product name>]\n"
799 " [--producturl <product url>]\n"
800 " [--vendor <vendor name>]\n"
801 " [--vendorurl <vendor url>]\n"
802 " [--version <version info>]\n"
803 " [--description <description info>]\n"
804 " [--eula <license text>]\n"
805 " [--eulafile <filename>]\n"
806 " [--cloud <number of virtual system>]\n"
807 " [--vmname <name>]\n"
808 " [--cloudprofile <cloud profile name>]\n"
809 " [--cloudbucket <bucket name>]\n"
810 " [--cloudkeepobject <true/false>]\n"
811 " [--cloudlaunchmode EMULATED|PARAVIRTUALIZED]\n"
812 " [--cloudlaunchinstance <true/false>]\n"
813 " [--clouddomain <domain>]\n"
814 " [--cloudshape <shape>]\n"
815 " [--clouddisksize <disk size in GB>]\n"
816 " [--cloudocivcn <OCI vcn id>]\n"
817 " [--cloudocisubnet <OCI subnet id>]\n"
818 " [--cloudpublicip <true/false>]\n"
819 " [--cloudprivateip <ip>]\n"
820 "\n", SEP);
821
822 if (enmCommand == USAGE_STARTVM || enmCommand == USAGE_S_ALL)
823 {
824 RTStrmPrintf(pStrm,
825 "%s startvm %s <uuid|vmname>...\n"
826 " [--type gui", SEP);
827 if (fVBoxSDL)
828 RTStrmPrintf(pStrm, "|sdl");
829 RTStrmPrintf(pStrm, "|headless|separate]\n");
830 RTStrmPrintf(pStrm,
831 " [-E|--putenv <NAME>[=<VALUE>]]\n"
832 "\n");
833 }
834
835 if (enmCommand == USAGE_CONTROLVM || enmCommand == USAGE_S_ALL)
836 {
837 RTStrmPrintf(pStrm,
838 "%s controlvm %s <uuid|vmname>\n"
839 " pause|resume|reset|poweroff|savestate|\n"
840#ifdef VBOX_WITH_GUEST_CONTROL
841 " reboot|shutdown [--force]|\n"
842#endif
843 " acpipowerbutton|acpisleepbutton|\n"
844 " keyboardputscancode <hex> [<hex> ...]|\n"
845 " keyboardputstring <string1> [<string2> ...]|\n"
846 " keyboardputfile <filename>|\n"
847 " setlinkstate<1-N> on|off |\n"
848#if defined(VBOX_WITH_NETFLT)
849 " nic<1-N> null|nat|bridged|intnet|hostonly|generic|\n"
850 " natnetwork [<devicename>] |\n"
851#else /* !VBOX_WITH_NETFLT */
852 " nic<1-N> null|nat|bridged|intnet|generic|natnetwork\n"
853 " [<devicename>] |\n"
854#endif /* !VBOX_WITH_NETFLT */
855 " nictrace<1-N> on|off |\n"
856 " nictracefile<1-N> <filename> |\n"
857 " nicproperty<1-N> name=[value] |\n"
858 " nicpromisc<1-N> deny|allow-vms|allow-all |\n"
859 " natpf<1-N> [<rulename>],tcp|udp,[<hostip>],\n"
860 " <hostport>,[<guestip>],<guestport> |\n"
861 " natpf<1-N> delete <rulename> |\n"
862 " guestmemoryballoon <balloonsize in MB> |\n"
863 " usbattach <uuid>|<address>\n"
864 " [--capturefile <filename>] |\n"
865 " usbdetach <uuid>|<address> |\n"
866 " audioin on|off |\n"
867 " audioout on|off |\n"
868#ifdef VBOX_WITH_SHARED_CLIPBOARD
869 " clipboard mode disabled|hosttoguest|guesttohost|\n"
870 " bidirectional |\n"
871# ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
872 " clipboard filetransfers enabled|disabled |\n"
873# endif
874#endif
875 " draganddrop disabled|hosttoguest|guesttohost|\n"
876 " bidirectional |\n"
877 " vrde on|off |\n"
878 " vrdeport <port> |\n"
879 " vrdeproperty <name=[value]> |\n"
880 " vrdevideochannelquality <percent> |\n"
881 " setvideomodehint <xres> <yres> <bpp>\n"
882 " [[<display>] [<enabled:yes|no> |\n"
883 " [<xorigin> <yorigin>]]] |\n"
884 " setscreenlayout <display> on|primary <xorigin> <yorigin> <xres> <yres> <bpp> | off\n"
885 " screenshotpng <file> [display] |\n"
886#ifdef VBOX_WITH_RECORDING
887 " recording on|off |\n"
888 " recording screens all|none|<screen>,[<screen>...] |\n"
889 " recording filename <file> |\n"
890 " recording videores <width>x<height> |\n"
891 " recording videorate <rate> |\n"
892 " recording videofps <fps> |\n"
893 " recording maxtime <s> |\n"
894 " recording maxfilesize <MB> |\n"
895#endif /* VBOX_WITH_RECORDING */
896 " setcredentials <username>\n"
897 " --passwordfile <file> | <password>\n"
898 " <domain>\n"
899 " [--allowlocallogon <yes|no>] |\n"
900 " teleport --host <name> --port <port>\n"
901 " [--maxdowntime <msec>]\n"
902 " [--passwordfile <file> |\n"
903 " --password <password>] |\n"
904 " plugcpu <id> |\n"
905 " unplugcpu <id> |\n"
906 " cpuexecutioncap <1-100>\n"
907 " webcam <attach [path [settings]]> | <detach [path]> | <list>\n"
908 " addencpassword <id>\n"
909 " <password file>|-\n"
910 " [--removeonsuspend <yes|no>]\n"
911 " removeencpassword <id>\n"
912 " removeallencpasswords\n"
913 " changeuartmode<1-N> disconnected|\n"
914 " server <pipe>|\n"
915 " client <pipe>|\n"
916 " tcpserver <port>|\n"
917 " tcpclient <hostname:port>|\n"
918 " file <file>|\n"
919 " <devicename>\n"
920 " vm-process-priority default|flat|low|normal|high\n"
921 "\n", SEP);
922 }
923
924 if (enmCommand == USAGE_DISCARDSTATE || enmCommand == USAGE_S_ALL)
925 RTStrmPrintf(pStrm,
926 "%s discardstate %s <uuid|vmname>\n"
927 "\n", SEP);
928
929 if (enmCommand == USAGE_ADOPTSTATE || enmCommand == USAGE_S_ALL)
930 RTStrmPrintf(pStrm,
931 "%s adoptstate %s <uuid|vmname> <state_file>\n"
932 "\n", SEP);
933
934 if (enmCommand == USAGE_CLOSEMEDIUM || enmCommand == USAGE_S_ALL)
935 RTStrmPrintf(pStrm,
936 "%s closemedium %s [disk|dvd|floppy] <uuid|filename>\n"
937 " [--delete]\n"
938 "\n", SEP);
939
940 if (enmCommand == USAGE_STORAGEATTACH || enmCommand == USAGE_S_ALL)
941 RTStrmPrintf(pStrm,
942 "%s storageattach %s <uuid|vmname>\n"
943 " --storagectl <name>\n"
944 " [--port <number>]\n"
945 " [--device <number>]\n"
946 " [--type dvddrive|hdd|fdd]\n"
947 " [--medium none|emptydrive|additions|\n"
948 " <uuid|filename>|host:<drive>|iscsi]\n"
949 " [--mtype normal|writethrough|immutable|shareable|\n"
950 " readonly|multiattach]\n"
951 " [--comment <text>]\n"
952 " [--setuuid <uuid>]\n"
953 " [--setparentuuid <uuid>]\n"
954 " [--passthrough on|off]\n"
955 " [--tempeject on|off]\n"
956 " [--nonrotational on|off]\n"
957 " [--discard on|off]\n"
958 " [--hotpluggable on|off]\n"
959 " [--bandwidthgroup <name>]\n"
960 " [--forceunmount]\n"
961 " [--server <name>|<ip>]\n"
962 " [--target <target>]\n"
963 " [--tport <port>]\n"
964 " [--lun <lun>]\n"
965 " [--encodedlun <lun>]\n"
966 " [--username <username>]\n"
967 " [--password <password>]\n"
968 " [--passwordfile <file>]\n"
969 " [--initiator <initiator>]\n"
970 " [--intnet]\n"
971 "\n", SEP);
972
973 if (enmCommand == USAGE_STORAGECONTROLLER || enmCommand == USAGE_S_ALL)
974 RTStrmPrintf(pStrm,
975 "%s storagectl %s <uuid|vmname>\n"
976 " --name <name>\n"
977 " [--add ide|sata|scsi|floppy|sas|usb|pcie|virtio]\n"
978 " [--controller LSILogic|LSILogicSAS|BusLogic|\n"
979 " IntelAHCI|PIIX3|PIIX4|ICH6|I82078|\n"
980 " [ USB|NVMe|VirtIO]\n"
981 " [--portcount <1-n>]\n"
982 " [--hostiocache on|off]\n"
983 " [--bootable on|off]\n"
984 " [--rename <name>]\n"
985 " [--remove]\n"
986 "\n", SEP);
987
988 if (enmCommand == USAGE_BANDWIDTHCONTROL || enmCommand == USAGE_S_ALL)
989 RTStrmPrintf(pStrm,
990 "%s bandwidthctl %s <uuid|vmname>\n"
991 " add <name> --type disk|network\n"
992 " --limit <megabytes per second>[k|m|g|K|M|G] |\n"
993 " set <name>\n"
994 " --limit <megabytes per second>[k|m|g|K|M|G] |\n"
995 " remove <name> |\n"
996 " list [--machinereadable]\n"
997 " (limit units: k=kilobit, m=megabit, g=gigabit,\n"
998 " K=kilobyte, M=megabyte, G=gigabyte)\n"
999 "\n", SEP);
1000
1001 if (enmCommand == USAGE_SHOWMEDIUMINFO || enmCommand == USAGE_S_ALL)
1002 RTStrmPrintf(pStrm,
1003 "%s showmediuminfo %s [disk|dvd|floppy] <uuid|filename>\n"
1004 "\n", SEP);
1005
1006 if (enmCommand == USAGE_CREATEMEDIUM || enmCommand == USAGE_S_ALL)
1007 RTStrmPrintf(pStrm,
1008 "%s createmedium %s [disk|dvd|floppy] --filename <filename>\n"
1009 " [--size <megabytes>|--sizebyte <bytes>]\n"
1010 " [--diffparent <uuid>|<filename>]\n"
1011 " [--format VDI|VMDK|VHD] (default: VDI)]\n"
1012 " [--variant Standard,Fixed,Split2G,Stream,ESX,\n"
1013 " Formatted,RawDisk]\n"
1014 " [[--property <name>=<value>] --property <name>=<value>\n"
1015 " --property-file <name>=</path/to/file/with/value>]...\n"
1016 "\n", SEP);
1017
1018 if (enmCommand == USAGE_MODIFYMEDIUM || enmCommand == USAGE_S_ALL)
1019 RTStrmPrintf(pStrm,
1020 "%s modifymedium %s [disk|dvd|floppy] <uuid|filename>\n"
1021 " [--type normal|writethrough|immutable|shareable|\n"
1022 " readonly|multiattach]\n"
1023 " [--autoreset on|off]\n"
1024 " [--property <name=[value]>]\n"
1025 " [--compact]\n"
1026 " [--resize <megabytes>|--resizebyte <bytes>]\n"
1027 " [--move <path>]\n"
1028 " [--setlocation <path>]\n"
1029 " [--description <description string>]"
1030 "\n", SEP);
1031
1032 if (enmCommand == USAGE_CLONEMEDIUM || enmCommand == USAGE_S_ALL)
1033 RTStrmPrintf(pStrm,
1034 "%s clonemedium %s [disk|dvd|floppy] <uuid|inputfile> <uuid|outputfile>\n"
1035 " [--format VDI|VMDK|VHD|RAW|<other>]\n"
1036 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1037 " [--existing]\n"
1038 "\n", SEP);
1039
1040 if (enmCommand == USAGE_MEDIUMPROPERTY || enmCommand == USAGE_S_ALL)
1041 RTStrmPrintf(pStrm,
1042 "%s mediumproperty %s [disk|dvd|floppy] set <uuid|filename>\n"
1043 " <property> <value>\n"
1044 "\n"
1045 " [disk|dvd|floppy] get <uuid|filename>\n"
1046 " <property>\n"
1047 "\n"
1048 " [disk|dvd|floppy] delete <uuid|filename>\n"
1049 " <property>\n"
1050 "\n", SEP);
1051
1052 if (enmCommand == USAGE_ENCRYPTMEDIUM || enmCommand == USAGE_S_ALL)
1053 RTStrmPrintf(pStrm,
1054 "%s encryptmedium %s <uuid|filename>\n"
1055 " [--newpassword <file>|-]\n"
1056 " [--oldpassword <file>|-]\n"
1057 " [--cipher <cipher identifier>]\n"
1058 " [--newpasswordid <password identifier>]\n"
1059 "\n", SEP);
1060
1061 if (enmCommand == USAGE_MEDIUMENCCHKPWD || enmCommand == USAGE_S_ALL)
1062 RTStrmPrintf(pStrm,
1063 "%s checkmediumpwd %s <uuid|filename>\n"
1064 " <pwd file>|-\n"
1065 "\n", SEP);
1066
1067 if (enmCommand == USAGE_CONVERTFROMRAW || enmCommand == USAGE_S_ALL)
1068 RTStrmPrintf(pStrm,
1069 "%s convertfromraw %s <filename> <outputfile>\n"
1070 " [--format VDI|VMDK|VHD]\n"
1071 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1072 " [--uuid <uuid>]\n"
1073 "%s convertfromraw %s stdin <outputfile> <bytes>\n"
1074 " [--format VDI|VMDK|VHD]\n"
1075 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
1076 " [--uuid <uuid>]\n"
1077 "\n", SEP, SEP);
1078
1079 if (enmCommand == USAGE_GETEXTRADATA || enmCommand == USAGE_S_ALL)
1080 RTStrmPrintf(pStrm,
1081 "%s getextradata %s global|<uuid|vmname>\n"
1082 " <key>|[enumerate]\n"
1083 "\n", SEP);
1084
1085 if (enmCommand == USAGE_SETEXTRADATA || enmCommand == USAGE_S_ALL)
1086 RTStrmPrintf(pStrm,
1087 "%s setextradata %s global|<uuid|vmname>\n"
1088 " <key>\n"
1089 " [<value>] (no value deletes key)\n"
1090 "\n", SEP);
1091
1092 if (enmCommand == USAGE_SETPROPERTY || enmCommand == USAGE_S_ALL)
1093 RTStrmPrintf(pStrm,
1094 "%s setproperty %s machinefolder default|<folder> |\n"
1095 " hwvirtexclusive on|off |\n"
1096 " vrdeauthlibrary default|<library> |\n"
1097 " websrvauthlibrary default|null|<library> |\n"
1098 " vrdeextpack null|<library> |\n"
1099 " autostartdbpath null|<folder> |\n"
1100 " loghistorycount <value>\n"
1101 " defaultfrontend default|<name>\n"
1102 " logginglevel <log setting>\n"
1103 " proxymode system|noproxy|manual\n"
1104 " proxyurl <url>\n"
1105 "\n", SEP);
1106
1107 if (enmCommand == USAGE_USBFILTER || enmCommand == USAGE_S_ALL)
1108 {
1109 if (fSubcommandScope & HELP_SCOPE_USBFILTER_ADD)
1110 RTStrmPrintf(pStrm,
1111 "%s usbfilter %s add <index,0-N>\n"
1112 " --target <uuid|vmname>|global\n"
1113 " --name <string>\n"
1114 " --action ignore|hold (global filters only)\n"
1115 " [--active yes|no] (yes)\n"
1116 " [--vendorid <XXXX>] (null)\n"
1117 " [--productid <XXXX>] (null)\n"
1118 " [--revision <IIFF>] (null)\n"
1119 " [--manufacturer <string>] (null)\n"
1120 " [--product <string>] (null)\n"
1121 " [--remote yes|no] (null, VM filters only)\n"
1122 " [--serialnumber <string>] (null)\n"
1123 " [--maskedinterfaces <XXXXXXXX>]\n"
1124 "\n", SEP);
1125
1126 if (fSubcommandScope & HELP_SCOPE_USBFILTER_MODIFY)
1127 RTStrmPrintf(pStrm,
1128 "%s usbfilter %s modify <index,0-N>\n"
1129 " --target <uuid|vmname>|global\n"
1130 " [--name <string>]\n"
1131 " [--action ignore|hold] (global filters only)\n"
1132 " [--active yes|no]\n"
1133 " [--vendorid <XXXX>|\"\"]\n"
1134 " [--productid <XXXX>|\"\"]\n"
1135 " [--revision <IIFF>|\"\"]\n"
1136 " [--manufacturer <string>|\"\"]\n"
1137 " [--product <string>|\"\"]\n"
1138 " [--remote yes|no] (null, VM filters only)\n"
1139 " [--serialnumber <string>|\"\"]\n"
1140 " [--maskedinterfaces <XXXXXXXX>]\n"
1141 "\n", SEP);
1142
1143 if (fSubcommandScope & HELP_SCOPE_USBFILTER_REMOVE)
1144 RTStrmPrintf(pStrm,
1145 "%s usbfilter %s remove <index,0-N>\n"
1146 " --target <uuid|vmname>|global\n"
1147 "\n", SEP);
1148 }
1149
1150#ifdef VBOX_WITH_GUEST_PROPS
1151 if (enmCommand == USAGE_GUESTPROPERTY || enmCommand == USAGE_S_ALL)
1152 usageGuestProperty(pStrm, SEP);
1153#endif /* VBOX_WITH_GUEST_PROPS defined */
1154
1155#ifdef VBOX_WITH_GUEST_CONTROL
1156 if (enmCommand == USAGE_GUESTCONTROL || enmCommand == USAGE_S_ALL)
1157 usageGuestControl(pStrm, SEP, fSubcommandScope);
1158#endif /* VBOX_WITH_GUEST_CONTROL defined */
1159
1160 if (enmCommand == USAGE_METRICS || enmCommand == USAGE_S_ALL)
1161 RTStrmPrintf(pStrm,
1162 "%s metrics %s list [*|host|<vmname> [<metric_list>]]\n"
1163 " (comma-separated)\n\n"
1164 "%s metrics %s setup\n"
1165 " [--period <seconds>] (default: 1)\n"
1166 " [--samples <count>] (default: 1)\n"
1167 " [--list]\n"
1168 " [*|host|<vmname> [<metric_list>]]\n\n"
1169 "%s metrics %s query [*|host|<vmname> [<metric_list>]]\n\n"
1170 "%s metrics %s enable\n"
1171 " [--list]\n"
1172 " [*|host|<vmname> [<metric_list>]]\n\n"
1173 "%s metrics %s disable\n"
1174 " [--list]\n"
1175 " [*|host|<vmname> [<metric_list>]]\n\n"
1176 "%s metrics %s collect\n"
1177 " [--period <seconds>] (default: 1)\n"
1178 " [--samples <count>] (default: 1)\n"
1179 " [--list]\n"
1180 " [--detach]\n"
1181 " [*|host|<vmname> [<metric_list>]]\n"
1182 "\n", SEP, SEP, SEP, SEP, SEP, SEP);
1183
1184#if defined(VBOX_WITH_NAT_SERVICE)
1185 if (enmCommand == USAGE_NATNETWORK || enmCommand == USAGE_S_ALL)
1186 {
1187 RTStrmPrintf(pStrm,
1188 "%s natnetwork %s add --netname <name>\n"
1189 " --network <network>\n"
1190 " [--enable|--disable]\n"
1191 " [--dhcp on|off]\n"
1192 " [--port-forward-4 <rule>]\n"
1193 " [--loopback-4 <rule>]\n"
1194 " [--ipv6 on|off]\n"
1195 " [--port-forward-6 <rule>]\n"
1196 " [--loopback-6 <rule>]\n\n"
1197 "%s natnetwork %s remove --netname <name>\n\n"
1198 "%s natnetwork %s modify --netname <name>\n"
1199 " [--network <network>]\n"
1200 " [--enable|--disable]\n"
1201 " [--dhcp on|off]\n"
1202 " [--port-forward-4 <rule>]\n"
1203 " [--loopback-4 <rule>]\n"
1204 " [--ipv6 on|off]\n"
1205 " [--port-forward-6 <rule>]\n"
1206 " [--loopback-6 <rule>]\n\n"
1207 "%s natnetwork %s start --netname <name>\n\n"
1208 "%s natnetwork %s stop --netname <name>\n\n"
1209 "%s natnetwork %s list [<pattern>]\n"
1210 "\n", SEP, SEP, SEP, SEP, SEP, SEP);
1211
1212
1213 }
1214#endif
1215
1216#if defined(VBOX_WITH_NETFLT)
1217 if (enmCommand == USAGE_HOSTONLYIFS || enmCommand == USAGE_S_ALL)
1218 {
1219 RTStrmPrintf(pStrm,
1220 "%s hostonlyif %s ipconfig <name>\n"
1221 " [--dhcp |\n"
1222 " --ip<ipv4> [--netmask<ipv4> (def: 255.255.255.0)] |\n"
1223 " --ipv6<ipv6> [--netmasklengthv6<length> (def: 64)]]\n"
1224# if !defined(RT_OS_SOLARIS) || defined(VBOX_ONLY_DOCS)
1225 " create |\n"
1226 " remove <name>\n"
1227# endif
1228 "\n", SEP);
1229 }
1230#endif
1231
1232 if (enmCommand == USAGE_USBDEVSOURCE || enmCommand == USAGE_S_ALL)
1233 {
1234 RTStrmPrintf(pStrm,
1235 "%s usbdevsource %s add <source name>\n"
1236 " --backend <backend>\n"
1237 " --address <address>\n"
1238 "%s usbdevsource %s remove <source name>\n"
1239 "\n", SEP, SEP);
1240 }
1241
1242#ifndef VBOX_ONLY_DOCS /* Converted to man page, not needed. */
1243 if (enmCommand == USAGE_S_ALL)
1244 {
1245 uint32_t cPendingBlankLines = 0;
1246 for (uint32_t i = 0; i < g_cHelpEntries; i++)
1247 {
1248 PCRTMSGREFENTRY pHelp = g_apHelpEntries[i];
1249 while (cPendingBlankLines-- > 0)
1250 RTStrmPutCh(pStrm, '\n');
1251 RTStrmPrintf(pStrm, " %c%s:\n", RT_C_TO_UPPER(pHelp->pszBrief[0]), pHelp->pszBrief + 1);
1252 cPendingBlankLines = 0;
1253 RTMsgRefEntryPrintStringTable(pStrm, &pHelp->Synopsis, RTMSGREFENTRYSTR_SCOPE_GLOBAL,
1254 &cPendingBlankLines, NULL /*pcLinesWritten*/);
1255 cPendingBlankLines = RT_MAX(cPendingBlankLines, 1);
1256 }
1257 }
1258#endif
1259}
1260
1261/**
1262 * Print a usage synopsis and the syntax error message.
1263 * @returns RTEXITCODE_SYNTAX.
1264 */
1265RTEXITCODE errorSyntax(USAGECATEGORY enmCommand, const char *pszFormat, ...)
1266{
1267 va_list args;
1268 showLogo(g_pStdErr); // show logo even if suppressed
1269#ifndef VBOX_ONLY_DOCS
1270 if (g_fInternalMode)
1271 printUsageInternal(enmCommand, g_pStdErr);
1272 else
1273 printUsage(enmCommand, RTMSGREFENTRYSTR_SCOPE_GLOBAL, g_pStdErr);
1274#else
1275 RT_NOREF_PV(enmCommand);
1276#endif
1277 va_start(args, pszFormat);
1278 RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
1279 va_end(args);
1280 return RTEXITCODE_SYNTAX;
1281}
1282
1283/**
1284 * Print a usage synopsis and the syntax error message.
1285 * @returns RTEXITCODE_SYNTAX.
1286 */
1287RTEXITCODE errorSyntaxEx(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, const char *pszFormat, ...)
1288{
1289 va_list args;
1290 showLogo(g_pStdErr); // show logo even if suppressed
1291#ifndef VBOX_ONLY_DOCS
1292 if (g_fInternalMode)
1293 printUsageInternal(enmCommand, g_pStdErr);
1294 else
1295 printUsage(enmCommand, fSubcommandScope, g_pStdErr);
1296#else
1297 RT_NOREF2(enmCommand, fSubcommandScope);
1298#endif
1299 va_start(args, pszFormat);
1300 RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
1301 va_end(args);
1302 return RTEXITCODE_SYNTAX;
1303}
1304
1305/**
1306 * errorSyntax for RTGetOpt users.
1307 *
1308 * @returns RTEXITCODE_SYNTAX.
1309 *
1310 * @param enmCommand The command.
1311 * @param fSubcommandScope The subcommand scope, REFENTRYSTR_SCOPE_GLOBAL
1312 * for all.
1313 * @param rc The RTGetOpt return code.
1314 * @param pValueUnion The value union.
1315 */
1316RTEXITCODE errorGetOptEx(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, int rc, union RTGETOPTUNION const *pValueUnion)
1317{
1318 /*
1319 * Check if it is an unhandled standard option.
1320 */
1321#ifndef VBOX_ONLY_DOCS
1322 if (rc == 'V')
1323 {
1324 RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision());
1325 return RTEXITCODE_SUCCESS;
1326 }
1327#endif
1328
1329 if (rc == 'h')
1330 {
1331 showLogo(g_pStdErr);
1332#ifndef VBOX_ONLY_DOCS
1333 if (g_fInternalMode)
1334 printUsageInternal(enmCommand, g_pStdOut);
1335 else
1336 printUsage(enmCommand, fSubcommandScope, g_pStdOut);
1337#endif
1338 return RTEXITCODE_SUCCESS;
1339 }
1340
1341 /*
1342 * General failure.
1343 */
1344 showLogo(g_pStdErr); // show logo even if suppressed
1345#ifndef VBOX_ONLY_DOCS
1346 if (g_fInternalMode)
1347 printUsageInternal(enmCommand, g_pStdErr);
1348 else
1349 printUsage(enmCommand, fSubcommandScope, g_pStdErr);
1350#else
1351 RT_NOREF2(enmCommand, fSubcommandScope);
1352#endif
1353
1354 if (rc == VINF_GETOPT_NOT_OPTION)
1355 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid parameter '%s'", pValueUnion->psz);
1356 if (rc > 0)
1357 {
1358 if (RT_C_IS_PRINT(rc))
1359 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option -%c", rc);
1360 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option case %i", rc);
1361 }
1362 if (rc == VERR_GETOPT_UNKNOWN_OPTION)
1363 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unknown option: %s", pValueUnion->psz);
1364 if (rc == VERR_GETOPT_INVALID_ARGUMENT_FORMAT)
1365 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid argument format: %s", pValueUnion->psz);
1366 if (pValueUnion->pDef)
1367 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%s: %Rrs", pValueUnion->pDef->pszLong, rc);
1368 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%Rrs", rc);
1369}
1370
1371/**
1372 * errorSyntax for RTGetOpt users.
1373 *
1374 * @returns RTEXITCODE_SYNTAX.
1375 *
1376 * @param enmCommand The command.
1377 * @param rc The RTGetOpt return code.
1378 * @param pValueUnion The value union.
1379 */
1380RTEXITCODE errorGetOpt(USAGECATEGORY enmCommand, int rc, union RTGETOPTUNION const *pValueUnion)
1381{
1382 return errorGetOptEx(enmCommand, RTMSGREFENTRYSTR_SCOPE_GLOBAL, rc, pValueUnion);
1383}
1384
1385/**
1386 * Print an error message without the syntax stuff.
1387 *
1388 * @returns RTEXITCODE_SYNTAX.
1389 */
1390RTEXITCODE errorArgument(const char *pszFormat, ...)
1391{
1392 va_list args;
1393 va_start(args, pszFormat);
1394 RTMsgErrorV(pszFormat, args);
1395 va_end(args);
1396 return RTEXITCODE_SYNTAX;
1397}
1398
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