VirtualBox

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

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

doc/manual,Main,Frontends: API changes in preparation for full VM encryption, guarded by VBOX_WITH_FULL_VM_ENCRYPTION (disabled by default) and returning a not supported error for now, bugref:9955

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.9 KB
Line 
1/* $Id: VBoxManage.h 94660 2022-04-21 08:38:34Z 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/** command handler argument */
92struct HandlerArg
93{
94 int argc;
95 char **argv;
96
97 ComPtr<IVirtualBox> virtualBox;
98 ComPtr<ISession> session;
99};
100
101
102/** showVMInfo details */
103typedef enum
104{
105 VMINFO_NONE = 0,
106 VMINFO_STANDARD = 1, /**< standard details */
107 VMINFO_FULL = 2, /**< both */
108 VMINFO_MACHINEREADABLE = 3, /**< both, and make it machine readable */
109 VMINFO_COMPACT = 4
110} VMINFO_DETAILS;
111
112
113////////////////////////////////////////////////////////////////////////////////
114//
115// global variables
116//
117////////////////////////////////////////////////////////////////////////////////
118
119extern bool g_fDetailedProgress; // in VBoxManage.cpp
120
121
122////////////////////////////////////////////////////////////////////////////////
123//
124// prototypes
125//
126////////////////////////////////////////////////////////////////////////////////
127
128/* VBoxManageHelp.cpp */
129void setCurrentCommand(enum HELP_CMD_VBOXMANAGE enmCommand);
130void setCurrentSubcommand(uint64_t fCurSubcommandScope);
131
132void printUsage(PRTSTREAM pStrm);
133void printHelp(PRTSTREAM pStrm);
134RTEXITCODE errorNoSubcommand(void);
135RTEXITCODE errorUnknownSubcommand(const char *pszSubCmd);
136RTEXITCODE errorTooManyParameters(char **papszArgs);
137RTEXITCODE errorGetOpt(int rcGetOpt, union RTGETOPTUNION const *pValueUnion);
138RTEXITCODE errorFetchValue(int iValueNo, const char *pszOption, int rcGetOptFetchValue, union RTGETOPTUNION const *pValueUnion);
139RTEXITCODE errorSyntax(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
140RTEXITCODE errorSyntaxV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
141HRESULT errorSyntaxHr(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
142RTEXITCODE errorArgument(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
143HRESULT errorArgumentHr(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
144
145# define SHOW_PROGRESS_NONE 0
146# define SHOW_PROGRESS_DESC RT_BIT_32(0)
147# define SHOW_PROGRESS RT_BIT_32(1)
148# define SHOW_PROGRESS_DETAILS RT_BIT_32(2)
149HRESULT showProgress(ComPtr<IProgress> progress, uint32_t fFlags = SHOW_PROGRESS);
150
151/* VBoxManage.cpp */
152void showLogo(PRTSTREAM pStrm);
153
154/* VBoxInternalManage.cpp */
155DECLHIDDEN(void) printUsageInternalCmds(PRTSTREAM pStrm);
156RTEXITCODE handleInternalCommands(HandlerArg *a);
157
158/* VBoxManageControlVM.cpp */
159RTEXITCODE handleControlVM(HandlerArg *a);
160
161/* VBoxManageModifyVM.cpp */
162void parseGroups(const char *pcszGroups, com::SafeArray<BSTR> *pGroups);
163#ifdef VBOX_WITH_RECORDING
164int parseScreens(const char *pcszScreens, com::SafeArray<BOOL> *pScreens);
165#endif
166RTEXITCODE handleModifyVM(HandlerArg *a);
167
168/* VBoxManageDebugVM.cpp */
169RTEXITCODE handleDebugVM(HandlerArg *a);
170
171/* VBoxManageGuestProp.cpp */
172RTEXITCODE handleGuestProperty(HandlerArg *a);
173
174/* VBoxManageGuestCtrl.cpp */
175RTEXITCODE handleGuestControl(HandlerArg *a);
176
177/* VBoxManageVMInfo.cpp */
178HRESULT showSnapshots(ComPtr<ISnapshot> &rootSnapshot,
179 ComPtr<ISnapshot> &currentSnapshot,
180 VMINFO_DETAILS details,
181 const com::Utf8Str &prefix = "",
182 int level = 0);
183RTEXITCODE handleShowVMInfo(HandlerArg *a);
184HRESULT showVMInfo(ComPtr<IVirtualBox> pVirtualBox,
185 ComPtr<IMachine> pMachine,
186 ComPtr<ISession> pSession,
187 VMINFO_DETAILS details = VMINFO_NONE);
188const char *machineStateToName(MachineState_T machineState, bool fShort);
189HRESULT showBandwidthGroups(ComPtr<IBandwidthControl> &bwCtrl,
190 VMINFO_DETAILS details);
191void outputMachineReadableString(const char *pszName, const char *pszValue, bool fQuoteName = false, bool fNewline = true);
192void outputMachineReadableString(const char *pszName, com::Bstr const *pbstrValue, bool fQuoteName = false, bool fNewline = true);
193void outputMachineReadableStringWithFmtName(const char *pszValue, bool fQuoteName, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(3, 4);
194void outputMachineReadableStringWithFmtName(com::Bstr const *pbstrValue, bool fQuoteName, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(3, 4);
195void outputMachineReadableBool(const char *pszName, BOOL const *pfValue);
196void outputMachineReadableBool(const char *pszName, bool const *pfValue);
197void outputMachineReadableULong(const char *pszName, ULONG *uValue);
198void outputMachineReadableLong64(const char *pszName, LONG64 *uValue);
199
200/* VBoxManageList.cpp */
201RTEXITCODE handleList(HandlerArg *a);
202
203/* VBoxManageMetrics.cpp */
204RTEXITCODE handleMetrics(HandlerArg *a);
205
206/* VBoxManageMisc.cpp */
207RTEXITCODE handleRegisterVM(HandlerArg *a);
208RTEXITCODE handleUnregisterVM(HandlerArg *a);
209RTEXITCODE handleCreateVM(HandlerArg *a);
210RTEXITCODE handleCloneVM(HandlerArg *a);
211RTEXITCODE handleStartVM(HandlerArg *a);
212#ifdef VBOX_WITH_FULL_VM_ENCRYPTION
213RTEXITCODE handleEncryptVM(HandlerArg *a);
214#endif
215RTEXITCODE handleDiscardState(HandlerArg *a);
216RTEXITCODE handleAdoptState(HandlerArg *a);
217RTEXITCODE handleGetExtraData(HandlerArg *a);
218RTEXITCODE handleSetExtraData(HandlerArg *a);
219RTEXITCODE handleSetProperty(HandlerArg *a);
220RTEXITCODE handleSharedFolder(HandlerArg *a);
221RTEXITCODE handleExtPack(HandlerArg *a);
222RTEXITCODE handleUnattended(HandlerArg *a);
223RTEXITCODE handleMoveVM(HandlerArg *a);
224RTEXITCODE handleCloudProfile(HandlerArg *a);
225
226/* VBoxManageDisk.cpp */
227HRESULT openMedium(HandlerArg *a, const char *pszFilenameOrUuid,
228 DeviceType_T enmDevType, AccessMode_T enmAccessMode,
229 ComPtr<IMedium> &pMedium, bool fForceNewUuidOnOpen,
230 bool fSilent);
231RTEXITCODE handleCreateMedium(HandlerArg *a);
232RTEXITCODE handleModifyMedium(HandlerArg *a);
233RTEXITCODE handleCloneMedium(HandlerArg *a);
234RTEXITCODE handleMediumProperty(HandlerArg *a);
235RTEXITCODE handleEncryptMedium(HandlerArg *a);
236RTEXITCODE handleCheckMediumPassword(HandlerArg *a);
237RTEXITCODE handleConvertFromRaw(HandlerArg *a);
238HRESULT showMediumInfo(const ComPtr<IVirtualBox> &pVirtualBox,
239 const ComPtr<IMedium> &pMedium,
240 const char *pszParentUUID,
241 bool fOptLong);
242RTEXITCODE handleShowMediumInfo(HandlerArg *a);
243RTEXITCODE handleCloseMedium(HandlerArg *a);
244RTEXITCODE handleMediumIO(HandlerArg *a);
245int parseMediumType(const char *psz, MediumType_T *penmMediumType);
246int parseBool(const char *psz, bool *pb);
247
248/* VBoxManageStorageController.cpp */
249RTEXITCODE handleStorageAttach(HandlerArg *a);
250RTEXITCODE handleStorageController(HandlerArg *a);
251
252// VBoxManageAppliance.cpp
253RTEXITCODE handleImportAppliance(HandlerArg *a);
254RTEXITCODE handleExportAppliance(HandlerArg *a);
255RTEXITCODE handleSignAppliance(HandlerArg *a);
256
257// VBoxManageSnapshot.cpp
258RTEXITCODE handleSnapshot(HandlerArg *a);
259
260/* VBoxManageUSB.cpp */
261RTEXITCODE handleUSBFilter(HandlerArg *a);
262RTEXITCODE handleUSBDevSource(HandlerArg *a);
263
264/* VBoxManageHostonly.cpp */
265RTEXITCODE handleHostonlyIf(HandlerArg *a);
266#ifdef VBOX_WITH_VMNET
267RTEXITCODE handleHostonlyNet(HandlerArg *a);
268#endif /* VBOX_WITH_VMNET */
269
270/* VBoxManageDHCPServer.cpp */
271RTEXITCODE handleDHCPServer(HandlerArg *a);
272
273/* VBoxManageNATNetwork.cpp */
274RTEXITCODE handleNATNetwork(HandlerArg *a);
275RTEXITCODE listNATNetworks(bool fLong, bool fSorted,
276 const ComPtr<IVirtualBox> &pVirtualBox);
277
278/* VBoxManageBandwidthControl.cpp */
279RTEXITCODE handleBandwidthControl(HandlerArg *a);
280
281/* VBoxManageCloud.cpp */
282RTEXITCODE handleCloud(HandlerArg *a);
283
284/* VBoxManageCloudMachine.cpp */
285RTEXITCODE handleCloudMachine(HandlerArg *a, int iFirst,
286 const char *pcszProviderName,
287 const char *pcszProfileName);
288RTEXITCODE listCloudMachines(HandlerArg *a, int iFirst,
289 const char *pcszProviderName,
290 const char *pcszProfileName);
291RTEXITCODE handleCloudShowVMInfo(HandlerArg *a, int iFirst,
292 const char *pcszProviderName,
293 const char *pcszProfileName);
294
295#ifdef VBOX_WITH_UPDATE_AGENT
296/* VBoxManageUpdateCheck.cpp */
297RTEXITCODE handleUpdateCheck(HandlerArg *a);
298#endif
299
300/* VBoxManageModifyNvram.cpp */
301RTEXITCODE handleModifyNvram(HandlerArg *a);
302
303#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