VirtualBox

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

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

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