ConsoleImpl2.cpp revision d9bf8ddf3b5e9153e550670acc4263a5b6c8d9e5
/* $Id$ */
/** @file
* VBox Console COM Class implementation
*
* @remark We've split out the code that the 64-bit VC++ v8 compiler finds
* problematic to optimize so we can disable optimizations and later,
* perhaps, find a real solution for it (like rewriting the code and
* to stop resemble a tonne of spaghetti).
*/
/*
* Copyright (C) 2006-2009 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "ConsoleImpl.h"
#include "DisplayImpl.h"
#include "VMMDev.h"
// generated header
#include "SchemaDefs.h"
#include "Logging.h"
#include <iprt/buildconfig.h>
#if 0 /* enable to play with lots of memory. */
#endif
#ifdef VBOX_WITH_CROGL
#endif
#ifdef VBOX_WITH_GUEST_PROPS
* extension using a VMMDev callback. */
# include <vector>
#endif /* VBOX_WITH_GUEST_PROPS */
#if defined(RT_OS_SOLARIS) && defined(VBOX_WITH_NETFLT)
# include <zone.h>
#endif
#if defined(RT_OS_LINUX) && defined(VBOX_WITH_NETFLT)
# include <unistd.h>
# include <linux/wireless.h>
#endif
#if defined(RT_OS_FREEBSD) && defined(VBOX_WITH_NETFLT)
# include <unistd.h>
#endif
#if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
# include <VBox/WinNetConfig.h>
# include <Ntddndis.h>
# include <devguid.h>
#endif
#if !defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
# include <HostNetworkInterfaceImpl.h>
# include <netif.h>
#endif
#include "DHCPServerRunner.h"
/* Comment out the following line to remove VMWare compatibility hack. */
#define VMWARE_NET_IN_SLOT_11
/**
* Translate IDE StorageControllerType_T to string representation.
*/
{
switch (enmType)
{
return "PIIX3";
return "PIIX4";
return "ICH6";
default:
return "Unknown";
}
}
/*
* VC++ 8 / amd64 has some serious trouble with this function.
* As a temporary measure, we'll drop global optimizations.
*/
#if defined(_MSC_VER) && defined(RT_ARCH_AMD64)
#endif
/**
* Construct the VM configuration tree (CFGM).
*
* This is a callback for VMR3Create() call. It is called from CFGMR3Init()
* is done here.
*
* @param pVM VM handle.
* @param pvConsole Pointer to the VMPowerUpTask object.
* @return VBox status code.
*
* @note Locks the Console object for writing.
*/
{
/* Note: hardcoded assumption about number of slots; see rom bios */
bool afPciDeviceNo[32] = {false};
bool fFdcEnabled = false;
#if !defined (VBOX_WITH_XPCOM)
{
/* initialize COM */
}
#endif
/* lock the console because we widely use internal fields and methods */
/* Save the VM pointer in the machine object */
int rc;
#define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0)
#define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%#x\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0)
/*
* Get necessary objects and frequently used parameters.
*/
STR_FREE();
#if 0 /* enable to play with lots of memory. */
if (RTEnvExist("VBOX_RAM_SIZE"))
#endif
/*
* Get root node first.
* This is the only node in the tree.
*/
/*
* Set the root (and VMM) level values.
*/
/** @todo Config: RawR0, PATMEnabled and CSAMEnabled needs attention later. */
/* cpuid leaf overrides. */
static uint32_t const s_auCpuIdRanges[] =
{
};
{
{
}
else if (hrc != E_INVALIDARG) H();
}
if (osTypeId == "WindowsNT4")
{
/*
* We must limit CPUID count for Windows NT 4, as otherwise it stops
* with error 0x3e (MULTIPROCESSOR_CONFIGURATION_NOT_SUPPORTED).
*/
LogRel(("Limiting CPUID leaf count for NT4 guests\n"));
}
/* hardware virtualization extensions */
#ifdef RT_OS_DARWIN
#else
/* - With more than 4GB PGM will use different RAMRANGE sizes for raw
mode and hv mode to optimize lookup times.
- With more than one virtual CPU, raw-mode isn't a fallback option. */
|| cCpus > 1);
#endif
if (fHWVirtExEnabled)
{
/* Indicate whether 64-bit guests are supported or not. */
/** @todo This is currently only forced off on 32-bit hosts only because it
* makes a lof of difference there (REM and Solaris performance).
*/
BOOL fSupportsLongMode = false;
&fSupportsLongMode); H();
BOOL fIs64BitGuest = false;
if (fSupportsLongMode && fIs64BitGuest)
{
#endif
}
else
{
}
#endif
/* @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
&& ( osTypeId == "WindowsNT4"
|| osTypeId == "Windows2000"
|| osTypeId == "WindowsXP"
|| osTypeId == "Windows2003"))
{
/* Only allow TPR patching for NT, Win2k, XP and Windows Server 2003. (32 bits mode)
* We may want to consider adding more guest OSes (Solaris) later on.
*/
}
}
/* HWVirtEx exclusive mode */
BOOL fHWVirtExExclusive = true;
BOOL fEnableNestedPaging = false;
/* VPID (VT-x) */
BOOL fEnableVPID = false;
/* Physical Address Extension (PAE) */
BOOL fEnablePAE = false;
/* Synthetic CPU */
BOOL fSyntheticCpu = false;
/*
* PDM config.
* Load drivers in VBoxC.[so|dll]
*/
#ifdef VBOX_WITH_XPCOM
// VBoxC is located in the components subdirectory
char szPathVBoxC[RTPATH_MAX];
#else
#endif
/*
* Devices
*/
/*
* PC Arch.
*/
/*
* The time offset
*/
/*
* DMA
*/
/*
* PCI buses.
*/
#if 0 /* enable this to test PCI bridging */
#endif
/*
* Temporary hack for enabling the next three devices and various ACPI features.
*/
/*
* High Precision Event Timer (HPET)
*/
#ifdef VBOX_WITH_HPET
#else
fHpetEnabled = false;
#endif
if (fHpetEnabled)
{
}
/*
* System Management Controller (SMC)
*/
#ifdef VBOX_WITH_SMC
#else
fSmcEnabled = false;
#endif
if (fSmcEnabled)
{
}
/*
* Low Pin Count (LPC) bus
*/
/** @todo: implement appropriate getter */
#ifdef VBOX_WITH_LPC
#else
fLpcEnabled = false;
#endif
if (fLpcEnabled)
{
}
/*
* PS/2 keyboard & mouse.
*/
/*
* i8254 Programmable Interval Timer And Dummy Speaker
*/
#ifdef DEBUG
#endif
/*
* i8259 Programmable Interrupt Controller.
*/
/*
* Advanced Programmable Interrupt Controller.
* SMP: Each CPU has a LAPIC, but we have a single device representing all LAPICs states,
* thus only single insert
*/
if (fIOAPIC)
{
/*
* I/O Advanced Programmable Interrupt Controller.
*/
}
/*
* RTC MC146818.
*/
/*
* VGA.
*/
afPciDeviceNo[2] = true;
#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE /* not safe here yet. */ /** @todo this needs fixing !!! No wonder VGA is slooooooooow on 32-bit darwin! */
#endif
/*
* BIOS logo
*/
rc = CFGMR3InsertString(pCfg, "LogoFile", logoImagePath ? Utf8Str(logoImagePath).c_str() : ""); RC_CHECK();
/*
* Boot menu
*/
int iShowBootMenu;
switch (eBootMenuMode)
{
case BIOSBootMenuMode_Disabled: iShowBootMenu = 0; break;
default: iShowBootMenu = 2; break;
}
/* Custom VESA mode list */
unsigned cModes = 0;
{
char szExtraDataKey[sizeof("CustomVideoModeXX")];
break;
STR_FREE();
++cModes;
}
STR_FREE();
/* VESA height reduction */
if (pFramebuffer)
{
}
else
{
/* If framebuffer is not available, there is no height reduction. */
ulHeightReduction = 0;
}
/* Attach the display. */
/*
* Firmware.
*/
#ifdef VBOX_WITH_EFI
/**
* @todo: VBoxInternal2/UseEFI extradata will go away soon, and we'll
* just use this code
*/
if (!fEfiEnabled)
{
}
#else
BOOL fEfiEnabled = false;
#endif
if (!fEfiEnabled)
{
/*
* PC Bios.
*/
{
AssertMsgFailed (("Too many boot devices %d\n",
return VERR_INVALID_PARAMETER;
}
{
char szParamName[] = "BootDeviceX";
const char *pszBootDevice;
switch (bootDevice)
{
case DeviceType_Null:
pszBootDevice = "NONE";
break;
case DeviceType_HardDisk:
pszBootDevice = "IDE";
break;
case DeviceType_DVD:
pszBootDevice = "DVD";
break;
case DeviceType_Floppy:
pszBootDevice = "FLOPPY";
break;
case DeviceType_Network:
pszBootDevice = "LAN";
break;
default:
}
}
}
else
{
/*
* EFI.
*/
}
/*
* Storage controllers.
*/
{
/* /Devices/<ctrldev>/ */
if (!pDev)
{
}
/* /Devices/<ctrldev>/<instance>/ */
switch (enmCtrlType)
{
{
afPciDeviceNo[20] = true;
/* Attach the status driver */
break;
}
{
afPciDeviceNo[21] = true;
/* Attach the status driver */
break;
}
{
afPciDeviceNo[13] = true;
/* Needed configuration values for the bios. */
if (pBiosCfg)
{
}
for (uint32_t j = 0; j < 4; ++j)
{
static const char * const s_apszConfig[4] =
{ "PrimaryMaster", "PrimarySlave", "SecondaryMaster", "SecondarySlave" };
static const char * const s_apszBiosConfig[4] =
{ "SataPrimaryMasterLUN", "SataPrimarySlaveLUN", "SataSecondaryMasterLUN", "SataSecondarySlaveLUN" };
if (pBiosCfg)
{
}
}
/* Attach the status driver */
break;
}
{
/*
* IDE (update this when the main interface changes)
*/
afPciDeviceNo[1] = true;
/* Attach the status driver */
/* IDE flavors */
break;
}
{
/*
* i82078 Floppy drive controller
*/
fFdcEnabled = true;
/* Attach the status driver */
break;
}
default:
AssertMsgFailedReturn(("invalid storage controller type: %d\n", enmCtrlType), VERR_GENERAL_FAILURE);
}
/* Attach the media to the storage controllers. */
ComSafeArrayAsOutParam(atts)); H();
{
unsigned uLUN;
/* SCSI has a another driver between device and block. */
if (enmBus == StorageBus_SCSI)
{
}
{
}
if (fHostDrive)
{
if (lType == DeviceType_DVD)
{
STR_FREE();
}
else if (lType == DeviceType_Floppy)
{
STR_FREE();
}
}
else
{
switch (lType)
{
case DeviceType_DVD:
break;
case DeviceType_Floppy:
break;
case DeviceType_HardDisk:
default:
}
{
STR_FREE();
STR_FREE();
/* DVDs are always readonly */
if (lType == DeviceType_DVD)
{
}
/* Pass all custom parameters. */
bool fHostIP = true;
ComSafeArrayAsOutParam(values)); H();
{
{
{
rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str()); AssertRC(rc); /** @todo r=bird: why not RC_CHECK() here? (I added the AssertRC.)*/
fHostIP = false;
}
}
}
/* Create an inversed tree of parents. */
{
break;
STR_FREE();
STR_FREE();
/* Pass all custom parameters. */
ComSafeArrayAsOutParam(values)); H();
{
{
{
rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str()); AssertRC(rc); /** @todo r=bird: why not RC_HCECK here? (I added the AssertRC.)*/
fHostIP = false;
}
}
}
/* Custom code: put marker to not use host IP stack to driver
* configuration node. Simplifies life of DrvVD a bit. */
if (!fHostIP)
{
}
/* next */
}
}
}
}
H();
}
H();
/*
* Network adapters
*/
#ifdef VMWARE_NET_IN_SLOT_11
bool fSwapSlots3and11 = false;
#endif
#ifdef VBOX_WITH_E1000
#endif
#ifdef VBOX_WITH_VIRTIO
#endif /* VBOX_WITH_VIRTIO */
{
if (!fEnabled)
continue;
/*
* The virtual hardware type. Create appropriate device first.
*/
const char *pszAdapterName = "pcnet";
switch (adapterType)
{
break;
#ifdef VBOX_WITH_E1000
pszAdapterName = "e1000";
break;
#endif
#ifdef VBOX_WITH_VIRTIO
pszAdapterName = "virtio-net";
break;
#endif /* VBOX_WITH_VIRTIO */
default:
AssertMsgFailed(("Invalid network adapter type '%d' for slot '%d'",
N_("Invalid network adapter type '%d' for slot '%d'"),
}
/* the first network card gets the PCI ID 3, the next 3 gets 8..10,
* next 4 get 16..19. */
unsigned iPciDeviceNo = 3;
if (ulInstance)
{
if (ulInstance < 4)
else
}
#ifdef VMWARE_NET_IN_SLOT_11
/*
* Dirty hack for PCI slot compatibility with VMWare,
* it assigns slot 11 to the first network controller.
*/
{
iPciDeviceNo = 0x11;
fSwapSlots3and11 = true;
}
iPciDeviceNo = 3;
#endif
afPciDeviceNo[iPciDeviceNo] = true;
#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE /* not safe here yet. */
{
}
#endif
/*
* The virtual hardware type. PCNet supports two types.
*/
switch (adapterType)
{
break;
break;
break;
break;
break;
}
/*
* Get the MAC address and convert it to binary representation
*/
for (uint32_t i = 0; i < 6; ++i)
{
if (c1 > 9)
c1 -= 7;
if (c2 > 9)
c2 -= 7;
}
/*
* Check if the cable is supposed to be unplugged
*/
/*
* Line speed to report from custom drivers
*/
/*
* Attach the status driver.
*/
rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapNetworkLeds[ulInstance]); RC_CHECK();
/*
* Configure the network card now
*/
}
/*
* Serial (UART) Ports
*/
{
if (serialPort)
if (!fEnabled)
continue;
if (eHostMode != PortMode_Disconnected)
{
if (eHostMode == PortMode_HostPipe)
{
}
else if (eHostMode == PortMode_HostDevice)
{
}
else if (eHostMode == PortMode_RawFile)
{
}
}
STR_FREE();
}
/*
* Parallel (LPT) Ports
*/
{
if (parallelPort)
{
}
if (!fEnabled)
continue;
STR_FREE();
}
/*
* VMM Device
*/
afPciDeviceNo[4] = true;
{
}
/* the VMM device's Main driver */
/*
* Attach the status driver.
*/
/*
* Audio Sniffer Device
*/
/* the Audio Sniffer device's Main driver */
/*
* AC'97 ICH / SoundBlaster16 audio
*/
if (audioAdapter)
if (enabled)
{
switch (audioController)
{
case AudioControllerType_AC97:
{
/* default: ICH AC97 */
afPciDeviceNo[5] = true;
break;
}
case AudioControllerType_SB16:
{
/* legacy SoundBlaster16 */
break;
}
}
/* the Audio driver */
switch (audioDriver)
{
case AudioDriverType_Null:
{
break;
}
#ifdef RT_OS_WINDOWS
#ifdef VBOX_WITH_WINMM
case AudioDriverType_WinMM:
{
break;
}
#endif
{
break;
}
#endif /* RT_OS_WINDOWS */
#ifdef RT_OS_SOLARIS
case AudioDriverType_SolAudio:
{
break;
}
#endif
#ifdef RT_OS_LINUX
# ifdef VBOX_WITH_ALSA
case AudioDriverType_ALSA:
{
break;
}
# endif
# ifdef VBOX_WITH_PULSE
case AudioDriverType_Pulse:
{
break;
}
# endif
#endif /* RT_OS_LINUX */
case AudioDriverType_OSS:
{
break;
}
#endif
#ifdef RT_OS_DARWIN
{
break;
}
#endif
}
STR_FREE();
}
/*
* The USB Controller.
*/
if (USBCtlPtr)
{
if (fEnabled)
{
afPciDeviceNo[6] = true;
/*
* Attach the status driver.
*/
#ifdef VBOX_WITH_EHCI
if (fEnabled)
{
afPciDeviceNo[11] = true;
/*
* Attach the status driver.
*/
}
else
#endif
{
/*
* Global USB options, currently unused as we'll apply the 2.0 -> 1.1 morphing
* on a per device level now.
*/
// This globally enables the 2.0 -> 1.1 device morphing of proxied devies to keep windows quiet.
//rc = CFGMR3InsertInteger(pCfg, "Force11Device", true); RC_CHECK();
// The following breaks stuff, but it makes MSDs work in vista. (I include it here so
// that it's documented somewhere.) Users needing it can use:
// VBoxManage setextradata "myvm" "VBoxInternal/USB/USBProxy/GlobalConfig/Force11PacketSize" 1
//rc = CFGMR3InsertInteger(pCfg, "Force11PacketSize", true); RC_CHECK();
}
}
}
/*
* Clipboard
*/
{
if (mode != ClipboardMode_Disabled)
{
/* Load the service */
if (RT_FAILURE(rc))
{
/* That is not a fatal failure. */
rc = VINF_SUCCESS;
}
else
{
/* Setup the service. */
switch (mode)
{
default:
case ClipboardMode_Disabled:
{
LogRel(("VBoxSharedClipboard mode: Off\n"));
break;
}
{
LogRel(("VBoxSharedClipboard mode: Guest to Host\n"));
break;
}
{
LogRel(("VBoxSharedClipboard mode: Host to Guest\n"));
break;
}
{
LogRel(("VBoxSharedClipboard mode: Bidirectional\n"));
break;
}
}
pConsole->mVMMDev->hgcmHostCall ("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm);
Log(("Set VBoxSharedClipboard mode\n"));
}
}
}
#ifdef VBOX_WITH_CROGL
/*
* crOpenGL
*/
{
if (fEnabled)
{
/* Load the service */
if (RT_FAILURE(rc))
{
/* That is not a fatal failure. */
rc = VINF_SUCCESS;
}
else
{
LogRel(("Shared crOpenGL service loaded.\n"));
/* Setup the service. */
rc = pConsole->mVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_FRAMEBUFFER, 1, &parm);
if (!RT_SUCCESS(rc))
if (!RT_SUCCESS(rc))
}
}
}
#endif
#ifdef VBOX_WITH_GUEST_PROPS
/*
* Guest property service
*/
#endif /* VBOX_WITH_GUEST_PROPS defined */
/*
* CFGM overlay handling.
*
* Here we check the extra data entries for CFGM values
* and create the nodes and insert the values on the fly. Existing
* values will be removed and reinserted. CFGM is typed, so by default
* we will guess whether it's a string or an integer (byte arrays are
* not currently supported). It's possible to override this autodetection
* by adding "string:", "integer:" or "bytes:" (future).
*
* We first perform a run on global extra data, then on the machine
* extra data to support global settings with local overrides.
*
*/
/** @todo add support for removing nodes and byte blobs. */
/*
* Get the next key
*/
// remember the no. of global values so we can call the correct method below
// build a combined list from global keys...
size_t i = 0;
for (i = 0; i < aGlobalExtraDataKeys.size(); ++i)
// ... and machine keys
for (i = 0; i < aMachineExtraDataKeys.size(); ++i)
i = 0;
++it, ++i)
{
/*
* We only care about keys starting with "VBoxInternal/" (skip "G:" or "M:")
*/
continue;
// get the value
if (i < cGlobalValues)
// this is still one of the global values:
else
/*
* Split the two and get the node, delete the value and create the node
* if necessary.
*/
if (pszCFGMValueName)
{
/* terminate the node and advance to the value (Utf8Str might not
offically like this but wtf) */
*(char*)pszCFGMValueName = '\0';
/* does the node already exist? */
if (pNode)
else
{
/* create the node */
if (RT_FAILURE(rc))
{
continue;
}
}
}
else
{
/* root value (no node path). */
}
/*
* Now let's have a look at the value.
* Empty strings means that we should remove the value, which we've
* already done above.
*/
if ( pszCFGMValue
&& *pszCFGMValue)
{
/* check for type prefix first. */
{
if (RT_SUCCESS(rc))
}
/* auto detect type. */
else
AssertLogRelMsgRC(rc, ("failed to insert CFGM value '%s' to key '%s'\n", pszCFGMValue, pszExtraDataKey));
}
}
/*
* ACPI
*/
if (fACPI)
{
/* Always show the CPU leafs when we have multiple VCPUs or when the IO-APIC is enabled.
* The Windows SMP kernel needs a CPU leaf or else its idle loop will burn cpu cycles; the
* intelppm driver refuses to register an idle state handler.
*/
fShowCpu = true;
#ifdef VBOX_WITH_HPET
#endif
#ifdef VBOX_WITH_SMC
#endif
afPciDeviceNo[7] = true;
}
#undef H
/* Register VM state change handler */
if (RT_SUCCESS(rc))
/* Register VM runtime error handler */
if (RT_SUCCESS(rc))
return rc;
}
/**
* Ellipsis to va_list wrapper for calling setVMRuntimeErrorCallback.
*/
/*static*/ void Console::setVMRuntimeErrorCallbackF(PVM pVM, void *pvConsole, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
{
}
/**
* Construct the Network configuration tree
*
* @returns VBox status code.
*
* @param pThis Pointer to the Console object.
* @param pszDevice The PDM device name.
* @param uInstance The PDM device instance.
* @param uLun The PDM LUN number of the drive.
* @param aNetworkAdapter The network adapter whose attachment needs to be changed
* @param pCfg Configuration node for the device
* @param pLunL0 To store the pointer to the LUN#0.
* @param pInst The instance CFGM node
* @param fAttachDetach To determine if the network attachment should
* configuration.
*
* @note Locks the Console object for writing.
*/
{
int rc = VINF_SUCCESS;
/*
* Locking the object before doing VMR3* calls is quite safe here, since
* we're on EMT. Write lock is necessary because we indirectly modify the
* meAttachmentType member.
*/
#define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0)
#define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%#x\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0)
H();
H();
H();
if (fAttachDetach && fSniffer)
{
const char *pszNetDriver = "IntNet";
pszNetDriver = "NAT";
#if !defined(VBOX_WITH_NETFLT) && defined(RT_OS_LINUX)
pszNetDriver = "HostInterface";
#endif
if (rc == VINF_PDM_NO_DRIVER_ATTACHED_TO_LUN)
rc = VINF_SUCCESS;
if (pLunAD)
{
}
else
{
if (str) /* check convention for indicating default file. */
{
}
STR_FREE();
}
}
else if (fAttachDetach && !fSniffer)
{
if (rc == VINF_PDM_NO_DRIVER_ATTACHED_TO_LUN)
rc = VINF_SUCCESS;
/* nuke anything which might have been left behind. */
}
else if (!fAttachDetach && fSniffer)
{
/* insert the sniffer filter driver. */
if (str) /* check convention for indicating default file. */
{
}
STR_FREE();
}
switch (eAttachmentType)
{
break;
{
if (fSniffer)
{
}
else
{
}
/* Configure TFTP prefix and boot filename. */
{
}
STR_FREE();
STR_FREE();
{
/* NAT uses its own DHCP implementation */
//networkName = Bstr(psz);
}
STR_FREE();
break;
}
{
{
switch (hrc)
{
case VERR_ACCESS_DENIED:
"change the group of that node and make yourself a member of that group. Make "
"sure that these changes are permanent, especially if you are "
"using udev"));
default:
AssertMsgFailed(("Could not attach to host interface! Bad!\n"));
"Failed to initialize Host Interface Networking"));
}
}
{
if (fSniffer)
{
}
else
{
}
}
#elif defined(VBOX_WITH_NETFLT)
/*
* This is the new VBoxNetFlt+IntNet stuff.
*/
if (fSniffer)
{
}
else
{
}
{
H();
}
# if defined(RT_OS_DARWIN)
/* The name is on the form 'ifX: long name', chop it off at the colon. */
char szTrunk[8];
if (!pszColon)
{
N_("Malformed host interface networking name '%ls'"),
}
*pszColon = '\0';
# elif defined(RT_OS_SOLARIS)
/* The name is on the form format 'ifX[:1] - long name, chop it off at space. */
char szTrunk[256];
/*
* Currently don't bother about malformed names here for the sake of people using
* VBoxManage and setting only the NIC name from there. If there is a space we
* chop it off and proceed, otherwise just use whatever we've got.
*/
if (pszSpace)
*pszSpace = '\0';
/* Chop it off at the colon (zone naming eg: e1000g:1 we need only the e1000g) */
if (pszColon)
*pszColon = '\0';
# elif defined(RT_OS_WINDOWS)
{
AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: FindByName failed, rc=%Rhrc (0x%x)", hrc, hrc));
N_("Inexistent host networking interface, name '%ls'"),
}
{
H();
}
{
N_("Interface ('%ls') is not a Bridged Adapter interface"),
}
{
H();
}
STR_FREE();
int rc = VERR_INTNET_FLT_IF_NOT_FOUND;
L"VirtualBox",
&pNc,
&pszApp);
{
/* get the adapter's INetCfgComponent*/
hrc = VBoxNetCfgWinGetComponentByGuid(pNc, &GUID_DEVCLASS_NET, (GUID*)hostIFGuid.ptr(), pAdaptorComponent.asOutParam());
{
H();
}
}
#define VBOX_WIN_BINDNAME_PREFIX "\\DEVICE\\"
char szTrunkName[INTNET_MAX_TRUNK_NAME];
char *pszTrunkName = szTrunkName;
wchar_t * pswzBindName;
{
int cbFullBindNamePrefix = sizeof(VBOX_WIN_BINDNAME_PREFIX);
{
{
AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: WideCharToMultiByte failed, hr=%Rhrc (0x%x) err=%u\n", hrc, hrc, err));
}
}
else
{
AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: insufficient szTrunkName buffer space\n"));
/** @todo set appropriate error code */
}
{
AssertFailed();
H();
}
/* we're not freeing the bind name since we'll use it later for detecting wireless*/
}
else
{
AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: VBoxNetCfgWinGetComponentByGuid failed, hrc (0x%x)", hrc));
H();
}
const char *pszTrunk = szTrunkName;
/* we're not releasing the INetCfg stuff here since we use it later to figure out whether it is wireless */
/** @todo Check for malformed names. */
const char *pszTrunk = pszHifName;
/* Issue a warning if the interface is down */
{
if (iSock >= 0)
{
{
setVMRuntimeErrorCallbackF(pVM, pThis, 0, "BridgedInterfaceDown", "Bridged interface %s is down. Guest will not be able to use this interface", pszHifName);
}
}
}
# else
# error "PORTME (VBOX_WITH_NETFLT)"
# endif
RC_CHECK();
char szNetwork[INTNET_MAX_NETWORK_NAME];
# if defined(RT_OS_DARWIN)
/** @todo Come up with a better deal here. Problem is that IHostNetworkInterface is completely useless here. */
{
}
# elif defined(RT_OS_LINUX)
if (iSock >= 0)
{
if (fSharedMacOnWire)
{
RC_CHECK();
Log(("Set SharedMacOnWire\n"));
}
else
Log(("Failed to get wireless name\n"));
}
else
Log(("Failed to open wireless socket\n"));
# elif defined(RT_OS_WINDOWS)
# define DEVNAME_PREFIX L"\\\\.\\"
/* we are getting the medium type via IOCTL_NDIS_QUERY_GLOBAL_STATS Io Control
* there is a pretty long way till there though since we need to obtain the symbolic link name
* for the adapter device we are going to query given the device Guid */
/* prepend the "\\\\.\\" to the bind name to obtain the link name */
/* open the device */
NULL,
NULL);
if (hDevice != INVALID_HANDLE_VALUE)
{
bool fSharedMacOnWire = false;
/* now issue the OID_GEN_PHYSICAL_MEDIUM query */
if (DeviceIoControl(hDevice,
&Oid,
sizeof(Oid),
&PhMedium,
sizeof(PhMedium),
&cbResult,
NULL))
{
/* that was simple, now examine PhMedium */
fSharedMacOnWire = true;
}
else
{
int winEr = GetLastError();
Assert(winEr == ERROR_INVALID_PARAMETER || winEr == ERROR_NOT_SUPPORTED || winEr == ERROR_BAD_COMMAND);
}
if (fSharedMacOnWire)
{
Log(("this is a wireless adapter"));
Log(("Set SharedMacOnWire\n"));
}
else
Log(("this is NOT a wireless adapter"));
}
else
{
int winEr = GetLastError();
AssertLogRelMsgFailed(("Console::configConstructor: CreateFile failed, err (0x%x), ignoring\n", winEr));
}
/* release the pNc finally */
# else
/** @todo PORTME: wireless detection */
# endif
# if defined(RT_OS_SOLARIS)
# if 0 /* bird: this is a bit questionable and might cause more trouble than its worth. */
/* Zone access restriction, don't allow snopping the global zone. */
if (ZoneId != GLOBAL_ZONEID)
{
}
# endif
# endif
/* NOTHING TO DO HERE */
#elif defined(RT_OS_LINUX)
/// @todo aleksey: is there anything to be done here?
#elif defined(RT_OS_FREEBSD)
/** @todo FreeBSD: Check out this later (HIF networking). */
#else
# error "Port me"
#endif
break;
}
{
{
if (fSniffer)
{
RC_CHECK();
}
else
{
RC_CHECK();
}
networkName = str;
}
STR_FREE();
break;
}
{
if (fSniffer)
{
RC_CHECK();
}
else
{
RC_CHECK();
}
{
H();
}
{
N_("Inexistent host networking interface, name '%ls'"),
}
char szNetwork[INTNET_MAX_NETWORK_NAME];
#if defined(RT_OS_WINDOWS)
# ifndef VBOX_WITH_NETFLT
LogRel(("NetworkAttachmentType_HostOnly: Not Implemented\n"));
H();
# else /* defined VBOX_WITH_NETFLT*/
/** @todo r=bird: Put this in a function. */
{
H();
}
N_("Interface ('%ls') is not a Host-Only Adapter interface"),
{
H();
}
STR_FREE();
L"VirtualBox",
&pNc,
&pszApp);
{
/* get the adapter's INetCfgComponent*/
hrc = VBoxNetCfgWinGetComponentByGuid(pNc, &GUID_DEVCLASS_NET, (GUID*)hostIFGuid.ptr(), pAdaptorComponent.asOutParam());
{
LogRel(("NetworkAttachmentType_HostOnly: VBoxNetCfgWinGetComponentByGuid failed, hrc=%Rhrc (0x%x)\n", hrc, hrc));
H();
}
}
#define VBOX_WIN_BINDNAME_PREFIX "\\DEVICE\\"
char szTrunkName[INTNET_MAX_TRUNK_NAME];
char *pszTrunkName = szTrunkName;
wchar_t * pswzBindName;
{
int cbFullBindNamePrefix = sizeof(VBOX_WIN_BINDNAME_PREFIX);
{
{
AssertLogRelMsgFailed(("NetworkAttachmentType_HostOnly: WideCharToMultiByte failed, hr=%Rhrc (0x%x) err=%u\n", hrc, hrc, err));
}
}
else
{
AssertLogRelMsgFailed(("NetworkAttachmentType_HostOnly: insufficient szTrunkName buffer space\n"));
/** @todo set appropriate error code */
}
{
AssertFailed();
H();
}
}
else
{
AssertLogRelMsgFailed(("NetworkAttachmentType_HostOnly: VBoxNetCfgWinGetComponentByGuid failed, hrc=%Rhrc (0x%x)\n", hrc, hrc));
H();
}
/* release the pNc finally */
const char *pszTrunk = szTrunkName;
# endif /* defined VBOX_WITH_NETFLT*/
#elif defined(RT_OS_DARWIN)
#else
#endif
#if !defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
{
else
}
else
hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6Address", pszHifName), tmpAddr.asOutParam());
hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6NetMask", pszHifName), tmpMask.asOutParam());
{
}
#endif
break;
}
default:
AssertMsgFailed(("should not get here!\n"));
break;
}
/*
* Attempt to attach the driver.
*/
switch (eAttachmentType)
{
break;
{
{
if (fAttachDetach)
{
}
{
/** @todo pritesh: get the dhcp server name from the
* previous network configuration and then stop the server
* else it may conflict with the dhcp server running with
* the current attachment type
*/
/* Stop the hostonly DHCP Server */
}
if (!networkName.isNull())
{
/*
* Until we implement service reference counters DHCP Server will be stopped
* by DHCPServerRunner destructor.
*/
{
/* there is a DHCP server available for this network */
{
H();
}
if (fEnabled)
}
else
}
}
break;
}
default:
AssertMsgFailed(("should not get here!\n"));
break;
}
#undef H
return VINF_SUCCESS;
}
#ifdef VBOX_WITH_GUEST_PROPS
/**
* Set an array of guest properties
*/
{
&parms[0]);
}
/**
* Set a single guest property
*/
{
&parms[0]);
}
#endif /* VBOX_WITH_GUEST_PROPS */
/**
* Set up the Guest Property service, populate it with properties read from
* the machine XML and set a couple of initial properties.
*/
{
#ifdef VBOX_WITH_GUEST_PROPS
/* Load the service */
if (RT_FAILURE(rc))
{
/* That is not a fatal failure. */
rc = VINF_SUCCESS;
}
else
{
/*
* Initialize built-in properties that can be changed and saved.
*
* These are typically transient properties that the guest cannot
* change.
*/
/* Sysprep execution by VBoxService. */
"/VirtualBox/HostGuest/SysprepExec", "",
"TRANSIENT, RDONLYGUEST");
"/VirtualBox/HostGuest/SysprepArgs", "",
"TRANSIENT, RDONLYGUEST");
/*
* Pull over the properties from the server.
*/
)
char szEmpty[] = "";
{
{
if (RT_FAILURE(rc))
break;
if (valuesOut[i])
else
papszValues[i] = szEmpty;
if (RT_FAILURE(rc))
break;
pau64Timestamps[i] = timestampsOut[i];
if (flagsOut[i])
else
papszFlags[i] = szEmpty;
}
if (RT_SUCCESS(rc))
(void *)papszNames,
(void *)papszValues,
(void *)pau64Timestamps,
(void *)papszFlags);
for (unsigned i = 0; i < cProps; ++i)
{
RTStrFree(papszNames[i]);
if (valuesOut[i])
RTStrFree(papszValues[i]);
if (flagsOut[i])
RTStrFree(papszFlags[i]);
}
}
else
rc = VERR_NO_MEMORY;
/*
* These properties have to be set before pulling over the properties
* from the machine XML, to ensure that properties saved in the XML
* will override them.
*/
/* Set the VBox version string as a guest property */
VBOX_VERSION_STRING, "TRANSIENT, RDONLYGUEST");
/* Set the VBox SVN revision as a guest property */
RTBldCfgRevisionStr(), "TRANSIENT, RDONLYGUEST");
/*
* Register the host notification callback
*/
Log(("Set VBoxGuestPropSvc property store\n"));
}
return VINF_SUCCESS;
#else /* !VBOX_WITH_GUEST_PROPS */
return VERR_NOT_SUPPORTED;
#endif /* !VBOX_WITH_GUEST_PROPS */
}