/* $Id: VBoxManageHelp.cpp 17843 2009-03-13 15:51:55Z vboxsync $ */ /** @file * VBoxManage - help and other message output. */ /* * Copyright (C) 2006-2009 Sun Microsystems, Inc. * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 USA or visit http://www.sun.com if you need * additional information or have any questions. */ #include #include #include "VBoxManage.h" void printUsage(USAGECATEGORY u64Cmd) { #ifdef RT_OS_LINUX bool fLinux = true; #else bool fLinux = false; #endif #ifdef RT_OS_WINDOWS bool fWin = true; #else bool fWin = false; #endif #ifdef RT_OS_SOLARIS bool fSolaris = true; #else bool fSolaris = false; #endif #ifdef RT_OS_DARWIN bool fDarwin = true; #else bool fDarwin = false; #endif #ifdef VBOX_WITH_VRDP bool fVRDP = true; #else bool fVRDP = false; #endif if (u64Cmd == USAGE_DUMPOPTS) { fLinux = true; fWin = true; fSolaris = true; fDarwin = true; fVRDP = true; u64Cmd = USAGE_ALL; } RTPrintf("Usage:\n" "\n"); if (u64Cmd == USAGE_ALL) { RTPrintf("VBoxManage [-v|-version] print version number and exit\n" "VBoxManage -nologo ... suppress the logo\n" "\n"); } if (u64Cmd & USAGE_LIST) { RTPrintf("VBoxManage list [--long|-l] vms|runningvms|ostypes|hostdvds|hostfloppies|\n" #if (defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)) " bridgedifs|hostonlyifs|hostinfo|hddbackends|hdds|dvds|floppies|\n" #else " bridgedifs|hostinfo|hddbackends|hdds|dvds|floppies|\n" #endif " usbhost|usbfilters|systemproperties\n" "\n"); } if (u64Cmd & USAGE_SHOWVMINFO) { RTPrintf("VBoxManage showvminfo | [-details] [-statistics]\n" " [-machinereadable]\n" "\n"); } if (u64Cmd & USAGE_REGISTERVM) { RTPrintf("VBoxManage registervm \n" "\n"); } if (u64Cmd & USAGE_UNREGISTERVM) { RTPrintf("VBoxManage unregistervm | [-delete]\n" "\n"); } if (u64Cmd & USAGE_CREATEVM) { RTPrintf("VBoxManage createvm -name \n" " [-ostype ]\n" " [-register]\n" " [-basefolder | -settingsfile ]\n" " [-uuid ]\n" "\n"); } if (u64Cmd & USAGE_IMPORTAPPLIANCE) { RTPrintf("VBoxManage import \n" "\n"); // @todo } if (u64Cmd & USAGE_EXPORTAPPLIANCE) { RTPrintf("VBoxManage export [--output|-o] \n" "\n"); } if (u64Cmd & USAGE_MODIFYVM) { RTPrintf("VBoxManage modifyvm \n" " [-name ]\n" " [-ostype ]\n" " [-memory ]\n" " [-vram ]\n" " [-acpi on|off]\n" " [-ioapic on|off]\n" " [-pae on|off]\n" " [-hwvirtex on|off|default]\n" " [-nestedpaging on|off]\n" " [-vtxvpid on|off]\n" " [-monitorcount ]\n" " [-accelerate3d ]\n" " [-bioslogofadein on|off]\n" " [-bioslogofadeout on|off]\n" " [-bioslogodisplaytime ]\n" " [-bioslogoimagepath ]\n" " [-biosbootmenu disabled|menuonly|messageandmenu]\n" " [-biossystemtimeoffset ]\n" " [-biospxedebug on|off]\n" " [-boot<1-4> none|floppy|dvd|disk|net>]\n" " [-hd none||]\n" " [-idecontroller PIIX3|PIIX4]\n" #ifdef VBOX_WITH_AHCI " [-sata on|off]\n" " [-sataportcount <1-30>]\n" " [-sataport<1-30> none||]\n" " [-sataideemulation<1-4> <1-30>]\n" #endif #ifdef VBOX_WITH_LSILOGIC " [-lsilogic on|off]\n" " [-lsilogicport<1-16> none||]\n" #endif " [-dvd none|||host:]\n" " [-dvdpassthrough on|off]\n" " [-floppy disabled|empty||\n" " |host:]\n" #if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || (defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)) " [-nic<1-N> none|null|nat|bridged|intnet|hostonly]\n" #else /* !RT_OS_LINUX && !RT_OS_DARWIN */ " [-nic<1-N> none|null|nat|bridged|intnet]\n" #endif /* !RT_OS_LINUX && !RT_OS_DARWIN */ " [-nictype<1-N> Am79C970A|Am79C973" #ifdef VBOX_WITH_E1000 "|82540EM|82543GC" #endif "]\n" " [-cableconnected<1-N> on|off]\n" " [-nictrace<1-N> on|off]\n" " [-nictracefile<1-N> ]\n" " [-nicspeed<1-N> ]\n" " [-bridgeadapter<1-N> none|]\n" #if defined(VBOX_WITH_NETFLT) " [-hostonlyadapter<1-N> none|]\n" #endif " [-intnet<1-N> ]\n" " [-natnet<1-N> |default]\n" " [-macaddress<1-N> auto|]\n" " [-uart<1-N> off| ]\n" " [-uartmode<1-N> disconnected|\n" " server |\n" " client |\n" " ]\n" #ifdef VBOX_WITH_MEM_BALLOONING " [-guestmemoryballoon ]\n" #endif " [-gueststatisticsinterval ]\n" ); RTPrintf(" [-audio none|null"); if (fWin) { #ifdef VBOX_WITH_WINMM RTPrintf( "|winmm|dsound"); #else RTPrintf( "|dsound"); #endif } if (fSolaris) { RTPrintf( "|solaudio"); } if (fLinux) { RTPrintf( "|oss" #ifdef VBOX_WITH_ALSA "|alsa" #endif #ifdef VBOX_WITH_PULSE "|pulse" #endif ); } if (fDarwin) { RTPrintf( "|coreaudio"); } RTPrintf( "]\n"); RTPrintf(" [-audiocontroller ac97|sb16]\n" " [-clipboard disabled|hosttoguest|guesttohost|\n" " bidirectional]\n"); if (fVRDP) { RTPrintf(" [-vrdp on|off]\n" " [-vrdpport default|]\n" " [-vrdpaddress ]\n" " [-vrdpauthtype null|external|guest]\n" " [-vrdpmulticon on|off]\n" " [-vrdpreusecon on|off]\n"); } RTPrintf(" [-usb on|off]\n" " [-usbehci on|off]\n" " [-snapshotfolder default|]\n"); RTPrintf("\n"); } if (u64Cmd & USAGE_STARTVM) { RTPrintf("VBoxManage startvm |\n"); if (fVRDP) RTPrintf(" [-type gui|vrdp]\n"); RTPrintf("\n"); } if (u64Cmd & USAGE_CONTROLVM) { RTPrintf("VBoxManage controlvm |\n" " pause|resume|reset|poweroff|savestate|\n" " acpipowerbutton|acpisleepbutton|\n" " keyboardputscancode [ ...]|\n" " injectnmi|\n" " setlinkstate<1-4> on|off |\n" " usbattach |
|\n" " usbdetach |
|\n" " dvdattach none|||host: |\n" " floppyattach none|||host: |\n"); if (fVRDP) { RTPrintf(" vrdp on|off] |\n"); } RTPrintf(" setvideomodehint [display]|\n" " setcredentials \n" " [-allowlocallogon ]\n" "\n"); } if (u64Cmd & USAGE_DISCARDSTATE) { RTPrintf("VBoxManage discardstate |\n" "\n"); } if (u64Cmd & USAGE_ADOPTSTATE) { RTPrintf("VBoxManage adoptstate | \n" "\n"); } if (u64Cmd & USAGE_SNAPSHOT) { RTPrintf("VBoxManage snapshot |\n" " take [-desc ] |\n" " discard | |\n" " discardcurrent -state|-all |\n" " edit ||-current\n" " [-newname ]\n" " [-newdesc ] |\n" " showvminfo |\n" "\n"); } if (u64Cmd & USAGE_REGISTERIMAGE) { RTPrintf("VBoxManage openmedium disk|dvd|floppy \n" " [-type normal|immutable|writethrough] (disk only)\n" "\n"); } if (u64Cmd & USAGE_UNREGISTERIMAGE) { RTPrintf("VBoxManage closemedium disk|dvd|floppy |\n" "\n"); } if (u64Cmd & USAGE_SHOWHDINFO) { RTPrintf("VBoxManage showhdinfo |\n" "\n"); } if (u64Cmd & USAGE_CREATEHD) { /// @todo NEWMEDIA add -format to specify the hard disk backend RTPrintf("VBoxManage createhd -filename \n" " -size \n" " [-format VDI|VMDK|VHD]\n" " [-static]\n" " [-comment ]\n" " [-register]\n" " [-type normal|writethrough] (default: normal)\n" "\n"); } if (u64Cmd & USAGE_MODIFYHD) { RTPrintf("VBoxManage modifyhd |\n" " settype normal|writethrough|immutable |\n" " autoreset on|off |\n" " compact\n" "\n"); } if (u64Cmd & USAGE_CLONEHD) { RTPrintf("VBoxManage clonehd | \n" " [-format VDI|VMDK|VHD|RAW|]\n" " [-remember]\n" "\n"); } if (u64Cmd & USAGE_CONVERTFROMRAW) { RTPrintf("VBoxManage convertfromraw [-static] [-format VDI|VMDK|VHD]\n" " \n" "VBoxManage convertfromraw [-static] [-format VDI|VMDK|VHD]\n" " stdin \n" "\n"); } if (u64Cmd & USAGE_ADDISCSIDISK) { RTPrintf("VBoxManage addiscsidisk -server |\n" " -target \n" " [-port ]\n" " [-lun ]\n" " [-encodedlun ]\n" " [-username ]\n" " [-password ]\n" " [-comment ]\n" " [-intnet]\n" "\n"); } if (u64Cmd & USAGE_GETEXTRADATA) { RTPrintf("VBoxManage getextradata global||\n" " |enumerate\n" "\n"); } if (u64Cmd & USAGE_SETEXTRADATA) { RTPrintf("VBoxManage setextradata global||\n" " \n" " [] (no value deletes key)\n" "\n"); } if (u64Cmd & USAGE_SETPROPERTY) { RTPrintf("VBoxManage setproperty hdfolder default| |\n" " machinefolder default| |\n" " vrdpauthlibrary default| |\n" " websrvauthlibrary default|null| |\n" " hwvirtexenabled yes|no\n" " loghistorycount \n" "\n"); } if (u64Cmd & USAGE_USBFILTER_ADD) { RTPrintf("VBoxManage usbfilter add \n" " -target ||global\n" " -name \n" " -action ignore|hold (global filters only)\n" " [-active yes|no] (yes)\n" " [-vendorid ] (null)\n" " [-productid ] (null)\n" " [-revision ] (null)\n" " [-manufacturer ] (null)\n" " [-product ] (null)\n" " [-remote yes|no] (null, VM filters only)\n" " [-serialnumber ] (null)\n" " [-maskedinterfaces ]\n" "\n"); } if (u64Cmd & USAGE_USBFILTER_MODIFY) { RTPrintf("VBoxManage usbfilter modify \n" " -target ||global\n" " [-name ]\n" " [-action ignore|hold] (global filters only)\n" " [-active yes|no]\n" " [-vendorid |\"\"]\n" " [-productid |\"\"]\n" " [-revision |\"\"]\n" " [-manufacturer |\"\"]\n" " [-product |\"\"]\n" " [-remote yes|no] (null, VM filters only)\n" " [-serialnumber |\"\"]\n" " [-maskedinterfaces ]\n" "\n"); } if (u64Cmd & USAGE_USBFILTER_REMOVE) { RTPrintf("VBoxManage usbfilter remove \n" " -target ||global\n" "\n"); } if (u64Cmd & USAGE_SHAREDFOLDER_ADD) { RTPrintf("VBoxManage sharedfolder add |\n" " -name -hostpath \n" " [-transient] [-readonly]\n" "\n"); } if (u64Cmd & USAGE_SHAREDFOLDER_REMOVE) { RTPrintf("VBoxManage sharedfolder remove |\n" " -name [-transient]\n" "\n"); } if (u64Cmd & USAGE_VM_STATISTICS) { RTPrintf("VBoxManage vmstatistics | [-reset]\n" " [-pattern ] [-descriptions]\n" "\n"); } #ifdef VBOX_WITH_GUEST_PROPS if (u64Cmd & USAGE_GUESTPROPERTY) usageGuestProperty(); #endif /* VBOX_WITH_GUEST_PROPS defined */ if (u64Cmd & USAGE_METRICS) { RTPrintf("VBoxManage metrics list [*|host| []] (comma-separated)\n\n" "VBoxManage metrics setup\n" " [-period ]\n" " [-samples ]\n" " [-list]\n" " [*|host| []]\n\n" "VBoxManage metrics query [*|host| []]\n\n" "VBoxManage metrics collect\n" " [-period ]\n" " [-samples ]\n" " [-list]\n" " [-detach]\n" " [*|host| []]\n" "\n"); } #if !defined(RT_OS_WINDOWS) || defined(VBOX_WITH_NETFLT) if (u64Cmd & USAGE_HOSTONLYIFS) { RTPrintf("VBoxManage hostonlyif ipconfig [-dhcp| -ip [-netmask (default is 255.255.255.0)]| -ipv6 [-netmasklengthv6 (default is 64)]]" # if defined(RT_OS_WINDOWS) "|\n" " create |\n" " remove \n" # endif "\n"); } #endif } /** * Print a usage synopsis and the syntax error message. */ int errorSyntax(USAGECATEGORY u64Cmd, const char *pszFormat, ...) { va_list args; showLogo(); // show logo even if suppressed #ifndef VBOX_ONLY_DOCS if (g_fInternalMode) printUsageInternal(u64Cmd); else printUsage(u64Cmd); #endif /* !VBOX_ONLY_DOCS */ va_start(args, pszFormat); RTPrintf("\n" "Syntax error: %N\n", pszFormat, &args); va_end(args); return 1; } /** * Print an error message without the syntax stuff. */ int errorArgument(const char *pszFormat, ...) { va_list args; va_start(args, pszFormat); RTPrintf("error: %N\n", pszFormat, &args); va_end(args); return 1; } #ifndef VBOX_ONLY_DOCS /** * Print out progress on the console */ void showProgress(ComPtr progress) { BOOL fCompleted; LONG currentPercent; LONG lastPercent = 0; RTPrintf("0%%..."); RTStrmFlush(g_pStdOut); while (SUCCEEDED(progress->COMGETTER(Completed(&fCompleted)))) { progress->COMGETTER(Percent(¤tPercent)); /* did we cross a 10% mark? */ if (((currentPercent / 10) > (lastPercent / 10))) { /* make sure to also print out missed steps */ for (LONG curVal = (lastPercent / 10) * 10 + 10; curVal <= (currentPercent / 10) * 10; curVal += 10) { if (curVal < 100) { RTPrintf("%ld%%...", curVal); RTStrmFlush(g_pStdOut); } } lastPercent = (currentPercent / 10) * 10; } if (fCompleted) break; /* make sure the loop is not too tight */ progress->WaitForCompletion(100); } /* complete the line. */ HRESULT rc; if (SUCCEEDED(progress->COMGETTER(ResultCode)(&rc))) { if (SUCCEEDED(rc)) RTPrintf("100%%\n"); else RTPrintf("FAILED\n"); } else RTPrintf("\n"); RTStrmFlush(g_pStdOut); } #endif /* !VBOX_ONLY_DOCS */