VBoxManage.cpp revision 2162ed290319349d7c9548c189f1730e594e1a2c
44c893d445b65632029af94fd8704471cda97dc7vboxsync * VBox frontends: VBoxManage (command-line interface)
44c893d445b65632029af94fd8704471cda97dc7vboxsync * VBoxManage is VirtualBox's command-line interface. This is its rather
44c893d445b65632029af94fd8704471cda97dc7vboxsync * long source.
44c893d445b65632029af94fd8704471cda97dc7vboxsync * Copyright (C) 2006 InnoTek Systemberatung GmbH
44c893d445b65632029af94fd8704471cda97dc7vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
44c893d445b65632029af94fd8704471cda97dc7vboxsync * available from http://www.virtualbox.org. This file is free software;
44c893d445b65632029af94fd8704471cda97dc7vboxsync * you can redistribute it and/or modify it under the terms of the GNU
44c893d445b65632029af94fd8704471cda97dc7vboxsync * General Public License as published by the Free Software Foundation,
44c893d445b65632029af94fd8704471cda97dc7vboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
44c893d445b65632029af94fd8704471cda97dc7vboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
44c893d445b65632029af94fd8704471cda97dc7vboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
44c893d445b65632029af94fd8704471cda97dc7vboxsync * If you received this file as part of a commercial VirtualBox
44c893d445b65632029af94fd8704471cda97dc7vboxsync * distribution, then only the terms of your commercial VirtualBox
44c893d445b65632029af94fd8704471cda97dc7vboxsync * license agreement apply instead of the previous paragraph.
44c893d445b65632029af94fd8704471cda97dc7vboxsync/*******************************************************************************
44c893d445b65632029af94fd8704471cda97dc7vboxsync* Header Files *
44c893d445b65632029af94fd8704471cda97dc7vboxsync*******************************************************************************/
#include "VBoxManage.h"
using namespace com;
#ifndef STDMETHOD_
#ifndef NS_GET_IID
#ifndef __WIN__
typedef DECLCALLBACK(int) FNHANDLER(int argc, char *argv[], ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession);
// public initializer/uninitializer for internal purposes only
MyUSBDevice(uint16_t a_u16VendorId, uint16_t a_u16ProductId, uint16_t a_bcdRevision, uint64_t a_u64SerialHash, const char *a_pszComment)
m_cRefs(0)
if (!cRefs)
return cRefs;
return E_NOINTERFACE;
AddRef();
return S_OK;
STDMETHOD(COMGETTER(VendorId))(USHORT *a_pusVendorId) { *a_pusVendorId = m_usVendorId; return S_OK; }
STDMETHOD(COMGETTER(ProductId))(USHORT *a_pusProductId) { *a_pusProductId = m_usProductId; return S_OK; }
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;
#ifdef __LINUX__
bool fLinux = true;
bool fLinux = false;
#ifdef __WIN__
bool fWin = true;
bool fWin = false;
#ifdef VBOX_VRDP
bool fVRDP = true;
bool fVRDP = false;
fLinux = true;
fWin = true;
fVRDP = true;
if (fWin)
if (fLinux)
if (fLinux)
#ifdef VBOX_WITH_ALSA
if (fWin)
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;
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)
switch (enmType)
if (console)
if (fEnabled)
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 (console)
while (fMore)
if (!numSharedFolders)
if (console)
if (NumberOfClients > 0)
if (Active)
if (Active)
return S_OK;
if (console)
#ifdef __WIN__
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)
if (!hardDisk)
if (type)
if (!hardDisk)
if (hardDisk)
for (int i = 0; i < argc; i++)
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 __LINUX__
ULONG n = 0;
#ifdef __LINUX__
#ifdef VBOX_VRDP
vrdpport = 0;
fUsbEnabled = 0;
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 (hdds[0])
if (!hardDisk)
if (hardDisk)
if (!hardDisk)
if (hardDisk)
if (!hardDisk)
if (hardDisk)
if (dvd)
if (!hostDVDDrive)
if (!dvdImage)
if (!dvdImage)
if (dvdpassthrough)
if (floppy)
if (!hostFloppyDrive)
if (!floppyImage)
if (audio)
#ifdef __LINUX__
#ifdef VBOX_WITH_ALSA
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 __LINUX__
if (tapsetup[n])
if (tapterm[n])
#ifdef VBOX_VRDP
if (vrdpServer)
if (vrdp)
if (vrdpauthtype)
if (snapshotFolder)
if (machine)
CHECK_ERROR_RET(virtualBox, OpenRemoteSession(session, uuid, sessionType, progress.asOutParam()), rc);
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)
if (!hardDisk)
if (description)
switch (type)
switch (storageType)
if (vdi)
if (!hardDisk)
if (!dvdImage)
if (!floppyImage)
#ifdef __WIN__
} 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)
if (!homeDir)
RTR3Init(false);
char *converted;
char *command;
} commandHandlers[] =
#ifdef __WIN__
int commandIndex;
return rc;