VirtualBox

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

Last change on this file since 37531 was 37525, checked in by vboxsync, 14 years ago

Main/VirtualBox+Medium: resurrect the feature of changing the medium UUID when opening the image, which allows to resolve duplicate UUIDs without using external tools. Also fixes Medium::setIDs, which wasn't correctly working.
Frontends/*: corresponding changes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 38.4 KB
Line 
1/* $Id: VBoxManageHelp.cpp 37525 2011-06-17 10:09:21Z 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.215389.xyz. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#include <VBox/version.h>
23
24#include <iprt/buildconfig.h>
25#include <iprt/ctype.h>
26#include <iprt/err.h>
27#include <iprt/getopt.h>
28#include <iprt/stream.h>
29
30#include "VBoxManage.h"
31
32
33
34void showLogo(PRTSTREAM pStrm)
35{
36 static bool s_fShown; /* show only once */
37
38 if (!s_fShown)
39 {
40 RTStrmPrintf(pStrm, VBOX_PRODUCT " Command Line Management Interface Version "
41 VBOX_VERSION_STRING "\n"
42 "(C) 2005-" VBOX_C_YEAR " " VBOX_VENDOR "\n"
43 "All rights reserved.\n"
44 "\n");
45 s_fShown = true;
46 }
47}
48
49void printUsage(USAGECATEGORY u64Cmd, PRTSTREAM pStrm)
50{
51 bool fDumpOpts = false;
52#ifdef RT_OS_LINUX
53 bool fLinux = true;
54#else
55 bool fLinux = false;
56#endif
57#ifdef RT_OS_WINDOWS
58 bool fWin = true;
59#else
60 bool fWin = false;
61#endif
62#ifdef RT_OS_SOLARIS
63 bool fSolaris = true;
64#else
65 bool fSolaris = false;
66#endif
67#ifdef RT_OS_FREEBSD
68 bool fFreeBSD = true;
69#else
70 bool fFreeBSD = false;
71#endif
72#ifdef RT_OS_DARWIN
73 bool fDarwin = true;
74#else
75 bool fDarwin = false;
76#endif
77#ifdef VBOX_WITH_VBOXSDL
78 bool fVBoxSDL = true;
79#else
80 bool fVBoxSDL = false;
81#endif
82
83 if (u64Cmd == USAGE_DUMPOPTS)
84 {
85 fDumpOpts = true;
86 fLinux = true;
87 fWin = true;
88 fSolaris = true;
89 fFreeBSD = true;
90 fDarwin = true;
91 fVBoxSDL = true;
92 u64Cmd = USAGE_ALL;
93 }
94
95 RTStrmPrintf(pStrm,
96 "Usage:\n"
97 "\n");
98
99 if (u64Cmd == USAGE_ALL)
100 RTStrmPrintf(pStrm,
101 "VBoxManage [-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 " [--attachpci 03:04.0]\n"
155 " [--attachpci 03:04.0@02:01.0]\n"
156 " [--detachpci 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|machineandchilds|all]\n"
338 " [--name <name>]\n"
339 " [--basefolder <basefolder>]\n"
340 " [--uuid <uuid>]\n"
341 " [--register]\n"
342 "\n");
343
344 if (u64Cmd & USAGE_IMPORTAPPLIANCE)
345 RTStrmPrintf(pStrm,
346 "VBoxManage import <ovf/ova> [--dry-run|-n] [more options]\n"
347 " (run with -n to have options displayed\n"
348 " for a particular OVF)\n\n");
349
350 if (u64Cmd & USAGE_EXPORTAPPLIANCE)
351 RTStrmPrintf(pStrm,
352 "VBoxManage export <machines> --output|-o <ovf/ova>\n"
353 " [--legacy09]\n"
354 " [--manifest]\n"
355 " [--vsys <number of virtual system>]\n"
356 " [--product <product name>]\n"
357 " [--producturl <product url>]\n"
358 " [--vendor <vendor name>]\n"
359 " [--vendorurl <vendor url>]\n"
360 " [--version <version info>]\n"
361 " [--eula <license text>]\n"
362 " [--eulafile <filename>]\n"
363 "\n");
364
365 if (u64Cmd & USAGE_STARTVM)
366 {
367 RTStrmPrintf(pStrm,
368 "VBoxManage startvm <uuid>|<name>\n");
369 RTStrmPrintf(pStrm,
370 " [--type gui");
371 if (fVBoxSDL)
372 RTStrmPrintf(pStrm, "|sdl");
373 RTStrmPrintf(pStrm, "|headless]\n");
374 RTStrmPrintf(pStrm,
375 "\n");
376 }
377
378 if (u64Cmd & USAGE_CONTROLVM)
379 {
380 RTStrmPrintf(pStrm,
381 "VBoxManage controlvm <uuid>|<name>\n"
382 " pause|resume|reset|poweroff|savestate|\n"
383 " acpipowerbutton|acpisleepbutton|\n"
384 " keyboardputscancode <hex> [<hex> ...]|\n"
385 " setlinkstate<1-N> on|off |\n"
386#if defined(VBOX_WITH_NETFLT)
387 " nic<1-N> null|nat|bridged|intnet|hostonly|generic"
388 "\n"
389 " [<devicename>] |\n"
390#else /* !VBOX_WITH_NETFLT */
391 " nic<1-N> null|nat|bridged|intnet|generic\n"
392 " [<devicename>] |\n"
393#endif /* !VBOX_WITH_NETFLT */
394 " nictrace<1-N> on|off\n"
395 " nictracefile<1-N> <filename>\n"
396 " nicproperty<1-N> name=[value]\n"
397 " natpf<1-N> [<rulename>],tcp|udp,[<hostip>],\n"
398 " <hostport>,[<guestip>],<guestport>\n"
399 " natpf<1-N> delete <rulename>\n"
400 " guestmemoryballoon <balloonsize in MB>]\n"
401 " gueststatisticsinterval <seconds>]\n"
402 " usbattach <uuid>|<address> |\n"
403 " usbdetach <uuid>|<address> |\n");
404 RTStrmPrintf(pStrm,
405 " vrde on|off |\n");
406 RTStrmPrintf(pStrm,
407 " vrdeport <port> |\n"
408 " vrdeproperty <name=[value]> |\n"
409 " vrdevideochannelquality <percent>\n");
410 RTStrmPrintf(pStrm,
411 " setvideomodehint <xres> <yres> <bpp> [display] |\n"
412 " screenshotpng <file> [display] |\n"
413 " setcredentials <username> <password> <domain>\n"
414 " [--allowlocallogon <yes|no>] |\n"
415 " teleport --host <name> --port <port>\n"
416 " [--maxdowntime <msec>] [--password password]\n"
417 " plugcpu <id>\n"
418 " unplugcpu <id>\n"
419 " cpuexecutioncap <1-100>\n"
420 "\n");
421 }
422
423 if (u64Cmd & USAGE_DISCARDSTATE)
424 RTStrmPrintf(pStrm,
425 "VBoxManage discardstate <uuid>|<name>\n"
426 "\n");
427
428 if (u64Cmd & USAGE_ADOPTSTATE)
429 RTStrmPrintf(pStrm,
430 "VBoxManage adoptstate <uuid>|<name> <state_file>\n"
431 "\n");
432
433 if (u64Cmd & USAGE_SNAPSHOT)
434 RTStrmPrintf(pStrm,
435 "VBoxManage snapshot <uuid>|<name>\n"
436 " take <name> [--description <desc>] [--pause] |\n"
437 " delete <uuid>|<name> |\n"
438 " restore <uuid>|<name> |\n"
439 " restorecurrent |\n"
440 " edit <uuid>|<name>|--current\n"
441 " [--name <name>]\n"
442 " [--description <desc>] |\n"
443 " showvminfo <uuid>|<name>\n"
444 "\n");
445
446 if (u64Cmd & USAGE_CLOSEMEDIUM)
447 RTStrmPrintf(pStrm,
448 "VBoxManage closemedium disk|dvd|floppy <uuid>|<filename>\n"
449 " [--delete]\n"
450 "\n");
451
452 if (u64Cmd & USAGE_STORAGEATTACH)
453 RTStrmPrintf(pStrm,
454 "VBoxManage storageattach <uuid|vmname>\n"
455 " --storagectl <name>\n"
456 " --port <number>\n"
457 " --device <number>\n"
458 " [--type dvddrive|hdd|fdd]\n"
459 " [--medium none|emptydrive|\n"
460 " <uuid>|<filename>|host:<drive>|iscsi]\n"
461 " [--mtype normal|writethrough|immutable|shareable|\n"
462 " readonly|multiattach]\n"
463 " [--comment <text>]\n"
464 " [--setuuid <uuid>]\n"
465 " [--setparentuuid <uuid>]\n"
466 " [--passthrough on|off]\n"
467 " [--bandwidthgroup <name>]\n"
468 " [--forceunmount]\n"
469 " [--server <name>|<ip>]\n"
470 " [--target <target>]\n"
471 " [--port <port>]\n"
472 " [--lun <lun>]\n"
473 " [--encodedlun <lun>]\n"
474 " [--username <username>]\n"
475 " [--password <password>]\n"
476 " [--intnet]\n"
477 "\n");
478
479 if (u64Cmd & USAGE_STORAGECONTROLLER)
480 RTStrmPrintf(pStrm,
481 "VBoxManage storagectl <uuid|vmname>\n"
482 " --name <name>\n"
483 " [--add ide|sata|scsi|floppy|sas]\n"
484 " [--controller LSILogic|LSILogicSAS|BusLogic|\n"
485 " IntelAHCI|PIIX3|PIIX4|ICH6|I82078]\n"
486 " [--sataideemulation<1-4> <1-30>]\n"
487 " [--sataportcount <1-30>]\n"
488 " [--hostiocache on|off]\n"
489 " [--bootable on|off]\n"
490 " [--remove]\n"
491 "\n");
492
493 if (u64Cmd & USAGE_BANDWIDTHCONTROL)
494 RTStrmPrintf(pStrm,
495 "VBoxManage bandwidthctl <uuid|vmname>\n"
496 " --name <name>\n"
497 " [--add disk|network]\n"
498 " [--limit <megabytes per second>\n"
499 " [--delete]\n"
500 "\n");
501
502 if (u64Cmd & USAGE_SHOWHDINFO)
503 RTStrmPrintf(pStrm,
504 "VBoxManage showhdinfo <uuid>|<filename>\n"
505 "\n");
506
507 if (u64Cmd & USAGE_CREATEHD)
508 RTStrmPrintf(pStrm,
509 "VBoxManage createhd --filename <filename>\n"
510 " --size <megabytes>|--sizebyte <bytes>\n"
511 " [--format VDI|VMDK|VHD] (default: VDI)\n"
512 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
513 "\n");
514
515 if (u64Cmd & USAGE_MODIFYHD)
516 RTStrmPrintf(pStrm,
517 "VBoxManage modifyhd <uuid>|<filename>\n"
518 " [--type normal|writethrough|immutable|shareable|\n"
519 " readonly|multiattach]\n"
520 " [--autoreset on|off]\n"
521 " [--compact]\n"
522 " [--resize <megabytes>|--resizebyte <bytes>]\n"
523 "\n");
524
525 if (u64Cmd & USAGE_CLONEHD)
526 RTStrmPrintf(pStrm,
527 "VBoxManage clonehd <uuid>|<filename> <uuid>|<outputfile>\n"
528 " [--format VDI|VMDK|VHD|RAW|<other>]\n"
529 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
530 " [--existing]\n"
531 "\n");
532
533 if (u64Cmd & USAGE_CONVERTFROMRAW)
534 RTStrmPrintf(pStrm,
535 "VBoxManage convertfromraw <filename> <outputfile>\n"
536 " [--format VDI|VMDK|VHD]\n"
537 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
538#ifndef RT_OS_WINDOWS
539 "VBoxManage convertfromraw stdin <outputfile> <bytes>\n"
540 " [--format VDI|VMDK|VHD]\n"
541 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
542#endif
543 "\n");
544
545 if (u64Cmd & USAGE_GETEXTRADATA)
546 RTStrmPrintf(pStrm,
547 "VBoxManage getextradata global|<uuid>|<name>\n"
548 " <key>|enumerate\n"
549 "\n");
550
551 if (u64Cmd & USAGE_SETEXTRADATA)
552 RTStrmPrintf(pStrm,
553 "VBoxManage setextradata global|<uuid>|<name>\n"
554 " <key>\n"
555 " [<value>] (no value deletes key)\n"
556 "\n");
557
558 if (u64Cmd & USAGE_SETPROPERTY)
559 RTStrmPrintf(pStrm,
560 "VBoxManage setproperty machinefolder default|<folder> |\n"
561 " vrdeauthlibrary default|<library> |\n"
562 " websrvauthlibrary default|null|<library> |\n"
563 " vrdeextpack null|<library> |\n"
564 " loghistorycount <value>\n"
565 "\n");
566
567 if (u64Cmd & USAGE_USBFILTER_ADD)
568 RTStrmPrintf(pStrm,
569 "VBoxManage usbfilter add <index,0-N>\n"
570 " --target <uuid>|<name>|global\n"
571 " --name <string>\n"
572 " --action ignore|hold (global filters only)\n"
573 " [--active yes|no] (yes)\n"
574 " [--vendorid <XXXX>] (null)\n"
575 " [--productid <XXXX>] (null)\n"
576 " [--revision <IIFF>] (null)\n"
577 " [--manufacturer <string>] (null)\n"
578 " [--product <string>] (null)\n"
579 " [--remote yes|no] (null, VM filters only)\n"
580 " [--serialnumber <string>] (null)\n"
581 " [--maskedinterfaces <XXXXXXXX>]\n"
582 "\n");
583
584 if (u64Cmd & USAGE_USBFILTER_MODIFY)
585 RTStrmPrintf(pStrm,
586 "VBoxManage usbfilter modify <index,0-N>\n"
587 " --target <uuid>|<name>|global\n"
588 " [--name <string>]\n"
589 " [--action ignore|hold] (global filters only)\n"
590 " [--active yes|no]\n"
591 " [--vendorid <XXXX>|\"\"]\n"
592 " [--productid <XXXX>|\"\"]\n"
593 " [--revision <IIFF>|\"\"]\n"
594 " [--manufacturer <string>|\"\"]\n"
595 " [--product <string>|\"\"]\n"
596 " [--remote yes|no] (null, VM filters only)\n"
597 " [--serialnumber <string>|\"\"]\n"
598 " [--maskedinterfaces <XXXXXXXX>]\n"
599 "\n");
600
601 if (u64Cmd & USAGE_USBFILTER_REMOVE)
602 RTStrmPrintf(pStrm,
603 "VBoxManage usbfilter remove <index,0-N>\n"
604 " --target <uuid>|<name>|global\n"
605 "\n");
606
607 if (u64Cmd & USAGE_SHAREDFOLDER_ADD)
608 RTStrmPrintf(pStrm,
609 "VBoxManage sharedfolder add <vmname>|<uuid>\n"
610 " --name <name> --hostpath <hostpath>\n"
611 " [--transient] [--readonly] [--automount]\n"
612 "\n");
613
614 if (u64Cmd & USAGE_SHAREDFOLDER_REMOVE)
615 RTStrmPrintf(pStrm,
616 "VBoxManage sharedfolder remove <vmname>|<uuid>\n"
617 " --name <name> [--transient]\n"
618 "\n");
619
620#ifdef VBOX_WITH_GUEST_PROPS
621 if (u64Cmd & USAGE_GUESTPROPERTY)
622 usageGuestProperty(pStrm);
623#endif /* VBOX_WITH_GUEST_PROPS defined */
624
625#ifdef VBOX_WITH_GUEST_CONTROL
626 if (u64Cmd & USAGE_GUESTCONTROL)
627 usageGuestControl(pStrm);
628#endif /* VBOX_WITH_GUEST_CONTROL defined */
629
630 if (u64Cmd & USAGE_DEBUGVM)
631 {
632 RTStrmPrintf(pStrm,
633 "VBoxManage debugvm <uuid>|<name>\n"
634 " dumpguestcore --filename <name> |\n"
635 " info <item> [args] |\n"
636 " injectnmi |\n"
637 " osdetect |\n"
638 " osinfo |\n"
639 " getregisters [--cpu <id>] <reg>|all ... |\n"
640 " setregisters [--cpu <id>] <reg>=<value> ... |\n"
641 " statistics [--reset] [--pattern <pattern>]\n"
642 " [--descriptions]\n"
643 "\n");
644 }
645 if (u64Cmd & USAGE_METRICS)
646 RTStrmPrintf(pStrm,
647 "VBoxManage metrics list [*|host|<vmname> [<metric_list>]]\n"
648 " (comma-separated)\n\n"
649 "VBoxManage metrics setup\n"
650 " [--period <seconds>] (default: 1)\n"
651 " [--samples <count>] (default: 1)\n"
652 " [--list]\n"
653 " [*|host|<vmname> [<metric_list>]]\n\n"
654 "VBoxManage metrics query [*|host|<vmname> [<metric_list>]]\n\n"
655 "VBoxManage metrics enable\n"
656 " [--list]\n"
657 " [*|host|<vmname> [<metric_list>]]\n\n"
658 "VBoxManage metrics disable\n"
659 " [--list]\n"
660 " [*|host|<vmname> [<metric_list>]]\n\n"
661 "VBoxManage metrics collect\n"
662 " [--period <seconds>] (default: 1)\n"
663 " [--samples <count>] (default: 1)\n"
664 " [--list]\n"
665 " [--detach]\n"
666 " [*|host|<vmname> [<metric_list>]]\n"
667 "\n");
668
669#if defined(VBOX_WITH_NETFLT)
670 if (u64Cmd & USAGE_HOSTONLYIFS)
671 {
672 RTStrmPrintf(pStrm,
673 "VBoxManage hostonlyif ipconfig <name>\n"
674 " [--dhcp |\n"
675 " --ip<ipv4> [--netmask<ipv4> (def: 255.255.255.0)] |\n"
676 " --ipv6<ipv6> [--netmasklengthv6<length> (def: 64)]]\n"
677# if !defined(RT_OS_SOLARIS)
678 " create |\n"
679 " remove <name>\n"
680# endif
681 "\n");
682 }
683#endif
684
685 if (u64Cmd & USAGE_DHCPSERVER)
686 {
687 RTStrmPrintf(pStrm,
688 "VBoxManage dhcpserver add|modify --netname <network_name> |\n"
689#if defined(VBOX_WITH_NETFLT)
690 " --ifname <hostonly_if_name>\n"
691#endif
692 " [--ip <ip_address>\n"
693 " --netmask <network_mask>\n"
694 " --lowerip <lower_ip>\n"
695 " --upperip <upper_ip>]\n"
696 " [--enable | --disable]\n\n"
697 "VBoxManage dhcpserver remove --netname <network_name> |\n"
698#if defined(VBOX_WITH_NETFLT)
699 " --ifname <hostonly_if_name>\n"
700#endif
701 "\n");
702 }
703 if (u64Cmd & USAGE_EXTPACK)
704 {
705 RTStrmPrintf(pStrm,
706 "VBoxManage extpack install <tarball> |\n"
707 " uninstall [--force] <name> |\n"
708 " cleanup\n"
709 "\n");
710 }
711}
712
713/**
714 * Print a usage synopsis and the syntax error message.
715 * @returns RTEXITCODE_SYNTAX.
716 */
717RTEXITCODE errorSyntax(USAGECATEGORY u64Cmd, const char *pszFormat, ...)
718{
719 va_list args;
720 showLogo(g_pStdErr); // show logo even if suppressed
721#ifndef VBOX_ONLY_DOCS
722 if (g_fInternalMode)
723 printUsageInternal(u64Cmd, g_pStdErr);
724 else
725 printUsage(u64Cmd, g_pStdErr);
726#endif /* !VBOX_ONLY_DOCS */
727 va_start(args, pszFormat);
728 RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
729 va_end(args);
730 return RTEXITCODE_SYNTAX;
731}
732
733/**
734 * errorSyntax for RTGetOpt users.
735 *
736 * @returns RTEXITCODE_SYNTAX.
737 *
738 * @param fUsageCategory The usage category of the command.
739 * @param rc The RTGetOpt return code.
740 * @param pValueUnion The value union.
741 */
742RTEXITCODE errorGetOpt(USAGECATEGORY fUsageCategory, int rc, union RTGETOPTUNION const *pValueUnion)
743{
744 /*
745 * Check if it is an unhandled standard option.
746 */
747 if (rc == 'V')
748 {
749 RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision());
750 return RTEXITCODE_SUCCESS;
751 }
752
753 if (rc == 'h')
754 {
755 showLogo(g_pStdErr);
756#ifndef VBOX_ONLY_DOCS
757 if (g_fInternalMode)
758 printUsageInternal(fUsageCategory, g_pStdOut);
759 else
760 printUsage(fUsageCategory, g_pStdOut);
761#endif
762 return RTEXITCODE_SUCCESS;
763 }
764
765 /*
766 * General failure.
767 */
768 showLogo(g_pStdErr); // show logo even if suppressed
769#ifndef VBOX_ONLY_DOCS
770 if (g_fInternalMode)
771 printUsageInternal(fUsageCategory, g_pStdErr);
772 else
773 printUsage(fUsageCategory, g_pStdErr);
774#endif /* !VBOX_ONLY_DOCS */
775
776 if (rc == VINF_GETOPT_NOT_OPTION)
777 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid parameter '%s'", pValueUnion->psz);
778 if (rc > 0)
779 {
780 if (RT_C_IS_PRINT(rc))
781 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option -%c", rc);
782 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option case %i", rc);
783 }
784 if (rc == VERR_GETOPT_UNKNOWN_OPTION)
785 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unknown option: %s", pValueUnion->psz);
786 if (pValueUnion->pDef)
787 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%s: %Rrs", pValueUnion->pDef->pszLong, rc);
788 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%Rrs", rc);
789}
790
791/**
792 * Print an error message without the syntax stuff.
793 *
794 * @returns RTEXITCODE_SYNTAX.
795 */
796RTEXITCODE errorArgument(const char *pszFormat, ...)
797{
798 va_list args;
799 va_start(args, pszFormat);
800 RTMsgErrorV(pszFormat, args);
801 va_end(args);
802 return RTEXITCODE_SYNTAX;
803}
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