VirtualBox

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

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

doc/manual,FE/VBoxManage: Convert natnetwork command to refentry documentation, ​bugref:9186

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