VirtualBox

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

Last change on this file since 92124 was 91432, checked in by vboxsync, 3 years ago

FE/VBoxManage: Start implementing an interface to manage the NVRAM of a VM, bugref:9580

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.4 KB
Line 
1/* $Id: VBoxManage.h 91432 2021-09-28 11:37:43Z vboxsync $ */
2/** @file
3 * VBoxManage - VirtualBox command-line interface, internal header file.
4 */
5
6/*
7 * Copyright (C) 2006-2020 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# include "PasswordInput.h"
40#endif
41
42
43////////////////////////////////////////////////////////////////////////////////
44//
45// definitions
46//
47////////////////////////////////////////////////////////////////////////////////
48
49/** @name Syntax diagram category, i.e. the command.
50 * @{ */
51typedef enum
52{
53 USAGE_INVALID = 0,
54 USAGE_LIST,
55 USAGE_SHOWVMINFO,
56 USAGE_REGISTERVM,
57 USAGE_UNREGISTERVM,
58 USAGE_CREATEVM,
59 USAGE_MODIFYVM,
60 USAGE_STARTVM,
61 USAGE_CONTROLVM,
62 USAGE_DISCARDSTATE,
63 USAGE_CLOSEMEDIUM,
64 USAGE_SHOWMEDIUMINFO,
65 USAGE_CREATEMEDIUM,
66 USAGE_MODIFYMEDIUM,
67 USAGE_CLONEMEDIUM,
68 USAGE_MOVEVM,
69 USAGE_CREATEHOSTIF,
70 USAGE_REMOVEHOSTIF,
71 USAGE_GETEXTRADATA,
72 USAGE_SETEXTRADATA,
73 USAGE_SETPROPERTY,
74 USAGE_USBFILTER,
75 USAGE_I_LOADSYMS,
76 USAGE_I_LOADMAP,
77 USAGE_I_SETHDUUID,
78 USAGE_CONVERTFROMRAW,
79 USAGE_I_LISTPARTITIONS,
80 USAGE_I_CREATERAWVMDK,
81 USAGE_ADOPTSTATE,
82 USAGE_I_MODINSTALL,
83 USAGE_I_MODUNINSTALL,
84 USAGE_I_RENAMEVMDK,
85#ifdef VBOX_WITH_GUEST_PROPS
86 USAGE_GUESTPROPERTY,
87#endif /* VBOX_WITH_GUEST_PROPS defined */
88 USAGE_I_CONVERTTORAW,
89 USAGE_METRICS,
90 USAGE_I_CONVERTHD,
91 USAGE_IMPORTAPPLIANCE,
92 USAGE_EXPORTAPPLIANCE,
93 USAGE_HOSTONLYIFS,
94 USAGE_I_DUMPHDINFO,
95 USAGE_STORAGEATTACH,
96 USAGE_STORAGECONTROLLER,
97#ifdef VBOX_WITH_GUEST_CONTROL
98 USAGE_GUESTCONTROL,
99#endif /* VBOX_WITH_GUEST_CONTROL defined */
100 USAGE_I_DEBUGLOG,
101 USAGE_I_SETHDPARENTUUID,
102 USAGE_I_PASSWORDHASH,
103 USAGE_BANDWIDTHCONTROL,
104 USAGE_I_GUESTSTATS,
105 USAGE_I_REPAIRHD,
106 USAGE_NATNETWORK,
107 USAGE_MEDIUMPROPERTY,
108 USAGE_ENCRYPTMEDIUM,
109 USAGE_MEDIUMENCCHKPWD,
110 USAGE_USBDEVSOURCE,
111 USAGE_CLOUDPROFILE,
112 /* Insert new entries before this line, but only if it is not an option
113 * to go for the new style command and help handling (see e.g. extpack,
114 * unattend or mediumio. */
115 USAGE_S_NEWCMD = 10000, /**< new style command with no old help support */
116 USAGE_S_ALL,
117 USAGE_S_DUMPOPTS
118} USAGECATEGORY;
119/** @} */
120
121
122#define HELP_SCOPE_USBFILTER_ADD RT_BIT_64(0)
123#define HELP_SCOPE_USBFILTER_MODIFY RT_BIT_64(1)
124#define HELP_SCOPE_USBFILTER_REMOVE RT_BIT_64(2)
125
126#ifdef VBOX_WITH_GUEST_CONTROL
127# define HELP_SCOPE_GSTCTRL_RUN RT_BIT(0)
128# define HELP_SCOPE_GSTCTRL_START RT_BIT(1)
129# define HELP_SCOPE_GSTCTRL_COPYFROM RT_BIT(2)
130# define HELP_SCOPE_GSTCTRL_COPYTO RT_BIT(3)
131# define HELP_SCOPE_GSTCTRL_MKDIR RT_BIT(4)
132# define HELP_SCOPE_GSTCTRL_RMDIR RT_BIT(5)
133# define HELP_SCOPE_GSTCTRL_RM RT_BIT(6)
134# define HELP_SCOPE_GSTCTRL_MV RT_BIT(7)
135# define HELP_SCOPE_GSTCTRL_MKTEMP RT_BIT(8)
136# define HELP_SCOPE_GSTCTRL_LIST RT_BIT(9)
137# define HELP_SCOPE_GSTCTRL_CLOSEPROCESS RT_BIT(10)
138# define HELP_SCOPE_GSTCTRL_CLOSESESSION RT_BIT(11)
139# define HELP_SCOPE_GSTCTRL_STAT RT_BIT(12)
140# define HELP_SCOPE_GSTCTRL_UPDATEGA RT_BIT(13)
141# define HELP_SCOPE_GSTCTRL_WATCH RT_BIT(14)
142# define HELP_SCOPE_GSTCTRL_WAITRUNLEVEL RT_BIT(15)
143#endif
144
145/** command handler argument */
146struct HandlerArg
147{
148 int argc;
149 char **argv;
150
151#ifndef VBOX_ONLY_DOCS
152 ComPtr<IVirtualBox> virtualBox;
153 ComPtr<ISession> session;
154#endif
155};
156
157/** flag whether we're in internal mode */
158extern bool g_fInternalMode;
159
160/** showVMInfo details */
161typedef enum
162{
163 VMINFO_NONE = 0,
164 VMINFO_STANDARD = 1, /**< standard details */
165 VMINFO_FULL = 2, /**< both */
166 VMINFO_MACHINEREADABLE = 3, /**< both, and make it machine readable */
167 VMINFO_COMPACT = 4
168} VMINFO_DETAILS;
169
170
171////////////////////////////////////////////////////////////////////////////////
172//
173// global variables
174//
175////////////////////////////////////////////////////////////////////////////////
176
177extern bool g_fDetailedProgress; // in VBoxManage.cpp
178
179
180////////////////////////////////////////////////////////////////////////////////
181//
182// prototypes
183//
184////////////////////////////////////////////////////////////////////////////////
185
186/* VBoxManageHelp.cpp */
187
188/* Legacy help infrastructure, to be replaced by new one using generated help. */
189void printUsage(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, PRTSTREAM pStrm);
190RTEXITCODE errorSyntax(USAGECATEGORY enmCommand, const char *pszFormat, ...);
191RTEXITCODE errorSyntaxEx(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, const char *pszFormat, ...);
192RTEXITCODE errorGetOpt(USAGECATEGORY enmCommand, int rc, union RTGETOPTUNION const *pValueUnion);
193RTEXITCODE errorGetOptEx(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, int rc, union RTGETOPTUNION const *pValueUnion);
194RTEXITCODE errorArgument(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
195
196void printUsageInternal(USAGECATEGORY enmCommand, PRTSTREAM pStrm);
197
198#ifndef VBOX_ONLY_DOCS
199void setCurrentCommand(enum HELP_CMD_VBOXMANAGE enmCommand);
200void setCurrentSubcommand(uint64_t fCurSubcommandScope);
201
202void printUsage(PRTSTREAM pStrm);
203void printHelp(PRTSTREAM pStrm);
204RTEXITCODE errorNoSubcommand(void);
205RTEXITCODE errorUnknownSubcommand(const char *pszSubCmd);
206RTEXITCODE errorTooManyParameters(char **papszArgs);
207RTEXITCODE errorGetOpt(int rcGetOpt, union RTGETOPTUNION const *pValueUnion);
208RTEXITCODE errorFetchValue(int iValueNo, const char *pszOption, int rcGetOptFetchValue, union RTGETOPTUNION const *pValueUnion);
209RTEXITCODE errorSyntax(const char *pszFormat, ...);
210
211
212#define SHOW_PROGRESS_NONE 0
213#define SHOW_PROGRESS_DESC (1u << 0)
214#define SHOW_PROGRESS (1u << 1)
215#define SHOW_PROGRESS_DETAILS (1u << 2)
216HRESULT showProgress(ComPtr<IProgress> progress, unsigned int fFlags = SHOW_PROGRESS);
217#endif
218
219/* VBoxManage.cpp */
220void showLogo(PRTSTREAM pStrm);
221
222#ifndef VBOX_ONLY_DOCS
223RTEXITCODE handleInternalCommands(HandlerArg *a);
224#endif /* !VBOX_ONLY_DOCS */
225
226/* VBoxManageControlVM.cpp */
227RTEXITCODE handleControlVM(HandlerArg *a);
228
229/* VBoxManageModifyVM.cpp */
230#ifndef VBOX_ONLY_DOCS
231void parseGroups(const char *pcszGroups, com::SafeArray<BSTR> *pGroups);
232#endif
233RTEXITCODE handleModifyVM(HandlerArg *a);
234
235/* VBoxManageDebugVM.cpp */
236RTEXITCODE handleDebugVM(HandlerArg *a);
237
238/* VBoxManageGuestProp.cpp */
239extern void usageGuestProperty(PRTSTREAM pStrm, const char *pcszSep1, const char *pcszSep2);
240
241/* VBoxManageGuestCtrl.cpp */
242extern void usageGuestControl(PRTSTREAM pStrm, const char *pcszSep1, const char *pcszSep2, uint64_t fSubcommandScope);
243
244#ifndef VBOX_ONLY_DOCS
245/* VBoxManageGuestProp.cpp */
246RTEXITCODE handleGuestProperty(HandlerArg *a);
247
248/* VBoxManageGuestCtrl.cpp */
249RTEXITCODE handleGuestControl(HandlerArg *a);
250
251/* VBoxManageVMInfo.cpp */
252HRESULT showSnapshots(ComPtr<ISnapshot> &rootSnapshot,
253 ComPtr<ISnapshot> &currentSnapshot,
254 VMINFO_DETAILS details,
255 const com::Utf8Str &prefix = "",
256 int level = 0);
257RTEXITCODE handleShowVMInfo(HandlerArg *a);
258HRESULT showVMInfo(ComPtr<IVirtualBox> pVirtualBox,
259 ComPtr<IMachine> pMachine,
260 ComPtr<ISession> pSession,
261 VMINFO_DETAILS details = VMINFO_NONE);
262const char *machineStateToName(MachineState_T machineState, bool fShort);
263HRESULT showBandwidthGroups(ComPtr<IBandwidthControl> &bwCtrl,
264 VMINFO_DETAILS details);
265void outputMachineReadableString(const char *pszName, const char *pszValue);
266void outputMachineReadableString(const char *pszName, com::Bstr const *pbstrValue);
267void outputMachineReadableBool(const char *pszName, BOOL const *pfValue);
268void outputMachineReadableBool(const char *pszName, bool const *pfValue);
269void outputMachineReadableULong(const char *pszName, ULONG *uValue);
270void outputMachineReadableLong64(const char *pszName, LONG64 *uValue);
271
272/* VBoxManageList.cpp */
273RTEXITCODE handleList(HandlerArg *a);
274
275/* VBoxManageMetrics.cpp */
276RTEXITCODE handleMetrics(HandlerArg *a);
277
278/* VBoxManageMisc.cpp */
279RTEXITCODE handleRegisterVM(HandlerArg *a);
280RTEXITCODE handleUnregisterVM(HandlerArg *a);
281RTEXITCODE handleCreateVM(HandlerArg *a);
282RTEXITCODE handleCloneVM(HandlerArg *a);
283RTEXITCODE handleStartVM(HandlerArg *a);
284RTEXITCODE handleDiscardState(HandlerArg *a);
285RTEXITCODE handleAdoptState(HandlerArg *a);
286RTEXITCODE handleGetExtraData(HandlerArg *a);
287RTEXITCODE handleSetExtraData(HandlerArg *a);
288RTEXITCODE handleSetProperty(HandlerArg *a);
289RTEXITCODE handleSharedFolder(HandlerArg *a);
290RTEXITCODE handleExtPack(HandlerArg *a);
291RTEXITCODE handleUnattended(HandlerArg *a);
292RTEXITCODE handleMoveVM(HandlerArg *a);
293RTEXITCODE handleCloudProfile(HandlerArg *a);
294
295/* VBoxManageDisk.cpp */
296HRESULT openMedium(HandlerArg *a, const char *pszFilenameOrUuid,
297 DeviceType_T enmDevType, AccessMode_T enmAccessMode,
298 ComPtr<IMedium> &pMedium, bool fForceNewUuidOnOpen,
299 bool fSilent);
300RTEXITCODE handleCreateMedium(HandlerArg *a);
301RTEXITCODE handleModifyMedium(HandlerArg *a);
302RTEXITCODE handleCloneMedium(HandlerArg *a);
303RTEXITCODE handleMediumProperty(HandlerArg *a);
304RTEXITCODE handleEncryptMedium(HandlerArg *a);
305RTEXITCODE handleCheckMediumPassword(HandlerArg *a);
306RTEXITCODE handleConvertFromRaw(HandlerArg *a);
307HRESULT showMediumInfo(const ComPtr<IVirtualBox> &pVirtualBox,
308 const ComPtr<IMedium> &pMedium,
309 const char *pszParentUUID,
310 bool fOptLong);
311RTEXITCODE handleShowMediumInfo(HandlerArg *a);
312RTEXITCODE handleCloseMedium(HandlerArg *a);
313RTEXITCODE handleMediumIO(HandlerArg *a);
314int parseMediumType(const char *psz, MediumType_T *penmMediumType);
315int parseBool(const char *psz, bool *pb);
316
317/* VBoxManageStorageController.cpp */
318RTEXITCODE handleStorageAttach(HandlerArg *a);
319RTEXITCODE handleStorageController(HandlerArg *a);
320
321// VBoxManageAppliance.cpp
322RTEXITCODE handleImportAppliance(HandlerArg *a);
323RTEXITCODE handleExportAppliance(HandlerArg *a);
324RTEXITCODE handleSignAppliance(HandlerArg *a);
325
326// VBoxManageSnapshot.cpp
327RTEXITCODE handleSnapshot(HandlerArg *a);
328
329/* VBoxManageUSB.cpp */
330RTEXITCODE handleUSBFilter(HandlerArg *a);
331RTEXITCODE handleUSBDevSource(HandlerArg *a);
332
333/* VBoxManageHostonly.cpp */
334RTEXITCODE handleHostonlyIf(HandlerArg *a);
335#ifdef VBOX_WITH_VMNET
336RTEXITCODE handleHostonlyNet(HandlerArg *a);
337#endif /* VBOX_WITH_VMNET */
338
339/* VBoxManageDHCPServer.cpp */
340RTEXITCODE handleDHCPServer(HandlerArg *a);
341
342/* VBoxManageNATNetwork.cpp */
343RTEXITCODE handleNATNetwork(HandlerArg *a);
344
345
346/* VBoxManageBandwidthControl.cpp */
347RTEXITCODE handleBandwidthControl(HandlerArg *a);
348
349/* VBoxManageCloud.cpp */
350RTEXITCODE handleCloud(HandlerArg *a);
351
352/* VBoxManageCloudMachine.cpp */
353RTEXITCODE handleCloudMachine(HandlerArg *a, int iFirst,
354 const char *pcszProviderName,
355 const char *pcszProfileName);
356RTEXITCODE listCloudMachines(HandlerArg *a, int iFirst,
357 const char *pcszProviderName,
358 const char *pcszProfileName);
359RTEXITCODE handleCloudShowVMInfo(HandlerArg *a, int iFirst,
360 const char *pcszProviderName,
361 const char *pcszProfileName);
362
363/* VBoxManageUpdateCheck.cpp */
364RTEXITCODE handleUpdateCheck(HandlerArg *a);
365
366/* VBoxManageModifyNvram.cpp */
367RTEXITCODE handleModifyNvram(HandlerArg *a);
368
369#endif /* !VBOX_ONLY_DOCS */
370
371#endif /* !VBOX_INCLUDED_SRC_VBoxManage_VBoxManage_h */
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