VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h@ 56210

Last change on this file since 56210 was 56118, checked in by vboxsync, 10 years ago

VBoxManage: A quick command handler return-code cleanup that turned out to be rather tedious.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette