VirtualBox

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

Last change on this file since 43421 was 42460, checked in by vboxsync, 12 years ago

VBoxManage: polished help

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 43.4 KB
Line 
1/* $Id: VBoxManageHelp.cpp 42460 2012-07-30 20:37:10Z vboxsync $ */
2/** @file
3 * VBoxManage - help and other message output.
4 */
5
6/*
7 * Copyright (C) 2006-2012 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#include <VBox/version.h>
23
24#include <iprt/buildconfig.h>
25#include <iprt/ctype.h>
26#include <iprt/err.h>
27#include <iprt/getopt.h>
28#include <iprt/stream.h>
29
30#include "VBoxManage.h"
31
32
33
34void showLogo(PRTSTREAM pStrm)
35{
36 static bool s_fShown; /* show only once */
37
38 if (!s_fShown)
39 {
40 RTStrmPrintf(pStrm, VBOX_PRODUCT " Command Line Management Interface Version "
41 VBOX_VERSION_STRING "\n"
42 "(C) 2005-" VBOX_C_YEAR " " VBOX_VENDOR "\n"
43 "All rights reserved.\n"
44 "\n");
45 s_fShown = true;
46 }
47}
48
49void printUsage(USAGECATEGORY u64Cmd, PRTSTREAM pStrm)
50{
51 bool fDumpOpts = false;
52#ifdef RT_OS_LINUX
53 bool fLinux = true;
54#else
55 bool fLinux = false;
56#endif
57#ifdef RT_OS_WINDOWS
58 bool fWin = true;
59#else
60 bool fWin = false;
61#endif
62#ifdef RT_OS_SOLARIS
63 bool fSolaris = true;
64#else
65 bool fSolaris = false;
66#endif
67#ifdef RT_OS_FREEBSD
68 bool fFreeBSD = true;
69#else
70 bool fFreeBSD = false;
71#endif
72#ifdef RT_OS_DARWIN
73 bool fDarwin = true;
74#else
75 bool fDarwin = false;
76#endif
77#ifdef VBOX_WITH_VBOXSDL
78 bool fVBoxSDL = true;
79#else
80 bool fVBoxSDL = false;
81#endif
82
83 if (u64Cmd == USAGE_DUMPOPTS)
84 {
85 fDumpOpts = true;
86 fLinux = true;
87 fWin = true;
88 fSolaris = true;
89 fFreeBSD = true;
90 fDarwin = true;
91 fVBoxSDL = true;
92 u64Cmd = USAGE_ALL;
93 }
94
95 RTStrmPrintf(pStrm,
96 "Usage:\n"
97 "\n");
98
99 if (u64Cmd == USAGE_ALL)
100 RTStrmPrintf(pStrm,
101 " VBoxManage [<general option>] <command>\n"
102 " \n \n"
103 "General Options:\n \n"
104 " [-v|--version] print version number and exit\n"
105 " [-q|--nologo] suppress the logo\n"
106 " [--settingspw <pw>] provide the settings password\n"
107 " [--settingspwfile <file>] provide a file containing the settings password\n"
108 " \n \n"
109 "Commands:\n \n");
110
111 const char *pcszSep1 = " ";
112 const char *pcszSep2 = " ";
113 if (u64Cmd != USAGE_ALL)
114 {
115 pcszSep1 = "VBoxManage";
116 pcszSep2 = "";
117 }
118
119#define SEP pcszSep1, pcszSep2
120
121 if (u64Cmd & USAGE_LIST)
122 RTStrmPrintf(pStrm,
123 "%s list [--long|-l]%s vms|runningvms|ostypes|hostdvds|hostfloppies|\n"
124#if defined(VBOX_WITH_NETFLT)
125 " bridgedifs|hostonlyifs|dhcpservers|hostinfo|\n"
126#else
127 " bridgedifs|dhcpservers|hostinfo|\n"
128#endif
129 " hostcpuids|hddbackends|hdds|dvds|floppies|\n"
130 " usbhost|usbfilters|systemproperties|extpacks|\n"
131 " groups\n"
132 "\n", SEP);
133
134 if (u64Cmd & USAGE_SHOWVMINFO)
135 RTStrmPrintf(pStrm,
136 "%s showvminfo %s <uuid>|<name> [--details]\n"
137 " [--machinereadable]\n"
138 "%s showvminfo %s <uuid>|<name> --log <idx>\n"
139 "\n", SEP, SEP);
140
141 if (u64Cmd & USAGE_REGISTERVM)
142 RTStrmPrintf(pStrm,
143 "%s registervm %s <filename>\n"
144 "\n", SEP);
145
146 if (u64Cmd & USAGE_UNREGISTERVM)
147 RTStrmPrintf(pStrm,
148 "%s unregistervm %s <uuid>|<name> [--delete]\n"
149 "\n", SEP);
150
151 if (u64Cmd & USAGE_CREATEVM)
152 RTStrmPrintf(pStrm,
153 "%s createvm %s --name <name>\n"
154 " [--groups <group>, ...]\n"
155 " [--ostype <ostype>]\n"
156 " [--register]\n"
157 " [--basefolder <path>]\n"
158 " [--uuid <uuid>]\n"
159 "\n", SEP);
160
161 if (u64Cmd & USAGE_MODIFYVM)
162 {
163 RTStrmPrintf(pStrm,
164 "%s modifyvm %s <uuid|name>\n"
165 " [--name <name>]\n"
166 " [--groups <group>, ...]\n"
167 " [--ostype <ostype>]\n"
168 " [--memory <memorysize in MB>]\n"
169 " [--pagefusion on|off]\n"
170 " [--vram <vramsize in MB>]\n"
171 " [--acpi on|off]\n"
172#ifdef VBOX_WITH_PCI_PASSTHROUGH
173 " [--pciattach 03:04.0]\n"
174 " [--pciattach 03:04.0@02:01.0]\n"
175 " [--pcidetach 03:04.0]\n"
176#endif
177 " [--ioapic on|off]\n"
178 " [--pae on|off]\n"
179 " [--hpet on|off]\n"
180 " [--hwvirtex on|off]\n"
181 " [--hwvirtexexcl on|off]\n"
182 " [--nestedpaging on|off]\n"
183 " [--largepages on|off]\n"
184 " [--vtxvpid on|off]\n"
185 " [--synthcpu on|off]\n"
186 " [--cpuidset <leaf> <eax> <ebx> <ecx> <edx>]\n"
187 " [--cpuidremove <leaf>]\n"
188 " [--cpuidremoveall]\n"
189 " [--hardwareuuid <uuid>]\n"
190 " [--cpus <number>]\n"
191 " [--cpuhotplug on|off]\n"
192 " [--plugcpu <id>]\n"
193 " [--unplugcpu <id>]\n"
194 " [--cpuexecutioncap <1-100>]\n"
195 " [--rtcuseutc on|off]\n"
196 " [--monitorcount <number>]\n"
197 " [--accelerate3d on|off]\n"
198#ifdef VBOX_WITH_VIDEOHWACCEL
199 " [--accelerate2dvideo on|off]\n"
200#endif
201 " [--firmware bios|efi|efi32|efi64]\n"
202 " [--chipset ich9|piix3]\n"
203 " [--bioslogofadein on|off]\n"
204 " [--bioslogofadeout on|off]\n"
205 " [--bioslogodisplaytime <msec>]\n"
206 " [--bioslogoimagepath <imagepath>]\n"
207 " [--biosbootmenu disabled|menuonly|messageandmenu]\n"
208 " [--biossystemtimeoffset <msec>]\n"
209 " [--biospxedebug on|off]\n"
210 " [--boot<1-4> none|floppy|dvd|disk|net>]\n"
211 " [--nic<1-N> none|null|nat|bridged|intnet"
212#if defined(VBOX_WITH_NETFLT)
213 "|hostonly"
214#endif
215 "|\n"
216 " generic"
217 "]\n"
218 " [--nictype<1-N> Am79C970A|Am79C973"
219#ifdef VBOX_WITH_E1000
220 "|\n 82540EM|82543GC|82545EM"
221#endif
222#ifdef VBOX_WITH_VIRTIO
223 "|\n virtio"
224#endif /* VBOX_WITH_VIRTIO */
225 "]\n"
226 " [--cableconnected<1-N> on|off]\n"
227 " [--nictrace<1-N> on|off]\n"
228 " [--nictracefile<1-N> <filename>]\n"
229 " [--nicproperty<1-N> name=[value]]\n"
230 " [--nicspeed<1-N> <kbps>]\n"
231 " [--nicbootprio<1-N> <priority>]\n"
232 " [--nicpromisc<1-N> deny|allow-vms|allow-all]\n"
233 " [--nicbandwidthgroup<1-N> none|<name>]\n"
234 " [--bridgeadapter<1-N> none|<devicename>]\n"
235#if defined(VBOX_WITH_NETFLT)
236 " [--hostonlyadapter<1-N> none|<devicename>]\n"
237#endif
238 " [--intnet<1-N> <network name>]\n"
239 " [--natnet<1-N> <network>|default]\n"
240 " [--nicgenericdrv<1-N> <driver>\n"
241 " [--natsettings<1-N> [<mtu>],[<socksnd>],\n"
242 " [<sockrcv>],[<tcpsnd>],\n"
243 " [<tcprcv>]]\n"
244 " [--natpf<1-N> [<rulename>],tcp|udp,[<hostip>],\n"
245 " <hostport>,[<guestip>],<guestport>]\n"
246 " [--natpf<1-N> delete <rulename>]\n"
247 " [--nattftpprefix<1-N> <prefix>]\n"
248 " [--nattftpfile<1-N> <file>]\n"
249 " [--nattftpserver<1-N> <ip>]\n"
250 " [--natbindip<1-N> <ip>\n"
251 " [--natdnspassdomain<1-N> on|off]\n"
252 " [--natdnsproxy<1-N> on|off]\n"
253 " [--natdnshostresolver<1-N> on|off]\n"
254 " [--nataliasmode<1-N> default|[log],[proxyonly],\n"
255 " [sameports]]\n"
256 " [--macaddress<1-N> auto|<mac>]\n"
257 " [--mouse ps2|usb|usbtablet\n"
258 " [--keyboard ps2|usb\n"
259 " [--uart<1-N> off|<I/O base> <IRQ>]\n"
260 " [--uartmode<1-N> disconnected|\n"
261 " server <pipe>|\n"
262 " client <pipe>|\n"
263 " file <file>|\n"
264 " <devicename>]\n"
265#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
266 " [--lpt<1-N> off|<I/O base> <IRQ>]\n"
267 " [--lptmode<1-N> <devicename>]\n"
268#endif
269 " [--guestmemoryballoon <balloonsize in MB>]\n"
270 " [--gueststatisticsinterval <seconds>]\n"
271 " [--audio none|null", SEP);
272 if (fWin)
273 {
274#ifdef VBOX_WITH_WINMM
275 RTStrmPrintf(pStrm, "|winmm|dsound");
276#else
277 RTStrmPrintf(pStrm, "|dsound");
278#endif
279 }
280 if (fSolaris)
281 {
282 RTStrmPrintf(pStrm, "|solaudio"
283#ifdef VBOX_WITH_SOLARIS_OSS
284 "|oss"
285#endif
286 );
287 }
288 if (fLinux)
289 {
290 RTStrmPrintf(pStrm, "|oss"
291#ifdef VBOX_WITH_ALSA
292 "|alsa"
293#endif
294#ifdef VBOX_WITH_PULSE
295 "|pulse"
296#endif
297 );
298 }
299 if (fFreeBSD)
300 {
301 /* Get the line break sorted when dumping all option variants. */
302 if (fDumpOpts)
303 {
304 RTStrmPrintf(pStrm, "|\n"
305 " oss");
306 }
307 else
308 RTStrmPrintf(pStrm, "|oss");
309#ifdef VBOX_WITH_PULSE
310 RTStrmPrintf(pStrm, "|pulse");
311#endif
312 }
313 if (fDarwin)
314 {
315 RTStrmPrintf(pStrm, "|coreaudio");
316 }
317 RTStrmPrintf(pStrm, "]\n");
318 RTStrmPrintf(pStrm,
319 " [--audiocontroller ac97|hda|sb16]\n"
320 " [--clipboard disabled|hosttoguest|guesttohost|\n"
321 " bidirectional]\n"
322 " [--draganddrop disabled|hosttoguest\n");
323 RTStrmPrintf(pStrm,
324 " [--vrde on|off]\n"
325 " [--vrdeextpack default|<name>\n"
326 " [--vrdeproperty <name=[value]>]\n"
327 " [--vrdeport <hostport>]\n"
328 " [--vrdeaddress <hostip>]\n"
329 " [--vrdeauthtype null|external|guest]\n"
330 " [--vrdeauthlibrary default|<name>\n"
331 " [--vrdemulticon on|off]\n"
332 " [--vrdereusecon on|off]\n"
333 " [--vrdevideochannel on|off]\n"
334 " [--vrdevideochannelquality <percent>]\n");
335 RTStrmPrintf(pStrm,
336 " [--usb on|off]\n"
337 " [--usbehci on|off]\n"
338 " [--snapshotfolder default|<path>]\n"
339 " [--teleporter on|off]\n"
340 " [--teleporterport <port>]\n"
341 " [--teleporteraddress <address|empty>\n"
342 " [--teleporterpassword <password>]\n"
343 " [--teleporterpasswordfile <file>|stdin]\n"
344 " [--tracing-enabled on|off]\n"
345 " [--tracing-config <config-string>]\n"
346 " [--tracing-allow-vm-access on|off]\n"
347#if 0
348 " [--iocache on|off]\n"
349 " [--iocachesize <I/O cache size in MB>]\n"
350#endif
351#if 0
352 " [--faulttolerance master|standby]\n"
353 " [--faulttoleranceaddress <name>]\n"
354 " [--faulttoleranceport <port>]\n"
355 " [--faulttolerancesyncinterval <msec>]\n"
356 " [--faulttolerancepassword <password>]\n"
357#endif
358#ifdef VBOX_WITH_USB_CARDREADER
359 " [--usbcardreader on|off]\n"
360#endif
361 " [--autostart-enabled on|off]\n"
362 " [--autostart-delay <seconds>]\n"
363 " [--autostop-type disabled|savestate|poweroff|\n"
364 " acpishutdown]\n"
365 "\n");
366 }
367
368 if (u64Cmd & USAGE_CLONEVM)
369 RTStrmPrintf(pStrm,
370 "%s clonevm %s <uuid>|<name>\n"
371 " [--snapshot <uuid>|<name>]\n"
372 " [--mode machine|machineandchildren|all]\n"
373 " [--options link|keepallmacs|keepnatmacs|\n"
374 " keepdisknames]\n"
375 " [--name <name>]\n"
376 " [--groups <group>, ...]\n"
377 " [--basefolder <basefolder>]\n"
378 " [--uuid <uuid>]\n"
379 " [--register]\n"
380 "\n", SEP);
381
382 if (u64Cmd & USAGE_IMPORTAPPLIANCE)
383 RTStrmPrintf(pStrm,
384 "%s import %s <ovf/ova>\n"
385 " [--dry-run|-n]\n"
386 " [--options keepallmacs|keepnatmacs]\n"
387 " [more options]\n"
388 " (run with -n to have options displayed\n"
389 " for a particular OVF)\n\n", SEP);
390
391 if (u64Cmd & USAGE_EXPORTAPPLIANCE)
392 RTStrmPrintf(pStrm,
393 "%s export %s <machines> --output|-o <name>.<ovf/ova>\n"
394 " [--legacy09|--ovf09|--ovf10|--ovf20]\n"
395 " [--manifest]\n"
396 " [--vsys <number of virtual system>]\n"
397 " [--product <product name>]\n"
398 " [--producturl <product url>]\n"
399 " [--vendor <vendor name>]\n"
400 " [--vendorurl <vendor url>]\n"
401 " [--version <version info>]\n"
402 " [--eula <license text>]\n"
403 " [--eulafile <filename>]\n"
404 "\n", SEP);
405
406 if (u64Cmd & USAGE_STARTVM)
407 {
408 RTStrmPrintf(pStrm,
409 "%s startvm %s <uuid>|<name>...\n"
410 " [--type gui", SEP);
411 if (fVBoxSDL)
412 RTStrmPrintf(pStrm, "|sdl");
413 RTStrmPrintf(pStrm, "|headless]\n");
414 RTStrmPrintf(pStrm,
415 "\n");
416 }
417
418 if (u64Cmd & USAGE_CONTROLVM)
419 {
420 RTStrmPrintf(pStrm,
421 "%s controlvm %s <uuid>|<name>\n"
422 " pause|resume|reset|poweroff|savestate|\n"
423 " acpipowerbutton|acpisleepbutton|\n"
424 " keyboardputscancode <hex> [<hex> ...]|\n"
425 " setlinkstate<1-N> on|off |\n"
426#if defined(VBOX_WITH_NETFLT)
427 " nic<1-N> null|nat|bridged|intnet|hostonly|generic"
428 "\n"
429 " [<devicename>] |\n"
430#else /* !VBOX_WITH_NETFLT */
431 " nic<1-N> null|nat|bridged|intnet|generic\n"
432 " [<devicename>] |\n"
433#endif /* !VBOX_WITH_NETFLT */
434 " nictrace<1-N> on|off\n"
435 " nictracefile<1-N> <filename>\n"
436 " nicproperty<1-N> name=[value]\n"
437 " natpf<1-N> [<rulename>],tcp|udp,[<hostip>],\n"
438 " <hostport>,[<guestip>],<guestport>\n"
439 " natpf<1-N> delete <rulename>\n"
440 " guestmemoryballoon <balloonsize in MB>]\n"
441 " gueststatisticsinterval <seconds>]\n"
442 " usbattach <uuid>|<address> |\n"
443 " usbdetach <uuid>|<address> |\n"
444 " clipboard disabled|hosttoguest|guesttohost|\n"
445 " bidirectional]\n"
446 " draganddrop disabled|hosttoguest]\n"
447 " vrde on|off |\n"
448 " vrdeport <port> |\n"
449 " vrdeproperty <name=[value]> |\n"
450 " vrdevideochannelquality <percent>\n"
451 " setvideomodehint <xres> <yres> <bpp>\n"
452 " [[<display>] [<enabled:yes|no>\n"
453 " [<xorigin> <yorigin>]]] |\n"
454 " screenshotpng <file> [display] |\n"
455 " setcredentials <username>\n"
456 " --passwordfile <file> | <password>\n"
457 " <domain>\n"
458 " [--allowlocallogon <yes|no>] |\n"
459 " teleport --host <name> --port <port>\n"
460 " [--maxdowntime <msec>]\n"
461 " [--passwordfile <file> |\n"
462 " --password <password>]\n"
463 " plugcpu <id>\n"
464 " unplugcpu <id>\n"
465 " cpuexecutioncap <1-100>\n"
466 "\n", SEP);
467 }
468
469 if (u64Cmd & USAGE_DISCARDSTATE)
470 RTStrmPrintf(pStrm,
471 "%s discardstate %s <uuid>|<name>\n"
472 "\n", SEP);
473
474 if (u64Cmd & USAGE_ADOPTSTATE)
475 RTStrmPrintf(pStrm,
476 "%s adoptstate %s <uuid>|<name> <state_file>\n"
477 "\n", SEP);
478
479 if (u64Cmd & USAGE_SNAPSHOT)
480 RTStrmPrintf(pStrm,
481 "%s snapshot %s <uuid>|<name>\n"
482 " take <name> [--description <desc>] [--pause] |\n"
483 " delete <uuid>|<name> |\n"
484 " restore <uuid>|<name> |\n"
485 " restorecurrent |\n"
486 " edit <uuid>|<name>|--current\n"
487 " [--name <name>]\n"
488 " [--description <desc>] |\n"
489 " list [--details|--machinereadable]\n"
490 " showvminfo <uuid>|<name>\n"
491 "\n", SEP);
492
493 if (u64Cmd & USAGE_CLOSEMEDIUM)
494 RTStrmPrintf(pStrm,
495 "%s closemedium %s disk|dvd|floppy <uuid>|<filename>\n"
496 " [--delete]\n"
497 "\n", SEP);
498
499 if (u64Cmd & USAGE_STORAGEATTACH)
500 RTStrmPrintf(pStrm,
501 "%s storageattach %s <uuid|vmname>\n"
502 " --storagectl <name>\n"
503 " [--port <number>]\n"
504 " [--device <number>]\n"
505 " [--type dvddrive|hdd|fdd]\n"
506 " [--medium none|emptydrive|\n"
507 " <uuid>|<filename>|host:<drive>|iscsi]\n"
508 " [--mtype normal|writethrough|immutable|shareable|\n"
509 " readonly|multiattach]\n"
510 " [--comment <text>]\n"
511 " [--setuuid <uuid>]\n"
512 " [--setparentuuid <uuid>]\n"
513 " [--passthrough on|off]\n"
514 " [--tempeject on|off]\n"
515 " [--nonrotational on|off]\n"
516 " [--discard on|off]\n"
517 " [--bandwidthgroup <name>]\n"
518 " [--forceunmount]\n"
519 " [--server <name>|<ip>]\n"
520 " [--target <target>]\n"
521 " [--tport <port>]\n"
522 " [--lun <lun>]\n"
523 " [--encodedlun <lun>]\n"
524 " [--username <username>]\n"
525 " [--password <password>]\n"
526 " [--initiator <initiator>]\n"
527 " [--intnet]\n"
528 "\n", SEP);
529
530 if (u64Cmd & USAGE_STORAGECONTROLLER)
531 RTStrmPrintf(pStrm,
532 "%s storagectl %s <uuid|vmname>\n"
533 " --name <name>\n"
534 " [--add ide|sata|scsi|floppy|sas]\n"
535 " [--controller LSILogic|LSILogicSAS|BusLogic|\n"
536 " IntelAHCI|PIIX3|PIIX4|ICH6|I82078]\n"
537 " [--sataideemulation<1-4> <1-30>]\n"
538 " [--sataportcount <1-30>]\n"
539 " [--hostiocache on|off]\n"
540 " [--bootable on|off]\n"
541 " [--remove]\n"
542 "\n", SEP);
543
544 if (u64Cmd & USAGE_BANDWIDTHCONTROL)
545 RTStrmPrintf(pStrm,
546 "%s bandwidthctl %s <uuid|vmname>\n"
547 " add <name> --type disk|network\n"
548 " --limit <megabytes per second>[k|m|g|K|M|G] |\n"
549 " set <name>\n"
550 " --limit <megabytes per second>[k|m|g|K|M|G] |\n"
551 " remove <name> |\n"
552 " list [--machinereadable]\n"
553 " (limit units: k=kilobit, m=megabit, g=gigabit,\n"
554 " K=kilobyte, M=megabyte, G=gigabyte)\n"
555 "\n", SEP);
556
557 if (u64Cmd & USAGE_SHOWHDINFO)
558 RTStrmPrintf(pStrm,
559 "%s showhdinfo %s <uuid>|<filename>\n"
560 "\n", SEP);
561
562 if (u64Cmd & USAGE_CREATEHD)
563 RTStrmPrintf(pStrm,
564 "%s createhd %s --filename <filename>\n"
565 " [--size <megabytes>|--sizebyte <bytes>]\n"
566 " [--diffparent <uuid>|<filename>\n"
567 " [--format VDI|VMDK|VHD] (default: VDI)\n"
568 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
569 "\n", SEP);
570
571 if (u64Cmd & USAGE_MODIFYHD)
572 RTStrmPrintf(pStrm,
573 "%s modifyhd %s <uuid>|<filename>\n"
574 " [--type normal|writethrough|immutable|shareable|\n"
575 " readonly|multiattach]\n"
576 " [--autoreset on|off]\n"
577 " [--compact]\n"
578 " [--resize <megabytes>|--resizebyte <bytes>]\n"
579 "\n", SEP);
580
581 if (u64Cmd & USAGE_CLONEHD)
582 RTStrmPrintf(pStrm,
583 "%s clonehd %s <uuid>|<filename> <uuid>|<outputfile>\n"
584 " [--format VDI|VMDK|VHD|RAW|<other>]\n"
585 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
586 " [--existing]\n"
587 "\n", SEP);
588
589 if (u64Cmd & USAGE_CONVERTFROMRAW)
590 RTStrmPrintf(pStrm,
591 "%s convertfromraw %s <filename> <outputfile>\n"
592 " [--format VDI|VMDK|VHD]\n"
593 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
594 " [--uuid <uuid>]\n"
595 "%s convertfromraw %s stdin <outputfile> <bytes>\n"
596 " [--format VDI|VMDK|VHD]\n"
597 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
598 " [--uuid <uuid>]\n"
599 "\n", SEP, SEP);
600
601 if (u64Cmd & USAGE_GETEXTRADATA)
602 RTStrmPrintf(pStrm,
603 "%s getextradata %s global|<uuid>|<name>\n"
604 " <key>|enumerate\n"
605 "\n", SEP);
606
607 if (u64Cmd & USAGE_SETEXTRADATA)
608 RTStrmPrintf(pStrm,
609 "%s setextradata %s global|<uuid>|<name>\n"
610 " <key>\n"
611 " [<value>] (no value deletes key)\n"
612 "\n", SEP);
613
614 if (u64Cmd & USAGE_SETPROPERTY)
615 RTStrmPrintf(pStrm,
616 "%s setproperty %s machinefolder default|<folder> |\n"
617 " vrdeauthlibrary default|<library> |\n"
618 " websrvauthlibrary default|null|<library> |\n"
619 " vrdeextpack null|<library> |\n"
620 " autostartdbpath null|<folder> |\n"
621 " loghistorycount <value>\n"
622 "\n", SEP);
623
624 if (u64Cmd & USAGE_USBFILTER_ADD)
625 RTStrmPrintf(pStrm,
626 "%s usbfilter %s add <index,0-N>\n"
627 " --target <uuid>|<name>|global\n"
628 " --name <string>\n"
629 " --action ignore|hold (global filters only)\n"
630 " [--active yes|no] (yes)\n"
631 " [--vendorid <XXXX>] (null)\n"
632 " [--productid <XXXX>] (null)\n"
633 " [--revision <IIFF>] (null)\n"
634 " [--manufacturer <string>] (null)\n"
635 " [--product <string>] (null)\n"
636 " [--remote yes|no] (null, VM filters only)\n"
637 " [--serialnumber <string>] (null)\n"
638 " [--maskedinterfaces <XXXXXXXX>]\n"
639 "\n", SEP);
640
641 if (u64Cmd & USAGE_USBFILTER_MODIFY)
642 RTStrmPrintf(pStrm,
643 "%s usbfilter %s modify <index,0-N>\n"
644 " --target <uuid>|<name>|global\n"
645 " [--name <string>]\n"
646 " [--action ignore|hold] (global filters only)\n"
647 " [--active yes|no]\n"
648 " [--vendorid <XXXX>|\"\"]\n"
649 " [--productid <XXXX>|\"\"]\n"
650 " [--revision <IIFF>|\"\"]\n"
651 " [--manufacturer <string>|\"\"]\n"
652 " [--product <string>|\"\"]\n"
653 " [--remote yes|no] (null, VM filters only)\n"
654 " [--serialnumber <string>|\"\"]\n"
655 " [--maskedinterfaces <XXXXXXXX>]\n"
656 "\n", SEP);
657
658 if (u64Cmd & USAGE_USBFILTER_REMOVE)
659 RTStrmPrintf(pStrm,
660 "%s usbfilter %s remove <index,0-N>\n"
661 " --target <uuid>|<name>|global\n"
662 "\n", SEP);
663
664 if (u64Cmd & USAGE_SHAREDFOLDER_ADD)
665 RTStrmPrintf(pStrm,
666 "%s sharedfolder %s add <vmname>|<uuid>\n"
667 " --name <name> --hostpath <hostpath>\n"
668 " [--transient] [--readonly] [--automount]\n"
669 "\n", SEP);
670
671 if (u64Cmd & USAGE_SHAREDFOLDER_REMOVE)
672 RTStrmPrintf(pStrm,
673 "%s sharedfolder %s remove <vmname>|<uuid>\n"
674 " --name <name> [--transient]\n"
675 "\n", SEP);
676
677#ifdef VBOX_WITH_GUEST_PROPS
678 if (u64Cmd & USAGE_GUESTPROPERTY)
679 usageGuestProperty(pStrm, SEP);
680#endif /* VBOX_WITH_GUEST_PROPS defined */
681
682#ifdef VBOX_WITH_GUEST_CONTROL
683 if (u64Cmd & USAGE_GUESTCONTROL)
684 usageGuestControl(pStrm, SEP);
685#endif /* VBOX_WITH_GUEST_CONTROL defined */
686
687 if (u64Cmd & USAGE_DEBUGVM)
688 {
689 RTStrmPrintf(pStrm,
690 "%s debugvm %s <uuid>|<name>\n"
691 " dumpguestcore --filename <name> |\n"
692 " info <item> [args] |\n"
693 " injectnmi |\n"
694 " log [--release|--debug] <settings> ...|\n"
695 " logdest [--release|--debug] <settings> ...|\n"
696 " logflags [--release|--debug] <settings> ...|\n"
697 " osdetect |\n"
698 " osinfo |\n"
699 " getregisters [--cpu <id>] <reg>|all ... |\n"
700 " setregisters [--cpu <id>] <reg>=<value> ... |\n"
701 " show [--human-readable|--sh-export|--sh-eval|\n"
702 " --cmd-set] \n"
703 " <logdbg-settings|logrel-settings>\n"
704 " [[opt] what ...] |\n"
705 " statistics [--reset] [--pattern <pattern>]\n"
706 " [--descriptions]\n"
707 "\n", SEP);
708 }
709 if (u64Cmd & USAGE_METRICS)
710 RTStrmPrintf(pStrm,
711 "%s metrics %s list [*|host|<vmname> [<metric_list>]]\n"
712 " (comma-separated)\n\n"
713 "%s metrics %s setup\n"
714 " [--period <seconds>] (default: 1)\n"
715 " [--samples <count>] (default: 1)\n"
716 " [--list]\n"
717 " [*|host|<vmname> [<metric_list>]]\n\n"
718 "%s metrics %s query [*|host|<vmname> [<metric_list>]]\n\n"
719 "%s metrics %s enable\n"
720 " [--list]\n"
721 " [*|host|<vmname> [<metric_list>]]\n\n"
722 "%s metrics %s disable\n"
723 " [--list]\n"
724 " [*|host|<vmname> [<metric_list>]]\n\n"
725 "%s metrics %s collect\n"
726 " [--period <seconds>] (default: 1)\n"
727 " [--samples <count>] (default: 1)\n"
728 " [--list]\n"
729 " [--detach]\n"
730 " [*|host|<vmname> [<metric_list>]]\n"
731 "\n", SEP, SEP, SEP, SEP, SEP, SEP);
732
733#if defined(VBOX_WITH_NETFLT)
734 if (u64Cmd & USAGE_HOSTONLYIFS)
735 {
736 RTStrmPrintf(pStrm,
737 "%s hostonlyif %s ipconfig <name>\n"
738 " [--dhcp |\n"
739 " --ip<ipv4> [--netmask<ipv4> (def: 255.255.255.0)] |\n"
740 " --ipv6<ipv6> [--netmasklengthv6<length> (def: 64)]]\n"
741# if !defined(RT_OS_SOLARIS)
742 " create |\n"
743 " remove <name>\n"
744# endif
745 "\n", SEP);
746 }
747#endif
748
749 if (u64Cmd & USAGE_DHCPSERVER)
750 {
751 RTStrmPrintf(pStrm,
752 "%s dhcpserver %s add|modify --netname <network_name> |\n"
753#if defined(VBOX_WITH_NETFLT)
754 " --ifname <hostonly_if_name>\n"
755#endif
756 " [--ip <ip_address>\n"
757 " --netmask <network_mask>\n"
758 " --lowerip <lower_ip>\n"
759 " --upperip <upper_ip>]\n"
760 " [--enable | --disable]\n\n"
761 "%s dhcpserver %s remove --netname <network_name> |\n"
762#if defined(VBOX_WITH_NETFLT)
763 " --ifname <hostonly_if_name>\n"
764#endif
765 "\n", SEP, SEP);
766 }
767 if (u64Cmd & USAGE_EXTPACK)
768 {
769 RTStrmPrintf(pStrm,
770 "%s extpack %s install [--replace] <tarball> |\n"
771 " uninstall [--force] <name> |\n"
772 " cleanup\n"
773 "\n", SEP);
774 }
775}
776
777/**
778 * Print a usage synopsis and the syntax error message.
779 * @returns RTEXITCODE_SYNTAX.
780 */
781RTEXITCODE errorSyntax(USAGECATEGORY u64Cmd, const char *pszFormat, ...)
782{
783 va_list args;
784 showLogo(g_pStdErr); // show logo even if suppressed
785#ifndef VBOX_ONLY_DOCS
786 if (g_fInternalMode)
787 printUsageInternal(u64Cmd, g_pStdErr);
788 else
789 printUsage(u64Cmd, g_pStdErr);
790#endif /* !VBOX_ONLY_DOCS */
791 va_start(args, pszFormat);
792 RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
793 va_end(args);
794 return RTEXITCODE_SYNTAX;
795}
796
797/**
798 * errorSyntax for RTGetOpt users.
799 *
800 * @returns RTEXITCODE_SYNTAX.
801 *
802 * @param fUsageCategory The usage category of the command.
803 * @param rc The RTGetOpt return code.
804 * @param pValueUnion The value union.
805 */
806RTEXITCODE errorGetOpt(USAGECATEGORY fUsageCategory, int rc, union RTGETOPTUNION const *pValueUnion)
807{
808 /*
809 * Check if it is an unhandled standard option.
810 */
811 if (rc == 'V')
812 {
813 RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision());
814 return RTEXITCODE_SUCCESS;
815 }
816
817 if (rc == 'h')
818 {
819 showLogo(g_pStdErr);
820#ifndef VBOX_ONLY_DOCS
821 if (g_fInternalMode)
822 printUsageInternal(fUsageCategory, g_pStdOut);
823 else
824 printUsage(fUsageCategory, g_pStdOut);
825#endif
826 return RTEXITCODE_SUCCESS;
827 }
828
829 /*
830 * General failure.
831 */
832 showLogo(g_pStdErr); // show logo even if suppressed
833#ifndef VBOX_ONLY_DOCS
834 if (g_fInternalMode)
835 printUsageInternal(fUsageCategory, g_pStdErr);
836 else
837 printUsage(fUsageCategory, g_pStdErr);
838#endif /* !VBOX_ONLY_DOCS */
839
840 if (rc == VINF_GETOPT_NOT_OPTION)
841 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid parameter '%s'", pValueUnion->psz);
842 if (rc > 0)
843 {
844 if (RT_C_IS_PRINT(rc))
845 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option -%c", rc);
846 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option case %i", rc);
847 }
848 if (rc == VERR_GETOPT_UNKNOWN_OPTION)
849 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unknown option: %s", pValueUnion->psz);
850 if (rc == VERR_GETOPT_INVALID_ARGUMENT_FORMAT)
851 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid argument format: %s", pValueUnion->psz);
852 if (pValueUnion->pDef)
853 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%s: %Rrs", pValueUnion->pDef->pszLong, rc);
854 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%Rrs", rc);
855}
856
857/**
858 * Print an error message without the syntax stuff.
859 *
860 * @returns RTEXITCODE_SYNTAX.
861 */
862RTEXITCODE errorArgument(const char *pszFormat, ...)
863{
864 va_list args;
865 va_start(args, pszFormat);
866 RTMsgErrorV(pszFormat, args);
867 va_end(args);
868 return RTEXITCODE_SYNTAX;
869}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use