VirtualBox

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

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

Port r124260, r124263, r124271, r124273, r124277, r124278, r124279, r124284, r124285, r124286, r124287, r124288, r124289 and r124290 (Ported fixes over from 5.2, see bugref:9179 for more information)

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

© 2023 Oracle
ContactPrivacy policyTerms of Use