VirtualBox

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

Last change on this file since 50447 was 50447, checked in by vboxsync, 11 years ago

Main/Appliance: new options for suppressing MAC addresses on export
Frontends/VBoxManage: add support for the new options
doc/manual: document the new feature

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

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