VirtualBox

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

Last change on this file since 55169 was 55169, checked in by vboxsync, 10 years ago

doc: mention UI/VM separation

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