VirtualBox

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

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

VBoxManage/modifyvm,showvminfo: Added --testing-enabled=bool, --testing-mmio=bool and --testing-cfg-dwordN=val switches to modifyvm for easy VMMDev/Testing config. Display these settings in showvminfo.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.5 KB
Line 
1/* $Id: VBoxManage.h 92538 2021-11-22 01:53:20Z vboxsync $ */
2/** @file
3 * VBoxManage - VirtualBox command-line interface, internal header file.
4 */
5
6/*
7 * Copyright (C) 2006-2020 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_LIST,
101 USAGE_SHOWVMINFO,
102 USAGE_REGISTERVM,
103 USAGE_UNREGISTERVM,
104 USAGE_CREATEVM,
105 USAGE_MODIFYVM,
106 USAGE_STARTVM,
107 USAGE_CONTROLVM,
108 USAGE_DISCARDSTATE,
109 USAGE_CLOSEMEDIUM,
110 USAGE_SHOWMEDIUMINFO,
111 USAGE_CREATEMEDIUM,
112 USAGE_MODIFYMEDIUM,
113 USAGE_CLONEMEDIUM,
114 USAGE_MOVEVM,
115 USAGE_CREATEHOSTIF,
116 USAGE_REMOVEHOSTIF,
117 USAGE_GETEXTRADATA,
118 USAGE_SETEXTRADATA,
119 USAGE_SETPROPERTY,
120 USAGE_USBFILTER,
121 USAGE_I_LOADSYMS,
122 USAGE_I_LOADMAP,
123 USAGE_I_SETHDUUID,
124 USAGE_CONVERTFROMRAW,
125 USAGE_I_LISTPARTITIONS,
126 USAGE_I_CREATERAWVMDK,
127 USAGE_ADOPTSTATE,
128 USAGE_I_MODINSTALL,
129 USAGE_I_MODUNINSTALL,
130 USAGE_I_RENAMEVMDK,
131#ifdef VBOX_WITH_GUEST_PROPS
132 USAGE_GUESTPROPERTY,
133#endif /* VBOX_WITH_GUEST_PROPS defined */
134 USAGE_I_CONVERTTORAW,
135 USAGE_METRICS,
136 USAGE_I_CONVERTHD,
137 USAGE_IMPORTAPPLIANCE,
138 USAGE_EXPORTAPPLIANCE,
139 USAGE_HOSTONLYIFS,
140 USAGE_I_DUMPHDINFO,
141 USAGE_STORAGEATTACH,
142 USAGE_STORAGECONTROLLER,
143#ifdef VBOX_WITH_GUEST_CONTROL
144 USAGE_GUESTCONTROL,
145#endif /* VBOX_WITH_GUEST_CONTROL defined */
146 USAGE_I_DEBUGLOG,
147 USAGE_I_SETHDPARENTUUID,
148 USAGE_I_PASSWORDHASH,
149 USAGE_BANDWIDTHCONTROL,
150 USAGE_I_GUESTSTATS,
151 USAGE_I_REPAIRHD,
152 USAGE_NATNETWORK,
153 USAGE_MEDIUMPROPERTY,
154 USAGE_ENCRYPTMEDIUM,
155 USAGE_MEDIUMENCCHKPWD,
156 USAGE_USBDEVSOURCE,
157 USAGE_CLOUDPROFILE,
158 /* Insert new entries before this line, but only if it is not an option
159 * to go for the new style command and help handling (see e.g. extpack,
160 * unattend or mediumio. */
161 USAGE_S_NEWCMD = 10000, /**< new style command with no old help support */
162 USAGE_S_ALL,
163 USAGE_S_DUMPOPTS
164} USAGECATEGORY;
165/** @} */
166
167
168#define HELP_SCOPE_USBFILTER_ADD RT_BIT_64(0)
169#define HELP_SCOPE_USBFILTER_MODIFY RT_BIT_64(1)
170#define HELP_SCOPE_USBFILTER_REMOVE RT_BIT_64(2)
171
172#ifdef VBOX_WITH_GUEST_CONTROL
173# define HELP_SCOPE_GSTCTRL_RUN RT_BIT(0)
174# define HELP_SCOPE_GSTCTRL_START RT_BIT(1)
175# define HELP_SCOPE_GSTCTRL_COPYFROM RT_BIT(2)
176# define HELP_SCOPE_GSTCTRL_COPYTO RT_BIT(3)
177# define HELP_SCOPE_GSTCTRL_MKDIR RT_BIT(4)
178# define HELP_SCOPE_GSTCTRL_RMDIR RT_BIT(5)
179# define HELP_SCOPE_GSTCTRL_RM RT_BIT(6)
180# define HELP_SCOPE_GSTCTRL_MV RT_BIT(7)
181# define HELP_SCOPE_GSTCTRL_MKTEMP RT_BIT(8)
182# define HELP_SCOPE_GSTCTRL_LIST RT_BIT(9)
183# define HELP_SCOPE_GSTCTRL_CLOSEPROCESS RT_BIT(10)
184# define HELP_SCOPE_GSTCTRL_CLOSESESSION RT_BIT(11)
185# define HELP_SCOPE_GSTCTRL_STAT RT_BIT(12)
186# define HELP_SCOPE_GSTCTRL_UPDATEGA RT_BIT(13)
187# define HELP_SCOPE_GSTCTRL_WATCH RT_BIT(14)
188# define HELP_SCOPE_GSTCTRL_WAITRUNLEVEL RT_BIT(15)
189#endif
190
191/** command handler argument */
192struct HandlerArg
193{
194 int argc;
195 char **argv;
196
197#ifndef VBOX_ONLY_DOCS
198 ComPtr<IVirtualBox> virtualBox;
199 ComPtr<ISession> session;
200#endif
201};
202
203/** flag whether we're in internal mode */
204extern bool g_fInternalMode;
205
206/** showVMInfo details */
207typedef enum
208{
209 VMINFO_NONE = 0,
210 VMINFO_STANDARD = 1, /**< standard details */
211 VMINFO_FULL = 2, /**< both */
212 VMINFO_MACHINEREADABLE = 3, /**< both, and make it machine readable */
213 VMINFO_COMPACT = 4
214} VMINFO_DETAILS;
215
216
217////////////////////////////////////////////////////////////////////////////////
218//
219// global variables
220//
221////////////////////////////////////////////////////////////////////////////////
222
223extern bool g_fDetailedProgress; // in VBoxManage.cpp
224
225
226////////////////////////////////////////////////////////////////////////////////
227//
228// prototypes
229//
230////////////////////////////////////////////////////////////////////////////////
231
232/* VBoxManageHelp.cpp */
233
234/* Legacy help infrastructure, to be replaced by new one using generated help. */
235void printUsage(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, PRTSTREAM pStrm);
236RTEXITCODE errorSyntax(USAGECATEGORY enmCommand, const char *pszFormat, ...);
237RTEXITCODE errorSyntaxEx(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, const char *pszFormat, ...);
238RTEXITCODE errorGetOpt(USAGECATEGORY enmCommand, int rc, union RTGETOPTUNION const *pValueUnion);
239RTEXITCODE errorGetOptEx(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, int rc, union RTGETOPTUNION const *pValueUnion);
240
241void printUsageInternal(USAGECATEGORY enmCommand, PRTSTREAM pStrm);
242
243#ifndef VBOX_ONLY_DOCS
244void setCurrentCommand(enum HELP_CMD_VBOXMANAGE enmCommand);
245void setCurrentSubcommand(uint64_t fCurSubcommandScope);
246
247void printUsage(PRTSTREAM pStrm);
248void printHelp(PRTSTREAM pStrm);
249RTEXITCODE errorNoSubcommand(void);
250RTEXITCODE errorUnknownSubcommand(const char *pszSubCmd);
251RTEXITCODE errorTooManyParameters(char **papszArgs);
252RTEXITCODE errorGetOpt(int rcGetOpt, union RTGETOPTUNION const *pValueUnion);
253RTEXITCODE errorFetchValue(int iValueNo, const char *pszOption, int rcGetOptFetchValue, union RTGETOPTUNION const *pValueUnion);
254RTEXITCODE errorSyntax(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
255RTEXITCODE errorSyntaxV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
256HRESULT errorSyntaxHr(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
257RTEXITCODE errorArgument(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
258HRESULT errorArgumentHr(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
259
260# define SHOW_PROGRESS_NONE 0
261# define SHOW_PROGRESS_DESC RT_BIT_32(0)
262# define SHOW_PROGRESS RT_BIT_32(1)
263# define SHOW_PROGRESS_DETAILS RT_BIT_32(2)
264HRESULT showProgress(ComPtr<IProgress> progress, uint32_t fFlags = SHOW_PROGRESS);
265#endif
266
267/* VBoxManage.cpp */
268void showLogo(PRTSTREAM pStrm);
269
270#ifndef VBOX_ONLY_DOCS
271RTEXITCODE handleInternalCommands(HandlerArg *a);
272#endif /* !VBOX_ONLY_DOCS */
273
274/* VBoxManageControlVM.cpp */
275RTEXITCODE handleControlVM(HandlerArg *a);
276
277/* VBoxManageModifyVM.cpp */
278#ifndef VBOX_ONLY_DOCS
279void parseGroups(const char *pcszGroups, com::SafeArray<BSTR> *pGroups);
280#endif
281RTEXITCODE handleModifyVM(HandlerArg *a);
282
283/* VBoxManageDebugVM.cpp */
284RTEXITCODE handleDebugVM(HandlerArg *a);
285
286/* VBoxManageGuestProp.cpp */
287extern void usageGuestProperty(PRTSTREAM pStrm, const char *pcszSep1, const char *pcszSep2);
288
289/* VBoxManageGuestCtrl.cpp */
290extern void usageGuestControl(PRTSTREAM pStrm, const char *pcszSep1, const char *pcszSep2, uint64_t fSubcommandScope);
291
292#ifndef VBOX_ONLY_DOCS
293/* VBoxManageGuestProp.cpp */
294RTEXITCODE handleGuestProperty(HandlerArg *a);
295
296/* VBoxManageGuestCtrl.cpp */
297RTEXITCODE handleGuestControl(HandlerArg *a);
298
299/* VBoxManageVMInfo.cpp */
300HRESULT showSnapshots(ComPtr<ISnapshot> &rootSnapshot,
301 ComPtr<ISnapshot> &currentSnapshot,
302 VMINFO_DETAILS details,
303 const com::Utf8Str &prefix = "",
304 int level = 0);
305RTEXITCODE handleShowVMInfo(HandlerArg *a);
306HRESULT showVMInfo(ComPtr<IVirtualBox> pVirtualBox,
307 ComPtr<IMachine> pMachine,
308 ComPtr<ISession> pSession,
309 VMINFO_DETAILS details = VMINFO_NONE);
310const char *machineStateToName(MachineState_T machineState, bool fShort);
311HRESULT showBandwidthGroups(ComPtr<IBandwidthControl> &bwCtrl,
312 VMINFO_DETAILS details);
313void outputMachineReadableString(const char *pszName, const char *pszValue, bool fQuoteName = false);
314void outputMachineReadableString(const char *pszName, com::Bstr const *pbstrValue, bool fQuoteName = false);
315void outputMachineReadableStringWithFmtName(const char *pszValue, bool fQuoteName, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(3, 4);
316void outputMachineReadableStringWithFmtName(com::Bstr const *pbstrValue, bool fQuoteName, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(3, 4);
317void outputMachineReadableBool(const char *pszName, BOOL const *pfValue);
318void outputMachineReadableBool(const char *pszName, bool const *pfValue);
319void outputMachineReadableULong(const char *pszName, ULONG *uValue);
320void outputMachineReadableLong64(const char *pszName, LONG64 *uValue);
321
322/* VBoxManageList.cpp */
323RTEXITCODE handleList(HandlerArg *a);
324
325/* VBoxManageMetrics.cpp */
326RTEXITCODE handleMetrics(HandlerArg *a);
327
328/* VBoxManageMisc.cpp */
329RTEXITCODE handleRegisterVM(HandlerArg *a);
330RTEXITCODE handleUnregisterVM(HandlerArg *a);
331RTEXITCODE handleCreateVM(HandlerArg *a);
332RTEXITCODE handleCloneVM(HandlerArg *a);
333RTEXITCODE handleStartVM(HandlerArg *a);
334RTEXITCODE handleDiscardState(HandlerArg *a);
335RTEXITCODE handleAdoptState(HandlerArg *a);
336RTEXITCODE handleGetExtraData(HandlerArg *a);
337RTEXITCODE handleSetExtraData(HandlerArg *a);
338RTEXITCODE handleSetProperty(HandlerArg *a);
339RTEXITCODE handleSharedFolder(HandlerArg *a);
340RTEXITCODE handleExtPack(HandlerArg *a);
341RTEXITCODE handleUnattended(HandlerArg *a);
342RTEXITCODE handleMoveVM(HandlerArg *a);
343RTEXITCODE handleCloudProfile(HandlerArg *a);
344
345/* VBoxManageDisk.cpp */
346HRESULT openMedium(HandlerArg *a, const char *pszFilenameOrUuid,
347 DeviceType_T enmDevType, AccessMode_T enmAccessMode,
348 ComPtr<IMedium> &pMedium, bool fForceNewUuidOnOpen,
349 bool fSilent);
350RTEXITCODE handleCreateMedium(HandlerArg *a);
351RTEXITCODE handleModifyMedium(HandlerArg *a);
352RTEXITCODE handleCloneMedium(HandlerArg *a);
353RTEXITCODE handleMediumProperty(HandlerArg *a);
354RTEXITCODE handleEncryptMedium(HandlerArg *a);
355RTEXITCODE handleCheckMediumPassword(HandlerArg *a);
356RTEXITCODE handleConvertFromRaw(HandlerArg *a);
357HRESULT showMediumInfo(const ComPtr<IVirtualBox> &pVirtualBox,
358 const ComPtr<IMedium> &pMedium,
359 const char *pszParentUUID,
360 bool fOptLong);
361RTEXITCODE handleShowMediumInfo(HandlerArg *a);
362RTEXITCODE handleCloseMedium(HandlerArg *a);
363RTEXITCODE handleMediumIO(HandlerArg *a);
364int parseMediumType(const char *psz, MediumType_T *penmMediumType);
365int parseBool(const char *psz, bool *pb);
366
367/* VBoxManageStorageController.cpp */
368RTEXITCODE handleStorageAttach(HandlerArg *a);
369RTEXITCODE handleStorageController(HandlerArg *a);
370
371// VBoxManageAppliance.cpp
372RTEXITCODE handleImportAppliance(HandlerArg *a);
373RTEXITCODE handleExportAppliance(HandlerArg *a);
374RTEXITCODE handleSignAppliance(HandlerArg *a);
375
376// VBoxManageSnapshot.cpp
377RTEXITCODE handleSnapshot(HandlerArg *a);
378
379/* VBoxManageUSB.cpp */
380RTEXITCODE handleUSBFilter(HandlerArg *a);
381RTEXITCODE handleUSBDevSource(HandlerArg *a);
382
383/* VBoxManageHostonly.cpp */
384RTEXITCODE handleHostonlyIf(HandlerArg *a);
385#ifdef VBOX_WITH_VMNET
386RTEXITCODE handleHostonlyNet(HandlerArg *a);
387#endif /* VBOX_WITH_VMNET */
388
389/* VBoxManageDHCPServer.cpp */
390RTEXITCODE handleDHCPServer(HandlerArg *a);
391
392/* VBoxManageNATNetwork.cpp */
393RTEXITCODE handleNATNetwork(HandlerArg *a);
394
395
396/* VBoxManageBandwidthControl.cpp */
397RTEXITCODE handleBandwidthControl(HandlerArg *a);
398
399/* VBoxManageCloud.cpp */
400RTEXITCODE handleCloud(HandlerArg *a);
401
402/* VBoxManageCloudMachine.cpp */
403RTEXITCODE handleCloudMachine(HandlerArg *a, int iFirst,
404 const char *pcszProviderName,
405 const char *pcszProfileName);
406RTEXITCODE listCloudMachines(HandlerArg *a, int iFirst,
407 const char *pcszProviderName,
408 const char *pcszProfileName);
409RTEXITCODE handleCloudShowVMInfo(HandlerArg *a, int iFirst,
410 const char *pcszProviderName,
411 const char *pcszProfileName);
412
413/* VBoxManageUpdateCheck.cpp */
414RTEXITCODE handleUpdateCheck(HandlerArg *a);
415
416/* VBoxManageModifyNvram.cpp */
417RTEXITCODE handleModifyNvram(HandlerArg *a);
418
419#endif /* !VBOX_ONLY_DOCS */
420
421#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