ConsoleImpl2.cpp revision 7ffa227f187f4ff5561da9916c2b7bc949723018
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * VBox Console COM Class implementation
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * @remark We've split out the code that the 64-bit VC++ v8 compiler finds
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * problematic to optimize so we can disable optimizations and later,
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * perhaps, find a real solution for it (like rewriting the code and
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * to stop resemble a tonne of spaghetti).
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * Copyright (C) 2006-2010 Oracle Corporation
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * available from http://www.virtualbox.org. This file is free software;
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * you can redistribute it and/or modify it under the terms of the GNU
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * General Public License (GPL) as published by the Free Software
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
1205f5a22a14de7b9cf3055d6f914eac690c1715vboxsync/*******************************************************************************
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync* Header Files *
b2def6ea46868a11f7fd2857874e46c51932223avboxsync*******************************************************************************/
b2def6ea46868a11f7fd2857874e46c51932223avboxsync// for some reason Windows burns in sdk\...\winsock.h if this isn't included first
1084dfee3c44a35cbe9aef69158474a913a3e0d9vboxsync// generated header
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync#if 0 /* enable to play with lots of memory. */
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync#include <VBox/pdmapi.h> /* For PDMR3DriverAttach/PDMR3DriverDetach */
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync# include <hgcm/HGCM.h> /** @todo it should be possible to register a service
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync * extension using a VMMDev callback. */
a448d0dfcede5c742c35e4aee5f9848a4a61bf18vboxsync#endif /* VBOX_WITH_GUEST_PROPS */
# if defined(RT_OS_WINDOWS)
# include <Ntddndis.h>
# include <devguid.h>
# include <HostNetworkInterfaceImpl.h>
# include <netif.h>
# include <stdlib.h>
#include "DHCPServerRunner.h"
#if defined(RT_OS_DARWIN)
# include "IOKit/IOKitLib.h"
if (!service)
return VERR_NOT_FOUND;
(const void *)&inputStruct,
sizeof(inputStruct),
(void *)&outputStruct,
return VINF_SUCCESS;
#define VMWARE_NET_IN_SLOT_11
switch (enmType)
struct BootNic
unsigned mPciDev;
unsigned mPciFn;
int rc;
if (!fPresent)
return VERR_FILE_NOT_FOUND;
return S_OK;
*pfGetKeyFromRealSMC = false;
&& *aKey
&& **aKey)
return VINF_SUCCESS;
#ifdef RT_OS_DARWIN
return rc;
*pfGetKeyFromRealSMC = true;
*pfGetKeyFromRealSMC = true;
return rc;
int vrc,
const char *pcszName)
int m_vrc;
const char *pcszName,
const char *pcszValue)
const char *pcszName,
const char *pcszName,
const char *pcszName,
const void *pvBytes,
cbBytes);
const char *pcszName,
const char *pcszName,
const char *pcszName)
bool fFdcEnabled = false;
#if !defined(VBOX_WITH_XPCOM)
int rc;
#ifdef VBOX_WITH_RAW_MODE
if (fOsXGuest)
#ifdef VBOX_WITH_RAW_MODE
# ifdef RT_OS_DARWIN
if (fHWVirtExEnabled)
&fSupportsLongMode); H();
/** @todo Not exactly pretty to check strings; VBOXOSTYPE would be better, but that requires quite a bit of API change in Main. */
if ( !fIs64BitGuest
&& fIOAPIC
#ifdef VBOX_WITH_XPCOM
if (ioBandwidthMax != 0)
#ifdef VBOX_WITH_HPET
fHpetEnabled = false;
if (fHpetEnabled)
#ifdef VBOX_WITH_SMC
fSmcEnabled = false;
if (fSmcEnabled)
bool fGetKeyFromRealSMC;
#ifdef VBOX_WITH_LPC
fLpcEnabled = false;
if (fLpcEnabled)
#ifdef DEBUG
if (fIOAPIC)
#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
int iShowBootMenu;
switch (eBootMenuMode)
unsigned cModes = 0;
++cModes;
if (pFramebuffer)
ulHeightReduction = 0;
#ifdef VBOX_WITH_EFI
if (!fEfiEnabled)
return VERR_INVALID_PARAMETER;
const char *pszBootDevice;
switch (bootDevice)
case DeviceType_Null:
case DeviceType_HardDisk:
case DeviceType_DVD:
case DeviceType_Floppy:
case DeviceType_Network:
eFwType =
hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiUgaHorizontalResolution"), bstr.asOutParam()); H();
hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiUgaVerticalResolution"), bstr.asOutParam()); H();
if (fOsXGuest)
if (!pDev)
switch (enmCtrlType)
if (pBiosCfg)
{ "SataPrimaryMasterLUN", "SataPrimarySlaveLUN", "SataSecondaryMasterLUN", "SataSecondarySlaveLUN" };
if (pBiosCfg)
fFdcEnabled = true;
AssertMsgFailedReturn(("invalid storage controller type: %d\n", enmCtrlType), VERR_GENERAL_FAILURE);
atts[j],
pVM,
return rc;
#ifdef VMWARE_NET_IN_SLOT_11
bool fSwapSlots3and11 = false;
#ifdef VBOX_WITH_E1000
#ifdef VBOX_WITH_VIRTIO
if (!fEnabled)
switch (adapterType)
#ifdef VBOX_WITH_E1000
#ifdef VBOX_WITH_VIRTIO
if (ulInstance)
#ifdef VMWARE_NET_IN_SLOT_11
fSwapSlots3and11 = true;
switch (adapterType)
pCfg,
return rc;
unsigned uBootIdx = 0;
if (serialPort)
if (!fEnabled)
if (parallelPort)
if (!fEnabled)
if (audioAdapter)
if (enabled)
switch (audioController)
case AudioControllerType_AC97:
case AudioControllerType_SB16:
case AudioControllerType_HDA:
switch (audioDriver)
case AudioDriverType_Null:
#ifdef RT_OS_WINDOWS
#ifdef VBOX_WITH_WINMM
case AudioDriverType_WinMM:
#ifdef RT_OS_SOLARIS
case AudioDriverType_SolAudio:
#ifdef RT_OS_LINUX
# ifdef VBOX_WITH_ALSA
case AudioDriverType_ALSA:
# ifdef VBOX_WITH_PULSE
case AudioDriverType_Pulse:
case AudioDriverType_OSS:
#ifdef RT_OS_FREEBSD
# ifdef VBOX_WITH_PULSE
case AudioDriverType_Pulse:
#ifdef RT_OS_DARWIN
if (USBCtlPtr)
if (fOhciEnabled)
#ifdef VBOX_WITH_EHCI
if (fEhciEnabled)
#ifdef VBOX_WITH_USB
// VBoxManage setextradata "myvm" "VBoxInternal/USB/USBProxy/GlobalConfig/Force11PacketSize" 1
switch (mode)
case ClipboardMode_Disabled:
pConsole->mVMMDev->hgcmHostCall("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm);
#ifdef VBOX_WITH_CROGL
if (fEnabled)
#ifdef VBOX_WITH_GUEST_PROPS
#ifdef VBOX_WITH_GUEST_CONTROL
if (fACPI)
fShowCpu = true;
if (fCpuHotPlug)
if (fCpuAttached)
if (pszCFGMValueName)
if (pNode)
AssertLogRelMsgRC(rc, ("failed to insert CFGM value '%s' to key '%s'\n", strCFGMValueUtf8.c_str(), pszExtraDataKey));
catch (ConfigError &x)
return x.m_vrc;
#undef H
return rc;
void Console::setVMRuntimeErrorCallbackF(PVM pVM, void *pvConsole, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
const char *pcszDevice,
unsigned uInstance,
bool fUseHostIOCache,
bool fSetupMerge,
unsigned uMergeSource,
unsigned uMergeTarget,
bool fAttachDetach,
bool fForceUnmount,
unsigned uLUN;
if (pLunL0)
if (fAttachDetach)
#ifdef RT_OS_WINDOWS
const char *pszUnit;
&& maxSize > 0
const char *pszUnitSiz;
const char *pszUnitMax;
const char *pszUnit;
#ifdef RT_OS_WINDOWS
mfSnapshotFolderSizeWarningShown = true;
#ifdef RT_OS_LINUX
&& !fUseHostIOCache
fUseHostIOCache = true;
&& !fUseHostIOCache
fUseHostIOCache = true;
mfSnapshotFolderExt4WarningShown = true;
!!fPassthrough,
phrc);
return rc;
if (fAttachDetach)
if (paLedDevType)
catch (ConfigError &x)
return x.m_vrc;
#undef H
return VINF_SUCCESS;;
bool fPassthrough,
bool fUseHostIOCache,
bool fSetupMerge,
unsigned uMergeSource,
unsigned uMergeTarget,
#define H() AssertMsgReturnStmt(!FAILED(hrc), ("hrc=%Rhrc\n", hrc), if (phrc) *phrc = hrc, VERR_GENERAL_FAILURE)
if (pMedium)
if (fHostDrive)
switch (enmType)
case DeviceType_DVD:
case DeviceType_Floppy:
case DeviceType_HardDisk:
if ( pMedium
"The image file '%ls' is inaccessible and is being ignored. Please select a different image file for the virtual %s drive.",
if (pMedium)
unsigned uImage = 0;
while (pTmp)
uImage++;
uImage--;
if (!fUseHostIOCache)
if (fSetupMerge)
bool fHostIP = true;
fHostIP = false;
uImage--;
if (!pMedium)
if (fSetupMerge)
fHostIP = false;
if (!fHostIP)
catch (ConfigError &x)
return x.m_vrc;
#undef H
return VINF_SUCCESS;
unsigned uInstance,
unsigned uLun,
bool fAttachDetach)
if (pLunAD)
switch (eAttachmentType)
if (fSniffer)
InsertConfigString(pCfg, "TFTPPrefix", Utf8StrFmt("%ls%c%s", bstr.raw(), RTPATH_DELIMITER, "TFTP"));
if (mtu)
if (sockRcv)
if (sockSnd)
if (tcpRcv)
if (tcpSnd)
bool fValid = true;
switch (proto)
case NATProtocol_UDP:
case NATProtocol_TCP:
fValid = false;
if (!fValid)
if (port)
if (port)
switch (hrc)
case VERR_ACCESS_DENIED:
if (fSniffer)
if (fSniffer)
# if defined(RT_OS_DARWIN)
if (!pszColon)
if (pszSpace)
if (pszColon)
AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: FindByName failed, rc=%Rhrc (0x%x)", hrc, hrc));
&pNc,
&pszApp);
hrc = VBoxNetCfgWinGetComponentByGuid(pNc, &GUID_DEVCLASS_NET, (GUID*)hostIFGuid.ptr(), pAdaptorComponent.asOutParam());
wchar_t * pswzBindName;
AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: WideCharToMultiByte failed, hr=%Rhrc (0x%x) err=%u\n", hrc, hrc, err));
AssertFailed();
AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: VBoxNetCfgWinGetComponentByGuid failed, hrc (0x%x)", hrc));
/* we're not releasing the INetCfg stuff here since we use it later to figure out whether it is wireless */
# if defined(RT_OS_FREEBSD)
switch (hrc)
case VERR_ACCESS_DENIED:
"permissions of that node, and that the net.link.tap.user_open "
if (iSock >= 0)
setVMRuntimeErrorCallbackF(pVM, this, 0, "BridgedInterfaceDown", "Bridged interface %s is down. Guest will not be able to use this interface", pszHifName);
# if defined(RT_OS_DARWIN)
/** @todo Come up with a better deal here. Problem is that IHostNetworkInterface is completely useless here. */
if (iSock >= 0)
if (fSharedMacOnWire)
if (iSock >= 0)
if (fSharedMacOnWire)
NULL,
NULL);
bool fSharedMacOnWire = false;
&Oid,
sizeof(Oid),
&PhMedium,
sizeof(PhMedium),
&cbResult,
NULL))
fSharedMacOnWire = true;
Assert(winEr == ERROR_INVALID_PARAMETER || winEr == ERROR_NOT_SUPPORTED || winEr == ERROR_BAD_COMMAND);
if (fSharedMacOnWire)
AssertLogRelMsgFailed(("Console::configConstructor: CreateFile failed, err (0x%x), ignoring\n", winEr));
# if defined(RT_OS_SOLARIS)
if (fSniffer)
if (fSniffer)
#if defined(RT_OS_WINDOWS)
# ifndef VBOX_WITH_NETFLT
&pNc,
&pszApp);
hrc = VBoxNetCfgWinGetComponentByGuid(pNc, &GUID_DEVCLASS_NET, (GUID*)hostIFGuid.ptr(), pAdaptorComponent.asOutParam());
LogRel(("NetworkAttachmentType_HostOnly: VBoxNetCfgWinGetComponentByGuid failed, hrc=%Rhrc (0x%x)\n", hrc, hrc));
wchar_t * pswzBindName;
AssertLogRelMsgFailed(("NetworkAttachmentType_HostOnly: WideCharToMultiByte failed, hr=%Rhrc (0x%x) err=%u\n", hrc, hrc, err));
AssertFailed();
AssertLogRelMsgFailed(("NetworkAttachmentType_HostOnly: VBoxNetCfgWinGetComponentByGuid failed, hrc=%Rhrc (0x%x)\n", hrc, hrc));
/* Grab the IP number from the 'vboxnetX' instance number (see netif.h) */
hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6Address", pszHifName), tmpAddr.asOutParam());
hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6NetMask", pszHifName), tmpMask.asOutParam());
#if defined(VBOX_WITH_VDE)
switch (eAttachmentType)
#if defined(VBOX_WITH_VDE)
if (fAttachDetach)
if (fEnabled)
catch (ConfigError &x)
return x.m_vrc;
#undef H
return VINF_SUCCESS;
#ifdef VBOX_WITH_GUEST_PROPS
void *names,
void *values,
void *timestamps,
void *flags)
&parms[0]);
&parms[0]);
&paParm);
return rc;
#ifdef VBOX_WITH_GUEST_PROPS
if (valuesOut[i])
if (flagsOut[i])
(void *)papszNames,
(void *)papszValues,
(void *)pau64Timestamps,
(void *)papszFlags);
for (unsigned i = 0; i < cProps; ++i)
if (valuesOut[i])
if (flagsOut[i])
return VINF_SUCCESS;
return VERR_NOT_SUPPORTED;
#ifdef VBOX_WITH_GUEST_CONTROL
return rc;
return VERR_NOT_SUPPORTED;