1 | /* $Id: VBoxManage.h 49621 2013-11-22 11:15:41Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxManage - VirtualBox command-line interface, internal header file.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2013 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 ___H_VBOXMANAGE
|
---|
19 | #define ___H_VBOXMANAGE
|
---|
20 |
|
---|
21 | #ifndef VBOX_ONLY_DOCS
|
---|
22 | #include <VBox/com/com.h>
|
---|
23 | #include <VBox/com/ptr.h>
|
---|
24 | #include <VBox/com/VirtualBox.h>
|
---|
25 | #include <VBox/com/string.h>
|
---|
26 | #include <VBox/com/array.h>
|
---|
27 | #endif /* !VBOX_ONLY_DOCS */
|
---|
28 |
|
---|
29 | #include <iprt/types.h>
|
---|
30 | #include <iprt/message.h>
|
---|
31 | #include <iprt/stream.h>
|
---|
32 | #include <iprt/getopt.h>
|
---|
33 |
|
---|
34 | ////////////////////////////////////////////////////////////////////////////////
|
---|
35 | //
|
---|
36 | // definitions
|
---|
37 | //
|
---|
38 | ////////////////////////////////////////////////////////////////////////////////
|
---|
39 |
|
---|
40 | /** @name Syntax diagram category.
|
---|
41 | * @{ */
|
---|
42 | #define USAGE_DUMPOPTS 0
|
---|
43 | #define USAGE_LIST RT_BIT_64(0)
|
---|
44 | #define USAGE_SHOWVMINFO RT_BIT_64(1)
|
---|
45 | #define USAGE_REGISTERVM RT_BIT_64(2)
|
---|
46 | #define USAGE_UNREGISTERVM RT_BIT_64(3)
|
---|
47 | #define USAGE_CREATEVM RT_BIT_64(4)
|
---|
48 | #define USAGE_MODIFYVM RT_BIT_64(5)
|
---|
49 | #define USAGE_CLONEVM RT_BIT_64(6)
|
---|
50 | #define USAGE_STARTVM RT_BIT_64(7)
|
---|
51 | #define USAGE_CONTROLVM RT_BIT_64(8)
|
---|
52 | #define USAGE_DISCARDSTATE RT_BIT_64(9)
|
---|
53 | #define USAGE_SNAPSHOT RT_BIT_64(10)
|
---|
54 | #define USAGE_CLOSEMEDIUM RT_BIT_64(11)
|
---|
55 | #define USAGE_SHOWHDINFO RT_BIT_64(12)
|
---|
56 | #define USAGE_CREATEHD RT_BIT_64(13)
|
---|
57 | #define USAGE_MODIFYHD RT_BIT_64(14)
|
---|
58 | #define USAGE_CLONEHD RT_BIT_64(15)
|
---|
59 | #define USAGE_CREATEHOSTIF RT_BIT_64(17)
|
---|
60 | #define USAGE_REMOVEHOSTIF RT_BIT_64(18)
|
---|
61 | #define USAGE_GETEXTRADATA RT_BIT_64(19)
|
---|
62 | #define USAGE_SETEXTRADATA RT_BIT_64(20)
|
---|
63 | #define USAGE_SETPROPERTY RT_BIT_64(21)
|
---|
64 | #define USAGE_USBFILTER (RT_BIT_64(22) | RT_BIT_64(23) | RT_BIT_64(24))
|
---|
65 | #define USAGE_USBFILTER_ADD RT_BIT_64(22)
|
---|
66 | #define USAGE_USBFILTER_MODIFY RT_BIT_64(23)
|
---|
67 | #define USAGE_USBFILTER_REMOVE RT_BIT_64(24)
|
---|
68 | #define USAGE_SHAREDFOLDER (RT_BIT_64(25) | RT_BIT_64(26))
|
---|
69 | #define USAGE_SHAREDFOLDER_ADD RT_BIT_64(25)
|
---|
70 | #define USAGE_SHAREDFOLDER_REMOVE RT_BIT_64(26)
|
---|
71 | #define USAGE_LOADSYMS RT_BIT_64(29)
|
---|
72 | #define USAGE_LOADMAP RT_BIT_64(30)
|
---|
73 | #define USAGE_SETHDUUID RT_BIT_64(31)
|
---|
74 | #define USAGE_CONVERTFROMRAW RT_BIT_64(32)
|
---|
75 | #define USAGE_LISTPARTITIONS RT_BIT_64(33)
|
---|
76 | #define USAGE_CREATERAWVMDK RT_BIT_64(34)
|
---|
77 | #define USAGE_DEBUGVM RT_BIT_64(35)
|
---|
78 | #define USAGE_ADOPTSTATE RT_BIT_64(36)
|
---|
79 | #define USAGE_MODINSTALL RT_BIT_64(37)
|
---|
80 | #define USAGE_MODUNINSTALL RT_BIT_64(38)
|
---|
81 | #define USAGE_RENAMEVMDK RT_BIT_64(39)
|
---|
82 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
83 | # define USAGE_GUESTPROPERTY RT_BIT_64(40)
|
---|
84 | #endif /* VBOX_WITH_GUEST_PROPS defined */
|
---|
85 | #define USAGE_CONVERTTORAW RT_BIT_64(41)
|
---|
86 | #define USAGE_METRICS RT_BIT_64(42)
|
---|
87 | #define USAGE_CONVERTHD RT_BIT_64(43)
|
---|
88 | #define USAGE_IMPORTAPPLIANCE RT_BIT_64(44)
|
---|
89 | #define USAGE_EXPORTAPPLIANCE RT_BIT_64(45)
|
---|
90 | #define USAGE_HOSTONLYIFS RT_BIT_64(46)
|
---|
91 | #define USAGE_DHCPSERVER RT_BIT_64(47)
|
---|
92 | #define USAGE_DUMPHDINFO RT_BIT_64(48)
|
---|
93 | #define USAGE_STORAGEATTACH RT_BIT_64(49)
|
---|
94 | #define USAGE_STORAGECONTROLLER RT_BIT_64(50)
|
---|
95 | #ifdef VBOX_WITH_GUEST_CONTROL
|
---|
96 | # define USAGE_GUESTCONTROL RT_BIT_64(51)
|
---|
97 | #endif /* VBOX_WITH_GUEST_CONTROL defined */
|
---|
98 | #define USAGE_DEBUGLOG RT_BIT_64(52)
|
---|
99 | #define USAGE_SETHDPARENTUUID RT_BIT_64(53)
|
---|
100 | #define USAGE_PASSWORDHASH RT_BIT_64(54)
|
---|
101 | #define USAGE_EXTPACK RT_BIT_64(55)
|
---|
102 | #define USAGE_BANDWIDTHCONTROL RT_BIT_64(56)
|
---|
103 | #define USAGE_GUESTSTATS RT_BIT_64(57)
|
---|
104 | #define USAGE_REPAIRHD RT_BIT_64(58)
|
---|
105 | #define USAGE_NATNETWORK RT_BIT_64(59)
|
---|
106 | #define USAGE_ALL (~(uint64_t)0)
|
---|
107 | /** @} */
|
---|
108 |
|
---|
109 | #ifdef VBOX_WITH_GUEST_CONTROL
|
---|
110 | # define USAGE_GSTCTRL_EXEC RT_BIT(0)
|
---|
111 | # define USAGE_GSTCTRL_COPYFROM RT_BIT(1)
|
---|
112 | # define USAGE_GSTCTRL_COPYTO RT_BIT(2)
|
---|
113 | # define USAGE_GSTCTRL_CREATEDIR RT_BIT(3)
|
---|
114 | # define USAGE_GSTCTRL_REMOVEDIR RT_BIT(4)
|
---|
115 | # define USAGE_GSTCTRL_REMOVEFILE RT_BIT(5)
|
---|
116 | # define USAGE_GSTCTRL_RENAME RT_BIT(6)
|
---|
117 | # define USAGE_GSTCTRL_CREATETEMP RT_BIT(7)
|
---|
118 | # define USAGE_GSTCTRL_LIST RT_BIT(8)
|
---|
119 | # define USAGE_GSTCTRL_PROCESS RT_BIT(9)
|
---|
120 | # define USAGE_GSTCTRL_KILL RT_BIT(10)
|
---|
121 | # define USAGE_GSTCTRL_SESSION RT_BIT(11)
|
---|
122 | # define USAGE_GSTCTRL_STAT RT_BIT(12)
|
---|
123 | # define USAGE_GSTCTRL_UPDATEADDS RT_BIT(13)
|
---|
124 | # define USAGE_GSTCTRL_WATCH RT_BIT(14)
|
---|
125 | #endif
|
---|
126 |
|
---|
127 | typedef uint64_t USAGECATEGORY;
|
---|
128 |
|
---|
129 | /** command handler argument */
|
---|
130 | struct HandlerArg
|
---|
131 | {
|
---|
132 | int argc;
|
---|
133 | char **argv;
|
---|
134 |
|
---|
135 | #ifndef VBOX_ONLY_DOCS
|
---|
136 | ComPtr<IVirtualBox> virtualBox;
|
---|
137 | ComPtr<ISession> session;
|
---|
138 | #endif
|
---|
139 | };
|
---|
140 |
|
---|
141 | /** flag whether we're in internal mode */
|
---|
142 | extern bool g_fInternalMode;
|
---|
143 |
|
---|
144 | /** showVMInfo details */
|
---|
145 | typedef enum
|
---|
146 | {
|
---|
147 | VMINFO_NONE = 0,
|
---|
148 | VMINFO_STANDARD = 1, /**< standard details */
|
---|
149 | VMINFO_FULL = 2, /**< both */
|
---|
150 | VMINFO_MACHINEREADABLE = 3, /**< both, and make it machine readable */
|
---|
151 | VMINFO_COMPACT = 4
|
---|
152 | } VMINFO_DETAILS;
|
---|
153 |
|
---|
154 | ////////////////////////////////////////////////////////////////////////////////
|
---|
155 | //
|
---|
156 | // global variables
|
---|
157 | //
|
---|
158 | ////////////////////////////////////////////////////////////////////////////////
|
---|
159 |
|
---|
160 | extern bool g_fDetailedProgress; // in VBoxManage.cpp
|
---|
161 |
|
---|
162 | ////////////////////////////////////////////////////////////////////////////////
|
---|
163 | //
|
---|
164 | // prototypes
|
---|
165 | //
|
---|
166 | ////////////////////////////////////////////////////////////////////////////////
|
---|
167 |
|
---|
168 | /* VBoxManageHelp.cpp */
|
---|
169 | void printUsage(USAGECATEGORY fCategory, uint32_t fSubCategory, PRTSTREAM pStrm);
|
---|
170 | RTEXITCODE errorSyntax(USAGECATEGORY fCategory, const char *pszFormat, ...);
|
---|
171 | RTEXITCODE errorSyntaxEx(USAGECATEGORY fCategory, uint32_t fSubCategory, const char *pszFormat, ...);
|
---|
172 | RTEXITCODE errorGetOpt(USAGECATEGORY fCategory, int rc, union RTGETOPTUNION const *pValueUnion);
|
---|
173 | RTEXITCODE errorGetOptEx(USAGECATEGORY fCategory, uint32_t fSubCategory, int rc, union RTGETOPTUNION const *pValueUnion);
|
---|
174 | RTEXITCODE errorArgument(const char *pszFormat, ...);
|
---|
175 |
|
---|
176 | void printUsageInternal(USAGECATEGORY fCategory, PRTSTREAM pStrm);
|
---|
177 |
|
---|
178 | #ifndef VBOX_ONLY_DOCS
|
---|
179 | HRESULT showProgress(ComPtr<IProgress> progress);
|
---|
180 | #endif
|
---|
181 |
|
---|
182 | /* VBoxManage.cpp */
|
---|
183 | void showLogo(PRTSTREAM pStrm);
|
---|
184 |
|
---|
185 | #ifndef VBOX_ONLY_DOCS
|
---|
186 | RTEXITCODE readPasswordFile(const char *pszFilename, com::Utf8Str *pPasswd);
|
---|
187 |
|
---|
188 | int handleInternalCommands(HandlerArg *a);
|
---|
189 | #endif /* !VBOX_ONLY_DOCS */
|
---|
190 |
|
---|
191 | /* VBoxManageControlVM.cpp */
|
---|
192 | int handleControlVM(HandlerArg *a);
|
---|
193 | #ifndef VBOX_ONLY_DOCS
|
---|
194 | unsigned int getMaxNics(IVirtualBox* vbox, IMachine* mach);
|
---|
195 | #endif
|
---|
196 |
|
---|
197 | /* VBoxManageModifyVM.cpp */
|
---|
198 | #ifndef VBOX_ONLY_DOCS
|
---|
199 | void parseGroups(const char *pcszGroups, com::SafeArray<BSTR> *pGroups);
|
---|
200 | #endif
|
---|
201 | int handleModifyVM(HandlerArg *a);
|
---|
202 |
|
---|
203 | /* VBoxManageDebugVM.cpp */
|
---|
204 | int handleDebugVM(HandlerArg *a);
|
---|
205 |
|
---|
206 | /* VBoxManageGuestProp.cpp */
|
---|
207 | extern void usageGuestProperty(PRTSTREAM pStrm, const char *pcszSep1, const char *pcszSep2);
|
---|
208 |
|
---|
209 | /* VBoxManageGuestCtrl.cpp */
|
---|
210 | extern void usageGuestControl(PRTSTREAM pStrm, const char *pcszSep1, const char *pcszSep2, uint32_t fSubCategory);
|
---|
211 |
|
---|
212 | #ifndef VBOX_ONLY_DOCS
|
---|
213 | /* VBoxManageGuestProp.cpp */
|
---|
214 | extern int handleGuestProperty(HandlerArg *a);
|
---|
215 |
|
---|
216 | /* VBoxManageGuestCtrl.cpp */
|
---|
217 | extern int handleGuestControl(HandlerArg *a);
|
---|
218 |
|
---|
219 | /* VBoxManageVMInfo.cpp */
|
---|
220 | HRESULT showSnapshots(ComPtr<ISnapshot> &rootSnapshot,
|
---|
221 | ComPtr<ISnapshot> ¤tSnapshot,
|
---|
222 | VMINFO_DETAILS details,
|
---|
223 | const com::Utf8Str &prefix = "",
|
---|
224 | int level = 0);
|
---|
225 | int handleShowVMInfo(HandlerArg *a);
|
---|
226 | HRESULT showVMInfo(ComPtr<IVirtualBox> virtualBox,
|
---|
227 | ComPtr<IMachine> machine,
|
---|
228 | VMINFO_DETAILS details = VMINFO_NONE,
|
---|
229 | ComPtr<IConsole> console = ComPtr<IConsole>());
|
---|
230 | const char *machineStateToName(MachineState_T machineState, bool fShort);
|
---|
231 | HRESULT showBandwidthGroups(ComPtr<IBandwidthControl> &bwCtrl,
|
---|
232 | VMINFO_DETAILS details);
|
---|
233 |
|
---|
234 | /* VBoxManageList.cpp */
|
---|
235 | int handleList(HandlerArg *a);
|
---|
236 |
|
---|
237 | /* VBoxManageMetrics.cpp */
|
---|
238 | int handleMetrics(HandlerArg *a);
|
---|
239 |
|
---|
240 | /* VBoxManageMisc.cpp */
|
---|
241 | int handleRegisterVM(HandlerArg *a);
|
---|
242 | int handleUnregisterVM(HandlerArg *a);
|
---|
243 | int handleCreateVM(HandlerArg *a);
|
---|
244 | int handleCloneVM(HandlerArg *a);
|
---|
245 | int handleStartVM(HandlerArg *a);
|
---|
246 | int handleDiscardState(HandlerArg *a);
|
---|
247 | int handleAdoptState(HandlerArg *a);
|
---|
248 | int handleGetExtraData(HandlerArg *a);
|
---|
249 | int handleSetExtraData(HandlerArg *a);
|
---|
250 | int handleSetProperty(HandlerArg *a);
|
---|
251 | int handleSharedFolder(HandlerArg *a);
|
---|
252 | int handleExtPack(HandlerArg *a);
|
---|
253 |
|
---|
254 | /* VBoxManageDisk.cpp */
|
---|
255 | HRESULT openMedium(HandlerArg *a, const char *pszFilenameOrUuid,
|
---|
256 | DeviceType_T enmDevType, AccessMode_T enmAccessMode,
|
---|
257 | ComPtr<IMedium> &pMedium, bool fForceNewUuidOnOpen,
|
---|
258 | bool fSilent);
|
---|
259 | int handleCreateHardDisk(HandlerArg *a);
|
---|
260 | int handleModifyHardDisk(HandlerArg *a);
|
---|
261 | int handleCloneHardDisk(HandlerArg *a);
|
---|
262 | RTEXITCODE handleConvertFromRaw(int argc, char *argv[]);
|
---|
263 | HRESULT showMediumInfo(const ComPtr<IVirtualBox> &pVirtualBox,
|
---|
264 | const ComPtr<IMedium> &pMedium,
|
---|
265 | const char *pszParentUUID,
|
---|
266 | bool fOptLong);
|
---|
267 | int handleShowHardDiskInfo(HandlerArg *a);
|
---|
268 | int handleCloseMedium(HandlerArg *a);
|
---|
269 | int parseDiskType(const char *psz, MediumType_T *pDiskType);
|
---|
270 | int parseBool(const char *psz, bool *pb);
|
---|
271 |
|
---|
272 | /* VBoxManageStorageController.cpp */
|
---|
273 | int handleStorageAttach(HandlerArg *a);
|
---|
274 | int handleStorageController(HandlerArg *a);
|
---|
275 |
|
---|
276 | // VBoxManageImport.cpp
|
---|
277 | int handleImportAppliance(HandlerArg *a);
|
---|
278 | int handleExportAppliance(HandlerArg *a);
|
---|
279 |
|
---|
280 | // VBoxManageSnapshot.cpp
|
---|
281 | int handleSnapshot(HandlerArg *a);
|
---|
282 |
|
---|
283 | /* VBoxManageUSB.cpp */
|
---|
284 | int handleUSBFilter(HandlerArg *a);
|
---|
285 |
|
---|
286 | /* VBoxManageHostonly.cpp */
|
---|
287 | int handleHostonlyIf(HandlerArg *a);
|
---|
288 |
|
---|
289 | /* VBoxManageDHCPServer.cpp */
|
---|
290 | int handleDHCPServer(HandlerArg *a);
|
---|
291 |
|
---|
292 | /* VBoxManageNATNetwork.cpp */
|
---|
293 | int handleNATNetwork(HandlerArg *a);
|
---|
294 |
|
---|
295 |
|
---|
296 | /* VBoxManageBandwidthControl.cpp */
|
---|
297 | int handleBandwidthControl(HandlerArg *a);
|
---|
298 |
|
---|
299 | #endif /* !VBOX_ONLY_DOCS */
|
---|
300 |
|
---|
301 | #endif /* !___H_VBOXMANAGE */
|
---|