VirtualBox

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

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

VBoxManage hostonly-related fixes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.7 KB
Line 
1/* $Id: VBoxManageHelp.cpp 17843 2009-03-13 15:51:55Z 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|hostinfo|hddbackends|hdds|dvds|floppies|\n"
80#else
81 " bridgedifs|hostinfo|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_LSILOGIC
161 " [-lsilogic on|off]\n"
162 " [-lsilogicport<1-16> none|<uuid>|<filename>]\n"
163#endif
164 " [-dvd none|<uuid>|<filename>|host:<drive>]\n"
165 " [-dvdpassthrough on|off]\n"
166 " [-floppy disabled|empty|<uuid>|\n"
167 " <filename>|host:<drive>]\n"
168#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || (defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT))
169 " [-nic<1-N> none|null|nat|bridged|intnet|hostonly]\n"
170#else /* !RT_OS_LINUX && !RT_OS_DARWIN */
171 " [-nic<1-N> none|null|nat|bridged|intnet]\n"
172#endif /* !RT_OS_LINUX && !RT_OS_DARWIN */
173 " [-nictype<1-N> Am79C970A|Am79C973"
174#ifdef VBOX_WITH_E1000
175 "|82540EM|82543GC"
176#endif
177 "]\n"
178 " [-cableconnected<1-N> on|off]\n"
179 " [-nictrace<1-N> on|off]\n"
180 " [-nictracefile<1-N> <filename>]\n"
181 " [-nicspeed<1-N> <kbps>]\n"
182 " [-bridgeadapter<1-N> none|<devicename>]\n"
183#if defined(VBOX_WITH_NETFLT)
184 " [-hostonlyadapter<1-N> none|<devicename>]\n"
185#endif
186 " [-intnet<1-N> <network name>]\n"
187 " [-natnet<1-N> <network>|default]\n"
188 " [-macaddress<1-N> auto|<mac>]\n"
189 " [-uart<1-N> off|<I/O base> <IRQ>]\n"
190 " [-uartmode<1-N> disconnected|\n"
191 " server <pipe>|\n"
192 " client <pipe>|\n"
193 " <devicename>]\n"
194#ifdef VBOX_WITH_MEM_BALLOONING
195 " [-guestmemoryballoon <balloonsize in MB>]\n"
196#endif
197 " [-gueststatisticsinterval <seconds>]\n"
198 );
199 RTPrintf(" [-audio none|null");
200 if (fWin)
201 {
202#ifdef VBOX_WITH_WINMM
203 RTPrintf( "|winmm|dsound");
204#else
205 RTPrintf( "|dsound");
206#endif
207 }
208 if (fSolaris)
209 {
210 RTPrintf( "|solaudio");
211 }
212 if (fLinux)
213 {
214 RTPrintf( "|oss"
215#ifdef VBOX_WITH_ALSA
216 "|alsa"
217#endif
218#ifdef VBOX_WITH_PULSE
219 "|pulse"
220#endif
221 );
222 }
223 if (fDarwin)
224 {
225 RTPrintf( "|coreaudio");
226 }
227 RTPrintf( "]\n");
228 RTPrintf(" [-audiocontroller ac97|sb16]\n"
229 " [-clipboard disabled|hosttoguest|guesttohost|\n"
230 " bidirectional]\n");
231 if (fVRDP)
232 {
233 RTPrintf(" [-vrdp on|off]\n"
234 " [-vrdpport default|<port>]\n"
235 " [-vrdpaddress <host>]\n"
236 " [-vrdpauthtype null|external|guest]\n"
237 " [-vrdpmulticon on|off]\n"
238 " [-vrdpreusecon on|off]\n");
239 }
240 RTPrintf(" [-usb on|off]\n"
241 " [-usbehci on|off]\n"
242 " [-snapshotfolder default|<path>]\n");
243 RTPrintf("\n");
244 }
245
246 if (u64Cmd & USAGE_STARTVM)
247 {
248 RTPrintf("VBoxManage startvm <uuid>|<name>\n");
249 if (fVRDP)
250 RTPrintf(" [-type gui|vrdp]\n");
251 RTPrintf("\n");
252 }
253
254 if (u64Cmd & USAGE_CONTROLVM)
255 {
256 RTPrintf("VBoxManage controlvm <uuid>|<name>\n"
257 " pause|resume|reset|poweroff|savestate|\n"
258 " acpipowerbutton|acpisleepbutton|\n"
259 " keyboardputscancode <hex> [<hex> ...]|\n"
260 " injectnmi|\n"
261 " setlinkstate<1-4> on|off |\n"
262 " usbattach <uuid>|<address> |\n"
263 " usbdetach <uuid>|<address> |\n"
264 " dvdattach none|<uuid>|<filename>|host:<drive> |\n"
265 " floppyattach none|<uuid>|<filename>|host:<drive> |\n");
266 if (fVRDP)
267 {
268 RTPrintf(" vrdp on|off] |\n");
269 }
270 RTPrintf(" setvideomodehint <xres> <yres> <bpp> [display]|\n"
271 " setcredentials <username> <password> <domain>\n"
272 " [-allowlocallogon <yes|no>]\n"
273 "\n");
274 }
275
276 if (u64Cmd & USAGE_DISCARDSTATE)
277 {
278 RTPrintf("VBoxManage discardstate <uuid>|<name>\n"
279 "\n");
280 }
281
282 if (u64Cmd & USAGE_ADOPTSTATE)
283 {
284 RTPrintf("VBoxManage adoptstate <uuid>|<name> <state_file>\n"
285 "\n");
286 }
287
288 if (u64Cmd & USAGE_SNAPSHOT)
289 {
290 RTPrintf("VBoxManage snapshot <uuid>|<name>\n"
291 " take <name> [-desc <desc>] |\n"
292 " discard <uuid>|<name> |\n"
293 " discardcurrent -state|-all |\n"
294 " edit <uuid>|<name>|-current\n"
295 " [-newname <name>]\n"
296 " [-newdesc <desc>] |\n"
297 " showvminfo <uuid>|<name>\n"
298 "\n");
299 }
300
301 if (u64Cmd & USAGE_REGISTERIMAGE)
302 {
303 RTPrintf("VBoxManage openmedium disk|dvd|floppy <filename>\n"
304 " [-type normal|immutable|writethrough] (disk only)\n"
305 "\n");
306 }
307
308 if (u64Cmd & USAGE_UNREGISTERIMAGE)
309 {
310 RTPrintf("VBoxManage closemedium disk|dvd|floppy <uuid>|<filename>\n"
311 "\n");
312 }
313
314 if (u64Cmd & USAGE_SHOWHDINFO)
315 {
316 RTPrintf("VBoxManage showhdinfo <uuid>|<filename>\n"
317 "\n");
318 }
319
320 if (u64Cmd & USAGE_CREATEHD)
321 {
322 /// @todo NEWMEDIA add -format to specify the hard disk backend
323 RTPrintf("VBoxManage createhd -filename <filename>\n"
324 " -size <megabytes>\n"
325 " [-format VDI|VMDK|VHD]\n"
326 " [-static]\n"
327 " [-comment <comment>]\n"
328 " [-register]\n"
329 " [-type normal|writethrough] (default: normal)\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 " [-remember]\n"
347 "\n");
348 }
349
350 if (u64Cmd & USAGE_CONVERTFROMRAW)
351 {
352 RTPrintf("VBoxManage convertfromraw [-static] [-format VDI|VMDK|VHD]\n"
353 " <filename> <outputfile>\n"
354 "VBoxManage convertfromraw [-static] [-format VDI|VMDK|VHD]\n"
355 " stdin <outputfile> <bytes>\n"
356 "\n");
357 }
358
359 if (u64Cmd & USAGE_ADDISCSIDISK)
360 {
361 RTPrintf("VBoxManage addiscsidisk -server <name>|<ip>\n"
362 " -target <target>\n"
363 " [-port <port>]\n"
364 " [-lun <lun>]\n"
365 " [-encodedlun <lun>]\n"
366 " [-username <username>]\n"
367 " [-password <password>]\n"
368 " [-comment <comment>]\n"
369 " [-intnet]\n"
370 "\n");
371 }
372
373 if (u64Cmd & USAGE_GETEXTRADATA)
374 {
375 RTPrintf("VBoxManage getextradata global|<uuid>|<name>\n"
376 " <key>|enumerate\n"
377 "\n");
378 }
379
380 if (u64Cmd & USAGE_SETEXTRADATA)
381 {
382 RTPrintf("VBoxManage setextradata global|<uuid>|<name>\n"
383 " <key>\n"
384 " [<value>] (no value deletes key)\n"
385 "\n");
386 }
387
388 if (u64Cmd & USAGE_SETPROPERTY)
389 {
390 RTPrintf("VBoxManage setproperty hdfolder default|<folder> |\n"
391 " machinefolder default|<folder> |\n"
392 " vrdpauthlibrary default|<library> |\n"
393 " websrvauthlibrary default|null|<library> |\n"
394 " hwvirtexenabled yes|no\n"
395 " loghistorycount <value>\n"
396 "\n");
397 }
398
399 if (u64Cmd & USAGE_USBFILTER_ADD)
400 {
401 RTPrintf("VBoxManage usbfilter add <index,0-N>\n"
402 " -target <uuid>|<name>|global\n"
403 " -name <string>\n"
404 " -action ignore|hold (global filters only)\n"
405 " [-active yes|no] (yes)\n"
406 " [-vendorid <XXXX>] (null)\n"
407 " [-productid <XXXX>] (null)\n"
408 " [-revision <IIFF>] (null)\n"
409 " [-manufacturer <string>] (null)\n"
410 " [-product <string>] (null)\n"
411 " [-remote yes|no] (null, VM filters only)\n"
412 " [-serialnumber <string>] (null)\n"
413 " [-maskedinterfaces <XXXXXXXX>]\n"
414 "\n");
415 }
416
417 if (u64Cmd & USAGE_USBFILTER_MODIFY)
418 {
419 RTPrintf("VBoxManage usbfilter modify <index,0-N>\n"
420 " -target <uuid>|<name>|global\n"
421 " [-name <string>]\n"
422 " [-action ignore|hold] (global filters only)\n"
423 " [-active yes|no]\n"
424 " [-vendorid <XXXX>|\"\"]\n"
425 " [-productid <XXXX>|\"\"]\n"
426 " [-revision <IIFF>|\"\"]\n"
427 " [-manufacturer <string>|\"\"]\n"
428 " [-product <string>|\"\"]\n"
429 " [-remote yes|no] (null, VM filters only)\n"
430 " [-serialnumber <string>|\"\"]\n"
431 " [-maskedinterfaces <XXXXXXXX>]\n"
432 "\n");
433 }
434
435 if (u64Cmd & USAGE_USBFILTER_REMOVE)
436 {
437 RTPrintf("VBoxManage usbfilter remove <index,0-N>\n"
438 " -target <uuid>|<name>|global\n"
439 "\n");
440 }
441
442 if (u64Cmd & USAGE_SHAREDFOLDER_ADD)
443 {
444 RTPrintf("VBoxManage sharedfolder add <vmname>|<uuid>\n"
445 " -name <name> -hostpath <hostpath>\n"
446 " [-transient] [-readonly]\n"
447 "\n");
448 }
449
450 if (u64Cmd & USAGE_SHAREDFOLDER_REMOVE)
451 {
452 RTPrintf("VBoxManage sharedfolder remove <vmname>|<uuid>\n"
453 " -name <name> [-transient]\n"
454 "\n");
455 }
456
457 if (u64Cmd & USAGE_VM_STATISTICS)
458 {
459 RTPrintf("VBoxManage vmstatistics <vmname>|<uuid> [-reset]\n"
460 " [-pattern <pattern>] [-descriptions]\n"
461 "\n");
462 }
463
464#ifdef VBOX_WITH_GUEST_PROPS
465 if (u64Cmd & USAGE_GUESTPROPERTY)
466 usageGuestProperty();
467#endif /* VBOX_WITH_GUEST_PROPS defined */
468
469 if (u64Cmd & USAGE_METRICS)
470 {
471 RTPrintf("VBoxManage metrics list [*|host|<vmname> [<metric_list>]] (comma-separated)\n\n"
472 "VBoxManage metrics setup\n"
473 " [-period <seconds>]\n"
474 " [-samples <count>]\n"
475 " [-list]\n"
476 " [*|host|<vmname> [<metric_list>]]\n\n"
477 "VBoxManage metrics query [*|host|<vmname> [<metric_list>]]\n\n"
478 "VBoxManage metrics collect\n"
479 " [-period <seconds>]\n"
480 " [-samples <count>]\n"
481 " [-list]\n"
482 " [-detach]\n"
483 " [*|host|<vmname> [<metric_list>]]\n"
484 "\n");
485 }
486
487#if !defined(RT_OS_WINDOWS) || defined(VBOX_WITH_NETFLT)
488 if (u64Cmd & USAGE_HOSTONLYIFS)
489 {
490 RTPrintf("VBoxManage hostonlyif ipconfig <name> [-dhcp| -ip<ipv4> [-netmask<ipv4> (default is 255.255.255.0)]| -ipv6<ipv6> [-netmasklengthv6<length> (default is 64)]]"
491# if defined(RT_OS_WINDOWS)
492 "|\n"
493 " create |\n"
494 " remove <name>\n"
495# endif
496 "\n");
497 }
498#endif
499}
500
501/**
502 * Print a usage synopsis and the syntax error message.
503 */
504int errorSyntax(USAGECATEGORY u64Cmd, const char *pszFormat, ...)
505{
506 va_list args;
507 showLogo(); // show logo even if suppressed
508#ifndef VBOX_ONLY_DOCS
509 if (g_fInternalMode)
510 printUsageInternal(u64Cmd);
511 else
512 printUsage(u64Cmd);
513#endif /* !VBOX_ONLY_DOCS */
514 va_start(args, pszFormat);
515 RTPrintf("\n"
516 "Syntax error: %N\n", pszFormat, &args);
517 va_end(args);
518 return 1;
519}
520
521/**
522 * Print an error message without the syntax stuff.
523 */
524int errorArgument(const char *pszFormat, ...)
525{
526 va_list args;
527 va_start(args, pszFormat);
528 RTPrintf("error: %N\n", pszFormat, &args);
529 va_end(args);
530 return 1;
531}
532
533#ifndef VBOX_ONLY_DOCS
534/**
535 * Print out progress on the console
536 */
537void showProgress(ComPtr<IProgress> progress)
538{
539 BOOL fCompleted;
540 LONG currentPercent;
541 LONG lastPercent = 0;
542
543 RTPrintf("0%%...");
544 RTStrmFlush(g_pStdOut);
545 while (SUCCEEDED(progress->COMGETTER(Completed(&fCompleted))))
546 {
547 progress->COMGETTER(Percent(&currentPercent));
548
549 /* did we cross a 10% mark? */
550 if (((currentPercent / 10) > (lastPercent / 10)))
551 {
552 /* make sure to also print out missed steps */
553 for (LONG curVal = (lastPercent / 10) * 10 + 10; curVal <= (currentPercent / 10) * 10; curVal += 10)
554 {
555 if (curVal < 100)
556 {
557 RTPrintf("%ld%%...", curVal);
558 RTStrmFlush(g_pStdOut);
559 }
560 }
561 lastPercent = (currentPercent / 10) * 10;
562 }
563 if (fCompleted)
564 break;
565
566 /* make sure the loop is not too tight */
567 progress->WaitForCompletion(100);
568 }
569
570 /* complete the line. */
571 HRESULT rc;
572 if (SUCCEEDED(progress->COMGETTER(ResultCode)(&rc)))
573 {
574 if (SUCCEEDED(rc))
575 RTPrintf("100%%\n");
576 else
577 RTPrintf("FAILED\n");
578 }
579 else
580 RTPrintf("\n");
581 RTStrmFlush(g_pStdOut);
582}
583
584#endif /* !VBOX_ONLY_DOCS */
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