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