VBoxManage.cpp revision f503eb77dfd7a1fd153f0ad602d78d783f7fe321
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync * VBox frontends: VBoxManage (command-line interface)
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync * VBoxManage is VirtualBox's command-line interface. This is its rather
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync * long source.
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync * Copyright (C) 2006-2007 innotek GmbH
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync * available from http://www.virtualbox.org. This file is free software;
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync * you can redistribute it and/or modify it under the terms of the GNU
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync * General Public License as published by the Free Software Foundation,
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync/*******************************************************************************
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync* Header Files *
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync*******************************************************************************/
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsyncusing namespace com;
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync/* missing XPCOM <-> COM wrappers */
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync# define STDMETHOD_(ret, meth) NS_IMETHOD_(ret) meth
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync/** command handler type */
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsynctypedef DECLCALLBACK(int) FNHANDLER(int argc, char *argv[], ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession);
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync * Quick IUSBDevice implementation for detaching / attaching
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync * devices to the USB Controller.
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync // public initializer/uninitializer for internal purposes only
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync MyUSBDevice(uint16_t a_u16VendorId, uint16_t a_u16ProductId, uint16_t a_bcdRevision, uint64_t a_u64SerialHash, const char *a_pszComment)
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync : m_usVendorId(a_u16VendorId), m_usProductId(a_u16ProductId),
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync m_bcdRevision(a_bcdRevision), m_u64SerialHash(a_u64SerialHash),
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync delete this;
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync STDMETHOD(QueryInterface)(const IID &iid, void **ppvObject)
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync STDMETHOD(COMGETTER(Id))(GUIDPARAMOUT a_pId) { return E_NOTIMPL; }
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync STDMETHOD(COMGETTER(VendorId))(USHORT *a_pusVendorId) { *a_pusVendorId = m_usVendorId; return S_OK; }
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync STDMETHOD(COMGETTER(ProductId))(USHORT *a_pusProductId) { *a_pusProductId = m_usProductId; return S_OK; }
cabde247f900dcf6e58d009bbdd15099c028c6fcvboxsync STDMETHOD(COMGETTER(Revision))(USHORT *a_pusRevision) { *a_pusRevision = m_bcdRevision; return S_OK; }
STDMETHOD(COMGETTER(SerialHash))(ULONG64 *a_pullSerialHash) { *a_pullSerialHash = m_u64SerialHash; return S_OK; }
class Nullable
operator const T&() const { return mValue; }
mIsNull = false;
bool mIsNull;
T mValue;
struct USBFilterCmd
struct USBFilter
USBFilter ()
bool mGlobal;
static void showLogo(void)
if (!fShown)
fShown = true;
#ifdef RT_OS_LINUX
bool fLinux = true;
bool fLinux = false;
#ifdef RT_OS_WINDOWS
bool fWin = true;
bool fWin = false;
#ifdef RT_OS_DARWIN
bool fDarwin = true;
bool fDarwin = false;
#ifdef VBOX_VRDP
bool fVRDP = true;
bool fVRDP = false;
fLinux = true;
fWin = true;
fVRDP = true;
if (fWin)
if (fLinux)
if (fWin)
#ifdef VBOX_WITH_WINMM
if (fLinux)
#ifdef VBOX_WITH_ALSA
if (fDarwin)
if (fVRDP)
if (fInternalMode)
for (LONG curVal = (lastPercent / 10) * 10 + 10; curVal <= (currentPercent / 10) * 10; curVal += 10)
if (fCompleted)
if (coll)
if (snapshot)
RTTIME t;
bool fDetails = false)
if (!accessible)
return S_OK;
switch (bootMenuMode)
switch (machineState)
case MachineState_PoweredOff:
case MachineState_Saved:
case MachineState_Aborted:
case MachineState_Running:
case MachineState_Paused:
case MachineState_Starting:
case MachineState_Stopping:
case MachineState_Saving:
case MachineState_Restoring:
if (fFloppyEnabled)
switch (floppyState)
case DriveState_ImageMounted:
case DriveState_NotMounted:
if (fPassthrough)
if (!fEnabled)
switch (attachment)
if (!fEnabled)
switch (HostMode)
case PortMode_HostPipePort:
case PortMode_HostDevicePort:
switch (enmType)
switch (enmMode)
if (console)
if (fEnabled)
const char *strAuthType;
switch (vrdpAuthType)
fEnabled = false;
if (!fMore)
while (fMore)
index ++;
if (console)
if (!more)
while (more)
if (!more)
while (more)
while (fMore)
while (fMore)
if (!numSharedFolders)
if (console)
while (fMore)
if (!numSharedFolders)
if (!numSharedFolders)
if (console)
if (NumberOfClients > 0)
if (Active)
if (Active)
if (fDetails)
return S_OK;
bool fDetails = false;
fDetails = true;
if (console)
#ifdef RT_OS_WINDOWS
switch (storageType)
CHECK_ERROR(virtualBox, GetFloppyImageUsage(uuid, ResourceUsage_AllUsage, machineUUIDs.asOutParam()));
if (!fMore)
while (fMore)
switch (state)
ASSERT (false);
if (!more)
while (more)
switch (action)
index ++;
if (machine)
bool fStatic = false;
bool fRegister = false;
for (int i = 0; i < argc; i++)
fStatic = true;
fRegister = true;
CHECK_ERROR(virtualBox, CreateHardDisk(HardDiskStorageType_VirtualDiskImage, hardDisk.asOutParam()));
if (fStatic)
return VINF_SUCCESS;
if (!hardDisk)
if (!hardDisk)
if (!vdi)
if (!vdi)
unsigned uProcent;
if (!hardDisk)
if (hardDisk)
#ifdef RT_OS_LINUX
const bool fReadFromStdIn = false;
if (fReadFromStdIn)
File = 0;
return rc;
if (fReadFromStdIn)
RTPrintf("Creating fixed image with size %RU64Bytes (%RU64MB)...\n", cbFile, (cbFile + _1M - 1) / _1M);
if (pvBuf)
unsigned cbRead = 0;
return rc;
for (int i = 0; i < argc; i++)
char *pszNext;
char *pszNext;
bool fRegister = false;
for (int i = 0; i < argc; i++)
fRegister = true;
if (!name)
if (!settingsFile)
if (fRegister)
char *pszNext;
return (unsigned)u32;
#ifdef VBOX_VRDP
#ifdef RT_OS_LINUX
ULONG n = 0;
#ifdef RT_OS_LINUX
#ifdef VBOX_VRDP
vrdpport = 0;
fUsbEnabled = 0;
#ifdef RT_OS_WINDOWS
if (argc <= i)
int vrc;
if (name)
if (ostype)
if (memorySize > 0)
if (vramSize > 0)
if (acpi)
if (ioapic)
if (hwvirtex)
if (bioslogofadein)
if (bioslogofadeout)
if (bioslogodisplaytime != ~0U)
if (bioslogoimagepath)
if (biosbootmenumode)
if (biossystemtimeoffset)
if (hdds[0])
if (!hardDisk)
if (hardDisk)
if (!hardDisk)
if (hardDisk)
if (!hardDisk)
if (hardDisk)
if (dvd)
if (!hostDVDDrive)
if (!hostDVDDrive)
if (!dvdImage)
if (!dvdImage)
if (dvdpassthrough)
if (floppy)
if (!hostFloppyDrive)
if (!floppyImage)
if (audio)
#ifdef RT_OS_WINDOWS
#ifdef VBOX_WITH_WINMM
#ifdef RT_OS_LINUX
# ifdef VBOX_WITH_ALSA
#ifdef RT_OS_DARWIN
if (clipboard)
if (nics[n])
if (nictype[n])
if (macs[n])
if (cableconnected[n])
if (nictrace[n])
if (nictracefile[n])
if (hostifdev[n])
if (intnet[n])
#ifdef RT_OS_LINUX
if (tapsetup[n])
if (tapterm[n])
if (uarts_base[n])
if (uarts_mode[n])
#ifdef VBOX_VRDP
if (vrdpServer)
if (vrdp)
if (vrdpaddress)
if (vrdpauthtype)
if (vrdpmulticon)
if (snapshotFolder)
if (machine)
#ifdef RT_OS_LINUX
if (display)
if (adapter)
if (attach)
if (attach)
bool fAllowLocalLogon = true;
fAllowLocalLogon = false;
CHECK_ERROR_BREAK(guest, SetCredentials(Bstr(argv[2]), Bstr(argv[3]), Bstr(argv[4]), fAllowLocalLogon));
if (!hostDVDDrive)
if (!dvdImage)
if (!dvdImage)
if (!hostFloppyDrive)
if (!floppyImage)
if (machine)
if (!machine)
bool fAll = false;
fAll = true;
if (fAll)
bool registered = true;
registered = false;
if (!accessible)
if (description)
switch (type)
switch (storageType)
if (registered)
if (vdi)
if (type)
if (!hardDisk)
if (!dvdImage)
if (!floppyImage)
#ifdef RT_OS_WINDOWS
} while (extraDataKey);
if (value)
if (machine)
} while (extraDataKey);
if (value)
if (machine)
if (!machine)
bool fTransient = false;
fTransient = true;
if (fTransient)
if (console)
bool fTransient = false;
fTransient = true;
if (!name)
if (fTransient)
if (console)
&errMsg);
if (errMsg)
return vrc;
bool skipInvalid)
return vrc;
if (skipInvalid)
return vrc;
bool apply = false;
bool nobackup = false;
bool skipinvalid = false;
for (int i = 0; i < argc; i++)
apply = true;
nobackup = true;
skipinvalid = true;
if (apply)
if (dirOrFilePath)
RTR3Init(false);
bool fShowLogo = true;
int iCmdArg;
showLogo();
exit(0);
fShowLogo = false;
iCmd++;
if (fShowLogo)
showLogo();
char *converted;
const char *command;
} commandHandlers[] =
#ifdef RT_OS_WINDOWS
int commandIndex;
return rc;