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