1 | /* $Id: VBoxManage.h 84519 2020-05-25 17:29:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxManage - VirtualBox command-line interface, internal header file.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2020 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 | #ifndef VBOX_ONLY_DOCS
|
---|
25 | #include <VBox/com/com.h>
|
---|
26 | #include <VBox/com/ptr.h>
|
---|
27 | #include <VBox/com/VirtualBox.h>
|
---|
28 | #include <VBox/com/string.h>
|
---|
29 | #include <VBox/com/array.h>
|
---|
30 | #endif /* !VBOX_ONLY_DOCS */
|
---|
31 |
|
---|
32 | #include <iprt/types.h>
|
---|
33 | #include <iprt/message.h>
|
---|
34 | #include <iprt/stream.h>
|
---|
35 | #include <iprt/getopt.h>
|
---|
36 |
|
---|
37 | #ifndef VBOX_ONLY_DOCS
|
---|
38 | # include "VBoxManageBuiltInHelp.h"
|
---|
39 | # include "PasswordInput.h"
|
---|
40 | #endif
|
---|
41 |
|
---|
42 |
|
---|
43 | ////////////////////////////////////////////////////////////////////////////////
|
---|
44 | //
|
---|
45 | // definitions
|
---|
46 | //
|
---|
47 | ////////////////////////////////////////////////////////////////////////////////
|
---|
48 |
|
---|
49 | /** @name Syntax diagram category, i.e. the command.
|
---|
50 | * @{ */
|
---|
51 | typedef enum
|
---|
52 | {
|
---|
53 | USAGE_INVALID = 0,
|
---|
54 | USAGE_LIST,
|
---|
55 | USAGE_SHOWVMINFO,
|
---|
56 | USAGE_REGISTERVM,
|
---|
57 | USAGE_UNREGISTERVM,
|
---|
58 | USAGE_CREATEVM,
|
---|
59 | USAGE_MODIFYVM,
|
---|
60 | USAGE_STARTVM,
|
---|
61 | USAGE_CONTROLVM,
|
---|
62 | USAGE_DISCARDSTATE,
|
---|
63 | USAGE_CLOSEMEDIUM,
|
---|
64 | USAGE_SHOWMEDIUMINFO,
|
---|
65 | USAGE_CREATEMEDIUM,
|
---|
66 | USAGE_MODIFYMEDIUM,
|
---|
67 | USAGE_CLONEMEDIUM,
|
---|
68 | USAGE_MOVEVM,
|
---|
69 | USAGE_CREATEHOSTIF,
|
---|
70 | USAGE_REMOVEHOSTIF,
|
---|
71 | USAGE_GETEXTRADATA,
|
---|
72 | USAGE_SETEXTRADATA,
|
---|
73 | USAGE_SETPROPERTY,
|
---|
74 | USAGE_USBFILTER,
|
---|
75 | USAGE_SHAREDFOLDER,
|
---|
76 | USAGE_I_LOADSYMS,
|
---|
77 | USAGE_I_LOADMAP,
|
---|
78 | USAGE_I_SETHDUUID,
|
---|
79 | USAGE_CONVERTFROMRAW,
|
---|
80 | USAGE_I_LISTPARTITIONS,
|
---|
81 | USAGE_I_CREATERAWVMDK,
|
---|
82 | USAGE_ADOPTSTATE,
|
---|
83 | USAGE_I_MODINSTALL,
|
---|
84 | USAGE_I_MODUNINSTALL,
|
---|
85 | USAGE_I_RENAMEVMDK,
|
---|
86 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
87 | USAGE_GUESTPROPERTY,
|
---|
88 | #endif /* VBOX_WITH_GUEST_PROPS defined */
|
---|
89 | USAGE_I_CONVERTTORAW,
|
---|
90 | USAGE_METRICS,
|
---|
91 | USAGE_I_CONVERTHD,
|
---|
92 | USAGE_IMPORTAPPLIANCE,
|
---|
93 | USAGE_EXPORTAPPLIANCE,
|
---|
94 | USAGE_HOSTONLYIFS,
|
---|
95 | USAGE_I_DUMPHDINFO,
|
---|
96 | USAGE_STORAGEATTACH,
|
---|
97 | USAGE_STORAGECONTROLLER,
|
---|
98 | #ifdef VBOX_WITH_GUEST_CONTROL
|
---|
99 | USAGE_GUESTCONTROL,
|
---|
100 | #endif /* VBOX_WITH_GUEST_CONTROL defined */
|
---|
101 | USAGE_I_DEBUGLOG,
|
---|
102 | USAGE_I_SETHDPARENTUUID,
|
---|
103 | USAGE_I_PASSWORDHASH,
|
---|
104 | USAGE_BANDWIDTHCONTROL,
|
---|
105 | USAGE_I_GUESTSTATS,
|
---|
106 | USAGE_I_REPAIRHD,
|
---|
107 | USAGE_NATNETWORK,
|
---|
108 | USAGE_MEDIUMPROPERTY,
|
---|
109 | USAGE_ENCRYPTMEDIUM,
|
---|
110 | USAGE_MEDIUMENCCHKPWD,
|
---|
111 | USAGE_USBDEVSOURCE,
|
---|
112 | USAGE_CLOUDPROFILE,
|
---|
113 | /* Insert new entries before this line, but only if it is not an option
|
---|
114 | * to go for the new style command and help handling (see e.g. extpack,
|
---|
115 | * unattend or mediumio. */
|
---|
116 | USAGE_S_NEWCMD = 10000, /**< new style command with no old help support */
|
---|
117 | USAGE_S_ALL,
|
---|
118 | USAGE_S_DUMPOPTS
|
---|
119 | } USAGECATEGORY;
|
---|
120 | /** @} */
|
---|
121 |
|
---|
122 |
|
---|
123 | #define HELP_SCOPE_USBFILTER_ADD RT_BIT_64(0)
|
---|
124 | #define HELP_SCOPE_USBFILTER_MODIFY RT_BIT_64(1)
|
---|
125 | #define HELP_SCOPE_USBFILTER_REMOVE RT_BIT_64(2)
|
---|
126 |
|
---|
127 | #define HELP_SCOPE_SHAREDFOLDER_ADD RT_BIT_64(0)
|
---|
128 | #define HELP_SCOPE_SHAREDFOLDER_REMOVE RT_BIT_64(1)
|
---|
129 |
|
---|
130 | #ifdef VBOX_WITH_GUEST_CONTROL
|
---|
131 | # define HELP_SCOPE_GSTCTRL_RUN RT_BIT(0)
|
---|
132 | # define HELP_SCOPE_GSTCTRL_START RT_BIT(1)
|
---|
133 | # define HELP_SCOPE_GSTCTRL_COPYFROM RT_BIT(2)
|
---|
134 | # define HELP_SCOPE_GSTCTRL_COPYTO RT_BIT(3)
|
---|
135 | # define HELP_SCOPE_GSTCTRL_MKDIR RT_BIT(4)
|
---|
136 | # define HELP_SCOPE_GSTCTRL_RMDIR RT_BIT(5)
|
---|
137 | # define HELP_SCOPE_GSTCTRL_RM RT_BIT(6)
|
---|
138 | # define HELP_SCOPE_GSTCTRL_MV RT_BIT(7)
|
---|
139 | # define HELP_SCOPE_GSTCTRL_MKTEMP RT_BIT(8)
|
---|
140 | # define HELP_SCOPE_GSTCTRL_LIST RT_BIT(9)
|
---|
141 | # define HELP_SCOPE_GSTCTRL_CLOSEPROCESS RT_BIT(10)
|
---|
142 | # define HELP_SCOPE_GSTCTRL_CLOSESESSION RT_BIT(11)
|
---|
143 | # define HELP_SCOPE_GSTCTRL_STAT RT_BIT(12)
|
---|
144 | # define HELP_SCOPE_GSTCTRL_UPDATEGA RT_BIT(13)
|
---|
145 | # define HELP_SCOPE_GSTCTRL_WATCH RT_BIT(14)
|
---|
146 | # define HELP_SCOPE_GSTCTRL_WAITRUNLEVEL RT_BIT(15)
|
---|
147 | #endif
|
---|
148 |
|
---|
149 | /** command handler argument */
|
---|
150 | struct HandlerArg
|
---|
151 | {
|
---|
152 | int argc;
|
---|
153 | char **argv;
|
---|
154 |
|
---|
155 | #ifndef VBOX_ONLY_DOCS
|
---|
156 | ComPtr<IVirtualBox> virtualBox;
|
---|
157 | ComPtr<ISession> session;
|
---|
158 | #endif
|
---|
159 | };
|
---|
160 |
|
---|
161 | /** flag whether we're in internal mode */
|
---|
162 | extern bool g_fInternalMode;
|
---|
163 |
|
---|
164 | /** showVMInfo details */
|
---|
165 | typedef enum
|
---|
166 | {
|
---|
167 | VMINFO_NONE = 0,
|
---|
168 | VMINFO_STANDARD = 1, /**< standard details */
|
---|
169 | VMINFO_FULL = 2, /**< both */
|
---|
170 | VMINFO_MACHINEREADABLE = 3, /**< both, and make it machine readable */
|
---|
171 | VMINFO_COMPACT = 4
|
---|
172 | } VMINFO_DETAILS;
|
---|
173 |
|
---|
174 |
|
---|
175 | ////////////////////////////////////////////////////////////////////////////////
|
---|
176 | //
|
---|
177 | // global variables
|
---|
178 | //
|
---|
179 | ////////////////////////////////////////////////////////////////////////////////
|
---|
180 |
|
---|
181 | extern bool g_fDetailedProgress; // in VBoxManage.cpp
|
---|
182 |
|
---|
183 |
|
---|
184 | ////////////////////////////////////////////////////////////////////////////////
|
---|
185 | //
|
---|
186 | // prototypes
|
---|
187 | //
|
---|
188 | ////////////////////////////////////////////////////////////////////////////////
|
---|
189 |
|
---|
190 | /* VBoxManageHelp.cpp */
|
---|
191 |
|
---|
192 | /* Legacy help infrastructure, to be replaced by new one using generated help. */
|
---|
193 | void printUsage(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, PRTSTREAM pStrm);
|
---|
194 | RTEXITCODE errorSyntax(USAGECATEGORY enmCommand, const char *pszFormat, ...);
|
---|
195 | RTEXITCODE errorSyntaxEx(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, const char *pszFormat, ...);
|
---|
196 | RTEXITCODE errorGetOpt(USAGECATEGORY enmCommand, int rc, union RTGETOPTUNION const *pValueUnion);
|
---|
197 | RTEXITCODE errorGetOptEx(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, int rc, union RTGETOPTUNION const *pValueUnion);
|
---|
198 | RTEXITCODE errorArgument(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
199 |
|
---|
200 | void printUsageInternal(USAGECATEGORY enmCommand, PRTSTREAM pStrm);
|
---|
201 |
|
---|
202 | #ifndef VBOX_ONLY_DOCS
|
---|
203 | void setCurrentCommand(enum HELP_CMD_VBOXMANAGE enmCommand);
|
---|
204 | void setCurrentSubcommand(uint64_t fCurSubcommandScope);
|
---|
205 |
|
---|
206 | void printUsage(PRTSTREAM pStrm);
|
---|
207 | void printHelp(PRTSTREAM pStrm);
|
---|
208 | RTEXITCODE errorNoSubcommand(void);
|
---|
209 | RTEXITCODE errorUnknownSubcommand(const char *pszSubCmd);
|
---|
210 | RTEXITCODE errorTooManyParameters(char **papszArgs);
|
---|
211 | RTEXITCODE errorGetOpt(int rcGetOpt, union RTGETOPTUNION const *pValueUnion);
|
---|
212 | RTEXITCODE errorFetchValue(int iValueNo, const char *pszOption, int rcGetOptFetchValue, union RTGETOPTUNION const *pValueUnion);
|
---|
213 | RTEXITCODE errorSyntax(const char *pszFormat, ...);
|
---|
214 |
|
---|
215 | HRESULT showProgress(ComPtr<IProgress> progress);
|
---|
216 | #endif
|
---|
217 |
|
---|
218 | /* VBoxManage.cpp */
|
---|
219 | void showLogo(PRTSTREAM pStrm);
|
---|
220 |
|
---|
221 | #ifndef VBOX_ONLY_DOCS
|
---|
222 | RTEXITCODE handleInternalCommands(HandlerArg *a);
|
---|
223 | #endif /* !VBOX_ONLY_DOCS */
|
---|
224 |
|
---|
225 | /* VBoxManageControlVM.cpp */
|
---|
226 | RTEXITCODE handleControlVM(HandlerArg *a);
|
---|
227 | #ifndef VBOX_ONLY_DOCS
|
---|
228 | unsigned int getMaxNics(IVirtualBox* vbox, IMachine* mach);
|
---|
229 | #endif
|
---|
230 |
|
---|
231 | /* VBoxManageModifyVM.cpp */
|
---|
232 | #ifndef VBOX_ONLY_DOCS
|
---|
233 | void parseGroups(const char *pcszGroups, com::SafeArray<BSTR> *pGroups);
|
---|
234 | #endif
|
---|
235 | RTEXITCODE handleModifyVM(HandlerArg *a);
|
---|
236 |
|
---|
237 | /* VBoxManageDebugVM.cpp */
|
---|
238 | RTEXITCODE handleDebugVM(HandlerArg *a);
|
---|
239 |
|
---|
240 | /* VBoxManageGuestProp.cpp */
|
---|
241 | extern void usageGuestProperty(PRTSTREAM pStrm, const char *pcszSep1, const char *pcszSep2);
|
---|
242 |
|
---|
243 | /* VBoxManageGuestCtrl.cpp */
|
---|
244 | extern void usageGuestControl(PRTSTREAM pStrm, const char *pcszSep1, const char *pcszSep2, uint64_t fSubcommandScope);
|
---|
245 |
|
---|
246 | #ifndef VBOX_ONLY_DOCS
|
---|
247 | /* VBoxManageGuestProp.cpp */
|
---|
248 | RTEXITCODE handleGuestProperty(HandlerArg *a);
|
---|
249 |
|
---|
250 | /* VBoxManageGuestCtrl.cpp */
|
---|
251 | RTEXITCODE handleGuestControl(HandlerArg *a);
|
---|
252 |
|
---|
253 | /* VBoxManageVMInfo.cpp */
|
---|
254 | HRESULT showSnapshots(ComPtr<ISnapshot> &rootSnapshot,
|
---|
255 | ComPtr<ISnapshot> ¤tSnapshot,
|
---|
256 | VMINFO_DETAILS details,
|
---|
257 | const com::Utf8Str &prefix = "",
|
---|
258 | int level = 0);
|
---|
259 | RTEXITCODE handleShowVMInfo(HandlerArg *a);
|
---|
260 | HRESULT showVMInfo(ComPtr<IVirtualBox> pVirtualBox,
|
---|
261 | ComPtr<IMachine> pMachine,
|
---|
262 | ComPtr<ISession> pSession,
|
---|
263 | VMINFO_DETAILS details = VMINFO_NONE);
|
---|
264 | const char *machineStateToName(MachineState_T machineState, bool fShort);
|
---|
265 | HRESULT showBandwidthGroups(ComPtr<IBandwidthControl> &bwCtrl,
|
---|
266 | VMINFO_DETAILS details);
|
---|
267 |
|
---|
268 | /* VBoxManageList.cpp */
|
---|
269 | RTEXITCODE handleList(HandlerArg *a);
|
---|
270 |
|
---|
271 | /* VBoxManageMetrics.cpp */
|
---|
272 | RTEXITCODE handleMetrics(HandlerArg *a);
|
---|
273 |
|
---|
274 | /* VBoxManageMisc.cpp */
|
---|
275 | RTEXITCODE handleRegisterVM(HandlerArg *a);
|
---|
276 | RTEXITCODE handleUnregisterVM(HandlerArg *a);
|
---|
277 | RTEXITCODE handleCreateVM(HandlerArg *a);
|
---|
278 | RTEXITCODE handleCloneVM(HandlerArg *a);
|
---|
279 | RTEXITCODE handleStartVM(HandlerArg *a);
|
---|
280 | RTEXITCODE handleDiscardState(HandlerArg *a);
|
---|
281 | RTEXITCODE handleAdoptState(HandlerArg *a);
|
---|
282 | RTEXITCODE handleGetExtraData(HandlerArg *a);
|
---|
283 | RTEXITCODE handleSetExtraData(HandlerArg *a);
|
---|
284 | RTEXITCODE handleSetProperty(HandlerArg *a);
|
---|
285 | RTEXITCODE handleSharedFolder(HandlerArg *a);
|
---|
286 | RTEXITCODE handleExtPack(HandlerArg *a);
|
---|
287 | RTEXITCODE handleUnattended(HandlerArg *a);
|
---|
288 | RTEXITCODE handleMoveVM(HandlerArg *a);
|
---|
289 | RTEXITCODE handleCloudProfile(HandlerArg *a);
|
---|
290 |
|
---|
291 | /* VBoxManageDisk.cpp */
|
---|
292 | HRESULT openMedium(HandlerArg *a, const char *pszFilenameOrUuid,
|
---|
293 | DeviceType_T enmDevType, AccessMode_T enmAccessMode,
|
---|
294 | ComPtr<IMedium> &pMedium, bool fForceNewUuidOnOpen,
|
---|
295 | bool fSilent);
|
---|
296 | RTEXITCODE handleCreateMedium(HandlerArg *a);
|
---|
297 | RTEXITCODE handleModifyMedium(HandlerArg *a);
|
---|
298 | RTEXITCODE handleCloneMedium(HandlerArg *a);
|
---|
299 | RTEXITCODE handleMediumProperty(HandlerArg *a);
|
---|
300 | RTEXITCODE handleEncryptMedium(HandlerArg *a);
|
---|
301 | RTEXITCODE handleCheckMediumPassword(HandlerArg *a);
|
---|
302 | RTEXITCODE handleConvertFromRaw(HandlerArg *a);
|
---|
303 | HRESULT showMediumInfo(const ComPtr<IVirtualBox> &pVirtualBox,
|
---|
304 | const ComPtr<IMedium> &pMedium,
|
---|
305 | const char *pszParentUUID,
|
---|
306 | bool fOptLong);
|
---|
307 | RTEXITCODE handleShowMediumInfo(HandlerArg *a);
|
---|
308 | RTEXITCODE handleCloseMedium(HandlerArg *a);
|
---|
309 | RTEXITCODE handleMediumIO(HandlerArg *a);
|
---|
310 | int parseMediumType(const char *psz, MediumType_T *penmMediumType);
|
---|
311 | int parseBool(const char *psz, bool *pb);
|
---|
312 |
|
---|
313 | /* VBoxManageStorageController.cpp */
|
---|
314 | RTEXITCODE handleStorageAttach(HandlerArg *a);
|
---|
315 | RTEXITCODE handleStorageController(HandlerArg *a);
|
---|
316 |
|
---|
317 | // VBoxManageAppliance.cpp
|
---|
318 | RTEXITCODE handleImportAppliance(HandlerArg *a);
|
---|
319 | RTEXITCODE handleExportAppliance(HandlerArg *a);
|
---|
320 | RTEXITCODE handleSignAppliance(HandlerArg *a);
|
---|
321 |
|
---|
322 | // VBoxManageSnapshot.cpp
|
---|
323 | RTEXITCODE handleSnapshot(HandlerArg *a);
|
---|
324 |
|
---|
325 | /* VBoxManageUSB.cpp */
|
---|
326 | RTEXITCODE handleUSBFilter(HandlerArg *a);
|
---|
327 | RTEXITCODE handleUSBDevSource(HandlerArg *a);
|
---|
328 |
|
---|
329 | /* VBoxManageHostonly.cpp */
|
---|
330 | RTEXITCODE handleHostonlyIf(HandlerArg *a);
|
---|
331 |
|
---|
332 | /* VBoxManageDHCPServer.cpp */
|
---|
333 | RTEXITCODE handleDHCPServer(HandlerArg *a);
|
---|
334 |
|
---|
335 | /* VBoxManageNATNetwork.cpp */
|
---|
336 | RTEXITCODE handleNATNetwork(HandlerArg *a);
|
---|
337 |
|
---|
338 |
|
---|
339 | /* VBoxManageBandwidthControl.cpp */
|
---|
340 | RTEXITCODE handleBandwidthControl(HandlerArg *a);
|
---|
341 |
|
---|
342 | /* VBoxManageCloud.cpp */
|
---|
343 | RTEXITCODE handleCloud(HandlerArg *a);
|
---|
344 |
|
---|
345 | #endif /* !VBOX_ONLY_DOCS */
|
---|
346 |
|
---|
347 | #endif /* !VBOX_INCLUDED_SRC_VBoxManage_VBoxManage_h */
|
---|