VirtualBox

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

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

FE/VBoxManage: Interface for setting, getting and deleting medium properties

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