ConsoleImpl2.cpp revision 6e12ccc60ac657fb87e27b7a2b26e0a63bebe024
af062818b47340eef15700d2f0211576ba3506eevboxsync/* $Id$ */
af062818b47340eef15700d2f0211576ba3506eevboxsync/** @file
af062818b47340eef15700d2f0211576ba3506eevboxsync * VBox Console COM Class implementation
af062818b47340eef15700d2f0211576ba3506eevboxsync *
af062818b47340eef15700d2f0211576ba3506eevboxsync * @remark We've split out the code that the 64-bit VC++ v8 compiler finds
af062818b47340eef15700d2f0211576ba3506eevboxsync * problematic to optimize so we can disable optimizations and later,
af062818b47340eef15700d2f0211576ba3506eevboxsync * perhaps, find a real solution for it (like rewriting the code and
af062818b47340eef15700d2f0211576ba3506eevboxsync * to stop resemble a tonne of spaghetti).
af062818b47340eef15700d2f0211576ba3506eevboxsync */
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync/*
af062818b47340eef15700d2f0211576ba3506eevboxsync * Copyright (C) 2006-2010 Sun Microsystems, Inc.
af062818b47340eef15700d2f0211576ba3506eevboxsync *
af062818b47340eef15700d2f0211576ba3506eevboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
af062818b47340eef15700d2f0211576ba3506eevboxsync * available from http://www.virtualbox.org. This file is free software;
af062818b47340eef15700d2f0211576ba3506eevboxsync * you can redistribute it and/or modify it under the terms of the GNU
af062818b47340eef15700d2f0211576ba3506eevboxsync * General Public License (GPL) as published by the Free Software
af062818b47340eef15700d2f0211576ba3506eevboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
af062818b47340eef15700d2f0211576ba3506eevboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
af062818b47340eef15700d2f0211576ba3506eevboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
af062818b47340eef15700d2f0211576ba3506eevboxsync *
af062818b47340eef15700d2f0211576ba3506eevboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
af062818b47340eef15700d2f0211576ba3506eevboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
af062818b47340eef15700d2f0211576ba3506eevboxsync * additional information or have any questions.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync/*******************************************************************************
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync* Header Files *
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync*******************************************************************************/
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync#include "ConsoleImpl.h"
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync#include "DisplayImpl.h"
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync#include "VMMDev.h"
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync// generated header
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync#include "SchemaDefs.h"
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#include "AutoCaller.h"
af062818b47340eef15700d2f0211576ba3506eevboxsync#include "Logging.h"
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#include <iprt/buildconfig.h>
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#include <iprt/string.h>
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#include <iprt/path.h>
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#include <iprt/dir.h>
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#include <iprt/param.h>
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#if 0 /* enable to play with lots of memory. */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync# include <iprt/env.h>
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#endif
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#include <iprt/file.h>
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#include <VBox/vmapi.h>
af062818b47340eef15700d2f0211576ba3506eevboxsync#include <VBox/err.h>
af062818b47340eef15700d2f0211576ba3506eevboxsync#include <VBox/version.h>
af062818b47340eef15700d2f0211576ba3506eevboxsync#include <VBox/HostServices/VBoxClipboardSvc.h>
af062818b47340eef15700d2f0211576ba3506eevboxsync#ifdef VBOX_WITH_CROGL
af062818b47340eef15700d2f0211576ba3506eevboxsync#include <VBox/HostServices/VBoxCrOpenGLSvc.h>
af062818b47340eef15700d2f0211576ba3506eevboxsync#endif
af062818b47340eef15700d2f0211576ba3506eevboxsync#ifdef VBOX_WITH_GUEST_PROPS
af062818b47340eef15700d2f0211576ba3506eevboxsync# include <VBox/HostServices/GuestPropertySvc.h>
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync# include <VBox/com/defs.h>
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync# include <VBox/com/array.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <hgcm/HGCM.h> /** @todo it should be possible to register a service
5112e32d7072e280613921c982a6672f2c859cf3vboxsync * extension using a VMMDev callback. */
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync# include <vector>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#endif /* VBOX_WITH_GUEST_PROPS */
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#include <VBox/intnet.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#include <VBox/com/com.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#include <VBox/com/string.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#include <VBox/com/array.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#if defined(RT_OS_SOLARIS) && defined(VBOX_WITH_NETFLT)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <zone.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#endif
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#if defined(RT_OS_LINUX) && defined(VBOX_WITH_NETFLT)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <unistd.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <sys/ioctl.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <sys/socket.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <linux/types.h>
af062818b47340eef15700d2f0211576ba3506eevboxsync# include <linux/if.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <linux/wireless.h>
af062818b47340eef15700d2f0211576ba3506eevboxsync#endif
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#if defined(RT_OS_FREEBSD) && defined(VBOX_WITH_NETFLT)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <unistd.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <sys/types.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <sys/ioctl.h>
af062818b47340eef15700d2f0211576ba3506eevboxsync# include <sys/socket.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <net/if.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <net80211/ieee80211_ioctl.h>
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#endif
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <VBox/WinNetConfig.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <Ntddndis.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <devguid.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#endif
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#if !defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <HostNetworkInterfaceImpl.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <netif.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# include <stdlib.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#endif
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#include "DHCPServerRunner.h"
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#include <VBox/param.h>
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#undef PVM
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync/* Comment out the following line to remove VMWare compatibility hack. */
af062818b47340eef15700d2f0211576ba3506eevboxsync#define VMWARE_NET_IN_SLOT_11
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync/**
5112e32d7072e280613921c982a6672f2c859cf3vboxsync * Translate IDE StorageControllerType_T to string representation.
5112e32d7072e280613921c982a6672f2c859cf3vboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsyncconst char* controllerString(StorageControllerType_T enmType)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync{
5112e32d7072e280613921c982a6672f2c859cf3vboxsync switch (enmType)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync {
5112e32d7072e280613921c982a6672f2c859cf3vboxsync case StorageControllerType_PIIX3:
5112e32d7072e280613921c982a6672f2c859cf3vboxsync return "PIIX3";
5112e32d7072e280613921c982a6672f2c859cf3vboxsync case StorageControllerType_PIIX4:
5112e32d7072e280613921c982a6672f2c859cf3vboxsync return "PIIX4";
af062818b47340eef15700d2f0211576ba3506eevboxsync case StorageControllerType_ICH6:
5112e32d7072e280613921c982a6672f2c859cf3vboxsync return "ICH6";
5112e32d7072e280613921c982a6672f2c859cf3vboxsync default:
5112e32d7072e280613921c982a6672f2c859cf3vboxsync return "Unknown";
5112e32d7072e280613921c982a6672f2c859cf3vboxsync }
5112e32d7072e280613921c982a6672f2c859cf3vboxsync}
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync/*
5112e32d7072e280613921c982a6672f2c859cf3vboxsync * VC++ 8 / amd64 has some serious trouble with this function.
5112e32d7072e280613921c982a6672f2c859cf3vboxsync * As a temporary measure, we'll drop global optimizations.
5112e32d7072e280613921c982a6672f2c859cf3vboxsync */
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#if defined(_MSC_VER) && defined(RT_ARCH_AMD64)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync# pragma optimize("g", off)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#endif
af062818b47340eef15700d2f0211576ba3506eevboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsyncstatic int findEfiRom(IVirtualBox* vbox, FirmwareType_T aFirmwareType, Utf8Str& aEfiRomFile)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync{
5112e32d7072e280613921c982a6672f2c859cf3vboxsync int rc;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync BOOL fPresent = FALSE;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync Bstr aFilePath, empty;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync rc = vbox->CheckFirmwarePresent(aFirmwareType, empty,
5112e32d7072e280613921c982a6672f2c859cf3vboxsync empty.asOutParam(), aFilePath.asOutParam(), &fPresent);
5112e32d7072e280613921c982a6672f2c859cf3vboxsync if (RT_FAILURE(rc))
5112e32d7072e280613921c982a6672f2c859cf3vboxsync AssertComRCReturn (rc, VERR_FILE_NOT_FOUND);
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync if (!fPresent)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync return VERR_FILE_NOT_FOUND;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync aEfiRomFile = Utf8Str(aFilePath);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync return S_OK;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync}
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync/**
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * Construct the VM configuration tree (CFGM).
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync *
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * This is a callback for VMR3Create() call. It is called from CFGMR3Init()
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * in the emulation thread (EMT). Any per thread COM/XPCOM initialization
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * is done here.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync *
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * @param pVM VM handle.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * @param pvConsole Pointer to the VMPowerUpTask object.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * @return VBox status code.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync *
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * @note Locks the Console object for writing.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsyncDECLCALLBACK(int) Console::configConstructor(PVM pVM, void *pvConsole)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync{
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync LogFlowFuncEnter();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* Note: hardcoded assumption about number of slots; see rom bios */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync bool afPciDeviceNo[32] = {false};
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync bool fFdcEnabled = false;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fIs64BitGuest = false;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#if !defined (VBOX_WITH_XPCOM)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* initialize COM */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync HRESULT hrc = CoInitializeEx(NULL,
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE |
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync COINIT_SPEED_OVER_MEMORY);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync LogFlow (("Console::configConstructor(): CoInitializeEx()=%08X\n", hrc));
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync AssertComRCReturn (hrc, VERR_GENERAL_FAILURE);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
040b4a09341f574825386333398110f4db3e1e51vboxsync#endif
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync AssertReturn(pvConsole, VERR_GENERAL_FAILURE);
040b4a09341f574825386333398110f4db3e1e51vboxsync ComObjPtr<Console> pConsole = static_cast <Console *> (pvConsole);
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync AutoCaller autoCaller(pConsole);
040b4a09341f574825386333398110f4db3e1e51vboxsync AssertComRCReturn (autoCaller.rc(), VERR_ACCESS_DENIED);
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync /* lock the console because we widely use internal fields and methods */
040b4a09341f574825386333398110f4db3e1e51vboxsync AutoWriteLock alock(pConsole COMMA_LOCKVAL_SRC_POS);
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync /* Save the VM pointer in the machine object */
040b4a09341f574825386333398110f4db3e1e51vboxsync pConsole->mpVM = pVM;
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync ComPtr<IMachine> pMachine = pConsole->machine();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync int rc;
040b4a09341f574825386333398110f4db3e1e51vboxsync HRESULT hrc;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync BSTR str = NULL;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } } while (0)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%#x\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /*
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * Get necessary objects and frequently used parameters.
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync ComPtr<IVirtualBox> virtualBox;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = pMachine->COMGETTER(Parent)(virtualBox.asOutParam()); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync ComPtr<IHost> host;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = virtualBox->COMGETTER(Host)(host.asOutParam()); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync ComPtr<ISystemProperties> systemProperties;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam()); H();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync ComPtr<IBIOSSettings> biosSettings;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = pMachine->COMGETTER(BIOSSettings)(biosSettings.asOutParam()); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = pMachine->COMGETTER(HardwareUUID)(&str); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync RTUUID HardwareUuid;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = RTUuidFromUtf16(&HardwareUuid, str); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync STR_FREE();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync ULONG cRamMBs;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = pMachine->COMGETTER(MemorySize)(&cRamMBs); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#if 0 /* enable to play with lots of memory. */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (RTEnvExist("VBOX_RAM_SIZE"))
af062818b47340eef15700d2f0211576ba3506eevboxsync cRamMBs = RTStrToUInt64(RTEnvGet("VBOX_RAM_SIZE"));
af062818b47340eef15700d2f0211576ba3506eevboxsync#endif
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync uint64_t const cbRam = cRamMBs * (uint64_t)_1M;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync uint32_t const cbRamHole = MM_RAM_HOLE_SIZE_DEFAULT;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync ULONG cCpus = 1;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->COMGETTER(CPUCount)(&cCpus); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync Bstr osTypeId;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->COMGETTER(OSTypeId)(osTypeId.asOutParam()); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fIOAPIC;
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync hrc = biosSettings->COMGETTER(IOAPICEnabled)(&fIOAPIC); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * Get root node first.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * This is the only node in the tree.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pRoot = CFGMR3GetRoot(pVM);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync Assert(pRoot);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * Set the root (and VMM) level values.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->COMGETTER(Name)(&str); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertStringW(pRoot, "Name", str); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertBytes(pRoot, "UUID", &HardwareUuid, sizeof(HardwareUuid)); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pRoot, "RamSize", cbRam); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pRoot, "RamHoleSize", cbRamHole); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pRoot, "NumCPUs", cCpus); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pRoot, "TimerMillies", 10); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pRoot, "RawR3Enabled", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pRoot, "RawR0Enabled", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /** @todo Config: RawR0, PATMEnabled and CSAMEnabled needs attention later. */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pRoot, "PATMEnabled", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pRoot, "CSAMEnabled", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* cpuid leaf overrides. */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync static uint32_t const s_auCpuIdRanges[] =
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync UINT32_C(0x00000000), UINT32_C(0x0000000a),
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync UINT32_C(0x80000000), UINT32_C(0x8000000a)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync };
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync for (unsigned i = 0; i < RT_ELEMENTS(s_auCpuIdRanges); i += 2)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync for (uint32_t uLeaf = s_auCpuIdRanges[i]; uLeaf < s_auCpuIdRanges[i + 1]; uLeaf++)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync ULONG ulEax, ulEbx, ulEcx, ulEdx;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->GetCpuIdLeaf(uLeaf, &ulEax, &ulEbx, &ulEcx, &ulEdx);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (SUCCEEDED(hrc))
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pLeaf;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNodeF(pRoot, &pLeaf, "CPUM/HostCPUID/%RX32", uLeaf); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pLeaf, "eax", ulEax); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pLeaf, "ebx", ulEbx); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pLeaf, "ecx", ulEcx); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pLeaf, "edx", ulEdx); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync else if (hrc != E_INVALIDARG) H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (osTypeId == "WindowsNT4")
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * We must limit CPUID count for Windows NT 4, as otherwise it stops
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * with error 0x3e (MULTIPROCESSOR_CONFIGURATION_NOT_SUPPORTED).
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync LogRel(("Limiting CPUID leaf count for NT4 guests\n"));
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pCPUM;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pRoot, "CPUM", &pCPUM); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCPUM, "NT4LeafLimit", true); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* hardware virtualization extensions */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fHWVirtExEnabled;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_Enabled, &fHWVirtExEnabled); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (cCpus > 1) /** @todo SMP: This isn't nice, but things won't work on mac otherwise. */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync fHWVirtExEnabled = TRUE;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#ifdef RT_OS_DARWIN
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pRoot, "HwVirtExtForced", fHWVirtExEnabled); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#else
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* - With more than 4GB PGM will use different RAMRANGE sizes for raw
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync mode and hv mode to optimize lookup times.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync - With more than one virtual CPU, raw-mode isn't a fallback option. */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fHwVirtExtForced = fHWVirtExEnabled
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync && ( cbRam > (_4G - cbRamHole)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync || cCpus > 1);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pRoot, "HwVirtExtForced", fHwVirtExtForced); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#endif
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pHWVirtExt;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pRoot, "HWVirtExt", &pHWVirtExt); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (fHWVirtExEnabled)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pHWVirtExt, "Enabled", 1); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* Indicate whether 64-bit guests are supported or not. */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /** @todo This is currently only forced off on 32-bit hosts only because it
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * makes a lof of difference there (REM and Solaris performance).
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync ComPtr<IGuestOSType> guestOSType;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = virtualBox->GetGuestOSType(osTypeId, guestOSType.asOutParam()); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fSupportsLongMode = false;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = host->GetProcessorFeature(ProcessorFeature_LongMode,
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync &fSupportsLongMode); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = guestOSType->COMGETTER(Is64Bit)(&fIs64BitGuest); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (fSupportsLongMode && fIs64BitGuest)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pHWVirtExt, "64bitEnabled", 1); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#if ARCH_BITS == 32 /* The recompiler must use VBoxREM64 (32-bit host only). */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pREM;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pRoot, "REM", &pREM); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pREM, "64bitEnabled", 1); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#endif
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#if ARCH_BITS == 32 /* 32-bit guests only. */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync else
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pHWVirtExt, "64bitEnabled", 0); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#endif
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* @todo Not exactly pretty to check strings; VBOXOSTYPE would be better, but that requires quite a bit of API change in Main. */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if ( !fIs64BitGuest
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync && fIOAPIC
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync && ( osTypeId == "WindowsNT4"
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync || osTypeId == "Windows2000"
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync || osTypeId == "WindowsXP"
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync || osTypeId == "Windows2003"))
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* Only allow TPR patching for NT, Win2k, XP and Windows Server 2003. (32 bits mode)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * We may want to consider adding more guest OSes (Solaris) later on.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pHWVirtExt, "TPRPatchingEnabled", 1); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* HWVirtEx exclusive mode */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fHWVirtExExclusive = true;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_Exclusive, &fHWVirtExExclusive); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pHWVirtExt, "Exclusive", fHWVirtExExclusive); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* Nested paging (VT-x/AMD-V) */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fEnableNestedPaging = false;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_NestedPaging, &fEnableNestedPaging); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pHWVirtExt, "EnableNestedPaging", fEnableNestedPaging); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* VPID (VT-x) */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fEnableVPID = false;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_VPID, &fEnableVPID); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pHWVirtExt, "EnableVPID", fEnableVPID); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* Physical Address Extension (PAE) */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fEnablePAE = false;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->GetCpuProperty(CpuPropertyType_PAE, &fEnablePAE); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pRoot, "EnablePAE", fEnablePAE); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* Synthetic CPU */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fSyntheticCpu = false;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->GetCpuProperty(CpuPropertyType_Synthetic, &fSyntheticCpu); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pRoot, "SyntheticCpu", fSyntheticCpu); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fPXEDebug;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = biosSettings->COMGETTER(PXEDebugEnabled)(&fPXEDebug); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * PDM config.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * Load drivers in VBoxC.[so|dll]
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pPDM;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pDrivers;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pMod;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pRoot, "PDM", &pPDM); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pPDM, "Drivers", &pDrivers); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDrivers, "VBoxC", &pMod); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#ifdef VBOX_WITH_XPCOM
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync // VBoxC is located in the components subdirectory
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync char szPathVBoxC[RTPATH_MAX];
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = RTPathAppPrivateArch(szPathVBoxC, RTPATH_MAX - sizeof("/components/VBoxC")); AssertRC(rc);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync strcat(szPathVBoxC, "/components/VBoxC");
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertString(pMod, "Path", szPathVBoxC); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#else
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertString(pMod, "Path", "VBoxC"); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#endif
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * Devices
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pDevices = NULL; /* /Devices */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pDev = NULL; /* /Devices/Dev/ */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pInst = NULL; /* /Devices/Dev/0/ */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pCfg = NULL; /* /Devices/Dev/.../Config/ */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pLunL0 = NULL; /* /Devices/Dev/0/LUN#0/ */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pLunL1 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/ */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pLunL2 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/Config/ */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pBiosCfg = NULL; /* /Devices/pcbios/0/Config/ */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pRoot, "Devices", &pDevices); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * PC Arch.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDevices, "pcarch", &pDev); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * The time offset
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync LONG64 timeOffset;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = biosSettings->COMGETTER(TimeOffset)(&timeOffset); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pTMNode;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pRoot, "TM", &pTMNode); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pTMNode, "UTCOffset", timeOffset * 1000000); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * DMA
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDevices, "8237A", &pDev); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * PCI buses.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDevices, "pci", &pDev); /* piix3 */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#if 0 /* enable this to test PCI bridging */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDevices, "pcibridge", &pDev); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 14); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "PCIBusNo", 0);/* -> pci[0] */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDev, "1", &pInst); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 1); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "PCIBusNo", 1);/* ->pcibridge[0] */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDev, "2", &pInst); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 3); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "PCIBusNo", 1);/* ->pcibridge[0] */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#endif
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * Temporary hack for enabling the next three devices and various ACPI features.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync Bstr tmpStr2;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/SupportExtHwProfile"), tmpStr2.asOutParam()); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fExtProfile = tmpStr2 == Bstr("on");
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * High Precision Event Timer (HPET)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fHpetEnabled;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#ifdef VBOX_WITH_HPET
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync fHpetEnabled = fExtProfile;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#else
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync fHpetEnabled = false;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#endif
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (fHpetEnabled)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDevices, "hpet", &pDev); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * System Management Controller (SMC)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fSmcEnabled;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#ifdef VBOX_WITH_SMC
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync fSmcEnabled = fExtProfile;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#else
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync fSmcEnabled = false;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#endif
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (fSmcEnabled)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDevices, "smc", &pDev); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * Low Pin Count (LPC) bus
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fLpcEnabled;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /** @todo: implement appropriate getter */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#ifdef VBOX_WITH_LPC
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync fLpcEnabled = fExtProfile;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#else
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync fLpcEnabled = false;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#endif
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (fLpcEnabled)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDevices, "lpc", &pDev); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * PS/2 keyboard & mouse.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDevices, "pckbd", &pDev); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "KeyboardQueue"); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertInteger(pCfg, "QueueSize", 64); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pLunL1, "Driver", "MainKeyboard"); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync Keyboard *pKeyboard = pConsole->mKeyboard;
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pKeyboard); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNode(pInst, "LUN#1", &pLunL0); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MouseQueue"); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "QueueSize", 128); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertString(pLunL1, "Driver", "MainMouse"); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync Mouse *pMouse = pConsole->mMouse;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pMouse); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync * i8254 Programmable Interval Timer And Dummy Speaker
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertNode(pDevices, "i8254", &pDev); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#ifdef DEBUG
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#endif
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync * i8259 Programmable Interrupt Controller.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNode(pDevices, "i8259", &pDev); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync * Advanced Programmable Interrupt Controller.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * SMP: Each CPU has a LAPIC, but we have a single device representing all LAPICs states,
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync * thus only single insert
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertNode(pDevices, "apic", &pDev); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "NumCPUs", cCpus); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync if (fIOAPIC)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * I/O Advanced Programmable Interrupt Controller.
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDevices, "ioapic", &pDev); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync * RTC MC146818.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertNode(pDevices, "mc146818", &pDev); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fRTCUseUTC;
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync hrc = pMachine->COMGETTER(RTCUseUTC)(&fRTCUseUTC); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "UseUTC", fRTCUseUTC ? 1 : 0);
af062818b47340eef15700d2f0211576ba3506eevboxsync
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * VGA.
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDevices, "vga", &pDev); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 2); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync Assert(!afPciDeviceNo[2]);
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync afPciDeviceNo[2] = true;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync ULONG cVRamMBs;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync hrc = pMachine->COMGETTER(VRAMSize)(&cVRamMBs); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "VRamSize", cVRamMBs * _1M); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync ULONG cMonitorCount;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->COMGETTER(MonitorCount)(&cMonitorCount); H();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertInteger(pCfg, "MonitorCount", cMonitorCount); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE /* not safe here yet. */ /** @todo this needs fixing !!! No wonder VGA is slooooooooow on 32-bit darwin! */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertInteger(pCfg, "R0Enabled", fHWVirtExEnabled); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#endif
af062818b47340eef15700d2f0211576ba3506eevboxsync
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * BIOS logo
5112e32d7072e280613921c982a6672f2c859cf3vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fFadeIn;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync hrc = biosSettings->COMGETTER(LogoFadeIn)(&fFadeIn); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "FadeIn", fFadeIn ? 1 : 0); RC_CHECK();
5112e32d7072e280613921c982a6672f2c859cf3vboxsync BOOL fFadeOut;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = biosSettings->COMGETTER(LogoFadeOut)(&fFadeOut); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "FadeOut", fFadeOut ? 1: 0); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync ULONG logoDisplayTime;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = biosSettings->COMGETTER(LogoDisplayTime)(&logoDisplayTime); H();
5112e32d7072e280613921c982a6672f2c859cf3vboxsync rc = CFGMR3InsertInteger(pCfg, "LogoTime", logoDisplayTime); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync Bstr logoImagePath;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync hrc = biosSettings->COMGETTER(LogoImagePath)(logoImagePath.asOutParam()); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertString(pCfg, "LogoFile", logoImagePath ? Utf8Str(logoImagePath).c_str() : ""); RC_CHECK();
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync * Boot menu
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
5112e32d7072e280613921c982a6672f2c859cf3vboxsync BIOSBootMenuMode_T eBootMenuMode;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync int iShowBootMenu;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync biosSettings->COMGETTER(BootMenuMode)(&eBootMenuMode);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync switch (eBootMenuMode)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync case BIOSBootMenuMode_Disabled: iShowBootMenu = 0; break;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync case BIOSBootMenuMode_MenuOnly: iShowBootMenu = 1; break;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync default: iShowBootMenu = 2; break;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "ShowBootMenu", iShowBootMenu); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* Custom VESA mode list */
5112e32d7072e280613921c982a6672f2c859cf3vboxsync unsigned cModes = 0;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync for (unsigned iMode = 1; iMode <= 16; ++iMode)
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync char szExtraDataKey[sizeof("CustomVideoModeXX")];
5112e32d7072e280613921c982a6672f2c859cf3vboxsync RTStrPrintf(szExtraDataKey, sizeof(szExtraDataKey), "CustomVideoMode%u", iMode);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->GetExtraData(Bstr(szExtraDataKey), &str); H();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync if (!str || !*str)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync break;
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertStringW(pCfg, szExtraDataKey, str); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync STR_FREE();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync ++cModes;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync STR_FREE();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "CustomVideoModes", cModes);
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* VESA height reduction */
5112e32d7072e280613921c982a6672f2c859cf3vboxsync ULONG ulHeightReduction;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync IFramebuffer *pFramebuffer = pConsole->getDisplay()->getFramebuffer();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync if (pFramebuffer)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync hrc = pFramebuffer->COMGETTER(HeightReduction)(&ulHeightReduction); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync else
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
5112e32d7072e280613921c982a6672f2c859cf3vboxsync /* If framebuffer is not available, there is no height reduction. */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync ulHeightReduction = 0;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "HeightReduction", ulHeightReduction); RC_CHECK();
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* Attach the display. */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MainDisplay"); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync Display *pDisplay = pConsole->mDisplay;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pDisplay); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * Firmware.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync FirmwareType_T eFwType = FirmwareType_BIOS;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->COMGETTER(FirmwareType)(&eFwType); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync#ifdef VBOX_WITH_EFI
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fEfiEnabled = (eFwType >= FirmwareType_EFI) && (eFwType <= FirmwareType_EFIDUAL);
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync#else
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BOOL fEfiEnabled = false;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync#endif
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (!fEfiEnabled)
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync * PC Bios.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertNode(pDevices, "pcbios", &pDev); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pBiosCfg); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pBiosCfg, "RamSize", cbRam); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertInteger(pBiosCfg, "RamHoleSize", cbRamHole); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pBiosCfg, "NumCPUs", cCpus); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertString(pBiosCfg, "HardDiskDevice", "piix3ide"); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertString(pBiosCfg, "FloppyDevice", "i82078"); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertInteger(pBiosCfg, "IOAPIC", fIOAPIC); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pBiosCfg, "PXEDebug", fPXEDebug); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertBytes(pBiosCfg, "UUID", &HardwareUuid,sizeof(HardwareUuid));RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync DeviceType_T bootDevice;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (SchemaDefs::MaxBootPosition > 9)
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync AssertMsgFailed (("Too many boot devices %d\n",
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync SchemaDefs::MaxBootPosition));
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync return VERR_INVALID_PARAMETER;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync for (ULONG pos = 1; pos <= SchemaDefs::MaxBootPosition; ++pos)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync hrc = pMachine->GetBootOrder(pos, &bootDevice); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync char szParamName[] = "BootDeviceX";
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync szParamName[sizeof (szParamName) - 2] = ((char (pos - 1)) + '0');
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync const char *pszBootDevice;
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync switch (bootDevice)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync case DeviceType_Null:
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync pszBootDevice = "NONE";
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync break;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync case DeviceType_HardDisk:
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync pszBootDevice = "IDE";
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync break;
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync case DeviceType_DVD:
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync pszBootDevice = "DVD";
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync break;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync case DeviceType_Floppy:
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync pszBootDevice = "FLOPPY";
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync break;
af062818b47340eef15700d2f0211576ba3506eevboxsync case DeviceType_Network:
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync pszBootDevice = "LAN";
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync break;
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync default:
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync AssertMsgFailed(("Invalid bootDevice=%d\n", bootDevice));
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync N_("Invalid boot device '%d'"), bootDevice);
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertString(pBiosCfg, szParamName, pszBootDevice); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync else
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync Utf8Str efiRomFile;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync /* Autodetect firmware type, basing on guest type */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (eFwType == FirmwareType_EFI)
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync eFwType =
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync fIs64BitGuest ?
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync (FirmwareType_T)FirmwareType_EFI64
5112e32d7072e280613921c982a6672f2c859cf3vboxsync :
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync (FirmwareType_T)FirmwareType_EFI32;
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync rc = findEfiRom(virtualBox, eFwType, efiRomFile); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync bool f64BitEntry = eFwType == FirmwareType_EFI64;
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * EFI.
5112e32d7072e280613921c982a6672f2c859cf3vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pDevices, "efi", &pDev); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "RamSize", cbRam); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertInteger(pCfg, "RamHoleSize", cbRamHole); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "NumCPUs", cCpus); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertString(pCfg, "EfiRom", efiRomFile.raw()); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertBytes(pCfg, "UUID", &HardwareUuid,sizeof(HardwareUuid));RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "64BitEntry", f64BitEntry); /* boolean */ RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * Storage controllers.
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync com::SafeIfaceArray<IStorageController> ctrls;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync PCFGMNODE aCtrlNodes[StorageControllerType_LsiLogicSas + 1] = {};
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->COMGETTER(StorageControllers)(ComSafeArrayAsOutParam(ctrls)); H();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync for (size_t i = 0; i < ctrls.size(); ++ i)
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync StorageControllerType_T enmCtrlType;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = ctrls[i]->COMGETTER(ControllerType)(&enmCtrlType); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync AssertRelease((unsigned)enmCtrlType < RT_ELEMENTS(aCtrlNodes));
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync StorageBus_T enmBus;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = ctrls[i]->COMGETTER(Bus)(&enmBus); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync Bstr controllerName;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = ctrls[i]->COMGETTER(Name)(controllerName.asOutParam()); H();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync ULONG ulInstance = 999;
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = ctrls[i]->COMGETTER(Instance)(&ulInstance); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /* /Devices/<ctrldev>/ */
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync const char *pszCtrlDev = pConsole->convertControllerTypeToDev(enmCtrlType);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync pDev = aCtrlNodes[enmCtrlType];
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync if (!pDev)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNode(pDevices, pszCtrlDev, &pDev); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync aCtrlNodes[enmCtrlType] = pDev; /* IDE variants are handled in the switch */
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /* /Devices/<ctrldev>/<instance>/ */
af062818b47340eef15700d2f0211576ba3506eevboxsync PCFGMNODE pCtlInst = NULL;
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNodeF(pDev, &pCtlInst, "%u", ulInstance); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Device config: /Devices/<ctrldev>/<instance>/<values> & /ditto/Config/<values> */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCtlInst, "Trusted", 1); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pCtlInst, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync switch (enmCtrlType)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync case StorageControllerType_LsiLogic:
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCtlInst, "PCIDeviceNo", 20); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync Assert(!afPciDeviceNo[20]);
af062818b47340eef15700d2f0211576ba3506eevboxsync afPciDeviceNo[20] = true;
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCtlInst, "PCIFunctionNo", 0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Attach the status driver */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pCtlInst, "LUN#999", &pLunL0); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapSCSILeds[0]); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCfg, "Last", 15); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync break;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync case StorageControllerType_BusLogic:
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCtlInst, "PCIDeviceNo", 21); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync Assert(!afPciDeviceNo[21]);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync afPciDeviceNo[21] = true;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCtlInst, "PCIFunctionNo", 0); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /* Attach the status driver */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pCtlInst, "LUN#999", &pLunL0); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapSCSILeds[0]); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCfg, "Last", 15); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync break;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync }
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync case StorageControllerType_IntelAhci:
5112e32d7072e280613921c982a6672f2c859cf3vboxsync {
5112e32d7072e280613921c982a6672f2c859cf3vboxsync rc = CFGMR3InsertInteger(pCtlInst, "PCIDeviceNo", 13); RC_CHECK();
5112e32d7072e280613921c982a6672f2c859cf3vboxsync Assert(!afPciDeviceNo[13]);
5112e32d7072e280613921c982a6672f2c859cf3vboxsync afPciDeviceNo[13] = true;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync rc = CFGMR3InsertInteger(pCtlInst, "PCIFunctionNo", 0); RC_CHECK();
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync ULONG cPorts = 0;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync hrc = ctrls[i]->COMGETTER(PortCount)(&cPorts); H();
5112e32d7072e280613921c982a6672f2c859cf3vboxsync rc = CFGMR3InsertInteger(pCfg, "PortCount", cPorts); RC_CHECK();
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync /* Needed configuration values for the bios. */
5112e32d7072e280613921c982a6672f2c859cf3vboxsync if (pBiosCfg)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pBiosCfg, "SataHardDiskDevice", "ahci"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync for (uint32_t j = 0; j < 4; ++j)
040b4a09341f574825386333398110f4db3e1e51vboxsync {
040b4a09341f574825386333398110f4db3e1e51vboxsync static const char * const s_apszConfig[4] =
040b4a09341f574825386333398110f4db3e1e51vboxsync { "PrimaryMaster", "PrimarySlave", "SecondaryMaster", "SecondarySlave" };
040b4a09341f574825386333398110f4db3e1e51vboxsync static const char * const s_apszBiosConfig[4] =
040b4a09341f574825386333398110f4db3e1e51vboxsync { "SataPrimaryMasterLUN", "SataPrimarySlaveLUN", "SataSecondaryMasterLUN", "SataSecondarySlaveLUN" };
040b4a09341f574825386333398110f4db3e1e51vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync LONG lPortNumber = -1;
040b4a09341f574825386333398110f4db3e1e51vboxsync hrc = ctrls[i]->GetIDEEmulationPort(j, &lPortNumber); H();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, s_apszConfig[j], lPortNumber); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync if (pBiosCfg)
040b4a09341f574825386333398110f4db3e1e51vboxsync {
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pBiosCfg, s_apszBiosConfig[j], lPortNumber); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync }
040b4a09341f574825386333398110f4db3e1e51vboxsync }
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync /* Attach the status driver */
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pCtlInst, "LUN#999", &pLunL0); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync AssertRelease(cPorts <= RT_ELEMENTS(pConsole->mapSATALeds));
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapSATALeds[0]); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "Last", cPorts - 1); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync break;
040b4a09341f574825386333398110f4db3e1e51vboxsync }
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync case StorageControllerType_PIIX3:
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync case StorageControllerType_PIIX4:
af062818b47340eef15700d2f0211576ba3506eevboxsync case StorageControllerType_ICH6:
040b4a09341f574825386333398110f4db3e1e51vboxsync {
040b4a09341f574825386333398110f4db3e1e51vboxsync /*
040b4a09341f574825386333398110f4db3e1e51vboxsync * IDE (update this when the main interface changes)
040b4a09341f574825386333398110f4db3e1e51vboxsync */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCtlInst, "PCIDeviceNo", 1); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync Assert(!afPciDeviceNo[1]);
af062818b47340eef15700d2f0211576ba3506eevboxsync afPciDeviceNo[1] = true;
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertInteger(pCtlInst, "PCIFunctionNo", 1); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertString(pCfg, "Type", controllerString(enmCtrlType)); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync /* Attach the status driver */
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pCtlInst, "LUN#999", &pLunL0); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapIDELeds[0]);RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "Last", 3); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync /* IDE flavors */
af062818b47340eef15700d2f0211576ba3506eevboxsync aCtrlNodes[StorageControllerType_PIIX3] = pDev;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync aCtrlNodes[StorageControllerType_PIIX4] = pDev;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync aCtrlNodes[StorageControllerType_ICH6] = pDev;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync break;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync case StorageControllerType_I82078:
040b4a09341f574825386333398110f4db3e1e51vboxsync {
040b4a09341f574825386333398110f4db3e1e51vboxsync /*
040b4a09341f574825386333398110f4db3e1e51vboxsync * i82078 Floppy drive controller
040b4a09341f574825386333398110f4db3e1e51vboxsync */
040b4a09341f574825386333398110f4db3e1e51vboxsync fFdcEnabled = true;
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "IRQ", 6); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "DMA", 2); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "MemMapped", 0 ); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "IOBase", 0x3f0); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync /* Attach the status driver */
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pCtlInst, "LUN#999", &pLunL0); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapFDLeds[0]); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync break;
040b4a09341f574825386333398110f4db3e1e51vboxsync }
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync case StorageControllerType_LsiLogicSas:
040b4a09341f574825386333398110f4db3e1e51vboxsync {
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCtlInst, "PCIDeviceNo", 21); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync Assert(!afPciDeviceNo[21]);
040b4a09341f574825386333398110f4db3e1e51vboxsync afPciDeviceNo[21] = true;
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCtlInst, "PCIFunctionNo", 0); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertString(pCfg, "ControllerType", "SAS1068"); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync /* Attach the status driver */
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pCtlInst, "LUN#999", &pLunL0); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapSCSILeds[0]); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertInteger(pCfg, "Last", 15); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync break;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync default:
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync AssertMsgFailedReturn(("invalid storage controller type: %d\n", enmCtrlType), VERR_GENERAL_FAILURE);
040b4a09341f574825386333398110f4db3e1e51vboxsync }
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync /* Attach the media to the storage controllers. */
040b4a09341f574825386333398110f4db3e1e51vboxsync com::SafeIfaceArray<IMediumAttachment> atts;
040b4a09341f574825386333398110f4db3e1e51vboxsync hrc = pMachine->GetMediumAttachmentsOfController(controllerName,
040b4a09341f574825386333398110f4db3e1e51vboxsync ComSafeArrayAsOutParam(atts)); H();
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync for (size_t j = 0; j < atts.size(); ++j)
040b4a09341f574825386333398110f4db3e1e51vboxsync {
040b4a09341f574825386333398110f4db3e1e51vboxsync ComPtr<IMedium> medium;
040b4a09341f574825386333398110f4db3e1e51vboxsync hrc = atts [j]->COMGETTER(Medium)(medium.asOutParam()); H();
040b4a09341f574825386333398110f4db3e1e51vboxsync LONG lDev;
040b4a09341f574825386333398110f4db3e1e51vboxsync hrc = atts[j]->COMGETTER(Device)(&lDev); H();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync LONG lPort;
040b4a09341f574825386333398110f4db3e1e51vboxsync hrc = atts[j]->COMGETTER(Port)(&lPort); H();
040b4a09341f574825386333398110f4db3e1e51vboxsync DeviceType_T lType;
040b4a09341f574825386333398110f4db3e1e51vboxsync hrc = atts[j]->COMGETTER(Type)(&lType); H();
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync unsigned uLUN;
040b4a09341f574825386333398110f4db3e1e51vboxsync hrc = pConsole->convertBusPortDeviceToLun(enmBus, lPort, lDev, uLUN); H();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNodeF(pCtlInst, &pLunL0, "LUN#%u", uLUN); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync /* SCSI has a another driver between device and block. */
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync if (enmBus == StorageBus_SCSI || enmBus == StorageBus_SAS)
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync {
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "SCSI"); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync }
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync BOOL fHostDrive = FALSE;
040b4a09341f574825386333398110f4db3e1e51vboxsync if (!medium.isNull())
040b4a09341f574825386333398110f4db3e1e51vboxsync {
040b4a09341f574825386333398110f4db3e1e51vboxsync hrc = medium->COMGETTER(HostDrive)(&fHostDrive); H();
040b4a09341f574825386333398110f4db3e1e51vboxsync }
040b4a09341f574825386333398110f4db3e1e51vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync if (fHostDrive)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync {
040b4a09341f574825386333398110f4db3e1e51vboxsync Assert(!medium.isNull());
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync if (lType == DeviceType_DVD)
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync {
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "HostDVD"); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync hrc = medium->COMGETTER(Location)(&str); H();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync STR_FREE();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync BOOL fPassthrough;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = atts[j]->COMGETTER(Passthrough)(&fPassthrough); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCfg, "Passthrough", !!fPassthrough); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync }
040b4a09341f574825386333398110f4db3e1e51vboxsync else if (lType == DeviceType_Floppy)
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync {
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "HostFloppy"); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync hrc = medium->COMGETTER(Location)(&str); H();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync STR_FREE();
040b4a09341f574825386333398110f4db3e1e51vboxsync }
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync else
040b4a09341f574825386333398110f4db3e1e51vboxsync {
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync switch (lType)
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync {
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync case DeviceType_DVD:
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertString(pCfg, "Type", "DVD"); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync break;
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync case DeviceType_Floppy:
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertString(pCfg, "Type", "Floppy 1.44"); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync break;
040b4a09341f574825386333398110f4db3e1e51vboxsync case DeviceType_HardDisk:
040b4a09341f574825386333398110f4db3e1e51vboxsync default:
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertString(pCfg, "Type", "HardDisk"); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "Mountable", 0); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync }
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync if (!medium.isNull())
040b4a09341f574825386333398110f4db3e1e51vboxsync {
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync hrc = medium->COMGETTER(Location)(&str); H();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync STR_FREE();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync hrc = medium->COMGETTER(Format)(&str); H();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertStringW(pCfg, "Format", str); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync STR_FREE();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync /* DVDs are always readonly */
040b4a09341f574825386333398110f4db3e1e51vboxsync if (lType == DeviceType_DVD)
040b4a09341f574825386333398110f4db3e1e51vboxsync {
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "ReadOnly", 1); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync }
040b4a09341f574825386333398110f4db3e1e51vboxsync /* Start without exclusive write access to the images. */
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync /** @todo Live Migration: I don't quite like this, we risk screwing up when
040b4a09341f574825386333398110f4db3e1e51vboxsync * we're resuming the VM if some 3rd dude have any of the VDIs open
040b4a09341f574825386333398110f4db3e1e51vboxsync * with write sharing denied. However, if the two VMs are sharing a
040b4a09341f574825386333398110f4db3e1e51vboxsync * image it really is necessary....
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync *
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync * So, on the "lock-media" command, the target teleporter should also
040b4a09341f574825386333398110f4db3e1e51vboxsync * make DrvVD undo TempReadOnly. It gets interesting if we fail after
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * that. Grumble. */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync else if (pConsole->mMachineState == MachineState_TeleportingIn)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "TempReadOnly", 1); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* Pass all custom parameters. */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync bool fHostIP = true;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync SafeArray<BSTR> names;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync SafeArray<BSTR> values;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = medium->GetProperties(NULL,
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync ComSafeArrayAsOutParam(names),
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync ComSafeArrayAsOutParam(values)); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (names.size() != 0)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync PCFGMNODE pVDC;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pCfg, "VDConfig", &pVDC); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync for (size_t ii = 0; ii < names.size(); ++ii)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (values[ii] && *values[ii])
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync Utf8Str name = names[ii];
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync Utf8Str value = values[ii];
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str()); AssertRC(rc); /** @todo r=bird: why not RC_CHECK() here? (I added the AssertRC.)*/
040b4a09341f574825386333398110f4db3e1e51vboxsync if ( name.compare("HostIPStack") == 0
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync && value.compare("0") == 0)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync fHostIP = false;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /* Create an inversed tree of parents. */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync ComPtr<IMedium> parentMedium = medium;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync for (PCFGMNODE pParent = pCfg;;)
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync {
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync hrc = parentMedium->COMGETTER(Parent)(medium.asOutParam()); H();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync if (medium.isNull())
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync break;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync PCFGMNODE pCur;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertNode(pParent, "Parent", &pCur); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync hrc = medium->COMGETTER(Location)(&str); H();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertStringW(pCur, "Path", str); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync STR_FREE();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync hrc = medium->COMGETTER(Format)(&str); H();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertStringW(pCur, "Format", str); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync STR_FREE();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync /* Pass all custom parameters. */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync SafeArray<BSTR> aNames;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync SafeArray<BSTR> aValues;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync hrc = medium->GetProperties(NULL,
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync ComSafeArrayAsOutParam(aNames),
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync ComSafeArrayAsOutParam(aValues)); H();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync if (aNames.size() != 0)
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync {
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync PCFGMNODE pVDC;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertNode(pCur, "VDConfig", &pVDC); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync for (size_t ii = 0; ii < aNames.size(); ++ii)
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync {
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync if (aValues[ii])
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync {
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync Utf8Str name = aNames[ii];
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync Utf8Str value = aValues[ii];
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str()); AssertRC(rc); /** @todo r=bird: why not RC_HCECK here? (I added the AssertRC.)*/
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync if ( name.compare("HostIPStack") == 0
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync && value.compare("0") == 0)
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync fHostIP = false;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync }
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync }
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync }
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync /* Custom code: put marker to not use host IP stack to driver
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync * configuration node. Simplifies life of DrvVD a bit. */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync if (!fHostIP)
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync {
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertInteger(pCfg, "HostIPStack", 0); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync }
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync /* next */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync pParent = pCur;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync parentMedium = medium;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync }
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync }
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync }
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync H();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync H();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync /*
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync * Network adapters
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync#ifdef VMWARE_NET_IN_SLOT_11
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync bool fSwapSlots3and11 = false;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync#endif
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync PCFGMNODE pDevPCNet = NULL; /* PCNet-type devices */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertNode(pDevices, "pcnet", &pDevPCNet); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync#ifdef VBOX_WITH_E1000
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync PCFGMNODE pDevE1000 = NULL; /* E1000-type devices */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertNode(pDevices, "e1000", &pDevE1000); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync#endif
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync#ifdef VBOX_WITH_VIRTIO
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync PCFGMNODE pDevVirtioNet = NULL; /* Virtio network devices */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertNode(pDevices, "virtio-net", &pDevVirtioNet); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync#endif /* VBOX_WITH_VIRTIO */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync for (ULONG ulInstance = 0; ulInstance < SchemaDefs::NetworkAdapterCount; ++ulInstance)
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync {
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync ComPtr<INetworkAdapter> networkAdapter;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync hrc = pMachine->GetNetworkAdapter(ulInstance, networkAdapter.asOutParam()); H();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync BOOL fEnabled = FALSE;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync hrc = networkAdapter->COMGETTER(Enabled)(&fEnabled); H();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync if (!fEnabled)
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync continue;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync /*
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync * The virtual hardware type. Create appropriate device first.
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync const char *pszAdapterName = "pcnet";
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync NetworkAdapterType_T adapterType;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync hrc = networkAdapter->COMGETTER(AdapterType)(&adapterType); H();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync switch (adapterType)
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync {
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync case NetworkAdapterType_Am79C970A:
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync case NetworkAdapterType_Am79C973:
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync pDev = pDevPCNet;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync break;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync#ifdef VBOX_WITH_E1000
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync case NetworkAdapterType_I82540EM:
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync case NetworkAdapterType_I82543GC:
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync case NetworkAdapterType_I82545EM:
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync pDev = pDevE1000;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync pszAdapterName = "e1000";
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync break;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync#endif
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync#ifdef VBOX_WITH_VIRTIO
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync case NetworkAdapterType_Virtio:
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync pDev = pDevVirtioNet;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync pszAdapterName = "virtio-net";
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync break;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync#endif /* VBOX_WITH_VIRTIO */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync default:
5112e32d7072e280613921c982a6672f2c859cf3vboxsync AssertMsgFailed(("Invalid network adapter type '%d' for slot '%d'",
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync adapterType, ulInstance));
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync N_("Invalid network adapter type '%d' for slot '%d'"),
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync adapterType, ulInstance);
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync }
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertNodeF(pDev, &pInst, "%u", ulInstance); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync /* the first network card gets the PCI ID 3, the next 3 gets 8..10,
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync * next 4 get 16..19. */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync unsigned iPciDeviceNo = 3;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync if (ulInstance)
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (ulInstance < 4)
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync iPciDeviceNo = ulInstance - 1 + 8;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync else
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync iPciDeviceNo = ulInstance - 4 + 16;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync }
5112e32d7072e280613921c982a6672f2c859cf3vboxsync#ifdef VMWARE_NET_IN_SLOT_11
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync /*
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync * Dirty hack for PCI slot compatibility with VMWare,
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync * it assigns slot 11 to the first network controller.
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync if (iPciDeviceNo == 3 && adapterType == NetworkAdapterType_I82545EM)
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync {
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync iPciDeviceNo = 0x11;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync fSwapSlots3and11 = true;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync }
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync else if (iPciDeviceNo == 0x11 && fSwapSlots3and11)
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync iPciDeviceNo = 3;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync#endif
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", iPciDeviceNo); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync Assert(!afPciDeviceNo[iPciDeviceNo]);
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync afPciDeviceNo[iPciDeviceNo] = true;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE /* not safe here yet. */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync if (pDev == pDevPCNet)
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync {
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertInteger(pCfg, "R0Enabled", false); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync }
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync#endif
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync /*
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync * The virtual hardware type. PCNet supports two types.
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync switch (adapterType)
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync {
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync case NetworkAdapterType_Am79C970A:
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertInteger(pCfg, "Am79C973", 0); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync break;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync case NetworkAdapterType_Am79C973:
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertInteger(pCfg, "Am79C973", 1); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync break;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync case NetworkAdapterType_I82540EM:
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertInteger(pCfg, "AdapterType", 0); RC_CHECK();
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync break;
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync case NetworkAdapterType_I82543GC:
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync rc = CFGMR3InsertInteger(pCfg, "AdapterType", 1); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync break;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync case NetworkAdapterType_I82545EM:
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCfg, "AdapterType", 2); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync break;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * Get the MAC address and convert it to binary representation
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync Bstr macAddr;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = networkAdapter->COMGETTER(MACAddress)(macAddr.asOutParam()); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync Assert(macAddr);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync Utf8Str macAddrUtf8 = macAddr;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync char *macStr = (char*)macAddrUtf8.raw();
af062818b47340eef15700d2f0211576ba3506eevboxsync Assert(strlen(macStr) == 12);
af062818b47340eef15700d2f0211576ba3506eevboxsync RTMAC Mac;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync memset(&Mac, 0, sizeof(Mac));
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync char *pMac = (char*)&Mac;
af062818b47340eef15700d2f0211576ba3506eevboxsync for (uint32_t i = 0; i < 6; ++i)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync char c1 = *macStr++ - '0';
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (c1 > 9)
af062818b47340eef15700d2f0211576ba3506eevboxsync c1 -= 7;
af062818b47340eef15700d2f0211576ba3506eevboxsync char c2 = *macStr++ - '0';
af062818b47340eef15700d2f0211576ba3506eevboxsync if (c2 > 9)
af062818b47340eef15700d2f0211576ba3506eevboxsync c2 -= 7;
af062818b47340eef15700d2f0211576ba3506eevboxsync *pMac++ = ((c1 & 0x0f) << 4) | (c2 & 0x0f);
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertBytes(pCfg, "MAC", &Mac, sizeof(Mac)); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * Check if the cable is supposed to be unplugged
af062818b47340eef15700d2f0211576ba3506eevboxsync */
5112e32d7072e280613921c982a6672f2c859cf3vboxsync BOOL fCableConnected;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = networkAdapter->COMGETTER(CableConnected)(&fCableConnected); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCfg, "CableConnected", fCableConnected ? 1 : 0); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * Line speed to report from custom drivers
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync ULONG ulLineSpeed;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = networkAdapter->COMGETTER(LineSpeed)(&ulLineSpeed); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "LineSpeed", ulLineSpeed); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /*
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * Attach the status driver.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapNetworkLeds[ulInstance]); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
5112e32d7072e280613921c982a6672f2c859cf3vboxsync * Configure the network card now
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = configNetwork(pConsole, pszAdapterName, ulInstance, 0, networkAdapter,
af062818b47340eef15700d2f0211576ba3506eevboxsync pCfg, pLunL0, pInst, false /*fAttachDetach*/); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * Serial (UART) Ports
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pDevices, "serial", &pDev); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync for (ULONG ulInstance = 0; ulInstance < SchemaDefs::SerialPortCount; ++ulInstance)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync ComPtr<ISerialPort> serialPort;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = pMachine->GetSerialPort (ulInstance, serialPort.asOutParam()); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync BOOL fEnabled = FALSE;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (serialPort)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = serialPort->COMGETTER(Enabled)(&fEnabled); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync if (!fEnabled)
af062818b47340eef15700d2f0211576ba3506eevboxsync continue;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNodeF(pDev, &pInst, "%u", ulInstance); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync ULONG ulIRQ;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync hrc = serialPort->COMGETTER(IRQ)(&ulIRQ); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCfg, "IRQ", ulIRQ); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync ULONG ulIOBase;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = serialPort->COMGETTER(IOBase)(&ulIOBase); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "IOBase", ulIOBase); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync BOOL fServer;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync hrc = serialPort->COMGETTER(Server)(&fServer); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = serialPort->COMGETTER(Path)(&str); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync PortMode_T eHostMode;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = serialPort->COMGETTER(HostMode)(&eHostMode); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync if (eHostMode != PortMode_Disconnected)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
5112e32d7072e280613921c982a6672f2c859cf3vboxsync if (eHostMode == PortMode_HostPipe)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "Char"); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pLunL1, "Driver", "NamedPipe"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pLunL1, "Config", &pLunL2); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertStringW(pLunL2, "Location", str); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pLunL2, "IsServer", fServer); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync else if (eHostMode == PortMode_HostDevice)
040b4a09341f574825386333398110f4db3e1e51vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "Host Serial"); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pLunL1); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertStringW(pLunL1, "DevicePath", str); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync else if (eHostMode == PortMode_RawFile)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "Char"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertString(pLunL1, "Driver", "RawFile"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pLunL1, "Config", &pLunL2); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertStringW(pLunL2, "Location", str); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync STR_FREE();
5112e32d7072e280613921c982a6672f2c859cf3vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /*
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * Parallel (LPT) Ports
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pDevices, "parallel", &pDev); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync for (ULONG ulInstance = 0; ulInstance < SchemaDefs::ParallelPortCount; ++ulInstance)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync ComPtr<IParallelPort> parallelPort;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = pMachine->GetParallelPort(ulInstance, parallelPort.asOutParam()); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync BOOL fEnabled = FALSE;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (parallelPort)
040b4a09341f574825386333398110f4db3e1e51vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = parallelPort->COMGETTER(Enabled)(&fEnabled); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (!fEnabled)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync continue;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNodeF(pDev, &pInst, "%u", ulInstance); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync ULONG ulIRQ;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = parallelPort->COMGETTER(IRQ)(&ulIRQ); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCfg, "IRQ", ulIRQ); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync ULONG ulIOBase;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = parallelPort->COMGETTER(IOBase)(&ulIOBase); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCfg, "IOBase", ulIOBase); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "HostParallel"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = parallelPort->COMGETTER(Path)(&str); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertStringW(pLunL1, "DevicePath", str); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync STR_FREE();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * VMM Device
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pDevices, "VMMDev", &pDev); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 4); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync Assert(!afPciDeviceNo[4]);
040b4a09341f574825386333398110f4db3e1e51vboxsync afPciDeviceNo[4] = true;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync Bstr hwVersion;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync hrc = pMachine->COMGETTER(HardwareVersion)(hwVersion.asOutParam()); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (hwVersion.compare(Bstr("1")) == 0) /* <= 2.0.x */
af062818b47340eef15700d2f0211576ba3506eevboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync CFGMR3InsertInteger(pCfg, "HeapEnabled", 0); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync }
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync /* the VMM device's Main driver */
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
5112e32d7072e280613921c982a6672f2c859cf3vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "HGCM"); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync VMMDev *pVMMDev = pConsole->mVMMDev;
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pVMMDev); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync /*
040b4a09341f574825386333398110f4db3e1e51vboxsync * Attach the status driver.
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
5112e32d7072e280613921c982a6672f2c859cf3vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapSharedFolderLed); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync /*
5112e32d7072e280613921c982a6672f2c859cf3vboxsync * Audio Sniffer Device
040b4a09341f574825386333398110f4db3e1e51vboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pDevices, "AudioSniffer", &pDev); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /* the Audio Sniffer device's Main driver */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MainAudioSniffer"); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync AudioSniffer *pAudioSniffer = pConsole->mAudioSniffer;
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pAudioSniffer); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /*
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * AC'97 ICH / SoundBlaster16 audio
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync BOOL enabled;
af062818b47340eef15700d2f0211576ba3506eevboxsync ComPtr<IAudioAdapter> audioAdapter;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = pMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam()); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync if (audioAdapter)
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = audioAdapter->COMGETTER(Enabled)(&enabled); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync if (enabled)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync AudioControllerType_T audioController;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync hrc = audioAdapter->COMGETTER(AudioController)(&audioController); H();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync switch (audioController)
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync {
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync case AudioControllerType_AC97:
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync {
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync /* default: ICH AC97 */
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNode(pDevices, "ichac97", &pDev); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst);
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* bool */ RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 5); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync Assert(!afPciDeviceNo[5]);
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync afPciDeviceNo[5] = true;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync break;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync case AudioControllerType_SB16:
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync /* legacy SoundBlaster16 */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pDevices, "sb16", &pDev); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* bool */ RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "IRQ", 5); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "DMA", 1); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "DMA16", 5); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "Port", 0x220); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "Version", 0x0405); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync break;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync /* the Audio driver */
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); RC_CHECK();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync AudioDriverType_T audioDriver;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = audioAdapter->COMGETTER(AudioDriver)(&audioDriver); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync switch (audioDriver)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync case AudioDriverType_Null:
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pCfg, "AudioDriver", "null"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync break;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#ifdef RT_OS_WINDOWS
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#ifdef VBOX_WITH_WINMM
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync case AudioDriverType_WinMM:
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pCfg, "AudioDriver", "winmm"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync break;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#endif
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync case AudioDriverType_DirectSound:
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pCfg, "AudioDriver", "dsound"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync break;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#endif /* RT_OS_WINDOWS */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#ifdef RT_OS_SOLARIS
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync case AudioDriverType_SolAudio:
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pCfg, "AudioDriver", "solaudio"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync break;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#endif
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#ifdef RT_OS_LINUX
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync# ifdef VBOX_WITH_ALSA
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync case AudioDriverType_ALSA:
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pCfg, "AudioDriver", "alsa"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync break;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync# endif
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync# ifdef VBOX_WITH_PULSE
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync case AudioDriverType_Pulse:
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pCfg, "AudioDriver", "pulse"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync break;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync# endif
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#endif /* RT_OS_LINUX */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#if defined (RT_OS_LINUX) || defined (RT_OS_FREEBSD) || defined(VBOX_WITH_SOLARIS_OSS)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync case AudioDriverType_OSS:
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pCfg, "AudioDriver", "oss"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync break;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#endif
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#ifdef RT_OS_FREEBSD
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync# ifdef VBOX_WITH_PULSE
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync case AudioDriverType_Pulse:
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pCfg, "AudioDriver", "pulse"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync break;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync# endif
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#endif
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#ifdef RT_OS_DARWIN
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync case AudioDriverType_CoreAudio:
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pCfg, "AudioDriver", "coreaudio"); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync break;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#endif
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = pMachine->COMGETTER(Name)(&str); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertStringW(pCfg, "StreamName", str); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync STR_FREE();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /*
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * The USB Controller.
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync ComPtr<IUSBController> USBCtlPtr;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = pMachine->COMGETTER(USBController)(USBCtlPtr.asOutParam());
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (USBCtlPtr)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync BOOL fEnabled;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = USBCtlPtr->COMGETTER(Enabled)(&fEnabled); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (fEnabled)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pDevices, "usb-ohci", &pDev); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 6); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync Assert(!afPciDeviceNo[6]);
af062818b47340eef15700d2f0211576ba3506eevboxsync afPciDeviceNo[6] = true;
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "VUSBRootHub"); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * Attach the status driver.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapUSBLed[0]);RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#ifdef VBOX_WITH_EHCI
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = USBCtlPtr->COMGETTER(EnabledEhci)(&fEnabled); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync if (fEnabled)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pDevices, "usb-ehci", &pDev); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* bool */ RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 11); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync Assert(!afPciDeviceNo[11]);
af062818b47340eef15700d2f0211576ba3506eevboxsync afPciDeviceNo[11] = true;
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "VUSBRootHub"); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync /*
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync * Attach the status driver.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapUSBLed[1]);RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync#endif
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync * Global USB options, currently unused as we'll apply the 2.0 -> 1.1 morphing
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync * on a per device level now.
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pRoot, "USB", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pCfg, "USBProxy", &pCfg); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync rc = CFGMR3InsertNode(pCfg, "GlobalConfig", &pCfg); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync // This globally enables the 2.0 -> 1.1 device morphing of proxied devies to keep windows quiet.
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync //rc = CFGMR3InsertInteger(pCfg, "Force11Device", true); RC_CHECK();
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync // The following breaks stuff, but it makes MSDs work in vista. (I include it here so
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync // that it's documented somewhere.) Users needing it can use:
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync // VBoxManage setextradata "myvm" "VBoxInternal/USB/USBProxy/GlobalConfig/Force11PacketSize" 1
af062818b47340eef15700d2f0211576ba3506eevboxsync //rc = CFGMR3InsertInteger(pCfg, "Force11PacketSize", true); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * Clipboard
af062818b47340eef15700d2f0211576ba3506eevboxsync */
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync {
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync ClipboardMode_T mode = ClipboardMode_Disabled;
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync hrc = pMachine->COMGETTER(ClipboardMode)(&mode); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync if (mode != ClipboardMode_Disabled)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Load the service */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = pConsole->mVMMDev->hgcmLoadService ("VBoxSharedClipboard", "VBoxSharedClipboard");
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync if (RT_FAILURE(rc))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("VBoxSharedClipboard is not available. rc = %Rrc\n", rc));
af062818b47340eef15700d2f0211576ba3506eevboxsync /* That is not a fatal failure. */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = VINF_SUCCESS;
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Setup the service. */
af062818b47340eef15700d2f0211576ba3506eevboxsync VBOXHGCMSVCPARM parm;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync parm.type = VBOX_HGCM_SVC_PARM_32BIT;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync switch (mode)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync default:
af062818b47340eef15700d2f0211576ba3506eevboxsync case ClipboardMode_Disabled:
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("VBoxSharedClipboard mode: Off\n"));
af062818b47340eef15700d2f0211576ba3506eevboxsync parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_OFF;
af062818b47340eef15700d2f0211576ba3506eevboxsync break;
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync case ClipboardMode_GuestToHost:
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("VBoxSharedClipboard mode: Guest to Host\n"));
af062818b47340eef15700d2f0211576ba3506eevboxsync parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST;
af062818b47340eef15700d2f0211576ba3506eevboxsync break;
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync case ClipboardMode_HostToGuest:
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("VBoxSharedClipboard mode: Host to Guest\n"));
af062818b47340eef15700d2f0211576ba3506eevboxsync parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_HOST_TO_GUEST;
af062818b47340eef15700d2f0211576ba3506eevboxsync break;
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync case ClipboardMode_Bidirectional:
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("VBoxSharedClipboard mode: Bidirectional\n"));
af062818b47340eef15700d2f0211576ba3506eevboxsync parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL;
af062818b47340eef15700d2f0211576ba3506eevboxsync break;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync pConsole->mVMMDev->hgcmHostCall ("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm);
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync Log(("Set VBoxSharedClipboard mode\n"));
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#ifdef VBOX_WITH_CROGL
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * crOpenGL
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync BOOL fEnabled = false;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = pMachine->COMGETTER(Accelerate3DEnabled)(&fEnabled); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync if (fEnabled)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Load the service */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = pConsole->mVMMDev->hgcmLoadService ("VBoxSharedCrOpenGL", "VBoxSharedCrOpenGL");
af062818b47340eef15700d2f0211576ba3506eevboxsync if (RT_FAILURE(rc))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync LogRel(("Failed to load Shared OpenGL service %Rrc\n", rc));
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /* That is not a fatal failure. */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = VINF_SUCCESS;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("Shared crOpenGL service loaded.\n"));
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Setup the service. */
af062818b47340eef15700d2f0211576ba3506eevboxsync VBOXHGCMSVCPARM parm;
af062818b47340eef15700d2f0211576ba3506eevboxsync parm.type = VBOX_HGCM_SVC_PARM_PTR;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync parm.u.pointer.addr = pConsole->getDisplay()->getFramebuffer();
af062818b47340eef15700d2f0211576ba3506eevboxsync parm.u.pointer.size = sizeof(IFramebuffer *);
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = pConsole->mVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_FRAMEBUFFER, 1, &parm);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (!RT_SUCCESS(rc))
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertMsgFailed(("SHCRGL_HOST_FN_SET_FRAMEBUFFER failed with %Rrc\n", rc));
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync parm.u.pointer.addr = pVM;
af062818b47340eef15700d2f0211576ba3506eevboxsync parm.u.pointer.size = sizeof(pVM);
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = pConsole->mVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_VM, 1, &parm);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (!RT_SUCCESS(rc))
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertMsgFailed(("SHCRGL_HOST_FN_SET_VM failed with %Rrc\n", rc));
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync#endif
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#ifdef VBOX_WITH_GUEST_PROPS
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * Guest property service
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = configGuestProperties(pConsole);
af062818b47340eef15700d2f0211576ba3506eevboxsync#endif /* VBOX_WITH_GUEST_PROPS defined */
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * ACPI
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync BOOL fACPI;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = biosSettings->COMGETTER(ACPIEnabled)(&fACPI); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync if (fACPI)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync BOOL fCpuHotPlug = false;
af062818b47340eef15700d2f0211576ba3506eevboxsync BOOL fShowCpu = fExtProfile;
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Always show the CPU leafs when we have multiple VCPUs or when the IO-APIC is enabled.
af062818b47340eef15700d2f0211576ba3506eevboxsync * The Windows SMP kernel needs a CPU leaf or else its idle loop will burn cpu cycles; the
af062818b47340eef15700d2f0211576ba3506eevboxsync * intelppm driver refuses to register an idle state handler.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync if ((cCpus > 1) || fIOAPIC)
af062818b47340eef15700d2f0211576ba3506eevboxsync fShowCpu = true;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = pMachine->COMGETTER(CPUHotPlugEnabled)(&fCpuHotPlug); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pDevices, "acpi", &pDev); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "RamSize", cbRam); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "RamHoleSize", cbRamHole); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "NumCPUs", cCpus); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "FdcEnabled", fFdcEnabled); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync#ifdef VBOX_WITH_HPET
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "HpetEnabled", fHpetEnabled); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync#endif
af062818b47340eef15700d2f0211576ba3506eevboxsync#ifdef VBOX_WITH_SMC
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "SmcEnabled", fSmcEnabled); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync#endif
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "ShowRtc", fExtProfile); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "ShowCpu", fShowCpu); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "CpuHotPlug", fCpuHotPlug); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 7); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync Assert(!afPciDeviceNo[7]);
af062818b47340eef15700d2f0211576ba3506eevboxsync afPciDeviceNo[7] = true;
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "ACPIHost"); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Attach the dummy CPU drivers */
af062818b47340eef15700d2f0211576ba3506eevboxsync for (ULONG iCpuCurr = 1; iCpuCurr < cCpus; iCpuCurr++)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync BOOL fCpuAttached = true;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync if (fCpuHotPlug)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = pMachine->GetCPUStatus(iCpuCurr, &fCpuAttached); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync if (fCpuAttached)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%u", iCpuCurr); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "ACPICpu"); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * CFGM overlay handling.
af062818b47340eef15700d2f0211576ba3506eevboxsync *
af062818b47340eef15700d2f0211576ba3506eevboxsync * Here we check the extra data entries for CFGM values
af062818b47340eef15700d2f0211576ba3506eevboxsync * and create the nodes and insert the values on the fly. Existing
af062818b47340eef15700d2f0211576ba3506eevboxsync * values will be removed and reinserted. CFGM is typed, so by default
af062818b47340eef15700d2f0211576ba3506eevboxsync * we will guess whether it's a string or an integer (byte arrays are
af062818b47340eef15700d2f0211576ba3506eevboxsync * not currently supported). It's possible to override this autodetection
af062818b47340eef15700d2f0211576ba3506eevboxsync * by adding "string:", "integer:" or "bytes:" (future).
af062818b47340eef15700d2f0211576ba3506eevboxsync *
af062818b47340eef15700d2f0211576ba3506eevboxsync * We first perform a run on global extra data, then on the machine
af062818b47340eef15700d2f0211576ba3506eevboxsync * extra data to support global settings with local overrides.
af062818b47340eef15700d2f0211576ba3506eevboxsync *
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync /** @todo add support for removing nodes and byte blobs. */
af062818b47340eef15700d2f0211576ba3506eevboxsync SafeArray<BSTR> aGlobalExtraDataKeys;
af062818b47340eef15700d2f0211576ba3506eevboxsync SafeArray<BSTR> aMachineExtraDataKeys;
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * Get the next key
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync if (FAILED(hrc = virtualBox->GetExtraDataKeys(ComSafeArrayAsOutParam(aGlobalExtraDataKeys))))
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertMsgFailed(("VirtualBox::GetExtraDataKeys failed with %Rrc\n", hrc));
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync // remember the no. of global values so we can call the correct method below
af062818b47340eef15700d2f0211576ba3506eevboxsync size_t cGlobalValues = aGlobalExtraDataKeys.size();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync if (FAILED(hrc = pMachine->GetExtraDataKeys(ComSafeArrayAsOutParam(aMachineExtraDataKeys))))
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertMsgFailed(("IMachine::GetExtraDataKeys failed with %Rrc\n", hrc));
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync // build a combined list from global keys...
af062818b47340eef15700d2f0211576ba3506eevboxsync std::list<Utf8Str> llExtraDataKeys;
af062818b47340eef15700d2f0211576ba3506eevboxsync size_t i = 0;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync for (i = 0; i < aGlobalExtraDataKeys.size(); ++i)
af062818b47340eef15700d2f0211576ba3506eevboxsync llExtraDataKeys.push_back(Utf8Str(aGlobalExtraDataKeys[i]));
af062818b47340eef15700d2f0211576ba3506eevboxsync // ... and machine keys
af062818b47340eef15700d2f0211576ba3506eevboxsync for (i = 0; i < aMachineExtraDataKeys.size(); ++i)
af062818b47340eef15700d2f0211576ba3506eevboxsync llExtraDataKeys.push_back(Utf8Str(aMachineExtraDataKeys[i]));
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync i = 0;
af062818b47340eef15700d2f0211576ba3506eevboxsync for (std::list<Utf8Str>::const_iterator it = llExtraDataKeys.begin();
af062818b47340eef15700d2f0211576ba3506eevboxsync it != llExtraDataKeys.end();
af062818b47340eef15700d2f0211576ba3506eevboxsync ++it, ++i)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync const Utf8Str &strKey = *it;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * We only care about keys starting with "VBoxInternal/" (skip "G:" or "M:")
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync if (!strKey.startsWith("VBoxInternal/"))
af062818b47340eef15700d2f0211576ba3506eevboxsync continue;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync const char *pszExtraDataKey = strKey.raw() + sizeof("VBoxInternal/") - 1;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync // get the value
af062818b47340eef15700d2f0211576ba3506eevboxsync Bstr strExtraDataValue;
af062818b47340eef15700d2f0211576ba3506eevboxsync if (i < cGlobalValues)
af062818b47340eef15700d2f0211576ba3506eevboxsync // this is still one of the global values:
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = virtualBox->GetExtraData(Bstr(strKey), strExtraDataValue.asOutParam());
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = pMachine->GetExtraData(Bstr(strKey), strExtraDataValue.asOutParam());
af062818b47340eef15700d2f0211576ba3506eevboxsync if (FAILED(hrc))
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("Warning: Cannot get extra data key %s, rc = %Rrc\n", strKey.raw(), hrc));
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * The key will be in the format "Node1/Node2/Value" or simply "Value".
af062818b47340eef15700d2f0211576ba3506eevboxsync * Split the two and get the node, delete the value and create the node
af062818b47340eef15700d2f0211576ba3506eevboxsync * if necessary.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync PCFGMNODE pNode;
af062818b47340eef15700d2f0211576ba3506eevboxsync const char *pszCFGMValueName = strrchr(pszExtraDataKey, '/');
af062818b47340eef15700d2f0211576ba3506eevboxsync if (pszCFGMValueName)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync /* terminate the node and advance to the value (Utf8Str might not
af062818b47340eef15700d2f0211576ba3506eevboxsync offically like this but wtf) */
af062818b47340eef15700d2f0211576ba3506eevboxsync *(char*)pszCFGMValueName = '\0';
af062818b47340eef15700d2f0211576ba3506eevboxsync ++pszCFGMValueName;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /* does the node already exist? */
af062818b47340eef15700d2f0211576ba3506eevboxsync pNode = CFGMR3GetChild(pRoot, pszExtraDataKey);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (pNode)
af062818b47340eef15700d2f0211576ba3506eevboxsync CFGMR3RemoveValue(pNode, pszCFGMValueName);
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync /* create the node */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pRoot, pszExtraDataKey, &pNode);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (RT_FAILURE(rc))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertLogRelMsgRC(rc, ("failed to insert node '%s'\n", pszExtraDataKey));
af062818b47340eef15700d2f0211576ba3506eevboxsync continue;
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync Assert(pNode);
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync /* root value (no node path). */
af062818b47340eef15700d2f0211576ba3506eevboxsync pNode = pRoot;
af062818b47340eef15700d2f0211576ba3506eevboxsync pszCFGMValueName = pszExtraDataKey;
af062818b47340eef15700d2f0211576ba3506eevboxsync pszExtraDataKey--;
af062818b47340eef15700d2f0211576ba3506eevboxsync CFGMR3RemoveValue(pNode, pszCFGMValueName);
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * Now let's have a look at the value.
af062818b47340eef15700d2f0211576ba3506eevboxsync * Empty strings means that we should remove the value, which we've
af062818b47340eef15700d2f0211576ba3506eevboxsync * already done above.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync Utf8Str strCFGMValueUtf8(strExtraDataValue);
af062818b47340eef15700d2f0211576ba3506eevboxsync const char *pszCFGMValue = strCFGMValueUtf8.raw();
af062818b47340eef15700d2f0211576ba3506eevboxsync if ( pszCFGMValue
af062818b47340eef15700d2f0211576ba3506eevboxsync && *pszCFGMValue)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync uint64_t u64Value;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /* check for type prefix first. */
af062818b47340eef15700d2f0211576ba3506eevboxsync if (!strncmp(pszCFGMValue, "string:", sizeof("string:") - 1))
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pNode, pszCFGMValueName, pszCFGMValue + sizeof("string:") - 1);
af062818b47340eef15700d2f0211576ba3506eevboxsync else if (!strncmp(pszCFGMValue, "integer:", sizeof("integer:") - 1))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = RTStrToUInt64Full(pszCFGMValue + sizeof("integer:") - 1, 0, &u64Value);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (RT_SUCCESS(rc))
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pNode, pszCFGMValueName, u64Value);
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else if (!strncmp(pszCFGMValue, "bytes:", sizeof("bytes:") - 1))
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = VERR_NOT_IMPLEMENTED;
af062818b47340eef15700d2f0211576ba3506eevboxsync /* auto detect type. */
af062818b47340eef15700d2f0211576ba3506eevboxsync else if (RT_SUCCESS(RTStrToUInt64Full(pszCFGMValue, 0, &u64Value)))
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pNode, pszCFGMValueName, u64Value);
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pNode, pszCFGMValueName, pszCFGMValue);
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertLogRelMsgRC(rc, ("failed to insert CFGM value '%s' to key '%s'\n", pszCFGMValue, pszExtraDataKey));
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#undef STR_FREE
af062818b47340eef15700d2f0211576ba3506eevboxsync#undef H
af062818b47340eef15700d2f0211576ba3506eevboxsync#undef RC_CHECK
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Register VM state change handler */
af062818b47340eef15700d2f0211576ba3506eevboxsync int rc2 = VMR3AtStateRegister (pVM, Console::vmstateChangeCallback, pConsole);
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertRC (rc2);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (RT_SUCCESS(rc))
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = rc2;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Register VM runtime error handler */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc2 = VMR3AtRuntimeErrorRegister (pVM, Console::setVMRuntimeErrorCallback, pConsole);
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertRC (rc2);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (RT_SUCCESS(rc))
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = rc2;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync LogFlowFunc (("vrc = %Rrc\n", rc));
af062818b47340eef15700d2f0211576ba3506eevboxsync LogFlowFuncLeave();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync return rc;
af062818b47340eef15700d2f0211576ba3506eevboxsync}
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync/**
af062818b47340eef15700d2f0211576ba3506eevboxsync * Ellipsis to va_list wrapper for calling setVMRuntimeErrorCallback.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync/*static*/ void Console::setVMRuntimeErrorCallbackF(PVM pVM, void *pvConsole, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
af062818b47340eef15700d2f0211576ba3506eevboxsync{
af062818b47340eef15700d2f0211576ba3506eevboxsync va_list va;
af062818b47340eef15700d2f0211576ba3506eevboxsync va_start(va, pszFormat);
af062818b47340eef15700d2f0211576ba3506eevboxsync setVMRuntimeErrorCallback(pVM, pvConsole, fFlags, pszErrorId, pszFormat, va);
af062818b47340eef15700d2f0211576ba3506eevboxsync va_end(va);
af062818b47340eef15700d2f0211576ba3506eevboxsync}
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync/**
af062818b47340eef15700d2f0211576ba3506eevboxsync * Construct the Network configuration tree
af062818b47340eef15700d2f0211576ba3506eevboxsync *
af062818b47340eef15700d2f0211576ba3506eevboxsync * @returns VBox status code.
af062818b47340eef15700d2f0211576ba3506eevboxsync *
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * @param pThis Pointer to the Console object.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * @param pszDevice The PDM device name.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * @param uInstance The PDM device instance.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * @param uLun The PDM LUN number of the drive.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * @param aNetworkAdapter The network adapter whose attachment needs to be changed
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * @param pCfg Configuration node for the device
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * @param pLunL0 To store the pointer to the LUN#0.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * @param pInst The instance CFGM node
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * @param fAttachDetach To determine if the network attachment should
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * be attached/detached after/before
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * configuration.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync *
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * @note Locks the Console object for writing.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync/*static*/ int Console::configNetwork(Console *pThis, const char *pszDevice,
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync unsigned uInstance, unsigned uLun,
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync INetworkAdapter *aNetworkAdapter,
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pCfg, PCFGMNODE pLunL0,
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PCFGMNODE pInst, bool fAttachDetach)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync{
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync int rc = VINF_SUCCESS;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync AutoCaller autoCaller(pThis);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * Locking the object before doing VMR3* calls is quite safe here, since
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * we're on EMT. Write lock is necessary because we indirectly modify the
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * meAttachmentType member.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync AutoWriteLock alock(pThis COMMA_LOCKVAL_SRC_POS);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync PVM pVM = pThis->mpVM;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync BSTR str = NULL;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } } while (0)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync#define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%#x\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync HRESULT hrc;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync ComPtr<IMachine> pMachine = pThis->machine();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync ComPtr<IVirtualBox> virtualBox;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->COMGETTER(Parent)(virtualBox.asOutParam());
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync H();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync ComPtr<IHost> host;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = virtualBox->COMGETTER(Host)(host.asOutParam());
af062818b47340eef15700d2f0211576ba3506eevboxsync H();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync BOOL fSniffer;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = aNetworkAdapter->COMGETTER(TraceEnabled)(&fSniffer);
af062818b47340eef15700d2f0211576ba3506eevboxsync H();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync if (fAttachDetach && fSniffer)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync const char *pszNetDriver = "IntNet";
af062818b47340eef15700d2f0211576ba3506eevboxsync if (pThis->meAttachmentType[uInstance] == NetworkAttachmentType_NAT)
af062818b47340eef15700d2f0211576ba3506eevboxsync pszNetDriver = "NAT";
af062818b47340eef15700d2f0211576ba3506eevboxsync#if !defined(VBOX_WITH_NETFLT) && defined(RT_OS_LINUX)
af062818b47340eef15700d2f0211576ba3506eevboxsync if (pThis->meAttachmentType[uInstance] == NetworkAttachmentType_Bridged)
af062818b47340eef15700d2f0211576ba3506eevboxsync pszNetDriver = "HostInterface";
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync#endif
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = PDMR3DriverDetach(pVM, pszDevice, uInstance, uLun, pszNetDriver, 0, 0 /*fFlags*/);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (rc == VINF_PDM_NO_DRIVER_ATTACHED_TO_LUN)
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = VINF_SUCCESS;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync AssertLogRelRCReturn(rc, rc);
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync pLunL0 = CFGMR3GetChildF(pInst, "LUN#%u", uLun);
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync PCFGMNODE pLunAD = CFGMR3GetChildF(pLunL0, "AttachedDriver");
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync if (pLunAD)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync CFGMR3RemoveNode(pLunAD);
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync CFGMR3RemoveNode(pLunL0);
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "NetSniffer"); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = aNetworkAdapter->COMGETTER(TraceFile)(&str); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync if (str) /* check convention for indicating default file. */
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertStringW(pCfg, "File", str); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync STR_FREE();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync else if (fAttachDetach && !fSniffer)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = PDMR3DeviceDetach(pVM, pszDevice, uInstance, uLun, 0 /*fFlags*/);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (rc == VINF_PDM_NO_DRIVER_ATTACHED_TO_LUN)
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = VINF_SUCCESS;
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertLogRelRCReturn(rc, rc);
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /* nuke anything which might have been left behind. */
af062818b47340eef15700d2f0211576ba3506eevboxsync CFGMR3RemoveNode(CFGMR3GetChildF(pInst, "LUN#%u", uLun));
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else if (!fAttachDetach && fSniffer)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync /* insert the sniffer filter driver. */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "NetSniffer"); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = aNetworkAdapter->COMGETTER(TraceFile)(&str); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync if (str) /* check convention for indicating default file. */
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertStringW(pCfg, "File", str); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync STR_FREE();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync Bstr networkName, trunkName, trunkType;
af062818b47340eef15700d2f0211576ba3506eevboxsync NetworkAttachmentType_T eAttachmentType;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = aNetworkAdapter->COMGETTER(AttachmentType)(&eAttachmentType); H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync switch (eAttachmentType)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync case NetworkAttachmentType_Null:
af062818b47340eef15700d2f0211576ba3506eevboxsync break;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync case NetworkAttachmentType_NAT:
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync if (fSniffer)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync else
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "NAT"); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Configure TFTP prefix and boot filename. */
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = virtualBox->COMGETTER(HomeFolder)(&str); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (str && *str)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertStringF(pCfg, "TFTPPrefix", "%ls%c%s", str, RTPATH_DELIMITER, "TFTP"); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync STR_FREE();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync hrc = pMachine->COMGETTER(Name)(&str); H();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertStringF(pCfg, "BootFile", "%ls.pxe", str); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync STR_FREE();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = aNetworkAdapter->COMGETTER(NATNetwork)(&str); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync if (str && *str)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertStringW(pCfg, "Network", str); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync /* NAT uses its own DHCP implementation */
af062818b47340eef15700d2f0211576ba3506eevboxsync //networkName = Bstr(psz);
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync STR_FREE();
af062818b47340eef15700d2f0211576ba3506eevboxsync break;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync case NetworkAttachmentType_Bridged:
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync#if (defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)) && !defined(VBOX_WITH_NETFLT)
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = pThis->attachToTapInterface(aNetworkAdapter);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (FAILED(hrc))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync switch (hrc)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync case VERR_ACCESS_DENIED:
af062818b47340eef15700d2f0211576ba3506eevboxsync return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync "Failed to open '/dev/net/tun' for read/write access. Please check the "
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync "permissions of that node. Either run 'chmod 0666 /dev/net/tun' or "
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync "change the group of that node and make yourself a member of that group. Make "
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync "sure that these changes are permanent, especially if you are "
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync "using udev"));
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync default:
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync AssertMsgFailed(("Could not attach to host interface! Bad!\n"));
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync "Failed to initialize Host Interface Networking"));
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync Assert ((int)pThis->maTapFD[uInstance] >= 0);
af062818b47340eef15700d2f0211576ba3506eevboxsync if ((int)pThis->maTapFD[uInstance] >= 0)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync if (fSniffer)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "HostInterface"); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "FileHandle", pThis->maTapFD[uInstance]); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#elif defined(VBOX_WITH_NETFLT)
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * This is the new VBoxNetFlt+IntNet stuff.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync if (fSniffer)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync Bstr HifName;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = aNetworkAdapter->COMGETTER(HostInterface)(HifName.asOutParam());
af062818b47340eef15700d2f0211576ba3506eevboxsync if (FAILED(hrc))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("NetworkAttachmentType_Bridged: COMGETTER(HostInterface) failed, hrc (0x%x)", hrc));
af062818b47340eef15700d2f0211576ba3506eevboxsync H();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync Utf8Str HifNameUtf8(HifName);
af062818b47340eef15700d2f0211576ba3506eevboxsync const char *pszHifName = HifNameUtf8.raw();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync# if defined(RT_OS_DARWIN)
af062818b47340eef15700d2f0211576ba3506eevboxsync /* The name is on the form 'ifX: long name', chop it off at the colon. */
af062818b47340eef15700d2f0211576ba3506eevboxsync char szTrunk[8];
af062818b47340eef15700d2f0211576ba3506eevboxsync strncpy(szTrunk, pszHifName, sizeof(szTrunk));
af062818b47340eef15700d2f0211576ba3506eevboxsync char *pszColon = (char *)memchr(szTrunk, ':', sizeof(szTrunk));
af062818b47340eef15700d2f0211576ba3506eevboxsync if (!pszColon)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = aNetworkAdapter->Detach(); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync N_("Malformed host interface networking name '%ls'"),
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync HifName.raw());
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync *pszColon = '\0';
af062818b47340eef15700d2f0211576ba3506eevboxsync const char *pszTrunk = szTrunk;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync# elif defined(RT_OS_SOLARIS)
af062818b47340eef15700d2f0211576ba3506eevboxsync /* The name is on the form format 'ifX[:1] - long name, chop it off at space. */
af062818b47340eef15700d2f0211576ba3506eevboxsync char szTrunk[256];
af062818b47340eef15700d2f0211576ba3506eevboxsync strlcpy(szTrunk, pszHifName, sizeof(szTrunk));
af062818b47340eef15700d2f0211576ba3506eevboxsync char *pszSpace = (char *)memchr(szTrunk, ' ', sizeof(szTrunk));
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
af062818b47340eef15700d2f0211576ba3506eevboxsync * Currently don't bother about malformed names here for the sake of people using
af062818b47340eef15700d2f0211576ba3506eevboxsync * VBoxManage and setting only the NIC name from there. If there is a space we
af062818b47340eef15700d2f0211576ba3506eevboxsync * chop it off and proceed, otherwise just use whatever we've got.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync if (pszSpace)
af062818b47340eef15700d2f0211576ba3506eevboxsync *pszSpace = '\0';
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Chop it off at the colon (zone naming eg: e1000g:1 we need only the e1000g) */
af062818b47340eef15700d2f0211576ba3506eevboxsync char *pszColon = (char *)memchr(szTrunk, ':', sizeof(szTrunk));
af062818b47340eef15700d2f0211576ba3506eevboxsync if (pszColon)
af062818b47340eef15700d2f0211576ba3506eevboxsync *pszColon = '\0';
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync const char *pszTrunk = szTrunk;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync# elif defined(RT_OS_WINDOWS)
af062818b47340eef15700d2f0211576ba3506eevboxsync ComPtr<IHostNetworkInterface> hostInterface;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = host->FindHostNetworkInterfaceByName(HifName, hostInterface.asOutParam());
af062818b47340eef15700d2f0211576ba3506eevboxsync if (!SUCCEEDED(hrc))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: FindByName failed, rc=%Rhrc (0x%x)", hrc, hrc));
af062818b47340eef15700d2f0211576ba3506eevboxsync return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
af062818b47340eef15700d2f0211576ba3506eevboxsync N_("Inexistent host networking interface, name '%ls'"),
af062818b47340eef15700d2f0211576ba3506eevboxsync HifName.raw());
af062818b47340eef15700d2f0211576ba3506eevboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync HostNetworkInterfaceType_T eIfType;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = hostInterface->COMGETTER(InterfaceType)(&eIfType);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (FAILED(hrc))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("NetworkAttachmentType_Bridged: COMGETTER(InterfaceType) failed, hrc (0x%x)", hrc));
af062818b47340eef15700d2f0211576ba3506eevboxsync H();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync if (eIfType != HostNetworkInterfaceType_Bridged)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync N_("Interface ('%ls') is not a Bridged Adapter interface"),
af062818b47340eef15700d2f0211576ba3506eevboxsync HifName.raw());
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = hostInterface->COMGETTER(Id)(&str);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (FAILED(hrc))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("NetworkAttachmentType_Bridged: COMGETTER(Id) failed, hrc (0x%x)", hrc));
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync Guid hostIFGuid(str);
af062818b47340eef15700d2f0211576ba3506eevboxsync STR_FREE();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync INetCfg *pNc;
af062818b47340eef15700d2f0211576ba3506eevboxsync ComPtr<INetCfgComponent> pAdaptorComponent;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync LPWSTR pszApp;
af062818b47340eef15700d2f0211576ba3506eevboxsync int rc = VERR_INTNET_FLT_IF_NOT_FOUND;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = VBoxNetCfgWinQueryINetCfg(FALSE /*fGetWriteLock*/,
af062818b47340eef15700d2f0211576ba3506eevboxsync L"VirtualBox",
af062818b47340eef15700d2f0211576ba3506eevboxsync &pNc,
af062818b47340eef15700d2f0211576ba3506eevboxsync &pszApp);
af062818b47340eef15700d2f0211576ba3506eevboxsync Assert(hrc == S_OK);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (hrc == S_OK)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync /* get the adapter's INetCfgComponent*/
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = VBoxNetCfgWinGetComponentByGuid(pNc, &GUID_DEVCLASS_NET, (GUID*)hostIFGuid.ptr(), pAdaptorComponent.asOutParam());
af062818b47340eef15700d2f0211576ba3506eevboxsync if (hrc != S_OK)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("NetworkAttachmentType_Bridged: VBoxNetCfgWinGetComponentByGuid failed, hrc (0x%x)", hrc));
af062818b47340eef15700d2f0211576ba3506eevboxsync H();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync#define VBOX_WIN_BINDNAME_PREFIX "\\DEVICE\\"
af062818b47340eef15700d2f0211576ba3506eevboxsync char szTrunkName[INTNET_MAX_TRUNK_NAME];
af062818b47340eef15700d2f0211576ba3506eevboxsync char *pszTrunkName = szTrunkName;
af062818b47340eef15700d2f0211576ba3506eevboxsync wchar_t * pswzBindName;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = pAdaptorComponent->GetBindName(&pswzBindName);
af062818b47340eef15700d2f0211576ba3506eevboxsync Assert(hrc == S_OK);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (hrc == S_OK)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync int cwBindName = (int)wcslen(pswzBindName) + 1;
af062818b47340eef15700d2f0211576ba3506eevboxsync int cbFullBindNamePrefix = sizeof(VBOX_WIN_BINDNAME_PREFIX);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (sizeof(szTrunkName) > cbFullBindNamePrefix + cwBindName)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync strcpy(szTrunkName, VBOX_WIN_BINDNAME_PREFIX);
af062818b47340eef15700d2f0211576ba3506eevboxsync pszTrunkName += cbFullBindNamePrefix-1;
af062818b47340eef15700d2f0211576ba3506eevboxsync if (!WideCharToMultiByte(CP_ACP, 0, pswzBindName, cwBindName, pszTrunkName,
af062818b47340eef15700d2f0211576ba3506eevboxsync sizeof(szTrunkName) - cbFullBindNamePrefix + 1, NULL, NULL))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync DWORD err = GetLastError();
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = HRESULT_FROM_WIN32(err);
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertMsgFailed(("%hrc=%Rhrc %#x\n", hrc, hrc));
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: WideCharToMultiByte failed, hr=%Rhrc (0x%x) err=%u\n", hrc, hrc, err));
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: insufficient szTrunkName buffer space\n"));
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /** @todo set appropriate error code */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = E_FAIL;
af062818b47340eef15700d2f0211576ba3506eevboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (hrc != S_OK)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync AssertFailed();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync CoTaskMemFree(pswzBindName);
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync H();
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync /* we're not freeing the bind name since we'll use it later for detecting wireless*/
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync else
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync {
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: VBoxNetCfgWinGetComponentByGuid failed, hrc (0x%x)", hrc));
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync H();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync const char *pszTrunk = szTrunkName;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /* we're not releasing the INetCfg stuff here since we use it later to figure out whether it is wireless */
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync# elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
af062818b47340eef15700d2f0211576ba3506eevboxsync# if defined(RT_OS_FREEBSD)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /*
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * If we bridge to a tap interface open it the `old' direct way.
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * This works and performs better than bridging a physical
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * interface via the current FreeBSD vboxnetflt implementation.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync if (!strncmp(pszHifName, "tap", sizeof "tap" - 1)) {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = pThis->attachToTapInterface(aNetworkAdapter);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (FAILED(hrc))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync switch (hrc)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync case VERR_ACCESS_DENIED:
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
af062818b47340eef15700d2f0211576ba3506eevboxsync "Failed to open '/dev/%s' for read/write access. Please check the "
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync "permissions of that node, and that the net.link.tap.user_open "
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync "sysctl is set. Either run 'chmod 0666 /dev/%s' or "
af062818b47340eef15700d2f0211576ba3506eevboxsync "change the group of that node to vboxusers and make yourself "
af062818b47340eef15700d2f0211576ba3506eevboxsync "a member of that group. Make sure that these changes are permanent."), pszHifName, pszHifName);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync default:
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync AssertMsgFailed(("Could not attach to tap interface! Bad!\n"));
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync "Failed to initialize Host Interface Networking"));
5112e32d7072e280613921c982a6672f2c859cf3vboxsync }
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync Assert ((int)pThis->maTapFD[uInstance] >= 0);
af062818b47340eef15700d2f0211576ba3506eevboxsync if ((int)pThis->maTapFD[uInstance] >= 0)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "HostInterface"); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "FileHandle", pThis->maTapFD[uInstance]); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync break;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync# endif
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /** @todo Check for malformed names. */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync const char *pszTrunk = pszHifName;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Issue a warning if the interface is down */
af062818b47340eef15700d2f0211576ba3506eevboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync int iSock = socket(AF_INET, SOCK_DGRAM, 0);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (iSock >= 0)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync struct ifreq Req;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync memset(&Req, 0, sizeof(Req));
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync strncpy(Req.ifr_name, pszHifName, sizeof(Req.ifr_name) - 1);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (ioctl(iSock, SIOCGIFFLAGS, &Req) >= 0)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if ((Req.ifr_flags & IFF_UP) == 0)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync setVMRuntimeErrorCallbackF(pVM, pThis, 0, "BridgedInterfaceDown", "Bridged interface %s is down. Guest will not be able to use this interface", pszHifName);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync close(iSock);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync# else
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync# error "PORTME (VBOX_WITH_NETFLT)"
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync# endif
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertString(pCfg, "Trunk", pszTrunk); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_NetFlt);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync char szNetwork[INTNET_MAX_NETWORK_NAME];
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync RTStrPrintf(szNetwork, sizeof(szNetwork), "HostInterfaceNetworking-%s", pszHifName);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertString(pCfg, "Network", szNetwork); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync networkName = Bstr(szNetwork);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync trunkName = Bstr(pszTrunk);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync trunkType = Bstr(TRUNKTYPE_NETFLT);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync# if defined(RT_OS_DARWIN)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /** @todo Come up with a better deal here. Problem is that IHostNetworkInterface is completely useless here. */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if ( strstr(pszHifName, "Wireless")
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync || strstr(pszHifName, "AirPort" ))
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "SharedMacOnWire", true); RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync# elif defined(RT_OS_LINUX)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync int iSock = socket(AF_INET, SOCK_DGRAM, 0);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (iSock >= 0)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync struct iwreq WRq;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync memset(&WRq, 0, sizeof(WRq));
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync strncpy(WRq.ifr_name, pszHifName, IFNAMSIZ);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync bool fSharedMacOnWire = ioctl(iSock, SIOCGIWNAME, &WRq) >= 0;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync close(iSock);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (fSharedMacOnWire)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "SharedMacOnWire", true);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync Log(("Set SharedMacOnWire\n"));
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync else
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync Log(("Failed to get wireless name\n"));
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync else
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync Log(("Failed to open wireless socket\n"));
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync# elif defined(RT_OS_FREEBSD)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync int iSock = socket(AF_INET, SOCK_DGRAM, 0);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (iSock >= 0)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync struct ieee80211req WReq;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync uint8_t abData[32];
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync memset(&WReq, 0, sizeof(WReq));
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync strncpy(WReq.i_name, pszHifName, sizeof(WReq.i_name));
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync WReq.i_type = IEEE80211_IOC_SSID;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync WReq.i_val = -1;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync WReq.i_data = abData;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync WReq.i_len = sizeof(abData);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync bool fSharedMacOnWire = ioctl(iSock, SIOCG80211, &WReq) >= 0;
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync close(iSock);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync if (fSharedMacOnWire)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync {
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync rc = CFGMR3InsertInteger(pCfg, "SharedMacOnWire", true);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync RC_CHECK();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync Log(("Set SharedMacOnWire\n"));
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync else
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync Log(("Failed to get wireless name\n"));
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync }
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync else
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync Log(("Failed to open wireless socket\n"));
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync# elif defined(RT_OS_WINDOWS)
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync# define DEVNAME_PREFIX L"\\\\.\\"
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* we are getting the medium type via IOCTL_NDIS_QUERY_GLOBAL_STATS Io Control
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * there is a pretty long way till there though since we need to obtain the symbolic link name
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync * for the adapter device we are going to query given the device Guid */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* prepend the "\\\\.\\" to the bind name to obtain the link name */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync wchar_t FileName[MAX_PATH];
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync wcscpy(FileName, DEVNAME_PREFIX);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync wcscpy((wchar_t*)(((char*)FileName) + sizeof(DEVNAME_PREFIX) - sizeof(FileName[0])), pswzBindName);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /* open the device */
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync HANDLE hDevice = CreateFile(FileName,
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync NULL,
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync OPEN_EXISTING,
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync FILE_ATTRIBUTE_NORMAL,
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync NULL);
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync if (hDevice != INVALID_HANDLE_VALUE)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync bool fSharedMacOnWire = false;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync /* now issue the OID_GEN_PHYSICAL_MEDIUM query */
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync DWORD Oid = OID_GEN_PHYSICAL_MEDIUM;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync NDIS_PHYSICAL_MEDIUM PhMedium;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync DWORD cbResult;
af062818b47340eef15700d2f0211576ba3506eevboxsync if (DeviceIoControl(hDevice,
af062818b47340eef15700d2f0211576ba3506eevboxsync IOCTL_NDIS_QUERY_GLOBAL_STATS,
af062818b47340eef15700d2f0211576ba3506eevboxsync &Oid,
af062818b47340eef15700d2f0211576ba3506eevboxsync sizeof(Oid),
af062818b47340eef15700d2f0211576ba3506eevboxsync &PhMedium,
af062818b47340eef15700d2f0211576ba3506eevboxsync sizeof(PhMedium),
af062818b47340eef15700d2f0211576ba3506eevboxsync &cbResult,
af062818b47340eef15700d2f0211576ba3506eevboxsync NULL))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync /* that was simple, now examine PhMedium */
af062818b47340eef15700d2f0211576ba3506eevboxsync if ( PhMedium == NdisPhysicalMediumWirelessWan
af062818b47340eef15700d2f0211576ba3506eevboxsync || PhMedium == NdisPhysicalMediumWirelessLan
af062818b47340eef15700d2f0211576ba3506eevboxsync || PhMedium == NdisPhysicalMediumNative802_11
af062818b47340eef15700d2f0211576ba3506eevboxsync || PhMedium == NdisPhysicalMediumBluetooth)
af062818b47340eef15700d2f0211576ba3506eevboxsync fSharedMacOnWire = true;
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync int winEr = GetLastError();
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("Console::configConstructor: DeviceIoControl failed, err (0x%x), ignoring\n", winEr));
af062818b47340eef15700d2f0211576ba3506eevboxsync Assert(winEr == ERROR_INVALID_PARAMETER || winEr == ERROR_NOT_SUPPORTED || winEr == ERROR_BAD_COMMAND);
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync CloseHandle(hDevice);
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync if (fSharedMacOnWire)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync Log(("this is a wireless adapter"));
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "SharedMacOnWire", true); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync Log(("Set SharedMacOnWire\n"));
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync Log(("this is NOT a wireless adapter"));
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync int winEr = GetLastError();
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertLogRelMsgFailed(("Console::configConstructor: CreateFile failed, err (0x%x), ignoring\n", winEr));
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync CoTaskMemFree(pswzBindName);
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync pAdaptorComponent.setNull();
af062818b47340eef15700d2f0211576ba3506eevboxsync /* release the pNc finally */
af062818b47340eef15700d2f0211576ba3506eevboxsync VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
af062818b47340eef15700d2f0211576ba3506eevboxsync# else
af062818b47340eef15700d2f0211576ba3506eevboxsync /** @todo PORTME: wireless detection */
af062818b47340eef15700d2f0211576ba3506eevboxsync# endif
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync# if defined(RT_OS_SOLARIS)
af062818b47340eef15700d2f0211576ba3506eevboxsync# if 0 /* bird: this is a bit questionable and might cause more trouble than its worth. */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /* Zone access restriction, don't allow snopping the global zone. */
af062818b47340eef15700d2f0211576ba3506eevboxsync zoneid_t ZoneId = getzoneid();
af062818b47340eef15700d2f0211576ba3506eevboxsync if (ZoneId != GLOBAL_ZONEID)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "IgnoreAllPromisc", true); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync# endif
af062818b47340eef15700d2f0211576ba3506eevboxsync# endif
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#elif defined(RT_OS_WINDOWS) /* not defined NetFlt */
af062818b47340eef15700d2f0211576ba3506eevboxsync /* NOTHING TO DO HERE */
af062818b47340eef15700d2f0211576ba3506eevboxsync#elif defined(RT_OS_LINUX)
af062818b47340eef15700d2f0211576ba3506eevboxsync/// @todo aleksey: is there anything to be done here?
af062818b47340eef15700d2f0211576ba3506eevboxsync#elif defined(RT_OS_FREEBSD)
af062818b47340eef15700d2f0211576ba3506eevboxsync/** @todo FreeBSD: Check out this later (HIF networking). */
af062818b47340eef15700d2f0211576ba3506eevboxsync#else
af062818b47340eef15700d2f0211576ba3506eevboxsync# error "Port me"
af062818b47340eef15700d2f0211576ba3506eevboxsync#endif
af062818b47340eef15700d2f0211576ba3506eevboxsync break;
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync case NetworkAttachmentType_Internal:
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = aNetworkAdapter->COMGETTER(InternalNetwork)(&str); H();
af062818b47340eef15700d2f0211576ba3506eevboxsync if (str && *str)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync if (fSniffer)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0);
af062818b47340eef15700d2f0211576ba3506eevboxsync RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0);
af062818b47340eef15700d2f0211576ba3506eevboxsync RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertStringW(pCfg, "Network", str); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_WhateverNone); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync networkName = str;
af062818b47340eef15700d2f0211576ba3506eevboxsync trunkType = Bstr(TRUNKTYPE_WHATEVER);
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync STR_FREE();
af062818b47340eef15700d2f0211576ba3506eevboxsync break;
af062818b47340eef15700d2f0211576ba3506eevboxsync }
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync case NetworkAttachmentType_HostOnly:
af062818b47340eef15700d2f0211576ba3506eevboxsync {
0ce9dd4fced41bc7abadafc3527762a27cd641ecvboxsync if (fSniffer)
0ce9dd4fced41bc7abadafc3527762a27cd641ecvboxsync {
5112e32d7072e280613921c982a6672f2c859cf3vboxsync rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0);
5112e32d7072e280613921c982a6672f2c859cf3vboxsync RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0);
af062818b47340eef15700d2f0211576ba3506eevboxsync RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync Bstr HifName;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = aNetworkAdapter->COMGETTER(HostInterface)(HifName.asOutParam());
af062818b47340eef15700d2f0211576ba3506eevboxsync if (FAILED(hrc))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("NetworkAttachmentType_HostOnly: COMGETTER(HostInterface) failed, hrc (0x%x)\n", hrc));
af062818b47340eef15700d2f0211576ba3506eevboxsync H();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync Utf8Str HifNameUtf8(HifName);
af062818b47340eef15700d2f0211576ba3506eevboxsync const char *pszHifName = HifNameUtf8.raw();
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("NetworkAttachmentType_HostOnly: COMGETTER(HostInterface): %s\n", pszHifName));
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync ComPtr<IHostNetworkInterface> hostInterface;
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = host->FindHostNetworkInterfaceByName(HifName, hostInterface.asOutParam());
af062818b47340eef15700d2f0211576ba3506eevboxsync if (!SUCCEEDED(rc))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("NetworkAttachmentType_HostOnly: FindByName failed, rc (0x%x)\n", rc));
af062818b47340eef15700d2f0211576ba3506eevboxsync return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
af062818b47340eef15700d2f0211576ba3506eevboxsync N_("Inexistent host networking interface, name '%ls'"),
af062818b47340eef15700d2f0211576ba3506eevboxsync HifName.raw());
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync char szNetwork[INTNET_MAX_NETWORK_NAME];
af062818b47340eef15700d2f0211576ba3506eevboxsync RTStrPrintf(szNetwork, sizeof(szNetwork), "HostInterfaceNetworking-%s", pszHifName);
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#if defined(RT_OS_WINDOWS)
af062818b47340eef15700d2f0211576ba3506eevboxsync# ifndef VBOX_WITH_NETFLT
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = E_NOTIMPL;
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("NetworkAttachmentType_HostOnly: Not Implemented\n"));
af062818b47340eef15700d2f0211576ba3506eevboxsync H();
af062818b47340eef15700d2f0211576ba3506eevboxsync# else /* defined VBOX_WITH_NETFLT*/
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /** @todo r=bird: Put this in a function. */
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync HostNetworkInterfaceType_T eIfType;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = hostInterface->COMGETTER(InterfaceType)(&eIfType);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (FAILED(hrc))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("NetworkAttachmentType_HostOnly: COMGETTER(InterfaceType) failed, hrc (0x%x)\n", hrc));
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync if (eIfType != HostNetworkInterfaceType_HostOnly)
040b4a09341f574825386333398110f4db3e1e51vboxsync return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync N_("Interface ('%ls') is not a Host-Only Adapter interface"),
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync HifName.raw());
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = hostInterface->COMGETTER(Id)(&str);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (FAILED(hrc))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("NetworkAttachmentType_HostOnly: COMGETTER(Id) failed, hrc (0x%x)\n", hrc));
af062818b47340eef15700d2f0211576ba3506eevboxsync H();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync Guid hostIFGuid(str);
af062818b47340eef15700d2f0211576ba3506eevboxsync STR_FREE();
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync INetCfg *pNc;
af062818b47340eef15700d2f0211576ba3506eevboxsync ComPtr<INetCfgComponent> pAdaptorComponent;
af062818b47340eef15700d2f0211576ba3506eevboxsync LPWSTR pszApp;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = VERR_INTNET_FLT_IF_NOT_FOUND;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = VBoxNetCfgWinQueryINetCfg(FALSE,
af062818b47340eef15700d2f0211576ba3506eevboxsync L"VirtualBox",
af062818b47340eef15700d2f0211576ba3506eevboxsync &pNc,
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync &pszApp);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync Assert(hrc == S_OK);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (hrc == S_OK)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /* get the adapter's INetCfgComponent*/
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = VBoxNetCfgWinGetComponentByGuid(pNc, &GUID_DEVCLASS_NET, (GUID*)hostIFGuid.ptr(), pAdaptorComponent.asOutParam());
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (hrc != S_OK)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync LogRel(("NetworkAttachmentType_HostOnly: VBoxNetCfgWinGetComponentByGuid failed, hrc=%Rhrc (0x%x)\n", hrc, hrc));
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync H();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#define VBOX_WIN_BINDNAME_PREFIX "\\DEVICE\\"
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync char szTrunkName[INTNET_MAX_TRUNK_NAME];
af062818b47340eef15700d2f0211576ba3506eevboxsync char *pszTrunkName = szTrunkName;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync wchar_t * pswzBindName;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = pAdaptorComponent->GetBindName(&pswzBindName);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync Assert(hrc == S_OK);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (hrc == S_OK)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync int cwBindName = (int)wcslen(pswzBindName) + 1;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync int cbFullBindNamePrefix = sizeof(VBOX_WIN_BINDNAME_PREFIX);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (sizeof(szTrunkName) > cbFullBindNamePrefix + cwBindName)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync strcpy(szTrunkName, VBOX_WIN_BINDNAME_PREFIX);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync pszTrunkName += cbFullBindNamePrefix-1;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (!WideCharToMultiByte(CP_ACP, 0, pswzBindName, cwBindName, pszTrunkName,
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync sizeof(szTrunkName) - cbFullBindNamePrefix + 1, NULL, NULL))
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync DWORD err = GetLastError();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = HRESULT_FROM_WIN32(err);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync AssertLogRelMsgFailed(("NetworkAttachmentType_HostOnly: WideCharToMultiByte failed, hr=%Rhrc (0x%x) err=%u\n", hrc, hrc, err));
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertLogRelMsgFailed(("NetworkAttachmentType_HostOnly: insufficient szTrunkName buffer space\n"));
040b4a09341f574825386333398110f4db3e1e51vboxsync /** @todo set appropriate error code */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = E_FAIL;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync if (hrc != S_OK)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertFailed();
af062818b47340eef15700d2f0211576ba3506eevboxsync CoTaskMemFree(pswzBindName);
af062818b47340eef15700d2f0211576ba3506eevboxsync VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
af062818b47340eef15700d2f0211576ba3506eevboxsync H();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertLogRelMsgFailed(("NetworkAttachmentType_HostOnly: VBoxNetCfgWinGetComponentByGuid failed, hrc=%Rhrc (0x%x)\n", hrc, hrc));
af062818b47340eef15700d2f0211576ba3506eevboxsync H();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync CoTaskMemFree(pswzBindName);
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync pAdaptorComponent.setNull();
af062818b47340eef15700d2f0211576ba3506eevboxsync /* release the pNc finally */
af062818b47340eef15700d2f0211576ba3506eevboxsync VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync const char *pszTrunk = szTrunkName;
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_NetAdp); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pCfg, "Trunk", pszTrunk); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pCfg, "Network", szNetwork); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync networkName = Bstr(szNetwork);
af062818b47340eef15700d2f0211576ba3506eevboxsync trunkName = Bstr(pszTrunk);
af062818b47340eef15700d2f0211576ba3506eevboxsync trunkType = TRUNKTYPE_NETADP;
af062818b47340eef15700d2f0211576ba3506eevboxsync# endif /* defined VBOX_WITH_NETFLT*/
af062818b47340eef15700d2f0211576ba3506eevboxsync#elif defined(RT_OS_DARWIN)
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pCfg, "Trunk", pszHifName); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pCfg, "Network", szNetwork); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_NetAdp); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync networkName = Bstr(szNetwork);
af062818b47340eef15700d2f0211576ba3506eevboxsync trunkName = Bstr(pszHifName);
af062818b47340eef15700d2f0211576ba3506eevboxsync trunkType = TRUNKTYPE_NETADP;
af062818b47340eef15700d2f0211576ba3506eevboxsync#else
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pCfg, "Trunk", pszHifName); RC_CHECK();
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = CFGMR3InsertString(pCfg, "Network", szNetwork); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_NetFlt); RC_CHECK();
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync networkName = Bstr(szNetwork);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync trunkName = Bstr(pszHifName);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync trunkType = TRUNKTYPE_NETFLT;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#endif
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#if !defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync Bstr tmpAddr, tmpMask;
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPAddress", pszHifName), tmpAddr.asOutParam());
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (SUCCEEDED(hrc) && !tmpAddr.isEmpty())
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync {
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPNetMask", pszHifName), tmpMask.asOutParam());
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (SUCCEEDED(hrc) && !tmpMask.isEmpty())
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hrc = hostInterface->EnableStaticIpConfig(tmpAddr, tmpMask);
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = hostInterface->EnableStaticIpConfig(tmpAddr,
af062818b47340eef15700d2f0211576ba3506eevboxsync Bstr(VBOXNET_IPV4MASK_DEFAULT));
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Grab the IP number from the 'vboxnetX' instance number (see netif.h) */
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = hostInterface->EnableStaticIpConfig(getDefaultIPv4Address(Bstr(pszHifName)),
af062818b47340eef15700d2f0211576ba3506eevboxsync Bstr(VBOXNET_IPV4MASK_DEFAULT));
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync ComAssertComRC(hrc); /** @todo r=bird: Why this isn't fatal? (H()) */
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6Address", pszHifName), tmpAddr.asOutParam());
af062818b47340eef15700d2f0211576ba3506eevboxsync if (SUCCEEDED(hrc))
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6NetMask", pszHifName), tmpMask.asOutParam());
af062818b47340eef15700d2f0211576ba3506eevboxsync if (SUCCEEDED(hrc) && !tmpAddr.isEmpty() && !tmpMask.isEmpty())
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = hostInterface->EnableStaticIpConfigV6(tmpAddr, Utf8Str(tmpMask).toUInt32());
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync ComAssertComRC(hrc); /** @todo r=bird: Why this isn't fatal? (H()) */
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
040b4a09341f574825386333398110f4db3e1e51vboxsync#endif
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync break;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
040b4a09341f574825386333398110f4db3e1e51vboxsync
040b4a09341f574825386333398110f4db3e1e51vboxsync default:
040b4a09341f574825386333398110f4db3e1e51vboxsync AssertMsgFailed(("should not get here!\n"));
040b4a09341f574825386333398110f4db3e1e51vboxsync break;
040b4a09341f574825386333398110f4db3e1e51vboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync * Attempt to attach the driver.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync switch (eAttachmentType)
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync {
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync case NetworkAttachmentType_Null:
af062818b47340eef15700d2f0211576ba3506eevboxsync break;
af062818b47340eef15700d2f0211576ba3506eevboxsync
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync case NetworkAttachmentType_Bridged:
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync case NetworkAttachmentType_Internal:
af062818b47340eef15700d2f0211576ba3506eevboxsync case NetworkAttachmentType_HostOnly:
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync case NetworkAttachmentType_NAT:
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync {
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync if (SUCCEEDED(hrc) && SUCCEEDED(rc))
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync {
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync if (fAttachDetach)
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = PDMR3DriverAttach(pVM, pszDevice, uInstance, uLun, 0 /*fFlags*/, NULL /* ppBase */);
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertRC(rc);
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync {
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync /** @todo pritesh: get the dhcp server name from the
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync * previous network configuration and then stop the server
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync * else it may conflict with the dhcp server running with
5112e32d7072e280613921c982a6672f2c859cf3vboxsync * the current attachment type
5112e32d7072e280613921c982a6672f2c859cf3vboxsync */
5112e32d7072e280613921c982a6672f2c859cf3vboxsync /* Stop the hostonly DHCP Server */
5112e32d7072e280613921c982a6672f2c859cf3vboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync if (!networkName.isNull())
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync /*
5112e32d7072e280613921c982a6672f2c859cf3vboxsync * Until we implement service reference counters DHCP Server will be stopped
5112e32d7072e280613921c982a6672f2c859cf3vboxsync * by DHCPServerRunner destructor.
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsync ComPtr<IDHCPServer> dhcpServer;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = virtualBox->FindDHCPServerByNetworkName(networkName.mutableRaw(), dhcpServer.asOutParam());
5112e32d7072e280613921c982a6672f2c859cf3vboxsync if (SUCCEEDED(hrc))
5112e32d7072e280613921c982a6672f2c859cf3vboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync /* there is a DHCP server available for this network */
af062818b47340eef15700d2f0211576ba3506eevboxsync BOOL fEnabled;
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = dhcpServer->COMGETTER(Enabled)(&fEnabled);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (FAILED(hrc))
af062818b47340eef15700d2f0211576ba3506eevboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync LogRel(("DHCP svr: COMGETTER(Enabled) failed, hrc (%Rhrc)", hrc));
af062818b47340eef15700d2f0211576ba3506eevboxsync H();
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync if (fEnabled)
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = dhcpServer->Start(networkName, trunkName, trunkType);
5112e32d7072e280613921c982a6672f2c859cf3vboxsync }
5112e32d7072e280613921c982a6672f2c859cf3vboxsync else
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = S_OK;
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync break;
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync default:
5112e32d7072e280613921c982a6672f2c859cf3vboxsync AssertMsgFailed(("should not get here!\n"));
af062818b47340eef15700d2f0211576ba3506eevboxsync break;
af062818b47340eef15700d2f0211576ba3506eevboxsync }
af062818b47340eef15700d2f0211576ba3506eevboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync pThis->meAttachmentType[uInstance] = eAttachmentType;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#undef STR_FREE
af062818b47340eef15700d2f0211576ba3506eevboxsync#undef H
af062818b47340eef15700d2f0211576ba3506eevboxsync#undef RC_CHECK
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync return VINF_SUCCESS;
af062818b47340eef15700d2f0211576ba3506eevboxsync}
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync#ifdef VBOX_WITH_GUEST_PROPS
af062818b47340eef15700d2f0211576ba3506eevboxsync/**
af062818b47340eef15700d2f0211576ba3506eevboxsync * Set an array of guest properties
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic void configSetProperties(VMMDev * const pVMMDev, void *names,
af062818b47340eef15700d2f0211576ba3506eevboxsync void *values, void *timestamps, void *flags)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync{
5112e32d7072e280613921c982a6672f2c859cf3vboxsync VBOXHGCMSVCPARM parms[4];
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[0].u.pointer.addr = names;
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[0].u.pointer.size = 0; /* We don't actually care. */
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[1].type = VBOX_HGCM_SVC_PARM_PTR;
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[1].u.pointer.addr = values;
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[1].u.pointer.size = 0; /* We don't actually care. */
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[2].type = VBOX_HGCM_SVC_PARM_PTR;
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[2].u.pointer.addr = timestamps;
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[2].u.pointer.size = 0; /* We don't actually care. */
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[3].type = VBOX_HGCM_SVC_PARM_PTR;
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[3].u.pointer.addr = flags;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync parms[3].u.pointer.size = 0; /* We don't actually care. */
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync pVMMDev->hgcmHostCall ("VBoxGuestPropSvc", guestProp::SET_PROPS_HOST, 4,
af062818b47340eef15700d2f0211576ba3506eevboxsync &parms[0]);
af062818b47340eef15700d2f0211576ba3506eevboxsync}
5112e32d7072e280613921c982a6672f2c859cf3vboxsync
5112e32d7072e280613921c982a6672f2c859cf3vboxsync/**
af062818b47340eef15700d2f0211576ba3506eevboxsync * Set a single guest property
af062818b47340eef15700d2f0211576ba3506eevboxsync */
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic void configSetProperty(VMMDev * const pVMMDev, const char *pszName,
af062818b47340eef15700d2f0211576ba3506eevboxsync const char *pszValue, const char *pszFlags)
af062818b47340eef15700d2f0211576ba3506eevboxsync{
af062818b47340eef15700d2f0211576ba3506eevboxsync VBOXHGCMSVCPARM parms[4];
af062818b47340eef15700d2f0211576ba3506eevboxsync
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync AssertPtrReturnVoid(pszName);
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync AssertPtrReturnVoid(pszValue);
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync AssertPtrReturnVoid(pszFlags);
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync parms[0].u.pointer.addr = (void *)pszName;
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[0].u.pointer.size = strlen(pszName) + 1;
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[1].type = VBOX_HGCM_SVC_PARM_PTR;
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[1].u.pointer.addr = (void *)pszValue;
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[1].u.pointer.size = strlen(pszValue) + 1;
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[2].type = VBOX_HGCM_SVC_PARM_PTR;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync parms[2].u.pointer.addr = (void *)pszFlags;
af062818b47340eef15700d2f0211576ba3506eevboxsync parms[2].u.pointer.size = strlen(pszFlags) + 1;
af062818b47340eef15700d2f0211576ba3506eevboxsync pVMMDev->hgcmHostCall ("VBoxGuestPropSvc", guestProp::SET_PROP_HOST, 3,
af062818b47340eef15700d2f0211576ba3506eevboxsync &parms[0]);
af062818b47340eef15700d2f0211576ba3506eevboxsync}
af062818b47340eef15700d2f0211576ba3506eevboxsync
af062818b47340eef15700d2f0211576ba3506eevboxsync/**
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync * Set the global flags value by calling the service
af062818b47340eef15700d2f0211576ba3506eevboxsync * @returns the status returned by the call to the service
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync *
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync * @param pTable the service instance handle
af062818b47340eef15700d2f0211576ba3506eevboxsync * @param eFlags the flags to set
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync */
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsyncint configSetGlobalPropertyFlags(VMMDev * const pVMMDev,
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync guestProp::ePropFlags eFlags)
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync{
af062818b47340eef15700d2f0211576ba3506eevboxsync VBOXHGCMSVCPARM paParm;
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync paParm.setUInt32(eFlags);
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync int rc = pVMMDev->hgcmHostCall ("VBoxGuestPropSvc",
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync guestProp::SET_GLOBAL_FLAGS_HOST, 1,
af062818b47340eef15700d2f0211576ba3506eevboxsync &paParm);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (RT_FAILURE(rc))
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync {
af062818b47340eef15700d2f0211576ba3506eevboxsync char szFlags[guestProp::MAX_FLAGS_LEN];
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync if (RT_FAILURE(writeFlags(eFlags, szFlags)))
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync Log(("Failed to set the global flags.\n"));
af062818b47340eef15700d2f0211576ba3506eevboxsync else
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync Log(("Failed to set the global flags \"%s\".\n", szFlags));
af062818b47340eef15700d2f0211576ba3506eevboxsync }
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync return rc;
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync}
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync#endif /* VBOX_WITH_GUEST_PROPS */
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync/**
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync * Set up the Guest Property service, populate it with properties read from
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync * the machine XML and set a couple of initial properties.
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync */
554f00fe75489f3f3ce7fbb6d126ce1d2c5c922cvboxsync/* static */ int Console::configGuestProperties(void *pvConsole)
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync{
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync#ifdef VBOX_WITH_GUEST_PROPS
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync AssertReturn(pvConsole, VERR_GENERAL_FAILURE);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync ComObjPtr<Console> pConsole = static_cast <Console *> (pvConsole);
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync /* Load the service */
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync int rc = pConsole->mVMMDev->hgcmLoadService ("VBoxGuestPropSvc", "VBoxGuestPropSvc");
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync if (RT_FAILURE(rc))
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync {
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync LogRel(("VBoxGuestPropSvc is not available. rc = %Rrc\n", rc));
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync /* That is not a fatal failure. */
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync rc = VINF_SUCCESS;
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync }
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync else
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync {
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync /*
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync * Initialize built-in properties that can be changed and saved.
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync *
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync * These are typically transient properties that the guest cannot
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * change.
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /* Sysprep execution by VBoxService. */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync configSetProperty(pConsole->mVMMDev,
5112e32d7072e280613921c982a6672f2c859cf3vboxsync "/VirtualBox/HostGuest/SysprepExec", "",
5112e32d7072e280613921c982a6672f2c859cf3vboxsync "TRANSIENT, RDONLYGUEST");
5112e32d7072e280613921c982a6672f2c859cf3vboxsync configSetProperty(pConsole->mVMMDev,
5112e32d7072e280613921c982a6672f2c859cf3vboxsync "/VirtualBox/HostGuest/SysprepArgs", "",
5112e32d7072e280613921c982a6672f2c859cf3vboxsync "TRANSIENT, RDONLYGUEST");
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync /*
5112e32d7072e280613921c982a6672f2c859cf3vboxsync * Pull over the properties from the server.
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync */
5112e32d7072e280613921c982a6672f2c859cf3vboxsync SafeArray<BSTR> namesOut;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync SafeArray<BSTR> valuesOut;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync SafeArray<ULONG64> timestampsOut;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync SafeArray<BSTR> flagsOut;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync HRESULT hrc;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync hrc = pConsole->mControl->PullGuestProperties(ComSafeArrayAsOutParam(namesOut),
5112e32d7072e280613921c982a6672f2c859cf3vboxsync ComSafeArrayAsOutParam(valuesOut),
5112e32d7072e280613921c982a6672f2c859cf3vboxsync ComSafeArrayAsOutParam(timestampsOut),
5112e32d7072e280613921c982a6672f2c859cf3vboxsync ComSafeArrayAsOutParam(flagsOut));
5112e32d7072e280613921c982a6672f2c859cf3vboxsync AssertMsgReturn(SUCCEEDED(hrc), ("hrc=%Rrc\n", hrc), VERR_GENERAL_FAILURE);
5112e32d7072e280613921c982a6672f2c859cf3vboxsync size_t cProps = namesOut.size();
ee6bcfc59fe3b0230aad85e2ef63d0402b7719b2vboxsync size_t cAlloc = cProps + 1;
5112e32d7072e280613921c982a6672f2c859cf3vboxsync if ( valuesOut.size() != cProps
5112e32d7072e280613921c982a6672f2c859cf3vboxsync || timestampsOut.size() != cProps
5112e32d7072e280613921c982a6672f2c859cf3vboxsync || flagsOut.size() != cProps
5112e32d7072e280613921c982a6672f2c859cf3vboxsync )
AssertFailedReturn(VERR_INVALID_PARAMETER);
char **papszNames, **papszValues, **papszFlags;
char szEmpty[] = "";
ULONG64 *pau64Timestamps;
papszNames = (char **)RTMemTmpAllocZ(sizeof(void *) * cAlloc);
papszValues = (char **)RTMemTmpAllocZ(sizeof(void *) * cAlloc);
pau64Timestamps = (ULONG64 *)RTMemTmpAllocZ(sizeof(ULONG64) * cAlloc);
papszFlags = (char **)RTMemTmpAllocZ(sizeof(void *) * cAlloc);
if (papszNames && papszValues && pau64Timestamps && papszFlags)
{
for (unsigned i = 0; RT_SUCCESS(rc) && i < cProps; ++i)
{
AssertPtrReturn(namesOut[i], VERR_INVALID_PARAMETER);
rc = RTUtf16ToUtf8(namesOut[i], &papszNames[i]);
if (RT_FAILURE(rc))
break;
if (valuesOut[i])
rc = RTUtf16ToUtf8(valuesOut[i], &papszValues[i]);
else
papszValues[i] = szEmpty;
if (RT_FAILURE(rc))
break;
pau64Timestamps[i] = timestampsOut[i];
if (flagsOut[i])
rc = RTUtf16ToUtf8(flagsOut[i], &papszFlags[i]);
else
papszFlags[i] = szEmpty;
}
if (RT_SUCCESS(rc))
configSetProperties(pConsole->mVMMDev,
(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;
RTMemTmpFree(papszNames);
RTMemTmpFree(papszValues);
RTMemTmpFree(pau64Timestamps);
RTMemTmpFree(papszFlags);
AssertRCReturn(rc, rc);
/*
* 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 */
configSetProperty(pConsole->mVMMDev, "/VirtualBox/HostInfo/VBoxVer",
VBOX_VERSION_STRING, "TRANSIENT, RDONLYGUEST");
/* Set the VBox SVN revision as a guest property */
configSetProperty(pConsole->mVMMDev, "/VirtualBox/HostInfo/VBoxRev",
RTBldCfgRevisionStr(), "TRANSIENT, RDONLYGUEST");
/*
* Register the host notification callback
*/
HGCMSVCEXTHANDLE hDummy;
HGCMHostRegisterServiceExtension(&hDummy, "VBoxGuestPropSvc",
Console::doGuestPropNotification,
pvConsole);
#ifdef VBOX_WITH_GUEST_PROPS_RDONLY_GUEST
rc = configSetGlobalPropertyFlags(pConsole->mVMMDev,
guestProp::RDONLYGUEST);
AssertRCReturn(rc, rc);
#endif
Log(("Set VBoxGuestPropSvc property store\n"));
}
return VINF_SUCCESS;
#else /* !VBOX_WITH_GUEST_PROPS */
return VERR_NOT_SUPPORTED;
#endif /* !VBOX_WITH_GUEST_PROPS */
}