VirtualBox

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

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

pr6927. ISO images are skipped by default during export. The command "VBoxManage export" has a new argument "--iso" to explicitly export ISO images.

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette