VirtualBox

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

Last change on this file since 38990 was 38874, checked in by vboxsync, 14 years ago

FE/VBoxManage: Add discard option

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