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