1 | /* $Id: VBoxManage.h 94660 2022-04-21 08:38:34Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxManage - VirtualBox command-line interface, internal header file.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2022 Oracle Corporation
|
---|
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 |
|
---|
18 | #ifndef VBOX_INCLUDED_SRC_VBoxManage_VBoxManage_h
|
---|
19 | #define VBOX_INCLUDED_SRC_VBoxManage_VBoxManage_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include <VBox/com/com.h>
|
---|
25 | #include <VBox/com/ptr.h>
|
---|
26 | #include <VBox/com/VirtualBox.h>
|
---|
27 | #include <VBox/com/string.h>
|
---|
28 | #include <VBox/com/array.h>
|
---|
29 |
|
---|
30 | #include <iprt/types.h>
|
---|
31 | #include <iprt/message.h>
|
---|
32 | #include <iprt/stream.h>
|
---|
33 | #include <iprt/getopt.h>
|
---|
34 |
|
---|
35 | #include "VBoxManageBuiltInHelp.h"
|
---|
36 | #include "PasswordInput.h"
|
---|
37 |
|
---|
38 | #ifdef VBOX_WITH_VBOXMANAGE_NLS
|
---|
39 | # include "VirtualBoxTranslator.h"
|
---|
40 | #endif
|
---|
41 |
|
---|
42 |
|
---|
43 | ////////////////////////////////////////////////////////////////////////////////
|
---|
44 | //
|
---|
45 | // definitions
|
---|
46 | //
|
---|
47 | ////////////////////////////////////////////////////////////////////////////////
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * This defines a a_CtxName::tr function that gives the translator context as
|
---|
51 | * well as providing a shorter way to call VirtualBoxTranslator::translate.
|
---|
52 | */
|
---|
53 | #ifdef VBOX_WITH_VBOXMANAGE_NLS
|
---|
54 | # define DECLARE_TRANSLATION_CONTEXT(a_CtxName) \
|
---|
55 | struct a_CtxName \
|
---|
56 | { \
|
---|
57 | static const char *tr(const char *pszSource, const char *pszComment = NULL, const size_t uNum = ~(size_t)0) \
|
---|
58 | { \
|
---|
59 | return VirtualBoxTranslator::translate(NULL, #a_CtxName, pszSource, pszComment, uNum); \
|
---|
60 | } \
|
---|
61 | }
|
---|
62 | #else
|
---|
63 | # define DECLARE_TRANSLATION_CONTEXT(a_CtxName) \
|
---|
64 | struct a_CtxName \
|
---|
65 | { \
|
---|
66 | static const char *tr(const char *pszSource, const char *pszComment = NULL, const size_t uNum = ~(size_t)0) \
|
---|
67 | { \
|
---|
68 | RT_NOREF(pszComment, uNum); \
|
---|
69 | return pszSource; \
|
---|
70 | } \
|
---|
71 | }
|
---|
72 | #endif
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * Defines an option with two variants, producing two RTGETOPTDEF entries.
|
---|
76 | *
|
---|
77 | * This is mainly for replacing character-soup option names like
|
---|
78 | * --natlocalhostreachable and --biossystemtimeoffset with more easily parsed
|
---|
79 | * ones, like --nat-localhost-reachable and --bios-system-time-offset, without
|
---|
80 | * removing the legacy name.
|
---|
81 | */
|
---|
82 | #define OPT2(a_pszWordDashWord, a_pszWordSoup, a_chOptOrValue, a_fFlags) \
|
---|
83 | { a_pszWordDashWord, a_chOptOrValue, a_fFlags }, \
|
---|
84 | { a_pszWordSoup, a_chOptOrValue, a_fFlags }
|
---|
85 |
|
---|
86 | /** A single option variant of OPT2 for better looking tables. */
|
---|
87 | #define OPT1(a_pszOption, a_chOptOrValue, a_fFlags) \
|
---|
88 | { a_pszOption, a_chOptOrValue, a_fFlags }
|
---|
89 |
|
---|
90 |
|
---|
91 | /** command handler argument */
|
---|
92 | struct HandlerArg
|
---|
93 | {
|
---|
94 | int argc;
|
---|
95 | char **argv;
|
---|
96 |
|
---|
97 | ComPtr<IVirtualBox> virtualBox;
|
---|
98 | ComPtr<ISession> session;
|
---|
99 | };
|
---|
100 |
|
---|
101 |
|
---|
102 | /** showVMInfo details */
|
---|
103 | typedef enum
|
---|
104 | {
|
---|
105 | VMINFO_NONE = 0,
|
---|
106 | VMINFO_STANDARD = 1, /**< standard details */
|
---|
107 | VMINFO_FULL = 2, /**< both */
|
---|
108 | VMINFO_MACHINEREADABLE = 3, /**< both, and make it machine readable */
|
---|
109 | VMINFO_COMPACT = 4
|
---|
110 | } VMINFO_DETAILS;
|
---|
111 |
|
---|
112 |
|
---|
113 | ////////////////////////////////////////////////////////////////////////////////
|
---|
114 | //
|
---|
115 | // global variables
|
---|
116 | //
|
---|
117 | ////////////////////////////////////////////////////////////////////////////////
|
---|
118 |
|
---|
119 | extern bool g_fDetailedProgress; // in VBoxManage.cpp
|
---|
120 |
|
---|
121 |
|
---|
122 | ////////////////////////////////////////////////////////////////////////////////
|
---|
123 | //
|
---|
124 | // prototypes
|
---|
125 | //
|
---|
126 | ////////////////////////////////////////////////////////////////////////////////
|
---|
127 |
|
---|
128 | /* VBoxManageHelp.cpp */
|
---|
129 | void setCurrentCommand(enum HELP_CMD_VBOXMANAGE enmCommand);
|
---|
130 | void setCurrentSubcommand(uint64_t fCurSubcommandScope);
|
---|
131 |
|
---|
132 | void printUsage(PRTSTREAM pStrm);
|
---|
133 | void printHelp(PRTSTREAM pStrm);
|
---|
134 | RTEXITCODE errorNoSubcommand(void);
|
---|
135 | RTEXITCODE errorUnknownSubcommand(const char *pszSubCmd);
|
---|
136 | RTEXITCODE errorTooManyParameters(char **papszArgs);
|
---|
137 | RTEXITCODE errorGetOpt(int rcGetOpt, union RTGETOPTUNION const *pValueUnion);
|
---|
138 | RTEXITCODE errorFetchValue(int iValueNo, const char *pszOption, int rcGetOptFetchValue, union RTGETOPTUNION const *pValueUnion);
|
---|
139 | RTEXITCODE errorSyntax(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
140 | RTEXITCODE errorSyntaxV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
|
---|
141 | HRESULT errorSyntaxHr(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
142 | RTEXITCODE errorArgument(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
143 | HRESULT errorArgumentHr(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
144 |
|
---|
145 | # define SHOW_PROGRESS_NONE 0
|
---|
146 | # define SHOW_PROGRESS_DESC RT_BIT_32(0)
|
---|
147 | # define SHOW_PROGRESS RT_BIT_32(1)
|
---|
148 | # define SHOW_PROGRESS_DETAILS RT_BIT_32(2)
|
---|
149 | HRESULT showProgress(ComPtr<IProgress> progress, uint32_t fFlags = SHOW_PROGRESS);
|
---|
150 |
|
---|
151 | /* VBoxManage.cpp */
|
---|
152 | void showLogo(PRTSTREAM pStrm);
|
---|
153 |
|
---|
154 | /* VBoxInternalManage.cpp */
|
---|
155 | DECLHIDDEN(void) printUsageInternalCmds(PRTSTREAM pStrm);
|
---|
156 | RTEXITCODE handleInternalCommands(HandlerArg *a);
|
---|
157 |
|
---|
158 | /* VBoxManageControlVM.cpp */
|
---|
159 | RTEXITCODE handleControlVM(HandlerArg *a);
|
---|
160 |
|
---|
161 | /* VBoxManageModifyVM.cpp */
|
---|
162 | void parseGroups(const char *pcszGroups, com::SafeArray<BSTR> *pGroups);
|
---|
163 | #ifdef VBOX_WITH_RECORDING
|
---|
164 | int parseScreens(const char *pcszScreens, com::SafeArray<BOOL> *pScreens);
|
---|
165 | #endif
|
---|
166 | RTEXITCODE handleModifyVM(HandlerArg *a);
|
---|
167 |
|
---|
168 | /* VBoxManageDebugVM.cpp */
|
---|
169 | RTEXITCODE handleDebugVM(HandlerArg *a);
|
---|
170 |
|
---|
171 | /* VBoxManageGuestProp.cpp */
|
---|
172 | RTEXITCODE handleGuestProperty(HandlerArg *a);
|
---|
173 |
|
---|
174 | /* VBoxManageGuestCtrl.cpp */
|
---|
175 | RTEXITCODE handleGuestControl(HandlerArg *a);
|
---|
176 |
|
---|
177 | /* VBoxManageVMInfo.cpp */
|
---|
178 | HRESULT showSnapshots(ComPtr<ISnapshot> &rootSnapshot,
|
---|
179 | ComPtr<ISnapshot> ¤tSnapshot,
|
---|
180 | VMINFO_DETAILS details,
|
---|
181 | const com::Utf8Str &prefix = "",
|
---|
182 | int level = 0);
|
---|
183 | RTEXITCODE handleShowVMInfo(HandlerArg *a);
|
---|
184 | HRESULT showVMInfo(ComPtr<IVirtualBox> pVirtualBox,
|
---|
185 | ComPtr<IMachine> pMachine,
|
---|
186 | ComPtr<ISession> pSession,
|
---|
187 | VMINFO_DETAILS details = VMINFO_NONE);
|
---|
188 | const char *machineStateToName(MachineState_T machineState, bool fShort);
|
---|
189 | HRESULT showBandwidthGroups(ComPtr<IBandwidthControl> &bwCtrl,
|
---|
190 | VMINFO_DETAILS details);
|
---|
191 | void outputMachineReadableString(const char *pszName, const char *pszValue, bool fQuoteName = false, bool fNewline = true);
|
---|
192 | void outputMachineReadableString(const char *pszName, com::Bstr const *pbstrValue, bool fQuoteName = false, bool fNewline = true);
|
---|
193 | void outputMachineReadableStringWithFmtName(const char *pszValue, bool fQuoteName, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(3, 4);
|
---|
194 | void outputMachineReadableStringWithFmtName(com::Bstr const *pbstrValue, bool fQuoteName, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(3, 4);
|
---|
195 | void outputMachineReadableBool(const char *pszName, BOOL const *pfValue);
|
---|
196 | void outputMachineReadableBool(const char *pszName, bool const *pfValue);
|
---|
197 | void outputMachineReadableULong(const char *pszName, ULONG *uValue);
|
---|
198 | void outputMachineReadableLong64(const char *pszName, LONG64 *uValue);
|
---|
199 |
|
---|
200 | /* VBoxManageList.cpp */
|
---|
201 | RTEXITCODE handleList(HandlerArg *a);
|
---|
202 |
|
---|
203 | /* VBoxManageMetrics.cpp */
|
---|
204 | RTEXITCODE handleMetrics(HandlerArg *a);
|
---|
205 |
|
---|
206 | /* VBoxManageMisc.cpp */
|
---|
207 | RTEXITCODE handleRegisterVM(HandlerArg *a);
|
---|
208 | RTEXITCODE handleUnregisterVM(HandlerArg *a);
|
---|
209 | RTEXITCODE handleCreateVM(HandlerArg *a);
|
---|
210 | RTEXITCODE handleCloneVM(HandlerArg *a);
|
---|
211 | RTEXITCODE handleStartVM(HandlerArg *a);
|
---|
212 | #ifdef VBOX_WITH_FULL_VM_ENCRYPTION
|
---|
213 | RTEXITCODE handleEncryptVM(HandlerArg *a);
|
---|
214 | #endif
|
---|
215 | RTEXITCODE handleDiscardState(HandlerArg *a);
|
---|
216 | RTEXITCODE handleAdoptState(HandlerArg *a);
|
---|
217 | RTEXITCODE handleGetExtraData(HandlerArg *a);
|
---|
218 | RTEXITCODE handleSetExtraData(HandlerArg *a);
|
---|
219 | RTEXITCODE handleSetProperty(HandlerArg *a);
|
---|
220 | RTEXITCODE handleSharedFolder(HandlerArg *a);
|
---|
221 | RTEXITCODE handleExtPack(HandlerArg *a);
|
---|
222 | RTEXITCODE handleUnattended(HandlerArg *a);
|
---|
223 | RTEXITCODE handleMoveVM(HandlerArg *a);
|
---|
224 | RTEXITCODE handleCloudProfile(HandlerArg *a);
|
---|
225 |
|
---|
226 | /* VBoxManageDisk.cpp */
|
---|
227 | HRESULT openMedium(HandlerArg *a, const char *pszFilenameOrUuid,
|
---|
228 | DeviceType_T enmDevType, AccessMode_T enmAccessMode,
|
---|
229 | ComPtr<IMedium> &pMedium, bool fForceNewUuidOnOpen,
|
---|
230 | bool fSilent);
|
---|
231 | RTEXITCODE handleCreateMedium(HandlerArg *a);
|
---|
232 | RTEXITCODE handleModifyMedium(HandlerArg *a);
|
---|
233 | RTEXITCODE handleCloneMedium(HandlerArg *a);
|
---|
234 | RTEXITCODE handleMediumProperty(HandlerArg *a);
|
---|
235 | RTEXITCODE handleEncryptMedium(HandlerArg *a);
|
---|
236 | RTEXITCODE handleCheckMediumPassword(HandlerArg *a);
|
---|
237 | RTEXITCODE handleConvertFromRaw(HandlerArg *a);
|
---|
238 | HRESULT showMediumInfo(const ComPtr<IVirtualBox> &pVirtualBox,
|
---|
239 | const ComPtr<IMedium> &pMedium,
|
---|
240 | const char *pszParentUUID,
|
---|
241 | bool fOptLong);
|
---|
242 | RTEXITCODE handleShowMediumInfo(HandlerArg *a);
|
---|
243 | RTEXITCODE handleCloseMedium(HandlerArg *a);
|
---|
244 | RTEXITCODE handleMediumIO(HandlerArg *a);
|
---|
245 | int parseMediumType(const char *psz, MediumType_T *penmMediumType);
|
---|
246 | int parseBool(const char *psz, bool *pb);
|
---|
247 |
|
---|
248 | /* VBoxManageStorageController.cpp */
|
---|
249 | RTEXITCODE handleStorageAttach(HandlerArg *a);
|
---|
250 | RTEXITCODE handleStorageController(HandlerArg *a);
|
---|
251 |
|
---|
252 | // VBoxManageAppliance.cpp
|
---|
253 | RTEXITCODE handleImportAppliance(HandlerArg *a);
|
---|
254 | RTEXITCODE handleExportAppliance(HandlerArg *a);
|
---|
255 | RTEXITCODE handleSignAppliance(HandlerArg *a);
|
---|
256 |
|
---|
257 | // VBoxManageSnapshot.cpp
|
---|
258 | RTEXITCODE handleSnapshot(HandlerArg *a);
|
---|
259 |
|
---|
260 | /* VBoxManageUSB.cpp */
|
---|
261 | RTEXITCODE handleUSBFilter(HandlerArg *a);
|
---|
262 | RTEXITCODE handleUSBDevSource(HandlerArg *a);
|
---|
263 |
|
---|
264 | /* VBoxManageHostonly.cpp */
|
---|
265 | RTEXITCODE handleHostonlyIf(HandlerArg *a);
|
---|
266 | #ifdef VBOX_WITH_VMNET
|
---|
267 | RTEXITCODE handleHostonlyNet(HandlerArg *a);
|
---|
268 | #endif /* VBOX_WITH_VMNET */
|
---|
269 |
|
---|
270 | /* VBoxManageDHCPServer.cpp */
|
---|
271 | RTEXITCODE handleDHCPServer(HandlerArg *a);
|
---|
272 |
|
---|
273 | /* VBoxManageNATNetwork.cpp */
|
---|
274 | RTEXITCODE handleNATNetwork(HandlerArg *a);
|
---|
275 | RTEXITCODE listNATNetworks(bool fLong, bool fSorted,
|
---|
276 | const ComPtr<IVirtualBox> &pVirtualBox);
|
---|
277 |
|
---|
278 | /* VBoxManageBandwidthControl.cpp */
|
---|
279 | RTEXITCODE handleBandwidthControl(HandlerArg *a);
|
---|
280 |
|
---|
281 | /* VBoxManageCloud.cpp */
|
---|
282 | RTEXITCODE handleCloud(HandlerArg *a);
|
---|
283 |
|
---|
284 | /* VBoxManageCloudMachine.cpp */
|
---|
285 | RTEXITCODE handleCloudMachine(HandlerArg *a, int iFirst,
|
---|
286 | const char *pcszProviderName,
|
---|
287 | const char *pcszProfileName);
|
---|
288 | RTEXITCODE listCloudMachines(HandlerArg *a, int iFirst,
|
---|
289 | const char *pcszProviderName,
|
---|
290 | const char *pcszProfileName);
|
---|
291 | RTEXITCODE handleCloudShowVMInfo(HandlerArg *a, int iFirst,
|
---|
292 | const char *pcszProviderName,
|
---|
293 | const char *pcszProfileName);
|
---|
294 |
|
---|
295 | #ifdef VBOX_WITH_UPDATE_AGENT
|
---|
296 | /* VBoxManageUpdateCheck.cpp */
|
---|
297 | RTEXITCODE handleUpdateCheck(HandlerArg *a);
|
---|
298 | #endif
|
---|
299 |
|
---|
300 | /* VBoxManageModifyNvram.cpp */
|
---|
301 | RTEXITCODE handleModifyNvram(HandlerArg *a);
|
---|
302 |
|
---|
303 | #endif /* !VBOX_INCLUDED_SRC_VBoxManage_VBoxManage_h */
|
---|