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