[14732] | 1 | /* $Id: VBoxManage.h 99775 2023-05-12 12:21:58Z vboxsync $ */
|
---|
[1] | 2 | /** @file
|
---|
[14732] | 3 | * VBoxManage - VirtualBox command-line interface, internal header file.
|
---|
[1] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[1] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[1] | 26 | */
|
---|
| 27 |
|
---|
[76582] | 28 | #ifndef VBOX_INCLUDED_SRC_VBoxManage_VBoxManage_h
|
---|
| 29 | #define VBOX_INCLUDED_SRC_VBoxManage_VBoxManage_h
|
---|
[76532] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[1] | 33 |
|
---|
[16054] | 34 | #include <VBox/com/com.h>
|
---|
[5146] | 35 | #include <VBox/com/ptr.h>
|
---|
| 36 | #include <VBox/com/VirtualBox.h>
|
---|
[14555] | 37 | #include <VBox/com/string.h>
|
---|
[42176] | 38 | #include <VBox/com/array.h>
|
---|
[5146] | 39 |
|
---|
[13908] | 40 | #include <iprt/types.h>
|
---|
[32701] | 41 | #include <iprt/message.h>
|
---|
[32709] | 42 | #include <iprt/stream.h>
|
---|
[49621] | 43 | #include <iprt/getopt.h>
|
---|
[13908] | 44 |
|
---|
[94234] | 45 | #include "VBoxManageBuiltInHelp.h"
|
---|
| 46 | #include "PasswordInput.h"
|
---|
[56118] | 47 |
|
---|
[92372] | 48 | #ifdef VBOX_WITH_VBOXMANAGE_NLS
|
---|
| 49 | # include "VirtualBoxTranslator.h"
|
---|
| 50 | #endif
|
---|
[56344] | 51 |
|
---|
[92372] | 52 |
|
---|
[18396] | 53 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 54 | //
|
---|
| 55 | // definitions
|
---|
| 56 | //
|
---|
| 57 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 58 |
|
---|
[92533] | 59 | /**
|
---|
| 60 | * This defines a a_CtxName::tr function that gives the translator context as
|
---|
| 61 | * well as providing a shorter way to call VirtualBoxTranslator::translate.
|
---|
| 62 | */
|
---|
[92372] | 63 | #ifdef VBOX_WITH_VBOXMANAGE_NLS
|
---|
[92533] | 64 | # define DECLARE_TRANSLATION_CONTEXT(a_CtxName) \
|
---|
| 65 | struct a_CtxName \
|
---|
| 66 | { \
|
---|
| 67 | static const char *tr(const char *pszSource, const char *pszComment = NULL, const size_t uNum = ~(size_t)0) \
|
---|
[92372] | 68 | { \
|
---|
[92533] | 69 | return VirtualBoxTranslator::translate(NULL, #a_CtxName, pszSource, pszComment, uNum); \
|
---|
[92372] | 70 | } \
|
---|
| 71 | }
|
---|
| 72 | #else
|
---|
[92533] | 73 | # define DECLARE_TRANSLATION_CONTEXT(a_CtxName) \
|
---|
| 74 | struct a_CtxName \
|
---|
| 75 | { \
|
---|
| 76 | static const char *tr(const char *pszSource, const char *pszComment = NULL, const size_t uNum = ~(size_t)0) \
|
---|
[92372] | 77 | { \
|
---|
[92533] | 78 | RT_NOREF(pszComment, uNum); \
|
---|
[92372] | 79 | return pszSource; \
|
---|
| 80 | } \
|
---|
| 81 | }
|
---|
| 82 | #endif
|
---|
| 83 |
|
---|
[92534] | 84 | /**
|
---|
| 85 | * Defines an option with two variants, producing two RTGETOPTDEF entries.
|
---|
| 86 | *
|
---|
| 87 | * This is mainly for replacing character-soup option names like
|
---|
| 88 | * --natlocalhostreachable and --biossystemtimeoffset with more easily parsed
|
---|
| 89 | * ones, like --nat-localhost-reachable and --bios-system-time-offset, without
|
---|
| 90 | * removing the legacy name.
|
---|
| 91 | */
|
---|
| 92 | #define OPT2(a_pszWordDashWord, a_pszWordSoup, a_chOptOrValue, a_fFlags) \
|
---|
| 93 | { a_pszWordDashWord, a_chOptOrValue, a_fFlags }, \
|
---|
| 94 | { a_pszWordSoup, a_chOptOrValue, a_fFlags }
|
---|
[92372] | 95 |
|
---|
[92534] | 96 | /** A single option variant of OPT2 for better looking tables. */
|
---|
| 97 | #define OPT1(a_pszOption, a_chOptOrValue, a_fFlags) \
|
---|
| 98 | { a_pszOption, a_chOptOrValue, a_fFlags }
|
---|
| 99 |
|
---|
| 100 |
|
---|
[16052] | 101 | /** command handler argument */
|
---|
| 102 | struct HandlerArg
|
---|
| 103 | {
|
---|
| 104 | int argc;
|
---|
| 105 | char **argv;
|
---|
[17079] | 106 |
|
---|
[16052] | 107 | ComPtr<IVirtualBox> virtualBox;
|
---|
| 108 | ComPtr<ISession> session;
|
---|
| 109 | };
|
---|
| 110 |
|
---|
[1] | 111 |
|
---|
[4649] | 112 | /** showVMInfo details */
|
---|
| 113 | typedef enum
|
---|
| 114 | {
|
---|
[4779] | 115 | VMINFO_NONE = 0,
|
---|
[5204] | 116 | VMINFO_STANDARD = 1, /**< standard details */
|
---|
[27822] | 117 | VMINFO_FULL = 2, /**< both */
|
---|
| 118 | VMINFO_MACHINEREADABLE = 3, /**< both, and make it machine readable */
|
---|
| 119 | VMINFO_COMPACT = 4
|
---|
[4649] | 120 | } VMINFO_DETAILS;
|
---|
| 121 |
|
---|
[56118] | 122 |
|
---|
[18396] | 123 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 124 | //
|
---|
| 125 | // global variables
|
---|
| 126 | //
|
---|
| 127 | ////////////////////////////////////////////////////////////////////////////////
|
---|
[16052] | 128 |
|
---|
[18396] | 129 | extern bool g_fDetailedProgress; // in VBoxManage.cpp
|
---|
| 130 |
|
---|
[56118] | 131 |
|
---|
[18396] | 132 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 133 | //
|
---|
| 134 | // prototypes
|
---|
| 135 | //
|
---|
| 136 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 137 |
|
---|
[17103] | 138 | /* VBoxManageHelp.cpp */
|
---|
[56344] | 139 | void setCurrentCommand(enum HELP_CMD_VBOXMANAGE enmCommand);
|
---|
| 140 | void setCurrentSubcommand(uint64_t fCurSubcommandScope);
|
---|
| 141 |
|
---|
[56349] | 142 | void printUsage(PRTSTREAM pStrm);
|
---|
| 143 | void printHelp(PRTSTREAM pStrm);
|
---|
[56344] | 144 | RTEXITCODE errorNoSubcommand(void);
|
---|
| 145 | RTEXITCODE errorUnknownSubcommand(const char *pszSubCmd);
|
---|
[56349] | 146 | RTEXITCODE errorTooManyParameters(char **papszArgs);
|
---|
[56344] | 147 | RTEXITCODE errorGetOpt(int rcGetOpt, union RTGETOPTUNION const *pValueUnion);
|
---|
[79611] | 148 | RTEXITCODE errorFetchValue(int iValueNo, const char *pszOption, int rcGetOptFetchValue, union RTGETOPTUNION const *pValueUnion);
|
---|
[92538] | 149 | RTEXITCODE errorSyntax(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
| 150 | RTEXITCODE errorSyntaxV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
|
---|
| 151 | HRESULT errorSyntaxHr(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
| 152 | RTEXITCODE errorArgument(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
| 153 | HRESULT errorArgumentHr(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
[56344] | 154 |
|
---|
[92538] | 155 | # define SHOW_PROGRESS_NONE 0
|
---|
| 156 | # define SHOW_PROGRESS_DESC RT_BIT_32(0)
|
---|
| 157 | # define SHOW_PROGRESS RT_BIT_32(1)
|
---|
| 158 | # define SHOW_PROGRESS_DETAILS RT_BIT_32(2)
|
---|
| 159 | HRESULT showProgress(ComPtr<IProgress> progress, uint32_t fFlags = SHOW_PROGRESS);
|
---|
[15492] | 160 |
|
---|
[17103] | 161 | /* VBoxManage.cpp */
|
---|
[32709] | 162 | void showLogo(PRTSTREAM pStrm);
|
---|
[17103] | 163 |
|
---|
[94290] | 164 | /* VBoxInternalManage.cpp */
|
---|
| 165 | DECLHIDDEN(void) printUsageInternalCmds(PRTSTREAM pStrm);
|
---|
[56118] | 166 | RTEXITCODE handleInternalCommands(HandlerArg *a);
|
---|
[14555] | 167 |
|
---|
[24903] | 168 | /* VBoxManageControlVM.cpp */
|
---|
[56118] | 169 | RTEXITCODE handleControlVM(HandlerArg *a);
|
---|
[24903] | 170 |
|
---|
[16485] | 171 | /* VBoxManageModifyVM.cpp */
|
---|
[42176] | 172 | void parseGroups(const char *pcszGroups, com::SafeArray<BSTR> *pGroups);
|
---|
[94234] | 173 | #ifdef VBOX_WITH_RECORDING
|
---|
[93704] | 174 | int parseScreens(const char *pcszScreens, com::SafeArray<BOOL> *pScreens);
|
---|
[42176] | 175 | #endif
|
---|
[56118] | 176 | RTEXITCODE handleModifyVM(HandlerArg *a);
|
---|
[99775] | 177 | VMProcPriority_T nameToVMProcPriority(const char *pszName);
|
---|
[16485] | 178 |
|
---|
[34913] | 179 | /* VBoxManageDebugVM.cpp */
|
---|
[56118] | 180 | RTEXITCODE handleDebugVM(HandlerArg *a);
|
---|
[34913] | 181 |
|
---|
[32712] | 182 | /* VBoxManageGuestProp.cpp */
|
---|
[56118] | 183 | RTEXITCODE handleGuestProperty(HandlerArg *a);
|
---|
[14555] | 184 |
|
---|
[27703] | 185 | /* VBoxManageGuestCtrl.cpp */
|
---|
[56118] | 186 | RTEXITCODE handleGuestControl(HandlerArg *a);
|
---|
[27703] | 187 |
|
---|
[14612] | 188 | /* VBoxManageVMInfo.cpp */
|
---|
[39119] | 189 | HRESULT showSnapshots(ComPtr<ISnapshot> &rootSnapshot,
|
---|
| 190 | ComPtr<ISnapshot> ¤tSnapshot,
|
---|
| 191 | VMINFO_DETAILS details,
|
---|
[44028] | 192 | const com::Utf8Str &prefix = "",
|
---|
[39119] | 193 | int level = 0);
|
---|
[56118] | 194 | RTEXITCODE handleShowVMInfo(HandlerArg *a);
|
---|
[53266] | 195 | HRESULT showVMInfo(ComPtr<IVirtualBox> pVirtualBox,
|
---|
| 196 | ComPtr<IMachine> pMachine,
|
---|
| 197 | ComPtr<ISession> pSession,
|
---|
| 198 | VMINFO_DETAILS details = VMINFO_NONE);
|
---|
[35907] | 199 | const char *machineStateToName(MachineState_T machineState, bool fShort);
|
---|
[40470] | 200 | HRESULT showBandwidthGroups(ComPtr<IBandwidthControl> &bwCtrl,
|
---|
| 201 | VMINFO_DETAILS details);
|
---|
[93627] | 202 | void outputMachineReadableString(const char *pszName, const char *pszValue, bool fQuoteName = false, bool fNewline = true);
|
---|
| 203 | void outputMachineReadableString(const char *pszName, com::Bstr const *pbstrValue, bool fQuoteName = false, bool fNewline = true);
|
---|
[92538] | 204 | void outputMachineReadableStringWithFmtName(const char *pszValue, bool fQuoteName, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(3, 4);
|
---|
| 205 | void outputMachineReadableStringWithFmtName(com::Bstr const *pbstrValue, bool fQuoteName, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(3, 4);
|
---|
[85780] | 206 | void outputMachineReadableBool(const char *pszName, BOOL const *pfValue);
|
---|
| 207 | void outputMachineReadableBool(const char *pszName, bool const *pfValue);
|
---|
| 208 | void outputMachineReadableULong(const char *pszName, ULONG *uValue);
|
---|
| 209 | void outputMachineReadableLong64(const char *pszName, LONG64 *uValue);
|
---|
[14612] | 210 |
|
---|
| 211 | /* VBoxManageList.cpp */
|
---|
[56118] | 212 | RTEXITCODE handleList(HandlerArg *a);
|
---|
[14555] | 213 |
|
---|
[14646] | 214 | /* VBoxManageMetrics.cpp */
|
---|
[56118] | 215 | RTEXITCODE handleMetrics(HandlerArg *a);
|
---|
[14646] | 216 |
|
---|
[24907] | 217 | /* VBoxManageMisc.cpp */
|
---|
[56118] | 218 | RTEXITCODE handleRegisterVM(HandlerArg *a);
|
---|
| 219 | RTEXITCODE handleUnregisterVM(HandlerArg *a);
|
---|
| 220 | RTEXITCODE handleCreateVM(HandlerArg *a);
|
---|
| 221 | RTEXITCODE handleCloneVM(HandlerArg *a);
|
---|
| 222 | RTEXITCODE handleStartVM(HandlerArg *a);
|
---|
[94660] | 223 | #ifdef VBOX_WITH_FULL_VM_ENCRYPTION
|
---|
| 224 | RTEXITCODE handleEncryptVM(HandlerArg *a);
|
---|
| 225 | #endif
|
---|
[56118] | 226 | RTEXITCODE handleDiscardState(HandlerArg *a);
|
---|
| 227 | RTEXITCODE handleAdoptState(HandlerArg *a);
|
---|
| 228 | RTEXITCODE handleGetExtraData(HandlerArg *a);
|
---|
| 229 | RTEXITCODE handleSetExtraData(HandlerArg *a);
|
---|
| 230 | RTEXITCODE handleSetProperty(HandlerArg *a);
|
---|
| 231 | RTEXITCODE handleSharedFolder(HandlerArg *a);
|
---|
| 232 | RTEXITCODE handleExtPack(HandlerArg *a);
|
---|
[68140] | 233 | RTEXITCODE handleUnattended(HandlerArg *a);
|
---|
[70582] | 234 | RTEXITCODE handleMoveVM(HandlerArg *a);
|
---|
[77777] | 235 | RTEXITCODE handleCloudProfile(HandlerArg *a);
|
---|
[24907] | 236 |
|
---|
[15492] | 237 | /* VBoxManageDisk.cpp */
|
---|
[44028] | 238 | HRESULT openMedium(HandlerArg *a, const char *pszFilenameOrUuid,
|
---|
| 239 | DeviceType_T enmDevType, AccessMode_T enmAccessMode,
|
---|
| 240 | ComPtr<IMedium> &pMedium, bool fForceNewUuidOnOpen,
|
---|
| 241 | bool fSilent);
|
---|
[56118] | 242 | RTEXITCODE handleCreateMedium(HandlerArg *a);
|
---|
| 243 | RTEXITCODE handleModifyMedium(HandlerArg *a);
|
---|
| 244 | RTEXITCODE handleCloneMedium(HandlerArg *a);
|
---|
| 245 | RTEXITCODE handleMediumProperty(HandlerArg *a);
|
---|
| 246 | RTEXITCODE handleEncryptMedium(HandlerArg *a);
|
---|
| 247 | RTEXITCODE handleCheckMediumPassword(HandlerArg *a);
|
---|
| 248 | RTEXITCODE handleConvertFromRaw(HandlerArg *a);
|
---|
[44498] | 249 | HRESULT showMediumInfo(const ComPtr<IVirtualBox> &pVirtualBox,
|
---|
| 250 | const ComPtr<IMedium> &pMedium,
|
---|
| 251 | const char *pszParentUUID,
|
---|
| 252 | bool fOptLong);
|
---|
[56118] | 253 | RTEXITCODE handleShowMediumInfo(HandlerArg *a);
|
---|
| 254 | RTEXITCODE handleCloseMedium(HandlerArg *a);
|
---|
[72949] | 255 | RTEXITCODE handleMediumIO(HandlerArg *a);
|
---|
[54438] | 256 | int parseMediumType(const char *psz, MediumType_T *penmMediumType);
|
---|
[42248] | 257 | int parseBool(const char *psz, bool *pb);
|
---|
[15492] | 258 |
|
---|
[23802] | 259 | /* VBoxManageStorageController.cpp */
|
---|
[56118] | 260 | RTEXITCODE handleStorageAttach(HandlerArg *a);
|
---|
| 261 | RTEXITCODE handleStorageController(HandlerArg *a);
|
---|
[23802] | 262 |
|
---|
[84032] | 263 | // VBoxManageAppliance.cpp
|
---|
[56118] | 264 | RTEXITCODE handleImportAppliance(HandlerArg *a);
|
---|
| 265 | RTEXITCODE handleExportAppliance(HandlerArg *a);
|
---|
[84032] | 266 | RTEXITCODE handleSignAppliance(HandlerArg *a);
|
---|
[16485] | 267 |
|
---|
[17102] | 268 | // VBoxManageSnapshot.cpp
|
---|
[56118] | 269 | RTEXITCODE handleSnapshot(HandlerArg *a);
|
---|
[17102] | 270 |
|
---|
[14555] | 271 | /* VBoxManageUSB.cpp */
|
---|
[56118] | 272 | RTEXITCODE handleUSBFilter(HandlerArg *a);
|
---|
[60089] | 273 | RTEXITCODE handleUSBDevSource(HandlerArg *a);
|
---|
[14555] | 274 |
|
---|
[17419] | 275 | /* VBoxManageHostonly.cpp */
|
---|
[56118] | 276 | RTEXITCODE handleHostonlyIf(HandlerArg *a);
|
---|
[91416] | 277 | #ifdef VBOX_WITH_VMNET
|
---|
| 278 | RTEXITCODE handleHostonlyNet(HandlerArg *a);
|
---|
| 279 | #endif /* VBOX_WITH_VMNET */
|
---|
[17419] | 280 |
|
---|
[45156] | 281 | /* VBoxManageDHCPServer.cpp */
|
---|
[56118] | 282 | RTEXITCODE handleDHCPServer(HandlerArg *a);
|
---|
[17882] | 283 |
|
---|
[45156] | 284 | /* VBoxManageNATNetwork.cpp */
|
---|
[56118] | 285 | RTEXITCODE handleNATNetwork(HandlerArg *a);
|
---|
[93279] | 286 | RTEXITCODE listNATNetworks(bool fLong, bool fSorted,
|
---|
| 287 | const ComPtr<IVirtualBox> &pVirtualBox);
|
---|
[45156] | 288 |
|
---|
[34587] | 289 | /* VBoxManageBandwidthControl.cpp */
|
---|
[56118] | 290 | RTEXITCODE handleBandwidthControl(HandlerArg *a);
|
---|
[34587] | 291 |
|
---|
[77883] | 292 | /* VBoxManageCloud.cpp */
|
---|
| 293 | RTEXITCODE handleCloud(HandlerArg *a);
|
---|
| 294 |
|
---|
[91154] | 295 | /* VBoxManageCloudMachine.cpp */
|
---|
| 296 | RTEXITCODE handleCloudMachine(HandlerArg *a, int iFirst,
|
---|
[91157] | 297 | const char *pcszProviderName,
|
---|
| 298 | const char *pcszProfileName);
|
---|
[91154] | 299 | RTEXITCODE listCloudMachines(HandlerArg *a, int iFirst,
|
---|
[91157] | 300 | const char *pcszProviderName,
|
---|
| 301 | const char *pcszProfileName);
|
---|
| 302 | RTEXITCODE handleCloudShowVMInfo(HandlerArg *a, int iFirst,
|
---|
| 303 | const char *pcszProviderName,
|
---|
| 304 | const char *pcszProfileName);
|
---|
[91154] | 305 |
|
---|
[94643] | 306 | #ifdef VBOX_WITH_UPDATE_AGENT
|
---|
[85683] | 307 | /* VBoxManageUpdateCheck.cpp */
|
---|
| 308 | RTEXITCODE handleUpdateCheck(HandlerArg *a);
|
---|
[94643] | 309 | #endif
|
---|
[85683] | 310 |
|
---|
[91432] | 311 | /* VBoxManageModifyNvram.cpp */
|
---|
| 312 | RTEXITCODE handleModifyNvram(HandlerArg *a);
|
---|
| 313 |
|
---|
[76582] | 314 | #endif /* !VBOX_INCLUDED_SRC_VBoxManage_VBoxManage_h */
|
---|