VirtualBox

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

Last change on this file since 96407 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • 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 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * VBoxManage - VirtualBox command-line interface, internal header file.
4 */
5
6/*
7 * Copyright (C) 2006-2022 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VBOX_INCLUDED_SRC_VBoxManage_VBoxManage_h
29#define VBOX_INCLUDED_SRC_VBoxManage_VBoxManage_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <VBox/com/com.h>
35#include <VBox/com/ptr.h>
36#include <VBox/com/VirtualBox.h>
37#include <VBox/com/string.h>
38#include <VBox/com/array.h>
39
40#include <iprt/types.h>
41#include <iprt/message.h>
42#include <iprt/stream.h>
43#include <iprt/getopt.h>
44
45#include "VBoxManageBuiltInHelp.h"
46#include "PasswordInput.h"
47
48#ifdef VBOX_WITH_VBOXMANAGE_NLS
49# include "VirtualBoxTranslator.h"
50#endif
51
52
53////////////////////////////////////////////////////////////////////////////////
54//
55// definitions
56//
57////////////////////////////////////////////////////////////////////////////////
58
59/**
60 * This defines a a_CtxName::tr function that gives the translator context as
61 * well as providing a shorter way to call VirtualBoxTranslator::translate.
62 */
63#ifdef VBOX_WITH_VBOXMANAGE_NLS
64# define DECLARE_TRANSLATION_CONTEXT(a_CtxName) \
65struct a_CtxName \
66{ \
67 static const char *tr(const char *pszSource, const char *pszComment = NULL, const size_t uNum = ~(size_t)0) \
68 { \
69 return VirtualBoxTranslator::translate(NULL, #a_CtxName, pszSource, pszComment, uNum); \
70 } \
71}
72#else
73# define DECLARE_TRANSLATION_CONTEXT(a_CtxName) \
74struct a_CtxName \
75{ \
76 static const char *tr(const char *pszSource, const char *pszComment = NULL, const size_t uNum = ~(size_t)0) \
77 { \
78 RT_NOREF(pszComment, uNum); \
79 return pszSource; \
80 } \
81}
82#endif
83
84/**
85 * Defines an option with two variants, producing two RTGETOPTDEF entries.
86 *
87 * This is mainly for replacing character-soup option names like
88 * --natlocalhostreachable and --biossystemtimeoffset with more easily parsed
89 * ones, like --nat-localhost-reachable and --bios-system-time-offset, without
90 * removing the legacy name.
91 */
92#define OPT2(a_pszWordDashWord, a_pszWordSoup, a_chOptOrValue, a_fFlags) \
93 { a_pszWordDashWord, a_chOptOrValue, a_fFlags }, \
94 { a_pszWordSoup, a_chOptOrValue, a_fFlags }
95
96/** A single option variant of OPT2 for better looking tables. */
97#define OPT1(a_pszOption, a_chOptOrValue, a_fFlags) \
98 { a_pszOption, a_chOptOrValue, a_fFlags }
99
100
101/** command handler argument */
102struct HandlerArg
103{
104 int argc;
105 char **argv;
106
107 ComPtr<IVirtualBox> virtualBox;
108 ComPtr<ISession> session;
109};
110
111
112/** showVMInfo details */
113typedef enum
114{
115 VMINFO_NONE = 0,
116 VMINFO_STANDARD = 1, /**< standard details */
117 VMINFO_FULL = 2, /**< both */
118 VMINFO_MACHINEREADABLE = 3, /**< both, and make it machine readable */
119 VMINFO_COMPACT = 4
120} VMINFO_DETAILS;
121
122
123////////////////////////////////////////////////////////////////////////////////
124//
125// global variables
126//
127////////////////////////////////////////////////////////////////////////////////
128
129extern bool g_fDetailedProgress; // in VBoxManage.cpp
130
131
132////////////////////////////////////////////////////////////////////////////////
133//
134// prototypes
135//
136////////////////////////////////////////////////////////////////////////////////
137
138/* VBoxManageHelp.cpp */
139void setCurrentCommand(enum HELP_CMD_VBOXMANAGE enmCommand);
140void setCurrentSubcommand(uint64_t fCurSubcommandScope);
141
142void printUsage(PRTSTREAM pStrm);
143void printHelp(PRTSTREAM pStrm);
144RTEXITCODE errorNoSubcommand(void);
145RTEXITCODE errorUnknownSubcommand(const char *pszSubCmd);
146RTEXITCODE errorTooManyParameters(char **papszArgs);
147RTEXITCODE errorGetOpt(int rcGetOpt, union RTGETOPTUNION const *pValueUnion);
148RTEXITCODE errorFetchValue(int iValueNo, const char *pszOption, int rcGetOptFetchValue, union RTGETOPTUNION const *pValueUnion);
149RTEXITCODE errorSyntax(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
150RTEXITCODE errorSyntaxV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
151HRESULT errorSyntaxHr(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
152RTEXITCODE errorArgument(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
153HRESULT errorArgumentHr(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
154
155# define SHOW_PROGRESS_NONE 0
156# define SHOW_PROGRESS_DESC RT_BIT_32(0)
157# define SHOW_PROGRESS RT_BIT_32(1)
158# define SHOW_PROGRESS_DETAILS RT_BIT_32(2)
159HRESULT showProgress(ComPtr<IProgress> progress, uint32_t fFlags = SHOW_PROGRESS);
160
161/* VBoxManage.cpp */
162void showLogo(PRTSTREAM pStrm);
163
164/* VBoxInternalManage.cpp */
165DECLHIDDEN(void) printUsageInternalCmds(PRTSTREAM pStrm);
166RTEXITCODE handleInternalCommands(HandlerArg *a);
167
168/* VBoxManageControlVM.cpp */
169RTEXITCODE handleControlVM(HandlerArg *a);
170
171/* VBoxManageModifyVM.cpp */
172void parseGroups(const char *pcszGroups, com::SafeArray<BSTR> *pGroups);
173#ifdef VBOX_WITH_RECORDING
174int parseScreens(const char *pcszScreens, com::SafeArray<BOOL> *pScreens);
175#endif
176RTEXITCODE handleModifyVM(HandlerArg *a);
177
178/* VBoxManageDebugVM.cpp */
179RTEXITCODE handleDebugVM(HandlerArg *a);
180
181/* VBoxManageGuestProp.cpp */
182RTEXITCODE handleGuestProperty(HandlerArg *a);
183
184/* VBoxManageGuestCtrl.cpp */
185RTEXITCODE handleGuestControl(HandlerArg *a);
186
187/* VBoxManageVMInfo.cpp */
188HRESULT showSnapshots(ComPtr<ISnapshot> &rootSnapshot,
189 ComPtr<ISnapshot> &currentSnapshot,
190 VMINFO_DETAILS details,
191 const com::Utf8Str &prefix = "",
192 int level = 0);
193RTEXITCODE handleShowVMInfo(HandlerArg *a);
194HRESULT showVMInfo(ComPtr<IVirtualBox> pVirtualBox,
195 ComPtr<IMachine> pMachine,
196 ComPtr<ISession> pSession,
197 VMINFO_DETAILS details = VMINFO_NONE);
198const char *machineStateToName(MachineState_T machineState, bool fShort);
199HRESULT showBandwidthGroups(ComPtr<IBandwidthControl> &bwCtrl,
200 VMINFO_DETAILS details);
201void outputMachineReadableString(const char *pszName, const char *pszValue, bool fQuoteName = false, bool fNewline = true);
202void outputMachineReadableString(const char *pszName, com::Bstr const *pbstrValue, bool fQuoteName = false, bool fNewline = true);
203void outputMachineReadableStringWithFmtName(const char *pszValue, bool fQuoteName, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(3, 4);
204void outputMachineReadableStringWithFmtName(com::Bstr const *pbstrValue, bool fQuoteName, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(3, 4);
205void outputMachineReadableBool(const char *pszName, BOOL const *pfValue);
206void outputMachineReadableBool(const char *pszName, bool const *pfValue);
207void outputMachineReadableULong(const char *pszName, ULONG *uValue);
208void outputMachineReadableLong64(const char *pszName, LONG64 *uValue);
209
210/* VBoxManageList.cpp */
211RTEXITCODE handleList(HandlerArg *a);
212
213/* VBoxManageMetrics.cpp */
214RTEXITCODE handleMetrics(HandlerArg *a);
215
216/* VBoxManageMisc.cpp */
217RTEXITCODE handleRegisterVM(HandlerArg *a);
218RTEXITCODE handleUnregisterVM(HandlerArg *a);
219RTEXITCODE handleCreateVM(HandlerArg *a);
220RTEXITCODE handleCloneVM(HandlerArg *a);
221RTEXITCODE handleStartVM(HandlerArg *a);
222#ifdef VBOX_WITH_FULL_VM_ENCRYPTION
223RTEXITCODE handleEncryptVM(HandlerArg *a);
224#endif
225RTEXITCODE handleDiscardState(HandlerArg *a);
226RTEXITCODE handleAdoptState(HandlerArg *a);
227RTEXITCODE handleGetExtraData(HandlerArg *a);
228RTEXITCODE handleSetExtraData(HandlerArg *a);
229RTEXITCODE handleSetProperty(HandlerArg *a);
230RTEXITCODE handleSharedFolder(HandlerArg *a);
231RTEXITCODE handleExtPack(HandlerArg *a);
232RTEXITCODE handleUnattended(HandlerArg *a);
233RTEXITCODE handleMoveVM(HandlerArg *a);
234RTEXITCODE handleCloudProfile(HandlerArg *a);
235
236/* VBoxManageDisk.cpp */
237HRESULT openMedium(HandlerArg *a, const char *pszFilenameOrUuid,
238 DeviceType_T enmDevType, AccessMode_T enmAccessMode,
239 ComPtr<IMedium> &pMedium, bool fForceNewUuidOnOpen,
240 bool fSilent);
241RTEXITCODE handleCreateMedium(HandlerArg *a);
242RTEXITCODE handleModifyMedium(HandlerArg *a);
243RTEXITCODE handleCloneMedium(HandlerArg *a);
244RTEXITCODE handleMediumProperty(HandlerArg *a);
245RTEXITCODE handleEncryptMedium(HandlerArg *a);
246RTEXITCODE handleCheckMediumPassword(HandlerArg *a);
247RTEXITCODE handleConvertFromRaw(HandlerArg *a);
248HRESULT showMediumInfo(const ComPtr<IVirtualBox> &pVirtualBox,
249 const ComPtr<IMedium> &pMedium,
250 const char *pszParentUUID,
251 bool fOptLong);
252RTEXITCODE handleShowMediumInfo(HandlerArg *a);
253RTEXITCODE handleCloseMedium(HandlerArg *a);
254RTEXITCODE handleMediumIO(HandlerArg *a);
255int parseMediumType(const char *psz, MediumType_T *penmMediumType);
256int parseBool(const char *psz, bool *pb);
257
258/* VBoxManageStorageController.cpp */
259RTEXITCODE handleStorageAttach(HandlerArg *a);
260RTEXITCODE handleStorageController(HandlerArg *a);
261
262// VBoxManageAppliance.cpp
263RTEXITCODE handleImportAppliance(HandlerArg *a);
264RTEXITCODE handleExportAppliance(HandlerArg *a);
265RTEXITCODE handleSignAppliance(HandlerArg *a);
266
267// VBoxManageSnapshot.cpp
268RTEXITCODE handleSnapshot(HandlerArg *a);
269
270/* VBoxManageUSB.cpp */
271RTEXITCODE handleUSBFilter(HandlerArg *a);
272RTEXITCODE handleUSBDevSource(HandlerArg *a);
273
274/* VBoxManageHostonly.cpp */
275RTEXITCODE handleHostonlyIf(HandlerArg *a);
276#ifdef VBOX_WITH_VMNET
277RTEXITCODE handleHostonlyNet(HandlerArg *a);
278#endif /* VBOX_WITH_VMNET */
279
280/* VBoxManageDHCPServer.cpp */
281RTEXITCODE handleDHCPServer(HandlerArg *a);
282
283/* VBoxManageNATNetwork.cpp */
284RTEXITCODE handleNATNetwork(HandlerArg *a);
285RTEXITCODE listNATNetworks(bool fLong, bool fSorted,
286 const ComPtr<IVirtualBox> &pVirtualBox);
287
288/* VBoxManageBandwidthControl.cpp */
289RTEXITCODE handleBandwidthControl(HandlerArg *a);
290
291/* VBoxManageCloud.cpp */
292RTEXITCODE handleCloud(HandlerArg *a);
293
294/* VBoxManageCloudMachine.cpp */
295RTEXITCODE handleCloudMachine(HandlerArg *a, int iFirst,
296 const char *pcszProviderName,
297 const char *pcszProfileName);
298RTEXITCODE listCloudMachines(HandlerArg *a, int iFirst,
299 const char *pcszProviderName,
300 const char *pcszProfileName);
301RTEXITCODE handleCloudShowVMInfo(HandlerArg *a, int iFirst,
302 const char *pcszProviderName,
303 const char *pcszProfileName);
304
305#ifdef VBOX_WITH_UPDATE_AGENT
306/* VBoxManageUpdateCheck.cpp */
307RTEXITCODE handleUpdateCheck(HandlerArg *a);
308#endif
309
310/* VBoxManageModifyNvram.cpp */
311RTEXITCODE handleModifyNvram(HandlerArg *a);
312
313#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