ConsoleImpl2.cpp revision 848d0facc122cd9f448b93c15a9f35b9149504ad
/* $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-2010 Oracle Corporation
*
* 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "ConsoleImpl.h"
#include "DisplayImpl.h"
#ifdef VBOX_WITH_GUEST_CONTROL
# include "GuestImpl.h"
#endif
#include "VMMDev.h"
#include "Global.h"
// generated header
#include "SchemaDefs.h"
#include "AutoCaller.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 */
#ifdef VBOX_WITH_NETFLT
# if defined(RT_OS_SOLARIS)
# include <zone.h>
# elif defined(RT_OS_LINUX)
# include <unistd.h>
# include <linux/wireless.h>
# elif defined(RT_OS_FREEBSD)
# include <unistd.h>
# include <net80211/ieee80211_ioctl.h>
# endif
# if defined(RT_OS_WINDOWS)
# include <VBox/WinNetConfig.h>
# include <Ntddndis.h>
# include <devguid.h>
# else
# include <HostNetworkInterfaceImpl.h>
# include <netif.h>
# include <stdlib.h>
# endif
#endif /* VBOX_WITH_NETFLT */
#include "DHCPServerRunner.h"
#if defined(RT_OS_DARWIN)
# include "IOKit/IOKitLib.h"
{
/*
* Method as described in Amit Singh's article:
*/
typedef struct
{
IOServiceMatching("AppleSMC"));
if (!service)
return VERR_NOT_FOUND;
if (kr != kIOReturnSuccess)
return RTErrConvertFromDarwin(kr);
for (int i = 0; i < 2; i++)
{
(uint32_t)2,
(const void *)&inputStruct,
sizeof(inputStruct),
(void *)&outputStruct,
if (kr != kIOReturnSuccess)
{
return RTErrConvertFromDarwin(kr);
}
for (int j = 0; j < 32; j++)
}
pabKey[64] = 0;
return VINF_SUCCESS;
}
#endif /* RT_OS_DARWIN */
/* Darwin compile cludge */
/* 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";
}
}
/**
* Simple class for storing network boot information.
*/
struct BootNic
{
unsigned mPciDev;
unsigned mPciFn;
{
}
};
/*
* 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
{
int rc;
if (RT_FAILURE(rc))
if (!fPresent)
return VERR_FILE_NOT_FOUND;
return S_OK;
}
{
*pfGetKeyFromRealSMC = false;
/*
* The extra data takes precedence (if non-zero).
*/
&& *aKey
&& **aKey)
return VINF_SUCCESS;
#ifdef RT_OS_DARWIN
/*
* Query it here and now.
*/
char abKeyBuf[65];
{
return rc;
}
#else
/*
* Is it apple hardware in bootcamp?
*/
/** @todo implement + test RTSYSDMISTR_MANUFACTURER on all hosts.
* Currently falling back on the product name. */
char szManufacturer[256];
szManufacturer[0] = '\0';
if (szManufacturer[0] != '\0')
{
)
*pfGetKeyFromRealSMC = true;
}
else
{
char szProdName[256];
szProdName[0] = '\0';
)
)
*pfGetKeyFromRealSMC = true;
}
int rc = VINF_SUCCESS;
#endif
return rc;
}
/**
* 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;
BOOL fIs64BitGuest = 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;
/*
* Get necessary objects and frequently used parameters.
*/
#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.
*/
#ifdef VBOX_WITH_RAW_MODE
/** @todo Config: RawR0, PATMEnabled and CSAMEnabled needs attention later. */
#endif
/* Not necessary, but to make sure these two settings end up in the release log. */
ULONG ulBalloonSize = 0;
/* 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"));
}
if (fOsXGuest)
{
/*
* Expose extended MWAIT features to Mac OS X guests.
*/
LogRel(("Using MWAIT extensions\n"));
}
/* hardware virtualization extensions */
#ifdef VBOX_WITH_RAW_MODE
# 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
#else /* !VBOX_WITH_RAW_MODE */
#endif /* !VBOX_WITH_RAW_MODE */
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();
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;
/* Large pages; requires nested paging */
BOOL fEnableLargePages = 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
/*
* I/O settings (cach, max bandwidth, ...).
*/
/* Builtin I/O cache */
/* I/O cache size */
/* Maximum I/O bandwidth */
ULONG ioBandwidthMax = 0;
if (ioBandwidthMax != 0)
{
}
/*
* Devices
*/
/*
* PC Arch.
*/
/*
* The time offset
*/
/*
* DMA
*/
/*
* PCI buses.
*/
#if 0 /* enable this to test PCI bridging */
#endif
/*
* Enable 3 following devices: HPET, SMC, LPC on MacOS X guests
*/
/*
* High Precision Event Timer (HPET)
*/
#ifdef VBOX_WITH_HPET
/* Other guests may wish to use HPET too, but MacOS X not functional without it */
/* so always enable HPET in extended profile */
#else
fHpetEnabled = false;
#endif
if (fHpetEnabled)
{
}
/*
* System Management Controller (SMC)
*/
#ifdef VBOX_WITH_SMC
#else
fSmcEnabled = false;
#endif
if (fSmcEnabled)
{
bool fGetKeyFromRealSMC;
}
/*
* 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
#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;
++cModes;
}
/* 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
#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
{
/* Autodetect firmware type, basing on guest type */
if (eFwType == FirmwareType_EFI)
{
eFwType =
:
}
/* Get boot args */
/* Get device props */
/* Get GOP mode settings */
/* UGA mode settings */
uint32_t u32UgaHorisontal = 0;
hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiUgaHorizontalResolution"), bstr.asOutParam()); H();
uint32_t u32UgaVertical = 0;
hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiUgaVerticalResolution"), bstr.asOutParam()); H();
/*
* EFI subtree.
*/
/* For OS X guests we'll force passing host's DMI info to the guest */
if (fOsXGuest)
{
}
}
/*
* Storage controllers.
*/
{
/* /Devices/<ctrldev>/ */
if (!pDev)
{
}
/* /Devices/<ctrldev>/<instance>/ */
switch (enmCtrlType)
{
{
afPciDeviceNo[20] = true;
/* Attach the status driver */
rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedScsi]); RC_CHECK();
break;
}
{
afPciDeviceNo[21] = true;
/* Attach the status driver */
rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedScsi]); RC_CHECK();
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 */
rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedSata]); RC_CHECK();
break;
}
{
/*
* IDE (update this when the main interface changes)
*/
afPciDeviceNo[1] = true;
/* Attach the status driver */
rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedIde]); RC_CHECK();
/* IDE flavors */
break;
}
{
/*
* i82078 Floppy drive controller
*/
fFdcEnabled = true;
/* Attach the status driver */
rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedFloppy]); RC_CHECK();
break;
}
{
afPciDeviceNo[22] = true;
/* Attach the status driver */
rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedSas]); RC_CHECK();
break;
}
default:
AssertMsgFailedReturn(("invalid storage controller type: %d\n", enmCtrlType), VERR_GENERAL_FAILURE);
}
/* Attach the media to the storage controllers. */
ComSafeArrayAsOutParam(atts)); H();
{
false /* fSetupMerge */,
0 /* uMergeSource */,
0 /* uMergeTarget */,
atts[j],
NULL /* phrc */,
false /* fAttachDetach */,
false /* fForceUnmount */,
pVM,
paLedDevType); RC_CHECK();
}
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
/*
* Collect information needed for network booting and add it to the list.
*/
/*
* 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
*/
false /*fAttachDetach*/); RC_CHECK();
}
/*
* Build network boot information and transfer it to the BIOS.
*/
{
char achBootIdx[] = "0";
unsigned uBootIdx = 0;
{
/* A NIC with priority 0 is only used if it's first in the list. */
break;
}
}
/*
* 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)
{
}
}
}
/*
* Parallel (LPT) Ports
*/
{
if (parallelPort)
{
}
if (!fEnabled)
continue;
}
/*
* 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_FREEBSD
# ifdef VBOX_WITH_PULSE
case AudioDriverType_Pulse:
{
break;
}
# endif
#endif
#ifdef RT_OS_DARWIN
{
break;
}
#endif
}
}
/*
* The USB Controller.
*/
if (USBCtlPtr)
{
if (fOhciEnabled)
{
afPciDeviceNo[6] = true;
/*
* Attach the status driver.
*/
#ifdef VBOX_WITH_EHCI
if (fEhciEnabled)
{
afPciDeviceNo[11] = true;
/*
* Attach the status driver.
*/
}
#endif
/*
* Virtual USB Devices.
*/
#ifdef VBOX_WITH_USB
{
/*
* 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();
}
#endif
# if 0 /* Virtual MSD*/
# endif
{
{
}
else
{
}
}
/* Virtual USB Keyboard */
if (aKbdHid == KeyboardHidType_USBKeyboard)
{
}
}
}
/*
* 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. */
if (!RT_SUCCESS(rc))
if (!RT_SUCCESS(rc))
}
}
}
#endif
#ifdef VBOX_WITH_GUEST_PROPS
/*
* Guest property service
*/
#endif /* VBOX_WITH_GUEST_PROPS defined */
#ifdef VBOX_WITH_GUEST_CONTROL
/*
* Guest control service
*/
#endif /* VBOX_WITH_GUEST_CONTROL defined */
/*
* ACPI
*/
if (fACPI)
{
BOOL fCpuHotPlug = false;
/* 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;
{
}
afPciDeviceNo[7] = true;
/* Attach the dummy CPU drivers */
{
BOOL fCpuAttached = true;
if (fCpuHotPlug)
{
}
if (fCpuAttached)
{
}
}
}
/*
* 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...
// ... and machine keys
{
/*
* We only care about keys starting with "VBoxInternal/" (skip "G:" or "M:")
*/
continue;
// get the value
if (i2 < 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));
}
}
#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, ...)
{
}
/* XXX introduce RT format specifier */
{
{
*pszUnit = "TB";
}
{
*pszUnit = "GB";
}
else
{
*pszUnit = "MB";
}
}
const char *pcszDevice,
unsigned uInstance,
bool fUseHostIOCache,
bool fSetupMerge,
unsigned uMergeSource,
unsigned uMergeTarget,
bool fAttachDetach,
bool fForceUnmount,
{
int rc = VINF_SUCCESS;
unsigned uLUN;
/* First check if the LUN already exists. */
if (pLunL0)
{
if (fAttachDetach)
{
if (lType != DeviceType_HardDisk)
{
/* Unmount existing media only for floppy and DVD drives. */
if (RT_FAILURE(rc))
{
rc = VINF_SUCCESS;
}
else
{
/* Unmount the media. */
if (rc == VERR_PDM_MEDIA_NOT_MOUNTED)
rc = VINF_SUCCESS;
}
}
if (rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN)
rc = VINF_SUCCESS;
RC_CHECK();
}
else
}
/* SCSI has a another driver between device and block. */
{
}
if (lType == DeviceType_HardDisk)
{
/*
* Some sanity checks.
*/
{
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
{
#ifdef RT_OS_WINDOWS
if ( typeFile == RTFS_FS_TYPE_FAT
{
const char *pszUnit;
setVMRuntimeErrorCallbackF(pVM, this, 0,
"FatPartitionDetected",
N_("The medium '%ls' has a logical size of %RU64%s "
"but the file system the medium is located on seems "
"to be FAT(32) which cannot handle files bigger than 4GB.\n"
"We strongly recommend to put all your virtual disk images and "
"the snapshot folder onto an NTFS partition"),
}
#else /* !RT_OS_WINDOWS */
if ( typeFile == RTFS_FS_TYPE_FAT
|| typeFile == RTFS_FS_TYPE_EXT
|| typeFile == RTFS_FS_TYPE_EXT2
|| typeFile == RTFS_FS_TYPE_EXT3
|| typeFile == RTFS_FS_TYPE_EXT4)
{
if (RT_SUCCESS(rc))
{
/* Careful: This function will work only on selected local file systems! */
if ( RT_SUCCESS(rc)
&& maxSize > 0
{
const char *pszUnitSiz;
const char *pszUnitMax;
setVMRuntimeErrorCallbackF(pVM, this, 0,
"FatPartitionDetected", /* <= not exact but ... */
N_("The medium '%ls' has a logical size of %RU64%s "
"but the file system the medium is located on can "
"only handle files up to %RU64%s in theory.\n"
"We strongly recommend to put all your virtual disk "
"images and the snapshot folder onto a proper "
"file system (e.g. ext3) with a sufficient size"),
}
}
}
#endif /* !RT_OS_WINDOWS */
/*
* Snapshot folder:
* Here we test only for a FAT partition as we had to create a dummy file otherwise
*/
if ( typeSnap == RTFS_FS_TYPE_FAT
{
const char *pszUnit;
setVMRuntimeErrorCallbackF(pVM, this, 0,
"FatPartitionDetected",
#ifdef RT_OS_WINDOWS
N_("The snapshot folder of this VM '%ls' seems to be located on "
"a FAT(32) file system. The logical size of the medium '%ls' "
"(%RU64%s) is bigger than the maximum file size this file "
"system can handle (4GB).\n"
"We strongly recommend to put all your virtual disk images and "
"the snapshot folder onto an NTFS partition"),
#else
N_("The snapshot folder of this VM '%ls' seems to be located on "
"a FAT(32) file system. The logical size of the medium '%ls' "
"(%RU64%s) is bigger than the maximum file size this file "
"system can handle (4GB).\n"
"We strongly recommend to put all your virtual disk images and "
"the snapshot folder onto a proper file system (e.g. ext3)"),
#endif
/* Show this particular warning only once */
mfSnapshotFolderSizeWarningShown = true;
}
#ifdef RT_OS_LINUX
/*
* Ext4 bug: Check if the host I/O cache is disabled and the disk image is located
* on an ext4 partition. Later we have to check the Linux kernel version!
* This bug apparently applies to the XFS file system as well.
*/
&& !fUseHostIOCache
&& ( typeFile == RTFS_FS_TYPE_EXT4
|| typeFile == RTFS_FS_TYPE_XFS))
{
setVMRuntimeErrorCallbackF(pVM, this, 0,
"Ext4PartitionDetected",
N_("The host I/O cache for at least one controller is disabled "
"and the medium '%ls' for this VM "
"is located on an %s partition. There is a known Linux "
"kernel bug which can lead to the corruption of the virtual "
"disk image under these conditions.\n"
"Either enable the host I/O cache permanently in the VM "
"settings or put the disk image and the snapshot folder "
"onto a different file system.\n"
"The host I/O cache will now be enabled for this medium"),
fUseHostIOCache = true;
}
else if ( (uCaps & MediumFormatCapabilities_Asynchronous)
&& !fUseHostIOCache
&& ( typeSnap == RTFS_FS_TYPE_EXT4
|| typeSnap == RTFS_FS_TYPE_XFS)
{
setVMRuntimeErrorCallbackF(pVM, this, 0,
"Ext4PartitionDetected",
N_("The host I/O cache for at least one controller is disabled "
"and the snapshot folder for this VM "
"is located on an %s partition. There is a known Linux "
"kernel bug which can lead to the corruption of the virtual "
"disk image under these conditions.\n"
"Either enable the host I/O cache permanently in the VM "
"settings or put the disk image and the snapshot folder "
"onto a different file system.\n"
"The host I/O cache will now be enabled for this medium"),
fUseHostIOCache = true;
mfSnapshotFolderExt4WarningShown = true;
}
#endif
}
}
}
!!fPassthrough,
if (fAttachDetach)
{
/* Attach the new driver. */
/* There is no need to handle removable medium mounting, as we
* unconditionally replace everthing including the block driver level.
* This means the new medium will be picked up automatically. */
}
if (paLedDevType)
#undef H
return VINF_SUCCESS;;
}
bool fPassthrough,
bool fUseHostIOCache,
bool fSetupMerge,
unsigned uMergeSource,
unsigned uMergeTarget,
{
int rc = VINF_SUCCESS;
#define H() AssertMsgReturnStmt(!FAILED(hrc), ("hrc=%Rhrc\n", hrc), if (phrc) *phrc = hrc, VERR_GENERAL_FAILURE)
if (pMedium)
{
}
if (fHostDrive)
{
if (enmType == DeviceType_DVD)
{
}
else if (enmType == DeviceType_Floppy)
{
}
}
else
{
switch (enmType)
{
case DeviceType_DVD:
break;
case DeviceType_Floppy:
break;
case DeviceType_HardDisk:
default:
}
if ( pMedium
&& ( enmType == DeviceType_DVD
|| enmType == DeviceType_Floppy
))
{
// if this medium represents an ISO image and this image is inaccessible,
// the ignore it instead of causing a failure; this can happen when we
// restore a VM state and the ISO has disappeared, e.g. because the Guest
// Additions were mounted and the user upgraded VirtualBox. Previously
// we failed on startup, but that's not good because the only way out then
// would be to discard the VM state...
RC_CHECK();
if (mediumState == MediumState_Inaccessible)
{
this,
0,
"DvdOrFloppyImageInaccessible",
"The image file '%ls' is inaccessible and is being ignored. Please select a different image file for the virtual %s drive.",
}
}
if (pMedium)
{
/* Start with length of parent chain, as the list is reversed */
unsigned uImage = 0;
while (pTmp)
{
uImage++;
}
/* Index of last image */
uImage--;
#if 0 /* Enable for I/O debugging */
#endif
/* DVDs are always readonly */
if (enmType == DeviceType_DVD)
{
}
/* Start without exclusive write access to the images. */
/** @todo Live Migration: I don't quite like this, we risk screwing up when
* we're resuming the VM if some 3rd dude have any of the VDIs open
* with write sharing denied. However, if the two VMs are sharing a
* image it really is necessary....
*
* So, on the "lock-media" command, the target teleporter should also
* make DrvVD undo TempReadOnly. It gets interesting if we fail after
* that. Grumble. */
else if (aMachineState == MachineState_TeleportingIn)
{
}
if (!fUseHostIOCache)
{
}
if (fSetupMerge)
{
if (uImage == uMergeSource)
{
}
else if (uImage == uMergeTarget)
{
}
}
/* Pass all custom parameters. */
bool fHostIP = true;
ComSafeArrayAsOutParam(values)); H();
{
{
{
fHostIP = false;
}
}
}
/* Create an inversed list of parents. */
uImage--;
{
if (!pMedium)
break;
if (fSetupMerge)
{
if (uImage == uMergeSource)
{
}
else if (uImage == uMergeTarget)
{
}
}
/* Pass all custom parameters. */
ComSafeArrayAsOutParam(aValues)); H();
{
{
{
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 */
}
}
}
#undef H
return VINF_SUCCESS;
}
/**
* Construct the Network configuration tree
*
* @returns VBox status code.
*
* @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 this object for writing.
*/
bool fAttachDetach)
{
AutoCaller autoCaller(this);
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.
*/
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
{
{
}
}
}
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. */
{
}
}
switch (eAttachmentType)
{
break;
{
if (fSniffer)
{
}
else
{
}
/* Configure TFTP prefix and boot filename. */
{
rc = CFGMR3InsertStringF(pCfg, "TFTPPrefix", "%ls%c%s", bstr.raw(), RTPATH_DELIMITER, "TFTP"); RC_CHECK();
}
{
}
else
{
}
{
}
if (mtu)
{
}
if (sockRcv)
{
}
if (sockSnd)
{
}
if (tcpRcv)
{
}
if (tcpSnd)
{
}
{
}
{
}
{
}
/* port-forwarding */
{
do { \
{ \
continue; \
} \
} while (0)
bool fValid = true;
switch (proto)
{
case NATProtocol_UDP:
strProto = "UDP";
break;
case NATProtocol_TCP:
strProto = "TCP";
break;
default:
fValid = false;
}
/* continue with next rule if no valid proto was passed */
if (!fValid)
continue;
{
}
if (!strGuestIP.isEmpty())
{
}
if (port)
{
}
if (port)
{
}
}
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)
{
/*
* Dynamic changing of attachment causes an attempt to configure
* network with invalid host adapter (as it is must be changed before
* the attachment), calling Detach here will cause a deadlock.
* See #4750.
* hrc = aNetworkAdapter->Detach(); H();
*/
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();
}
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 */
# if defined(RT_OS_FREEBSD)
/*
* If we bridge to a tap interface open it the `old' direct way.
* This works and performs better than bridging a physical
* interface via the current FreeBSD vboxnetflt implementation.
*/
{
switch (hrc)
{
case VERR_ACCESS_DENIED:
"permissions of that node, and that the net.link.tap.user_open "
"sysctl is set. Either run 'chmod 0666 /dev/%s' or "
"change the group of that node to vboxusers and make yourself "
default:
AssertMsgFailed(("Could not attach to tap interface! Bad!\n"));
"Failed to initialize Host Interface Networking"));
}
}
{
}
break;
}
# endif
/** @todo Check for malformed names. */
const char *pszTrunk = pszHifName;
/* Issue a warning if the interface is down */
{
if (iSock >= 0)
{
{
setVMRuntimeErrorCallbackF(pVM, this, 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_FREEBSD)
if (iSock >= 0)
{
struct ieee80211req WReq;
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 = bstr;
}
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();
}
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
{
/* 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());
{
}
#endif
break;
}
#if defined(VBOX_WITH_VDE)
{
{
networkName = bstr;
}
break;
}
#endif
default:
AssertMsgFailed(("should not get here!\n"));
break;
}
/*
* Attempt to attach the driver.
*/
switch (eAttachmentType)
{
break;
#if defined(VBOX_WITH_VDE)
#endif
{
{
if (fAttachDetach)
{
//AssertRC(rc);
}
{
/** @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.isEmpty())
{
/*
* 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]);
}
/**
* Set the global flags value by calling the service
* @returns the status returned by the call to the service
*
* @param pTable the service instance handle
* @param eFlags the flags to set
*/
{
&paParm);
if (RT_FAILURE(rc))
{
Log(("Failed to set the global flags.\n"));
else
}
return rc;
}
#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
*/
#endif
Log(("Set VBoxGuestPropSvc property store\n"));
}
return VINF_SUCCESS;
#else /* !VBOX_WITH_GUEST_PROPS */
return VERR_NOT_SUPPORTED;
#endif /* !VBOX_WITH_GUEST_PROPS */
}
/**
* Set up the Guest Control service.
*/
{
#ifdef VBOX_WITH_GUEST_CONTROL
/* Load the service */
if (RT_FAILURE(rc))
{
/* That is not a fatal failure. */
rc = VINF_SUCCESS;
}
else
{
if (RT_FAILURE(rc))
Log(("Cannot register VBoxGuestControlSvc extension!\n"));
else
Log(("VBoxGuestControlSvc loaded\n"));
}
return rc;
#else /* !VBOX_WITH_GUEST_CONTROL */
return VERR_NOT_SUPPORTED;
#endif /* !VBOX_WITH_GUEST_CONTROL */
}