VirtualBox

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

Last change on this file since 17979 was 17979, checked in by vboxsync, 16 years ago

VBoxManage:dhcp help fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 24.0 KB
Line 
1/* $Id: VBoxManageHelp.cpp 17979 2009-03-16 20:37:01Z vboxsync $ */
2/** @file
3 * VBoxManage - help and other message output.
4 */
5
6/*
7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#include <iprt/stream.h>
23#include <iprt/getopt.h>
24
25#include "VBoxManage.h"
26
27void printUsage(USAGECATEGORY u64Cmd)
28{
29#ifdef RT_OS_LINUX
30 bool fLinux = true;
31#else
32 bool fLinux = false;
33#endif
34#ifdef RT_OS_WINDOWS
35 bool fWin = true;
36#else
37 bool fWin = false;
38#endif
39#ifdef RT_OS_SOLARIS
40 bool fSolaris = true;
41#else
42 bool fSolaris = false;
43#endif
44#ifdef RT_OS_DARWIN
45 bool fDarwin = true;
46#else
47 bool fDarwin = false;
48#endif
49#ifdef VBOX_WITH_VRDP
50 bool fVRDP = true;
51#else
52 bool fVRDP = false;
53#endif
54
55 if (u64Cmd == USAGE_DUMPOPTS)
56 {
57 fLinux = true;
58 fWin = true;
59 fSolaris = true;
60 fDarwin = true;
61 fVRDP = true;
62 u64Cmd = USAGE_ALL;
63 }
64
65 RTPrintf("Usage:\n"
66 "\n");
67
68 if (u64Cmd == USAGE_ALL)
69 {
70 RTPrintf("VBoxManage [-v|-version] print version number and exit\n"
71 "VBoxManage -nologo ... suppress the logo\n"
72 "\n");
73 }
74
75 if (u64Cmd & USAGE_LIST)
76 {
77 RTPrintf("VBoxManage list [--long|-l] vms|runningvms|ostypes|hostdvds|hostfloppies|\n"
78#if (defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT))
79 " bridgedifs|hostonlyifs|dhcpservers|hostinfo|hddbackends|hdds|dvds|floppies|\n"
80#else
81 " bridgedifs|hostinfo|dhcpservers|hddbackends|hdds|dvds|floppies|\n"
82#endif
83
84 " usbhost|usbfilters|systemproperties\n"
85 "\n");
86 }
87
88 if (u64Cmd & USAGE_SHOWVMINFO)
89 {
90 RTPrintf("VBoxManage showvminfo <uuid>|<name> [-details] [-statistics]\n"
91 " [-machinereadable]\n"
92 "\n");
93 }
94
95 if (u64Cmd & USAGE_REGISTERVM)
96 {
97 RTPrintf("VBoxManage registervm <filename>\n"
98 "\n");
99 }
100
101 if (u64Cmd & USAGE_UNREGISTERVM)
102 {
103 RTPrintf("VBoxManage unregistervm <uuid>|<name> [-delete]\n"
104 "\n");
105 }
106
107 if (u64Cmd & USAGE_CREATEVM)
108 {
109 RTPrintf("VBoxManage createvm -name <name>\n"
110 " [-ostype <ostype>]\n"
111 " [-register]\n"
112 " [-basefolder <path> | -settingsfile <path>]\n"
113 " [-uuid <uuid>]\n"
114 "\n");
115 }
116
117 if (u64Cmd & USAGE_IMPORTAPPLIANCE)
118 {
119 RTPrintf("VBoxManage import <ovf>\n"
120 "\n"); // @todo
121 }
122
123 if (u64Cmd & USAGE_EXPORTAPPLIANCE)
124 {
125 RTPrintf("VBoxManage export <machines> [--output|-o] <ovf>\n"
126 "\n");
127 }
128
129 if (u64Cmd & USAGE_MODIFYVM)
130 {
131 RTPrintf("VBoxManage modifyvm <uuid|name>\n"
132 " [-name <name>]\n"
133 " [-ostype <ostype>]\n"
134 " [-memory <memorysize in MB>]\n"
135 " [-vram <vramsize in MB>]\n"
136 " [-acpi on|off]\n"
137 " [-ioapic on|off]\n"
138 " [-pae on|off]\n"
139 " [-hwvirtex on|off|default]\n"
140 " [-nestedpaging on|off]\n"
141 " [-vtxvpid on|off]\n"
142 " [-monitorcount <number>]\n"
143 " [-accelerate3d <on|off>]\n"
144 " [-bioslogofadein on|off]\n"
145 " [-bioslogofadeout on|off]\n"
146 " [-bioslogodisplaytime <msec>]\n"
147 " [-bioslogoimagepath <imagepath>]\n"
148 " [-biosbootmenu disabled|menuonly|messageandmenu]\n"
149 " [-biossystemtimeoffset <msec>]\n"
150 " [-biospxedebug on|off]\n"
151 " [-boot<1-4> none|floppy|dvd|disk|net>]\n"
152 " [-hd<a|b|d> none|<uuid>|<filename>]\n"
153 " [-idecontroller PIIX3|PIIX4]\n"
154#ifdef VBOX_WITH_AHCI
155 " [-sata on|off]\n"
156 " [-sataportcount <1-30>]\n"
157 " [-sataport<1-30> none|<uuid>|<filename>]\n"
158 " [-sataideemulation<1-4> <1-30>]\n"
159#endif
160#ifdef VBOX_WITH_SCSI
161 " [-scsi on|off]\n"
162 " [-scsiport<1-16> none|<uuid>|<filename>]\n"
163 " [-scsitype LsiLogic|BusLogic]\n"
164#endif
165 " [-dvd none|<uuid>|<filename>|host:<drive>]\n"
166 " [-dvdpassthrough on|off]\n"
167 " [-floppy disabled|empty|<uuid>|\n"
168 " <filename>|host:<drive>]\n"
169#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || (defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT))
170 " [-nic<1-N> none|null|nat|bridged|intnet|hostonly]\n"
171#else /* !RT_OS_LINUX && !RT_OS_DARWIN */
172 " [-nic<1-N> none|null|nat|bridged|intnet]\n"
173#endif /* !RT_OS_LINUX && !RT_OS_DARWIN */
174 " [-nictype<1-N> Am79C970A|Am79C973"
175#ifdef VBOX_WITH_E1000
176 "|82540EM|82543GC"
177#endif
178 "]\n"
179 " [-cableconnected<1-N> on|off]\n"
180 " [-nictrace<1-N> on|off]\n"
181 " [-nictracefile<1-N> <filename>]\n"
182 " [-nicspeed<1-N> <kbps>]\n"
183 " [-bridgeadapter<1-N> none|<devicename>]\n"
184#if defined(VBOX_WITH_NETFLT)
185 " [-hostonlyadapter<1-N> none|<devicename>]\n"
186#endif
187 " [-intnet<1-N> <network name>]\n"
188 " [-natnet<1-N> <network>|default]\n"
189 " [-macaddress<1-N> auto|<mac>]\n"
190 " [-uart<1-N> off|<I/O base> <IRQ>]\n"
191 " [-uartmode<1-N> disconnected|\n"
192 " server <pipe>|\n"
193 " client <pipe>|\n"
194 " <devicename>]\n"
195#ifdef VBOX_WITH_MEM_BALLOONING
196 " [-guestmemoryballoon <balloonsize in MB>]\n"
197#endif
198 " [-gueststatisticsinterval <seconds>]\n"
199 );
200 RTPrintf(" [-audio none|null");
201 if (fWin)
202 {
203#ifdef VBOX_WITH_WINMM
204 RTPrintf( "|winmm|dsound");
205#else
206 RTPrintf( "|dsound");
207#endif
208 }
209 if (fSolaris)
210 {
211 RTPrintf( "|solaudio");
212 }
213 if (fLinux)
214 {
215 RTPrintf( "|oss"
216#ifdef VBOX_WITH_ALSA
217 "|alsa"
218#endif
219#ifdef VBOX_WITH_PULSE
220 "|pulse"
221#endif
222 );
223 }
224 if (fDarwin)
225 {
226 RTPrintf( "|coreaudio");
227 }
228 RTPrintf( "]\n");
229 RTPrintf(" [-audiocontroller ac97|sb16]\n"
230 " [-clipboard disabled|hosttoguest|guesttohost|\n"
231 " bidirectional]\n");
232 if (fVRDP)
233 {
234 RTPrintf(" [-vrdp on|off]\n"
235 " [-vrdpport default|<port>]\n"
236 " [-vrdpaddress <host>]\n"
237 " [-vrdpauthtype null|external|guest]\n"
238 " [-vrdpmulticon on|off]\n"
239 " [-vrdpreusecon on|off]\n");
240 }
241 RTPrintf(" [-usb on|off]\n"
242 " [-usbehci on|off]\n"
243 " [-snapshotfolder default|<path>]\n");
244 RTPrintf("\n");
245 }
246
247 if (u64Cmd & USAGE_STARTVM)
248 {
249 RTPrintf("VBoxManage startvm <uuid>|<name>\n");
250 if (fVRDP)
251 RTPrintf(" [-type gui|vrdp]\n");
252 RTPrintf("\n");
253 }
254
255 if (u64Cmd & USAGE_CONTROLVM)
256 {
257 RTPrintf("VBoxManage controlvm <uuid>|<name>\n"
258 " pause|resume|reset|poweroff|savestate|\n"
259 " acpipowerbutton|acpisleepbutton|\n"
260 " keyboardputscancode <hex> [<hex> ...]|\n"
261 " injectnmi|\n"
262 " setlinkstate<1-4> on|off |\n"
263 " usbattach <uuid>|<address> |\n"
264 " usbdetach <uuid>|<address> |\n"
265 " dvdattach none|<uuid>|<filename>|host:<drive> |\n"
266 " floppyattach none|<uuid>|<filename>|host:<drive> |\n");
267 if (fVRDP)
268 {
269 RTPrintf(" vrdp on|off] |\n");
270 }
271 RTPrintf(" setvideomodehint <xres> <yres> <bpp> [display]|\n"
272 " setcredentials <username> <password> <domain>\n"
273 " [-allowlocallogon <yes|no>]\n"
274 "\n");
275 }
276
277 if (u64Cmd & USAGE_DISCARDSTATE)
278 {
279 RTPrintf("VBoxManage discardstate <uuid>|<name>\n"
280 "\n");
281 }
282
283 if (u64Cmd & USAGE_ADOPTSTATE)
284 {
285 RTPrintf("VBoxManage adoptstate <uuid>|<name> <state_file>\n"
286 "\n");
287 }
288
289 if (u64Cmd & USAGE_SNAPSHOT)
290 {
291 RTPrintf("VBoxManage snapshot <uuid>|<name>\n"
292 " take <name> [-desc <desc>] |\n"
293 " discard <uuid>|<name> |\n"
294 " discardcurrent -state|-all |\n"
295 " edit <uuid>|<name>|-current\n"
296 " [-newname <name>]\n"
297 " [-newdesc <desc>] |\n"
298 " showvminfo <uuid>|<name>\n"
299 "\n");
300 }
301
302 if (u64Cmd & USAGE_REGISTERIMAGE)
303 {
304 RTPrintf("VBoxManage openmedium disk|dvd|floppy <filename>\n"
305 " [-type normal|immutable|writethrough] (disk only)\n"
306 "\n");
307 }
308
309 if (u64Cmd & USAGE_UNREGISTERIMAGE)
310 {
311 RTPrintf("VBoxManage closemedium disk|dvd|floppy <uuid>|<filename>\n"
312 "\n");
313 }
314
315 if (u64Cmd & USAGE_SHOWHDINFO)
316 {
317 RTPrintf("VBoxManage showhdinfo <uuid>|<filename>\n"
318 "\n");
319 }
320
321 if (u64Cmd & USAGE_CREATEHD)
322 {
323 RTPrintf("VBoxManage createhd --filename <filename>\n"
324 " --size <megabytes>\n"
325 " [--format VDI|VMDK|VHD] (default: VDI)\n"
326 " [--variant Standard|Fixed|Diff|Split2G|Stream]\n"
327 " [--type normal|writethrough] (default: normal)\n"
328 " [--comment <comment>]\n"
329 " [--remember]\n"
330 "\n");
331 }
332
333 if (u64Cmd & USAGE_MODIFYHD)
334 {
335 RTPrintf("VBoxManage modifyhd <uuid>|<filename>\n"
336 " settype normal|writethrough|immutable |\n"
337 " autoreset on|off |\n"
338 " compact\n"
339 "\n");
340 }
341
342 if (u64Cmd & USAGE_CLONEHD)
343 {
344 RTPrintf("VBoxManage clonehd <uuid>|<filename> <outputfile>\n"
345 " [--format VDI|VMDK|VHD|RAW|<other>]\n"
346 " [--variant Standard|Fixed|Diff|Split2G|Stream]\n"
347 " [--type normal|writethrough|immutable]\n"
348 " [--remember]\n"
349 "\n");
350 }
351
352 if (u64Cmd & USAGE_CONVERTFROMRAW)
353 {
354 RTPrintf("VBoxManage convertfromraw <filename> <outputfile>\n"
355 " [--format VDI|VMDK|VHD]\n"
356 " [--variant Standard|Fixed|Diff|Split2G|Stream]\n"
357 "VBoxManage convertfromraw stdin <outputfile> <bytes>\n"
358 " [--format VDI|VMDK|VHD]\n"
359 " [--variant Standard|Fixed|Diff|Split2G|Stream]\n"
360 "\n");
361 }
362
363 if (u64Cmd & USAGE_ADDISCSIDISK)
364 {
365 RTPrintf("VBoxManage addiscsidisk -server <name>|<ip>\n"
366 " -target <target>\n"
367 " [-port <port>]\n"
368 " [-lun <lun>]\n"
369 " [-encodedlun <lun>]\n"
370 " [-username <username>]\n"
371 " [-password <password>]\n"
372 " [-comment <comment>]\n"
373 " [-intnet]\n"
374 "\n");
375 }
376
377 if (u64Cmd & USAGE_GETEXTRADATA)
378 {
379 RTPrintf("VBoxManage getextradata global|<uuid>|<name>\n"
380 " <key>|enumerate\n"
381 "\n");
382 }
383
384 if (u64Cmd & USAGE_SETEXTRADATA)
385 {
386 RTPrintf("VBoxManage setextradata global|<uuid>|<name>\n"
387 " <key>\n"
388 " [<value>] (no value deletes key)\n"
389 "\n");
390 }
391
392 if (u64Cmd & USAGE_SETPROPERTY)
393 {
394 RTPrintf("VBoxManage setproperty hdfolder default|<folder> |\n"
395 " machinefolder default|<folder> |\n"
396 " vrdpauthlibrary default|<library> |\n"
397 " websrvauthlibrary default|null|<library> |\n"
398 " hwvirtexenabled yes|no\n"
399 " loghistorycount <value>\n"
400 "\n");
401 }
402
403 if (u64Cmd & USAGE_USBFILTER_ADD)
404 {
405 RTPrintf("VBoxManage usbfilter add <index,0-N>\n"
406 " -target <uuid>|<name>|global\n"
407 " -name <string>\n"
408 " -action ignore|hold (global filters only)\n"
409 " [-active yes|no] (yes)\n"
410 " [-vendorid <XXXX>] (null)\n"
411 " [-productid <XXXX>] (null)\n"
412 " [-revision <IIFF>] (null)\n"
413 " [-manufacturer <string>] (null)\n"
414 " [-product <string>] (null)\n"
415 " [-remote yes|no] (null, VM filters only)\n"
416 " [-serialnumber <string>] (null)\n"
417 " [-maskedinterfaces <XXXXXXXX>]\n"
418 "\n");
419 }
420
421 if (u64Cmd & USAGE_USBFILTER_MODIFY)
422 {
423 RTPrintf("VBoxManage usbfilter modify <index,0-N>\n"
424 " -target <uuid>|<name>|global\n"
425 " [-name <string>]\n"
426 " [-action ignore|hold] (global filters only)\n"
427 " [-active yes|no]\n"
428 " [-vendorid <XXXX>|\"\"]\n"
429 " [-productid <XXXX>|\"\"]\n"
430 " [-revision <IIFF>|\"\"]\n"
431 " [-manufacturer <string>|\"\"]\n"
432 " [-product <string>|\"\"]\n"
433 " [-remote yes|no] (null, VM filters only)\n"
434 " [-serialnumber <string>|\"\"]\n"
435 " [-maskedinterfaces <XXXXXXXX>]\n"
436 "\n");
437 }
438
439 if (u64Cmd & USAGE_USBFILTER_REMOVE)
440 {
441 RTPrintf("VBoxManage usbfilter remove <index,0-N>\n"
442 " -target <uuid>|<name>|global\n"
443 "\n");
444 }
445
446 if (u64Cmd & USAGE_SHAREDFOLDER_ADD)
447 {
448 RTPrintf("VBoxManage sharedfolder add <vmname>|<uuid>\n"
449 " -name <name> -hostpath <hostpath>\n"
450 " [-transient] [-readonly]\n"
451 "\n");
452 }
453
454 if (u64Cmd & USAGE_SHAREDFOLDER_REMOVE)
455 {
456 RTPrintf("VBoxManage sharedfolder remove <vmname>|<uuid>\n"
457 " -name <name> [-transient]\n"
458 "\n");
459 }
460
461 if (u64Cmd & USAGE_VM_STATISTICS)
462 {
463 RTPrintf("VBoxManage vmstatistics <vmname>|<uuid> [-reset]\n"
464 " [-pattern <pattern>] [-descriptions]\n"
465 "\n");
466 }
467
468#ifdef VBOX_WITH_GUEST_PROPS
469 if (u64Cmd & USAGE_GUESTPROPERTY)
470 usageGuestProperty();
471#endif /* VBOX_WITH_GUEST_PROPS defined */
472
473 if (u64Cmd & USAGE_METRICS)
474 {
475 RTPrintf("VBoxManage metrics list [*|host|<vmname> [<metric_list>]] (comma-separated)\n\n"
476 "VBoxManage metrics setup\n"
477 " [-period <seconds>]\n"
478 " [-samples <count>]\n"
479 " [-list]\n"
480 " [*|host|<vmname> [<metric_list>]]\n\n"
481 "VBoxManage metrics query [*|host|<vmname> [<metric_list>]]\n\n"
482 "VBoxManage metrics collect\n"
483 " [-period <seconds>]\n"
484 " [-samples <count>]\n"
485 " [-list]\n"
486 " [-detach]\n"
487 " [*|host|<vmname> [<metric_list>]]\n"
488 "\n");
489 }
490#if !defined(RT_OS_WINDOWS) || defined(VBOX_WITH_NETFLT)
491 if (u64Cmd & USAGE_HOSTONLYIFS)
492 {
493 RTPrintf("VBoxManage hostonlyif ipconfig <name> \n"
494 " [-dhcp| \n"
495 " -ip<ipv4> [-netmask<ipv4> (default is 255.255.255.0)]| \n"
496 " -ipv6<ipv6> [-netmasklengthv6<length> (default is 64)]]\n"
497# if defined(RT_OS_WINDOWS)
498 " create |\n"
499 " remove <name>\n"
500# endif
501 "\n");
502 }
503#endif
504
505#if !defined(RT_OS_WINDOWS) || defined(VBOX_WITH_NETFLT)
506 if (u64Cmd & USAGE_DHCPSERVER)
507 {
508 RTPrintf("VBoxManage dhcpserver [add | modify] [-netname <network_name> | -ifname <hostonly_if_name>]\n"
509 " [-ip <ip_address>\n"
510 " -netmask <network_mask>\n"
511 " -lowerip <lower_ip>\n"
512 " -upperip <upper_ip>]\n"
513 " [-enable | -disable]\n"
514 " remove [-netname <network_name> | -ifname <hostonly_if_name>]\n"
515 "\n");
516 }
517#endif
518}
519
520/**
521 * Print a usage synopsis and the syntax error message.
522 */
523int errorSyntax(USAGECATEGORY u64Cmd, const char *pszFormat, ...)
524{
525 va_list args;
526 showLogo(); // show logo even if suppressed
527#ifndef VBOX_ONLY_DOCS
528 if (g_fInternalMode)
529 printUsageInternal(u64Cmd);
530 else
531 printUsage(u64Cmd);
532#endif /* !VBOX_ONLY_DOCS */
533 va_start(args, pszFormat);
534 RTPrintf("\n"
535 "Syntax error: %N\n", pszFormat, &args);
536 va_end(args);
537 return 1;
538}
539
540/**
541 * Print an error message without the syntax stuff.
542 */
543int errorArgument(const char *pszFormat, ...)
544{
545 va_list args;
546 va_start(args, pszFormat);
547 RTPrintf("error: %N\n", pszFormat, &args);
548 va_end(args);
549 return 1;
550}
551
552#ifndef VBOX_ONLY_DOCS
553/**
554 * Print out progress on the console
555 */
556void showProgress(ComPtr<IProgress> progress)
557{
558 BOOL fCompleted;
559 LONG currentPercent;
560 LONG lastPercent = 0;
561
562 RTPrintf("0%%...");
563 RTStrmFlush(g_pStdOut);
564 while (SUCCEEDED(progress->COMGETTER(Completed(&fCompleted))))
565 {
566 progress->COMGETTER(Percent(&currentPercent));
567
568 /* did we cross a 10% mark? */
569 if (((currentPercent / 10) > (lastPercent / 10)))
570 {
571 /* make sure to also print out missed steps */
572 for (LONG curVal = (lastPercent / 10) * 10 + 10; curVal <= (currentPercent / 10) * 10; curVal += 10)
573 {
574 if (curVal < 100)
575 {
576 RTPrintf("%ld%%...", curVal);
577 RTStrmFlush(g_pStdOut);
578 }
579 }
580 lastPercent = (currentPercent / 10) * 10;
581 }
582 if (fCompleted)
583 break;
584
585 /* make sure the loop is not too tight */
586 progress->WaitForCompletion(100);
587 }
588
589 /* complete the line. */
590 HRESULT rc;
591 if (SUCCEEDED(progress->COMGETTER(ResultCode)(&rc)))
592 {
593 if (SUCCEEDED(rc))
594 RTPrintf("100%%\n");
595 else
596 RTPrintf("FAILED\n");
597 }
598 else
599 RTPrintf("\n");
600 RTStrmFlush(g_pStdOut);
601}
602
603#endif /* !VBOX_ONLY_DOCS */
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