VirtualBox

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

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

FE/VBoxManage: Remove unused USAGE categories, ​bugref:9186

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.5 KB
Line 
1/* $Id: VBoxManage.h 94231 2022-03-15 08:36:45Z 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_I_LOADSYMS,
101 USAGE_I_LOADMAP,
102 USAGE_I_SETHDUUID,
103 USAGE_I_LISTPARTITIONS,
104 USAGE_I_CREATERAWVMDK,
105 USAGE_I_MODINSTALL,
106 USAGE_I_MODUNINSTALL,
107 USAGE_I_RENAMEVMDK,
108 USAGE_I_CONVERTTORAW,
109 USAGE_I_CONVERTHD,
110 USAGE_I_DUMPHDINFO,
111 USAGE_I_DEBUGLOG,
112 USAGE_I_SETHDPARENTUUID,
113 USAGE_I_PASSWORDHASH,
114 USAGE_I_GUESTSTATS,
115 USAGE_I_REPAIRHD,
116 /* Insert new entries before this line, but only if it is not an option
117 * to go for the new style command and help handling (see e.g. extpack,
118 * unattend or mediumio. */
119 USAGE_S_NEWCMD = 10000, /**< new style command with no old help support */
120 USAGE_S_ALL,
121 USAGE_S_DUMPOPTS
122} USAGECATEGORY;
123/** @} */
124
125
126/** command handler argument */
127struct HandlerArg
128{
129 int argc;
130 char **argv;
131
132#ifndef VBOX_ONLY_DOCS
133 ComPtr<IVirtualBox> virtualBox;
134 ComPtr<ISession> session;
135#endif
136};
137
138/** flag whether we're in internal mode */
139extern bool g_fInternalMode;
140
141/** showVMInfo details */
142typedef enum
143{
144 VMINFO_NONE = 0,
145 VMINFO_STANDARD = 1, /**< standard details */
146 VMINFO_FULL = 2, /**< both */
147 VMINFO_MACHINEREADABLE = 3, /**< both, and make it machine readable */
148 VMINFO_COMPACT = 4
149} VMINFO_DETAILS;
150
151
152////////////////////////////////////////////////////////////////////////////////
153//
154// global variables
155//
156////////////////////////////////////////////////////////////////////////////////
157
158extern bool g_fDetailedProgress; // in VBoxManage.cpp
159
160
161////////////////////////////////////////////////////////////////////////////////
162//
163// prototypes
164//
165////////////////////////////////////////////////////////////////////////////////
166
167/* VBoxManageHelp.cpp */
168
169/* Legacy help infrastructure, to be replaced by new one using generated help. */
170void printUsage(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, PRTSTREAM pStrm);
171RTEXITCODE errorSyntax(USAGECATEGORY enmCommand, const char *pszFormat, ...);
172RTEXITCODE errorSyntaxEx(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, const char *pszFormat, ...);
173RTEXITCODE errorGetOpt(USAGECATEGORY enmCommand, int rc, union RTGETOPTUNION const *pValueUnion);
174RTEXITCODE errorGetOptEx(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, int rc, union RTGETOPTUNION const *pValueUnion);
175
176void printUsageInternal(USAGECATEGORY enmCommand, PRTSTREAM pStrm);
177
178#ifndef VBOX_ONLY_DOCS
179void setCurrentCommand(enum HELP_CMD_VBOXMANAGE enmCommand);
180void setCurrentSubcommand(uint64_t fCurSubcommandScope);
181
182void printUsage(PRTSTREAM pStrm);
183void printHelp(PRTSTREAM pStrm);
184RTEXITCODE errorNoSubcommand(void);
185RTEXITCODE errorUnknownSubcommand(const char *pszSubCmd);
186RTEXITCODE errorTooManyParameters(char **papszArgs);
187RTEXITCODE errorGetOpt(int rcGetOpt, union RTGETOPTUNION const *pValueUnion);
188RTEXITCODE errorFetchValue(int iValueNo, const char *pszOption, int rcGetOptFetchValue, union RTGETOPTUNION const *pValueUnion);
189RTEXITCODE errorSyntax(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
190RTEXITCODE errorSyntaxV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
191HRESULT errorSyntaxHr(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
192RTEXITCODE errorArgument(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
193HRESULT errorArgumentHr(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
194
195# define SHOW_PROGRESS_NONE 0
196# define SHOW_PROGRESS_DESC RT_BIT_32(0)
197# define SHOW_PROGRESS RT_BIT_32(1)
198# define SHOW_PROGRESS_DETAILS RT_BIT_32(2)
199HRESULT showProgress(ComPtr<IProgress> progress, uint32_t fFlags = SHOW_PROGRESS);
200#endif
201
202/* VBoxManage.cpp */
203void showLogo(PRTSTREAM pStrm);
204
205#ifndef VBOX_ONLY_DOCS
206RTEXITCODE handleInternalCommands(HandlerArg *a);
207#endif /* !VBOX_ONLY_DOCS */
208
209/* VBoxManageControlVM.cpp */
210RTEXITCODE handleControlVM(HandlerArg *a);
211
212/* VBoxManageModifyVM.cpp */
213#ifndef VBOX_ONLY_DOCS
214void parseGroups(const char *pcszGroups, com::SafeArray<BSTR> *pGroups);
215# ifdef VBOX_WITH_RECORDING
216int parseScreens(const char *pcszScreens, com::SafeArray<BOOL> *pScreens);
217# endif
218#endif
219RTEXITCODE handleModifyVM(HandlerArg *a);
220
221/* VBoxManageDebugVM.cpp */
222RTEXITCODE handleDebugVM(HandlerArg *a);
223
224#ifndef VBOX_ONLY_DOCS
225/* VBoxManageGuestProp.cpp */
226RTEXITCODE handleGuestProperty(HandlerArg *a);
227
228/* VBoxManageGuestCtrl.cpp */
229RTEXITCODE handleGuestControl(HandlerArg *a);
230
231/* VBoxManageVMInfo.cpp */
232HRESULT showSnapshots(ComPtr<ISnapshot> &rootSnapshot,
233 ComPtr<ISnapshot> &currentSnapshot,
234 VMINFO_DETAILS details,
235 const com::Utf8Str &prefix = "",
236 int level = 0);
237RTEXITCODE handleShowVMInfo(HandlerArg *a);
238HRESULT showVMInfo(ComPtr<IVirtualBox> pVirtualBox,
239 ComPtr<IMachine> pMachine,
240 ComPtr<ISession> pSession,
241 VMINFO_DETAILS details = VMINFO_NONE);
242const char *machineStateToName(MachineState_T machineState, bool fShort);
243HRESULT showBandwidthGroups(ComPtr<IBandwidthControl> &bwCtrl,
244 VMINFO_DETAILS details);
245void outputMachineReadableString(const char *pszName, const char *pszValue, bool fQuoteName = false, bool fNewline = true);
246void outputMachineReadableString(const char *pszName, com::Bstr const *pbstrValue, bool fQuoteName = false, bool fNewline = true);
247void outputMachineReadableStringWithFmtName(const char *pszValue, bool fQuoteName, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(3, 4);
248void outputMachineReadableStringWithFmtName(com::Bstr const *pbstrValue, bool fQuoteName, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(3, 4);
249void outputMachineReadableBool(const char *pszName, BOOL const *pfValue);
250void outputMachineReadableBool(const char *pszName, bool const *pfValue);
251void outputMachineReadableULong(const char *pszName, ULONG *uValue);
252void outputMachineReadableLong64(const char *pszName, LONG64 *uValue);
253
254/* VBoxManageList.cpp */
255RTEXITCODE handleList(HandlerArg *a);
256
257/* VBoxManageMetrics.cpp */
258RTEXITCODE handleMetrics(HandlerArg *a);
259
260/* VBoxManageMisc.cpp */
261RTEXITCODE handleRegisterVM(HandlerArg *a);
262RTEXITCODE handleUnregisterVM(HandlerArg *a);
263RTEXITCODE handleCreateVM(HandlerArg *a);
264RTEXITCODE handleCloneVM(HandlerArg *a);
265RTEXITCODE handleStartVM(HandlerArg *a);
266RTEXITCODE handleDiscardState(HandlerArg *a);
267RTEXITCODE handleAdoptState(HandlerArg *a);
268RTEXITCODE handleGetExtraData(HandlerArg *a);
269RTEXITCODE handleSetExtraData(HandlerArg *a);
270RTEXITCODE handleSetProperty(HandlerArg *a);
271RTEXITCODE handleSharedFolder(HandlerArg *a);
272RTEXITCODE handleExtPack(HandlerArg *a);
273RTEXITCODE handleUnattended(HandlerArg *a);
274RTEXITCODE handleMoveVM(HandlerArg *a);
275RTEXITCODE handleCloudProfile(HandlerArg *a);
276
277/* VBoxManageDisk.cpp */
278HRESULT openMedium(HandlerArg *a, const char *pszFilenameOrUuid,
279 DeviceType_T enmDevType, AccessMode_T enmAccessMode,
280 ComPtr<IMedium> &pMedium, bool fForceNewUuidOnOpen,
281 bool fSilent);
282RTEXITCODE handleCreateMedium(HandlerArg *a);
283RTEXITCODE handleModifyMedium(HandlerArg *a);
284RTEXITCODE handleCloneMedium(HandlerArg *a);
285RTEXITCODE handleMediumProperty(HandlerArg *a);
286RTEXITCODE handleEncryptMedium(HandlerArg *a);
287RTEXITCODE handleCheckMediumPassword(HandlerArg *a);
288RTEXITCODE handleConvertFromRaw(HandlerArg *a);
289HRESULT showMediumInfo(const ComPtr<IVirtualBox> &pVirtualBox,
290 const ComPtr<IMedium> &pMedium,
291 const char *pszParentUUID,
292 bool fOptLong);
293RTEXITCODE handleShowMediumInfo(HandlerArg *a);
294RTEXITCODE handleCloseMedium(HandlerArg *a);
295RTEXITCODE handleMediumIO(HandlerArg *a);
296int parseMediumType(const char *psz, MediumType_T *penmMediumType);
297int parseBool(const char *psz, bool *pb);
298
299/* VBoxManageStorageController.cpp */
300RTEXITCODE handleStorageAttach(HandlerArg *a);
301RTEXITCODE handleStorageController(HandlerArg *a);
302
303// VBoxManageAppliance.cpp
304RTEXITCODE handleImportAppliance(HandlerArg *a);
305RTEXITCODE handleExportAppliance(HandlerArg *a);
306RTEXITCODE handleSignAppliance(HandlerArg *a);
307
308// VBoxManageSnapshot.cpp
309RTEXITCODE handleSnapshot(HandlerArg *a);
310
311/* VBoxManageUSB.cpp */
312RTEXITCODE handleUSBFilter(HandlerArg *a);
313RTEXITCODE handleUSBDevSource(HandlerArg *a);
314
315/* VBoxManageHostonly.cpp */
316RTEXITCODE handleHostonlyIf(HandlerArg *a);
317#ifdef VBOX_WITH_VMNET
318RTEXITCODE handleHostonlyNet(HandlerArg *a);
319#endif /* VBOX_WITH_VMNET */
320
321/* VBoxManageDHCPServer.cpp */
322RTEXITCODE handleDHCPServer(HandlerArg *a);
323
324/* VBoxManageNATNetwork.cpp */
325RTEXITCODE handleNATNetwork(HandlerArg *a);
326RTEXITCODE listNATNetworks(bool fLong, bool fSorted,
327 const ComPtr<IVirtualBox> &pVirtualBox);
328
329/* VBoxManageBandwidthControl.cpp */
330RTEXITCODE handleBandwidthControl(HandlerArg *a);
331
332/* VBoxManageCloud.cpp */
333RTEXITCODE handleCloud(HandlerArg *a);
334
335/* VBoxManageCloudMachine.cpp */
336RTEXITCODE handleCloudMachine(HandlerArg *a, int iFirst,
337 const char *pcszProviderName,
338 const char *pcszProfileName);
339RTEXITCODE listCloudMachines(HandlerArg *a, int iFirst,
340 const char *pcszProviderName,
341 const char *pcszProfileName);
342RTEXITCODE handleCloudShowVMInfo(HandlerArg *a, int iFirst,
343 const char *pcszProviderName,
344 const char *pcszProfileName);
345
346/* VBoxManageUpdateCheck.cpp */
347RTEXITCODE handleUpdateCheck(HandlerArg *a);
348
349/* VBoxManageModifyNvram.cpp */
350RTEXITCODE handleModifyNvram(HandlerArg *a);
351
352#endif /* !VBOX_ONLY_DOCS */
353
354#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