/* $Id: VBoxManageHelp.cpp 33202 2010-10-18 14:43:09Z vboxsync $ */ /** @file * VBoxManage - help and other message output. */ /* * Copyright (C) 2006-2010 Oracle Corporation * * 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. */ /******************************************************************************* * Header Files * *******************************************************************************/ #include #include #include #include #include #include "VBoxManage.h" void showLogo(PRTSTREAM pStrm) { static bool s_fShown; /* show only once */ if (!s_fShown) { RTStrmPrintf(pStrm, VBOX_PRODUCT " Command Line Management Interface Version " VBOX_VERSION_STRING "\n" "(C) 2005-" VBOX_C_YEAR " " VBOX_VENDOR "\n" "All rights reserved.\n" "\n"); s_fShown = true; } } void printUsage(USAGECATEGORY u64Cmd, PRTSTREAM pStrm) { bool fDumpOpts = false; #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_FREEBSD bool fFreeBSD = true; #else bool fFreeBSD = 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 #ifdef VBOX_WITH_VBOXSDL bool fVBoxSDL = true; #else bool fVBoxSDL = false; #endif if (u64Cmd == USAGE_DUMPOPTS) { fDumpOpts = true; fLinux = true; fWin = true; fSolaris = true; fFreeBSD = true; fDarwin = true; fVRDP = true; fVBoxSDL = true; u64Cmd = USAGE_ALL; } RTStrmPrintf(pStrm, "Usage:\n" "\n"); if (u64Cmd == USAGE_ALL) { RTStrmPrintf(pStrm, "VBoxManage [-v|--version] print version number and exit\n" "VBoxManage [-q|--nologo] ... suppress the logo\n" "\n"); } if (u64Cmd & USAGE_LIST) { RTStrmPrintf(pStrm, "VBoxManage list [--long|-l] vms|runningvms|ostypes|hostdvds|hostfloppies|\n" #if defined(VBOX_WITH_NETFLT) " bridgedifs|hostonlyifs|dhcpservers|hostinfo|\n" #else " bridgedifs|dhcpservers|hostinfo|\n" #endif " hostcpuids|hddbackends|hdds|dvds|floppies|\n" " usbhost|usbfilters|systemproperties\n" "\n"); } if (u64Cmd & USAGE_SHOWVMINFO) { RTStrmPrintf(pStrm, "VBoxManage showvminfo | [--details] [--statistics]\n" " [--machinereadable]\n" "VBoxManage showvminfo | --log \n" "\n"); } if (u64Cmd & USAGE_REGISTERVM) { RTStrmPrintf(pStrm, "VBoxManage registervm \n" "\n"); } if (u64Cmd & USAGE_UNREGISTERVM) { RTStrmPrintf(pStrm, "VBoxManage unregistervm | [--delete]\n" "\n"); } if (u64Cmd & USAGE_CREATEVM) { RTStrmPrintf(pStrm, "VBoxManage createvm --name \n" " [--ostype ]\n" " [--register]\n" " [--basefolder | --settingsfile ]\n" " [--uuid ]\n" "\n"); } if (u64Cmd & USAGE_MODIFYVM) { RTStrmPrintf(pStrm, "VBoxManage modifyvm \n" " [--name ]\n" " [--ostype ]\n" " [--memory ]\n" " [--pagefusion on|off]\n" " [--vram ]\n" " [--acpi on|off]\n" " [--ioapic on|off]\n" " [--pae on|off]\n" " [--hpet on|off]\n" " [--hwvirtex on|off]\n" " [--hwvirtexexcl on|off]\n" " [--nestedpaging on|off]\n" " [--largepages on|off]\n" " [--vtxvpid on|off]\n" " [--synthcpu on|off]\n" " [--cpuidset ]\n" " [--cpuidremove ]\n" " [--cpuidremoveall]\n" " [--hardwareuuid ]\n" " [--cpus ]\n" " [--cpuhotplug on|off]\n" " [--plugcpu ]\n" " [--unplugcpu ]\n" " [--cpuexecutioncap <1-100>]\n" " [--rtcuseutc on|off]\n" " [--monitorcount ]\n" " [--accelerate3d on|off]\n" #ifdef VBOX_WITH_VIDEOHWACCEL " [--accelerate2dvideo on|off]\n" #endif " [--firmware bios|efi|efi32|efi64]\n" " [--chipset ich9|piix3]\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" " [--nic<1-N> none|null|nat|bridged|intnet" #if defined(VBOX_WITH_NETFLT) "|hostonly" #endif #ifdef VBOX_WITH_VDE "|\n" " vde" #endif "]\n" " [--nictype<1-N> Am79C970A|Am79C973" #ifdef VBOX_WITH_E1000 "|\n 82540EM|82543GC|82545EM" #endif #ifdef VBOX_WITH_VIRTIO "|\n virtio" #endif /* VBOX_WITH_VIRTIO */ "]\n" " [--cableconnected<1-N> on|off]\n" " [--nictrace<1-N> on|off]\n" " [--nictracefile<1-N> ]\n" " [--nicspeed<1-N> ]\n" " [--nicbootprio<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" #ifdef VBOX_WITH_VDE " [--vdenet<1-N> |default]\n" #endif " [--natsettings<1-N> [],[],\n" " [],[],\n" " []]\n" " [--natpf<1-N> [],tcp|udp,[],\n" " ,[],]\n" " [--natpf<1-N> delete ]\n" " [--nattftpprefix<1-N> ]\n" " [--nattftpfile<1-N> ]\n" " [--nattftpserver<1-N> ]\n" " [--natdnspassdomain<1-N> on|off]\n" " [--natdnsproxy<1-N> on|off]\n" " [--natdnshostresolver<1-N> on|off]\n" " [--nataliasmode<1-N> default|[log],[proxyonly],\n" " [sameports]]\n" " [--macaddress<1-N> auto|]\n" " [--mouse ps2|usb|usbtablet\n" " [--keyboard ps2|usb\n" " [--uart<1-N> off| ]\n" " [--uartmode<1-N> disconnected|\n" " server |\n" " client |\n" " file |\n" " ]\n" " [--guestmemoryballoon ]\n" " [--gueststatisticsinterval ]\n" " [--audio none|null"); if (fWin) { #ifdef VBOX_WITH_WINMM RTStrmPrintf(pStrm, "|winmm|dsound"); #else RTStrmPrintf(pStrm, "|dsound"); #endif } if (fSolaris) { RTStrmPrintf(pStrm, "|solaudio" #ifdef VBOX_WITH_SOLARIS_OSS "|oss" #endif ); } if (fLinux) { RTStrmPrintf(pStrm, "|oss" #ifdef VBOX_WITH_ALSA "|alsa" #endif #ifdef VBOX_WITH_PULSE "|pulse" #endif ); } if (fFreeBSD) { /* Get the line break sorted when dumping all option variants. */ if (fDumpOpts) { RTStrmPrintf(pStrm, "|\n" " oss"); } else RTStrmPrintf(pStrm, "|oss"); #ifdef VBOX_WITH_PULSE RTStrmPrintf(pStrm, "|pulse"); #endif } if (fDarwin) { RTStrmPrintf(pStrm, "|coreaudio"); } RTStrmPrintf(pStrm, "]\n"); RTStrmPrintf(pStrm, " [--audiocontroller ac97|hda|sb16]\n" " [--clipboard disabled|hosttoguest|guesttohost|\n" " bidirectional]\n"); if (fVRDP) { RTStrmPrintf(pStrm, " [--vrdp on|off]\n" " [--vrdpport default|]\n" " [--vrdpaddress ]\n" " [--vrdpauthtype null|external|guest]\n" " [--vrdpmulticon on|off]\n" " [--vrdpreusecon on|off]\n" " [--vrdpvideochannel on|off]\n" " [--vrdpvideochannelquality ]\n"); } RTStrmPrintf(pStrm, " [--usb on|off]\n" " [--usbehci on|off]\n" " [--snapshotfolder default|]\n" " [--teleporter on|off]\n" " [--teleporterport ]\n" " [--teleporteraddress \n" " [--teleporterpassword ]\n" #if 0 " [--iocache on|off]\n" " [--iocachesize ]\n" #endif #if 0 " [--faulttolerance master|standby]\n" " [--faulttoleranceaddress ]\n" " [--faulttoleranceport ]\n" " [--faulttolerancesyncinterval ]\n" " [--faulttolerancepassword ]\n" #endif "\n"); } if (u64Cmd & USAGE_IMPORTAPPLIANCE) { RTStrmPrintf(pStrm, "VBoxManage import [--dry-run|-n] [more options]\n" " (run with -n to have options displayed\n" " for a particular OVF)\n\n"); } if (u64Cmd & USAGE_EXPORTAPPLIANCE) { RTStrmPrintf(pStrm, "VBoxManage export --output|-o \n" " [--legacy09]\n" " [--manifest]\n" " [--vsys ]\n" " [--product ]\n" " [--producturl ]\n" " [--vendor ]\n" " [--vendorurl ]\n" " [--version ]\n" " [--eula ]\n" " [--eulafile ]\n" "\n"); } if (u64Cmd & USAGE_STARTVM) { RTStrmPrintf(pStrm, "VBoxManage startvm |\n"); RTStrmPrintf(pStrm, " [--type gui"); if (fVBoxSDL) RTStrmPrintf(pStrm, "|sdl"); if (fVRDP) RTStrmPrintf(pStrm, "|vrdp"); RTStrmPrintf(pStrm, "|headless]\n"); RTStrmPrintf(pStrm, "\n"); } if (u64Cmd & USAGE_CONTROLVM) { RTStrmPrintf(pStrm, "VBoxManage controlvm |\n" " pause|resume|reset|poweroff|savestate|\n" " acpipowerbutton|acpisleepbutton|\n" " keyboardputscancode [ ...]|\n" " injectnmi|\n" " setlinkstate<1-N> on|off |\n" #ifdef VBOX_DYNAMIC_NET_ATTACH #if defined(VBOX_WITH_NETFLT) " nic<1-N> null|nat|bridged|intnet|hostonly\n" " [] |\n" #else /* !RT_OS_LINUX && !RT_OS_DARWIN */ " nic<1-N> null|nat|bridged|intnet\n" " [] |\n" #endif /* !RT_OS_LINUX && !RT_OS_DARWIN */ " nictrace<1-N> on|off\n" " nictracefile<1-N> \n" #endif /* VBOX_DYNAMIC_NET_ATTACH */ " guestmemoryballoon ]\n" " gueststatisticsinterval ]\n" " usbattach |
|\n" " usbdetach |
|\n"); if (fVRDP) { RTStrmPrintf(pStrm, " vrdp on|off |\n"); RTStrmPrintf(pStrm, " vrdpport default| |\n" " vrdpvideochannelquality \n"); } RTStrmPrintf(pStrm, " setvideomodehint [display] |\n" " setcredentials \n" " [--allowlocallogon ] |\n" " teleport --host --port \n" " [--maxdowntime ] [--password password]\n" " plugcpu \n" " unplugcpu \n" " cpuexecutioncap <1-100>\n" "\n"); } if (u64Cmd & USAGE_DISCARDSTATE) { RTStrmPrintf(pStrm, "VBoxManage discardstate |\n" "\n"); } if (u64Cmd & USAGE_ADOPTSTATE) { RTStrmPrintf(pStrm, "VBoxManage adoptstate | \n" "\n"); } if (u64Cmd & USAGE_SNAPSHOT) { RTStrmPrintf(pStrm, "VBoxManage snapshot |\n" " take [--description ] [--pause] |\n" " delete | |\n" " restore | |\n" " restorecurrent |\n" " edit ||--current\n" " [--name ]\n" " [--description ] |\n" " showvminfo |\n" "\n"); } if (u64Cmd & USAGE_OPENMEDIUM) { RTStrmPrintf(pStrm, "VBoxManage openmedium disk|dvd|floppy \n" " [--type normal|immutable|writethrough|\n" " shareable] (disk only)\n" " [--uuid ]\n" " [--parentuuid ] (disk only)\n" "\n"); } if (u64Cmd & USAGE_CLOSEMEDIUM) { RTStrmPrintf(pStrm, "VBoxManage closemedium disk|dvd|floppy |\n" " [--delete]\n" "\n"); } if (u64Cmd & USAGE_STORAGEATTACH) { RTStrmPrintf(pStrm, "VBoxManage storageattach \n" " --storagectl \n" " --port \n" " --device \n" " [--type dvddrive|hdd|fdd]\n" " [--medium none|emptydrive|\n" " ||host:]\n" " [--passthrough on|off]\n" " [--forceunmount]\n" "\n"); } if (u64Cmd & USAGE_STORAGECONTROLLER) { RTStrmPrintf(pStrm, "VBoxManage storagectl \n" " --name \n" " [--add ide|sata|scsi|floppy|sas]\n" " [--controller LSILogic|LSILogicSAS|BusLogic|\n" " IntelAHCI|PIIX3|PIIX4|ICH6|I82078]\n" " [--sataideemulation<1-4> <1-30>]\n" " [--sataportcount <1-30>]\n" " [--hostiocache on|off]\n" " [--remove]\n" "\n"); } if (u64Cmd & USAGE_SHOWHDINFO) { RTStrmPrintf(pStrm, "VBoxManage showhdinfo |\n" "\n"); } if (u64Cmd & USAGE_CREATEHD) { RTStrmPrintf(pStrm, "VBoxManage createhd --filename \n" " --size |--sizebyte \n" " [--format VDI|VMDK|VHD] (default: VDI)\n" " [--variant Standard,Fixed,Split2G,Stream,ESX]\n" " [--type normal|writethrough|\n" " shareable] (default: normal)\n" " [--comment ]\n" " [--remember]\n" "\n"); } if (u64Cmd & USAGE_MODIFYHD) { RTStrmPrintf(pStrm, "VBoxManage modifyhd |\n" " [--type normal|writethrough|immutable|shareable]\n" " [--autoreset on|off]\n" " [--compact]\n" " [--resize ]\n" "\n"); } if (u64Cmd & USAGE_CLONEHD) { RTStrmPrintf(pStrm, "VBoxManage clonehd | \n" " [--format VDI|VMDK|VHD|RAW|]\n" " [--variant Standard,Fixed,Split2G,Stream,ESX]\n" " [--type normal|writethrough|immutable|shareable]\n" " [--remember] [--existing]\n" "\n"); } if (u64Cmd & USAGE_CONVERTFROMRAW) { RTStrmPrintf(pStrm, "VBoxManage convertfromraw \n" " [--format VDI|VMDK|VHD]\n" " [--variant Standard,Fixed,Split2G,Stream,ESX]\n" #ifndef RT_OS_WINDOWS "VBoxManage convertfromraw stdin \n" " [--format VDI|VMDK|VHD]\n" " [--variant Standard,Fixed,Split2G,Stream,ESX]\n" #endif "\n"); } if (u64Cmd & USAGE_ADDISCSIDISK) { RTStrmPrintf(pStrm, "VBoxManage addiscsidisk --server |\n" " --target \n" " [--port ]\n" " [--lun ]\n" " [--encodedlun ]\n" " [--username ]\n" " [--password ]\n" " [--type normal|writethrough|immutable|shareable]\n" " [--intnet]\n" "\n"); } if (u64Cmd & USAGE_GETEXTRADATA) { RTStrmPrintf(pStrm, "VBoxManage getextradata global||\n" " |enumerate\n" "\n"); } if (u64Cmd & USAGE_SETEXTRADATA) { RTStrmPrintf(pStrm, "VBoxManage setextradata global||\n" " \n" " [] (no value deletes key)\n" "\n"); } if (u64Cmd & USAGE_SETPROPERTY) { RTStrmPrintf(pStrm, "VBoxManage setproperty hdfolder default| |\n" " machinefolder default| |\n" " vrdpauthlibrary default| |\n" " websrvauthlibrary default|null| |\n" " loghistorycount \n" "\n"); } if (u64Cmd & USAGE_USBFILTER_ADD) { RTStrmPrintf(pStrm, "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) { RTStrmPrintf(pStrm, "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) { RTStrmPrintf(pStrm, "VBoxManage usbfilter remove \n" " --target ||global\n" "\n"); } if (u64Cmd & USAGE_SHAREDFOLDER_ADD) { RTStrmPrintf(pStrm, "VBoxManage sharedfolder add |\n" " --name --hostpath \n" " [--transient] [--readonly] [--automount]\n" "\n"); } if (u64Cmd & USAGE_SHAREDFOLDER_REMOVE) { RTStrmPrintf(pStrm, "VBoxManage sharedfolder remove |\n" " --name [--transient]\n" "\n"); } if (u64Cmd & USAGE_VM_STATISTICS) { RTStrmPrintf(pStrm, "VBoxManage vmstatistics | [--reset]\n" " [--pattern ] [--descriptions]\n" "\n"); } #ifdef VBOX_WITH_GUEST_PROPS if (u64Cmd & USAGE_GUESTPROPERTY) usageGuestProperty(pStrm); #endif /* VBOX_WITH_GUEST_PROPS defined */ #ifdef VBOX_WITH_GUEST_CONTROL if (u64Cmd & USAGE_GUESTCONTROL) usageGuestControl(pStrm); #endif /* VBOX_WITH_GUEST_CONTROL defined */ if (u64Cmd & USAGE_METRICS) { RTStrmPrintf(pStrm, "VBoxManage metrics list [*|host| []]\n" " (comma-separated)\n\n" "VBoxManage metrics setup\n" " [--period ] (default: 1)\n" " [--samples ] (default: 1)\n" " [--list]\n" " [*|host| []]\n\n" "VBoxManage metrics query [*|host| []]\n\n" "VBoxManage metrics enable\n" " [--list]\n" " [*|host| []]\n\n" "VBoxManage metrics disable\n" " [--list]\n" " [*|host| []]\n\n" "VBoxManage metrics collect\n" " [--period ] (default: 1)\n" " [--samples ] (default: 1)\n" " [--list]\n" " [--detach]\n" " [*|host| []]\n" "\n"); } #if defined(VBOX_WITH_NETFLT) if (u64Cmd & USAGE_HOSTONLYIFS) { RTStrmPrintf(pStrm, "VBoxManage hostonlyif ipconfig \n" " [--dhcp |\n" " --ip [--netmask (def: 255.255.255.0)] |\n" " --ipv6 [--netmasklengthv6 (def: 64)]]\n" # if defined(RT_OS_WINDOWS) " create |\n" " remove \n" # endif "\n"); } #endif if (u64Cmd & USAGE_DHCPSERVER) { RTStrmPrintf(pStrm, "VBoxManage dhcpserver add|modify --netname |\n" #if defined(VBOX_WITH_NETFLT) " --ifname \n" #endif " [--ip \n" " --netmask \n" " --lowerip \n" " --upperip ]\n" " [--enable | --disable]\n\n" "VBoxManage dhcpserver remove --netname |\n" #if defined(VBOX_WITH_NETFLT) " --ifname \n" #endif "\n"); } } /** * Print a usage synopsis and the syntax error message. */ int errorSyntax(USAGECATEGORY u64Cmd, const char *pszFormat, ...) { va_list args; showLogo(g_pStdErr); // show logo even if suppressed #ifndef VBOX_ONLY_DOCS if (g_fInternalMode) printUsageInternal(u64Cmd, g_pStdErr); else printUsage(u64Cmd, g_pStdErr); #endif /* !VBOX_ONLY_DOCS */ va_start(args, pszFormat); RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args); va_end(args); return 1; } /** * errorSyntax for RTGetOpt users. * * @returns 1. * * @param fUsageCategory The usage category of the command. * @param rc The RTGetOpt return code. * @param pValueUnion The value union. */ int errorGetOpt(USAGECATEGORY fUsageCategory, int rc, union RTGETOPTUNION const *pValueUnion) { showLogo(g_pStdErr); // show logo even if suppressed #ifndef VBOX_ONLY_DOCS if (g_fInternalMode) printUsageInternal(fUsageCategory, g_pStdErr); else printUsage(fUsageCategory, g_pStdErr); #endif /* !VBOX_ONLY_DOCS */ if (rc == VINF_GETOPT_NOT_OPTION) return RTMsgError("Invalid parameter '%s'", pValueUnion->psz); if (rc > 0) { if (RT_C_IS_PRINT(rc)) return RTMsgError("Invalid option -%c", rc); return RTMsgError("Invalid option case %i", rc); } if (rc == VERR_GETOPT_UNKNOWN_OPTION) return RTMsgError("Unknown option: %s", pValueUnion->psz); if (pValueUnion->pDef) return RTMsgError("%s: %Rrs", pValueUnion->pDef->pszLong, rc); return RTMsgError("%Rrs", rc); } /** * Print an error message without the syntax stuff. */ int errorArgument(const char *pszFormat, ...) { va_list args; va_start(args, pszFormat); RTMsgErrorV(pszFormat, args); va_end(args); return 1; }