VirtualBox

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

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

FE/VBoxManage: Remove the now unused VBoxManageHelp build target and the VBOX_ONLY_DOCS #ifdef's in the code, ​bugref:9186

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.2 KB
Line 
1/* $Id: VBoxManage.h 94234 2022-03-15 09:19:29Z vboxsync $ */
2/** @file
3 * VBoxManage - VirtualBox command-line interface, internal header file.
4 */
5
6/*
7 * Copyright (C) 2006-2022 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#include <VBox/com/com.h>
25#include <VBox/com/ptr.h>
26#include <VBox/com/VirtualBox.h>
27#include <VBox/com/string.h>
28#include <VBox/com/array.h>
29
30#include <iprt/types.h>
31#include <iprt/message.h>
32#include <iprt/stream.h>
33#include <iprt/getopt.h>
34
35#include "VBoxManageBuiltInHelp.h"
36#include "PasswordInput.h"
37
38#ifdef VBOX_WITH_VBOXMANAGE_NLS
39# include "VirtualBoxTranslator.h"
40#endif
41
42
43////////////////////////////////////////////////////////////////////////////////
44//
45// definitions
46//
47////////////////////////////////////////////////////////////////////////////////
48
49/**
50 * This defines a a_CtxName::tr function that gives the translator context as
51 * well as providing a shorter way to call VirtualBoxTranslator::translate.
52 */
53#ifdef VBOX_WITH_VBOXMANAGE_NLS
54# define DECLARE_TRANSLATION_CONTEXT(a_CtxName) \
55struct a_CtxName \
56{ \
57 static const char *tr(const char *pszSource, const char *pszComment = NULL, const size_t uNum = ~(size_t)0) \
58 { \
59 return VirtualBoxTranslator::translate(NULL, #a_CtxName, pszSource, pszComment, uNum); \
60 } \
61}
62#else
63# define DECLARE_TRANSLATION_CONTEXT(a_CtxName) \
64struct a_CtxName \
65{ \
66 static const char *tr(const char *pszSource, const char *pszComment = NULL, const size_t uNum = ~(size_t)0) \
67 { \
68 RT_NOREF(pszComment, uNum); \
69 return pszSource; \
70 } \
71}
72#endif
73
74/**
75 * Defines an option with two variants, producing two RTGETOPTDEF entries.
76 *
77 * This is mainly for replacing character-soup option names like
78 * --natlocalhostreachable and --biossystemtimeoffset with more easily parsed
79 * ones, like --nat-localhost-reachable and --bios-system-time-offset, without
80 * removing the legacy name.
81 */
82#define OPT2(a_pszWordDashWord, a_pszWordSoup, a_chOptOrValue, a_fFlags) \
83 { a_pszWordDashWord, a_chOptOrValue, a_fFlags }, \
84 { a_pszWordSoup, a_chOptOrValue, a_fFlags }
85
86/** A single option variant of OPT2 for better looking tables. */
87#define OPT1(a_pszOption, a_chOptOrValue, a_fFlags) \
88 { a_pszOption, a_chOptOrValue, a_fFlags }
89
90
91/** @name Syntax diagram category, i.e. the command.
92 * @{ */
93typedef enum
94{
95 USAGE_INVALID = 0,
96 USAGE_I_LOADSYMS,
97 USAGE_I_LOADMAP,
98 USAGE_I_SETHDUUID,
99 USAGE_I_LISTPARTITIONS,
100 USAGE_I_CREATERAWVMDK,
101 USAGE_I_MODINSTALL,
102 USAGE_I_MODUNINSTALL,
103 USAGE_I_RENAMEVMDK,
104 USAGE_I_CONVERTTORAW,
105 USAGE_I_CONVERTHD,
106 USAGE_I_DUMPHDINFO,
107 USAGE_I_DEBUGLOG,
108 USAGE_I_SETHDPARENTUUID,
109 USAGE_I_PASSWORDHASH,
110 USAGE_I_GUESTSTATS,
111 USAGE_I_REPAIRHD,
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/** command handler argument */
123struct HandlerArg
124{
125 int argc;
126 char **argv;
127
128 ComPtr<IVirtualBox> virtualBox;
129 ComPtr<ISession> session;
130};
131
132/** flag whether we're in internal mode */
133extern bool g_fInternalMode;
134
135/** showVMInfo details */
136typedef enum
137{
138 VMINFO_NONE = 0,
139 VMINFO_STANDARD = 1, /**< standard details */
140 VMINFO_FULL = 2, /**< both */
141 VMINFO_MACHINEREADABLE = 3, /**< both, and make it machine readable */
142 VMINFO_COMPACT = 4
143} VMINFO_DETAILS;
144
145
146////////////////////////////////////////////////////////////////////////////////
147//
148// global variables
149//
150////////////////////////////////////////////////////////////////////////////////
151
152extern bool g_fDetailedProgress; // in VBoxManage.cpp
153
154
155////////////////////////////////////////////////////////////////////////////////
156//
157// prototypes
158//
159////////////////////////////////////////////////////////////////////////////////
160
161/* VBoxManageHelp.cpp */
162
163/* Legacy help infrastructure, to be replaced by new one using generated help. */
164void printUsage(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, PRTSTREAM pStrm);
165RTEXITCODE errorSyntax(USAGECATEGORY enmCommand, const char *pszFormat, ...);
166RTEXITCODE errorSyntaxEx(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, const char *pszFormat, ...);
167RTEXITCODE errorGetOpt(USAGECATEGORY enmCommand, int rc, union RTGETOPTUNION const *pValueUnion);
168RTEXITCODE errorGetOptEx(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, int rc, union RTGETOPTUNION const *pValueUnion);
169
170void printUsageInternal(USAGECATEGORY enmCommand, PRTSTREAM pStrm);
171
172void setCurrentCommand(enum HELP_CMD_VBOXMANAGE enmCommand);
173void setCurrentSubcommand(uint64_t fCurSubcommandScope);
174
175void printUsage(PRTSTREAM pStrm);
176void printHelp(PRTSTREAM pStrm);
177RTEXITCODE errorNoSubcommand(void);
178RTEXITCODE errorUnknownSubcommand(const char *pszSubCmd);
179RTEXITCODE errorTooManyParameters(char **papszArgs);
180RTEXITCODE errorGetOpt(int rcGetOpt, union RTGETOPTUNION const *pValueUnion);
181RTEXITCODE errorFetchValue(int iValueNo, const char *pszOption, int rcGetOptFetchValue, union RTGETOPTUNION const *pValueUnion);
182RTEXITCODE errorSyntax(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
183RTEXITCODE errorSyntaxV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
184HRESULT errorSyntaxHr(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
185RTEXITCODE errorArgument(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
186HRESULT errorArgumentHr(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
187
188# define SHOW_PROGRESS_NONE 0
189# define SHOW_PROGRESS_DESC RT_BIT_32(0)
190# define SHOW_PROGRESS RT_BIT_32(1)
191# define SHOW_PROGRESS_DETAILS RT_BIT_32(2)
192HRESULT showProgress(ComPtr<IProgress> progress, uint32_t fFlags = SHOW_PROGRESS);
193
194/* VBoxManage.cpp */
195void showLogo(PRTSTREAM pStrm);
196
197RTEXITCODE handleInternalCommands(HandlerArg *a);
198
199/* VBoxManageControlVM.cpp */
200RTEXITCODE handleControlVM(HandlerArg *a);
201
202/* VBoxManageModifyVM.cpp */
203void parseGroups(const char *pcszGroups, com::SafeArray<BSTR> *pGroups);
204#ifdef VBOX_WITH_RECORDING
205int parseScreens(const char *pcszScreens, com::SafeArray<BOOL> *pScreens);
206#endif
207RTEXITCODE handleModifyVM(HandlerArg *a);
208
209/* VBoxManageDebugVM.cpp */
210RTEXITCODE handleDebugVM(HandlerArg *a);
211
212/* VBoxManageGuestProp.cpp */
213RTEXITCODE handleGuestProperty(HandlerArg *a);
214
215/* VBoxManageGuestCtrl.cpp */
216RTEXITCODE handleGuestControl(HandlerArg *a);
217
218/* VBoxManageVMInfo.cpp */
219HRESULT showSnapshots(ComPtr<ISnapshot> &rootSnapshot,
220 ComPtr<ISnapshot> &currentSnapshot,
221 VMINFO_DETAILS details,
222 const com::Utf8Str &prefix = "",
223 int level = 0);
224RTEXITCODE handleShowVMInfo(HandlerArg *a);
225HRESULT showVMInfo(ComPtr<IVirtualBox> pVirtualBox,
226 ComPtr<IMachine> pMachine,
227 ComPtr<ISession> pSession,
228 VMINFO_DETAILS details = VMINFO_NONE);
229const char *machineStateToName(MachineState_T machineState, bool fShort);
230HRESULT showBandwidthGroups(ComPtr<IBandwidthControl> &bwCtrl,
231 VMINFO_DETAILS details);
232void outputMachineReadableString(const char *pszName, const char *pszValue, bool fQuoteName = false, bool fNewline = true);
233void outputMachineReadableString(const char *pszName, com::Bstr const *pbstrValue, bool fQuoteName = false, bool fNewline = true);
234void outputMachineReadableStringWithFmtName(const char *pszValue, bool fQuoteName, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(3, 4);
235void outputMachineReadableStringWithFmtName(com::Bstr const *pbstrValue, bool fQuoteName, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(3, 4);
236void outputMachineReadableBool(const char *pszName, BOOL const *pfValue);
237void outputMachineReadableBool(const char *pszName, bool const *pfValue);
238void outputMachineReadableULong(const char *pszName, ULONG *uValue);
239void outputMachineReadableLong64(const char *pszName, LONG64 *uValue);
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);
260RTEXITCODE handleUnattended(HandlerArg *a);
261RTEXITCODE handleMoveVM(HandlerArg *a);
262RTEXITCODE handleCloudProfile(HandlerArg *a);
263
264/* VBoxManageDisk.cpp */
265HRESULT openMedium(HandlerArg *a, const char *pszFilenameOrUuid,
266 DeviceType_T enmDevType, AccessMode_T enmAccessMode,
267 ComPtr<IMedium> &pMedium, bool fForceNewUuidOnOpen,
268 bool fSilent);
269RTEXITCODE handleCreateMedium(HandlerArg *a);
270RTEXITCODE handleModifyMedium(HandlerArg *a);
271RTEXITCODE handleCloneMedium(HandlerArg *a);
272RTEXITCODE handleMediumProperty(HandlerArg *a);
273RTEXITCODE handleEncryptMedium(HandlerArg *a);
274RTEXITCODE handleCheckMediumPassword(HandlerArg *a);
275RTEXITCODE handleConvertFromRaw(HandlerArg *a);
276HRESULT showMediumInfo(const ComPtr<IVirtualBox> &pVirtualBox,
277 const ComPtr<IMedium> &pMedium,
278 const char *pszParentUUID,
279 bool fOptLong);
280RTEXITCODE handleShowMediumInfo(HandlerArg *a);
281RTEXITCODE handleCloseMedium(HandlerArg *a);
282RTEXITCODE handleMediumIO(HandlerArg *a);
283int parseMediumType(const char *psz, MediumType_T *penmMediumType);
284int parseBool(const char *psz, bool *pb);
285
286/* VBoxManageStorageController.cpp */
287RTEXITCODE handleStorageAttach(HandlerArg *a);
288RTEXITCODE handleStorageController(HandlerArg *a);
289
290// VBoxManageAppliance.cpp
291RTEXITCODE handleImportAppliance(HandlerArg *a);
292RTEXITCODE handleExportAppliance(HandlerArg *a);
293RTEXITCODE handleSignAppliance(HandlerArg *a);
294
295// VBoxManageSnapshot.cpp
296RTEXITCODE handleSnapshot(HandlerArg *a);
297
298/* VBoxManageUSB.cpp */
299RTEXITCODE handleUSBFilter(HandlerArg *a);
300RTEXITCODE handleUSBDevSource(HandlerArg *a);
301
302/* VBoxManageHostonly.cpp */
303RTEXITCODE handleHostonlyIf(HandlerArg *a);
304#ifdef VBOX_WITH_VMNET
305RTEXITCODE handleHostonlyNet(HandlerArg *a);
306#endif /* VBOX_WITH_VMNET */
307
308/* VBoxManageDHCPServer.cpp */
309RTEXITCODE handleDHCPServer(HandlerArg *a);
310
311/* VBoxManageNATNetwork.cpp */
312RTEXITCODE handleNATNetwork(HandlerArg *a);
313RTEXITCODE listNATNetworks(bool fLong, bool fSorted,
314 const ComPtr<IVirtualBox> &pVirtualBox);
315
316/* VBoxManageBandwidthControl.cpp */
317RTEXITCODE handleBandwidthControl(HandlerArg *a);
318
319/* VBoxManageCloud.cpp */
320RTEXITCODE handleCloud(HandlerArg *a);
321
322/* VBoxManageCloudMachine.cpp */
323RTEXITCODE handleCloudMachine(HandlerArg *a, int iFirst,
324 const char *pcszProviderName,
325 const char *pcszProfileName);
326RTEXITCODE listCloudMachines(HandlerArg *a, int iFirst,
327 const char *pcszProviderName,
328 const char *pcszProfileName);
329RTEXITCODE handleCloudShowVMInfo(HandlerArg *a, int iFirst,
330 const char *pcszProviderName,
331 const char *pcszProfileName);
332
333/* VBoxManageUpdateCheck.cpp */
334RTEXITCODE handleUpdateCheck(HandlerArg *a);
335
336/* VBoxManageModifyNvram.cpp */
337RTEXITCODE handleModifyNvram(HandlerArg *a);
338
339#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