ConsoleImpl2.cpp revision 8ad4991aaa9695a98840f9d1f718417c59bedf8f
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync/* $Id$ */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync/** @file
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync * VBox Console COM Class implementation
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync *
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * @remark We've split out the code that the 64-bit VC++ v8 compiler finds
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * problematic to optimize so we can disable optimizations and later,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * perhaps, find a real solution for it (like rewriting the code and
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * to stop resemble a tonne of spaghetti).
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync/*
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * Copyright (C) 2006-2010 Oracle Corporation
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync *
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * available from http://www.virtualbox.org. This file is free software;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * you can redistribute it and/or modify it under the terms of the GNU
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * General Public License (GPL) as published by the Free Software
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync/*******************************************************************************
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync* Header Files *
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync*******************************************************************************/
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync// for some reason Windows burns in sdk\...\winsock.h if this isn't included first
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include "VBox/com/ptr.h"
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include "ConsoleImpl.h"
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include "DisplayImpl.h"
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#ifdef VBOX_WITH_GUEST_CONTROL
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync# include "GuestImpl.h"
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#endif
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include "VMMDev.h"
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync#include "Global.h"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync// generated header
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include "SchemaDefs.h"
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include "AutoCaller.h"
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include "Logging.h"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include <iprt/buildconfig.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include <iprt/ctype.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include <iprt/dir.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <iprt/file.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <iprt/param.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <iprt/path.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <iprt/string.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <iprt/system.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <iprt/cpp/exception.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#if 0 /* enable to play with lots of memory. */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync# include <iprt/env.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#endif
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <iprt/stream.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include <VBox/vmapi.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <VBox/err.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include <VBox/param.h>
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#include <VBox/pdmapi.h> /* For PDMR3DriverAttach/PDMR3DriverDetach */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include <VBox/version.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include <VBox/HostServices/VBoxClipboardSvc.h>
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#ifdef VBOX_WITH_CROGL
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync# include <VBox/HostServices/VBoxCrOpenGLSvc.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#ifdef VBOX_WITH_GUEST_PROPS
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync# include <VBox/HostServices/GuestPropertySvc.h>
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync# include <VBox/com/defs.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync# include <VBox/com/array.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync# include <hgcm/HGCM.h> /** @todo it should be possible to register a service
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * extension using a VMMDev callback. */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync# include <vector>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#endif /* VBOX_WITH_GUEST_PROPS */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include <VBox/intnet.h>
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include <VBox/com/com.h>
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include <VBox/com/string.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include <VBox/com/array.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#ifdef VBOX_WITH_NETFLT
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync# if defined(RT_OS_SOLARIS)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync# include <zone.h>
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync# elif defined(RT_OS_LINUX)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync# include <unistd.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync# include <sys/ioctl.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync# include <sys/socket.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync# include <linux/types.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync# include <linux/if.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync# include <linux/wireless.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync# elif defined(RT_OS_FREEBSD)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync# include <unistd.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync# include <sys/types.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync# include <sys/ioctl.h>
0c94a8282c9042b02f022302a3d987746140eab9vboxsync# include <sys/socket.h>
0c94a8282c9042b02f022302a3d987746140eab9vboxsync# include <net/if.h>
0c94a8282c9042b02f022302a3d987746140eab9vboxsync# include <net80211/ieee80211_ioctl.h>
0c94a8282c9042b02f022302a3d987746140eab9vboxsync# endif
0c94a8282c9042b02f022302a3d987746140eab9vboxsync# if defined(RT_OS_WINDOWS)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync# include <VBox/WinNetConfig.h>
0c94a8282c9042b02f022302a3d987746140eab9vboxsync# include <Ntddndis.h>
0c94a8282c9042b02f022302a3d987746140eab9vboxsync# include <devguid.h>
0c94a8282c9042b02f022302a3d987746140eab9vboxsync# else
0c94a8282c9042b02f022302a3d987746140eab9vboxsync# include <HostNetworkInterfaceImpl.h>
0c94a8282c9042b02f022302a3d987746140eab9vboxsync# include <netif.h>
0c94a8282c9042b02f022302a3d987746140eab9vboxsync# include <stdlib.h>
0c94a8282c9042b02f022302a3d987746140eab9vboxsync# endif
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#endif /* VBOX_WITH_NETFLT */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include "DHCPServerRunner.h"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include "BusAssignmentManager.h"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#ifdef VBOX_WITH_EXTPACK
0c94a8282c9042b02f022302a3d987746140eab9vboxsync# include "ExtPackManagerImpl.h"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#endif
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#if defined(RT_OS_DARWIN)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync# include "IOKit/IOKitLib.h"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncstatic int DarwinSmcKey(char *pabKey, uint32_t cbKey)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync{
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * Method as described in Amit Singh's article:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * http://osxbook.com/book/bonus/chapter7/tpmdrmmyth/
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync typedef struct
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint32_t key;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint8_t pad0[22];
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint32_t datasize;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint8_t pad1[10];
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint8_t cmd;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint32_t pad2;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint8_t data[32];
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync } AppleSMCBuffer;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync AssertReturn(cbKey >= 65, VERR_INTERNAL_ERROR);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync IOServiceMatching("AppleSMC"));
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (!service)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return VERR_NOT_FOUND;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync io_connect_t port = (io_connect_t)0;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync kern_return_t kr = IOServiceOpen(service, mach_task_self(), 0, &port);
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync IOObjectRelease(service);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (kr != kIOReturnSuccess)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return RTErrConvertFromDarwin(kr);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync AppleSMCBuffer inputStruct = { 0, {0}, 32, {0}, 5, };
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync AppleSMCBuffer outputStruct;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync size_t cbOutputStruct = sizeof(outputStruct);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync for (int i = 0; i < 2; i++)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync inputStruct.key = (uint32_t)((i == 0) ? 'OSK0' : 'OSK1');
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync kr = IOConnectCallStructMethod((mach_port_t)port,
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync (uint32_t)2,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync (const void *)&inputStruct,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync sizeof(inputStruct),
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync (void *)&outputStruct,
1969e98a26e5b56b67fbe3b6bfa007f8f09e86ebvboxsync &cbOutputStruct);
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync if (kr != kIOReturnSuccess)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync IOServiceClose(port);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return RTErrConvertFromDarwin(kr);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync }
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync for (int j = 0; j < 32; j++)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync pabKey[j + i*32] = outputStruct.data[j];
0c94a8282c9042b02f022302a3d987746140eab9vboxsync }
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync IOServiceClose(port);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync pabKey[64] = 0;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync return VINF_SUCCESS;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync}
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#endif /* RT_OS_DARWIN */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync/* Darwin compile kludge */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#undef PVM
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync/* Comment out the following line to remove VMWare compatibility hack. */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#define VMWARE_NET_IN_SLOT_11
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync/**
0c94a8282c9042b02f022302a3d987746140eab9vboxsync * Translate IDE StorageControllerType_T to string representation.
0c94a8282c9042b02f022302a3d987746140eab9vboxsync */
0c94a8282c9042b02f022302a3d987746140eab9vboxsyncconst char* controllerString(StorageControllerType_T enmType)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync{
0c94a8282c9042b02f022302a3d987746140eab9vboxsync switch (enmType)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync {
0c94a8282c9042b02f022302a3d987746140eab9vboxsync case StorageControllerType_PIIX3:
0c94a8282c9042b02f022302a3d987746140eab9vboxsync return "PIIX3";
0c94a8282c9042b02f022302a3d987746140eab9vboxsync case StorageControllerType_PIIX4:
0c94a8282c9042b02f022302a3d987746140eab9vboxsync return "PIIX4";
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync case StorageControllerType_ICH6:
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return "ICH6";
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync default:
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return "Unknown";
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync}
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync/**
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * Simple class for storing network boot information.
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncstruct BootNic
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync{
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync ULONG mInstance;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync unsigned mPciDev;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync unsigned mPciFn;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync ULONG mBootPrio;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync bool operator < (const BootNic &rhs) const
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync ULONG lval = mBootPrio - 1; /* 0 will wrap around and get the lowest priority. */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync ULONG rval = rhs.mBootPrio - 1;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync return lval < rval; /* Zero compares as highest number (lowest prio). */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync};
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync/*
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * VC++ 8 / amd64 has some serious trouble with this function.
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * As a temporary measure, we'll drop global optimizations.
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#if defined(_MSC_VER) && defined(RT_ARCH_AMD64)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync# pragma optimize("g", off)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#endif
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncstatic int findEfiRom(IVirtualBox* vbox, FirmwareType_T aFirmwareType, Utf8Str& aEfiRomFile)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync{
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync int rc;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync BOOL fPresent = FALSE;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync Bstr aFilePath, empty;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync rc = vbox->CheckFirmwarePresent(aFirmwareType, empty.raw(),
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync empty.asOutParam(), aFilePath.asOutParam(), &fPresent);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (RT_FAILURE(rc))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync AssertComRCReturn(rc, VERR_FILE_NOT_FOUND);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (!fPresent)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return VERR_FILE_NOT_FOUND;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync aEfiRomFile = Utf8Str(aFilePath);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return S_OK;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync}
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncstatic int getSmcDeviceKey(IMachine *pMachine, BSTR *aKey, bool *pfGetKeyFromRealSMC)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync{
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync *pfGetKeyFromRealSMC = false;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /*
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * The extra data takes precedence (if non-zero).
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync HRESULT hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/SmcDeviceKey").raw(),
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync aKey);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (FAILED(hrc))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return Global::vboxStatusCodeFromCOM(hrc);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if ( SUCCEEDED(hrc)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync && *aKey
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync && **aKey)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return VINF_SUCCESS;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#ifdef RT_OS_DARWIN
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /*
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * Query it here and now.
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync char abKeyBuf[65];
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync int rc = DarwinSmcKey(abKeyBuf, sizeof(abKeyBuf));
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (SUCCEEDED(rc))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync Bstr(abKeyBuf).detachTo(aKey);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return rc;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync LogRel(("Warning: DarwinSmcKey failed with rc=%Rrc!\n", rc));
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#else
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /*
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * Is it apple hardware in bootcamp?
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /** @todo implement + test RTSYSDMISTR_MANUFACTURER on all hosts.
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * Currently falling back on the product name. */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync char szManufacturer[256];
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync szManufacturer[0] = '\0';
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTSystemQueryDmiString(RTSYSDMISTR_MANUFACTURER, szManufacturer, sizeof(szManufacturer));
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (szManufacturer[0] != '\0')
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if ( !strcmp(szManufacturer, "Apple Computer, Inc.")
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync || !strcmp(szManufacturer, "Apple Inc.")
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync )
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync *pfGetKeyFromRealSMC = true;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync else
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync char szProdName[256];
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync szProdName[0] = '\0';
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTSystemQueryDmiString(RTSYSDMISTR_PRODUCT_NAME, szProdName, sizeof(szProdName));
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if ( ( !strncmp(szProdName, "Mac", 3)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync || !strncmp(szProdName, "iMac", 4)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync || !strncmp(szProdName, "iMac", 4)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync || !strncmp(szProdName, "Xserve", 6)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync )
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync && !strchr(szProdName, ' ') /* no spaces */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync && RT_C_IS_DIGIT(szProdName[strlen(szProdName) - 1]) /* version number */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync )
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync *pfGetKeyFromRealSMC = true;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync int rc = VINF_SUCCESS;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return rc;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync}
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncclass ConfigError : public iprt::Error
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync{
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncpublic:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ConfigError(const char *pcszFunction,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync int vrc,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync const char *pcszName)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync : iprt::Error(Utf8StrFmt("%s failed: rc=%Rrc, pcszName=%s", pcszFunction, vrc, pcszName)),
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync m_vrc(vrc)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync AssertMsgFailed(("%s\n", what())); // in strict mode, hit a breakpoint here
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync int m_vrc;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync};
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync/**
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * Helper that calls CFGMR3InsertString and throws an iprt::Error if that
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * fails (C-string variant).
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * @param pParent See CFGMR3InsertStringN.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * @param pcszNodeName See CFGMR3InsertStringN.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * @param pcszValue The string value.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncstatic void InsertConfigString(PCFGMNODE pNode,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync const char *pcszName,
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync const char *pcszValue)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync{
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync int vrc = CFGMR3InsertString(pNode,
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync pcszName,
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync pcszValue);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (RT_FAILURE(vrc))
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync throw ConfigError("CFGMR3InsertString", vrc, pcszName);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync}
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync/**
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * Helper that calls CFGMR3InsertString and throws an iprt::Error if that
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * fails (Utf8Str variant).
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * @param pParent See CFGMR3InsertStringN.
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * @param pcszNodeName See CFGMR3InsertStringN.
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * @param rStrValue The string value.
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncstatic void InsertConfigString(PCFGMNODE pNode,
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync const char *pcszName,
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync const Utf8Str &rStrValue)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync{
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync int vrc = CFGMR3InsertStringN(pNode,
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync pcszName,
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync rStrValue.c_str(),
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync rStrValue.length());
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (RT_FAILURE(vrc))
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync throw ConfigError("CFGMR3InsertStringLengthKnown", vrc, pcszName);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync}
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync/**
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * Helper that calls CFGMR3InsertString and throws an iprt::Error if that
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * fails (Bstr variant).
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync *
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * @param pParent See CFGMR3InsertStringN.
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * @param pcszNodeName See CFGMR3InsertStringN.
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * @param rBstrValue The string value.
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncstatic void InsertConfigString(PCFGMNODE pNode,
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync const char *pcszName,
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync const Bstr &rBstrValue)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync{
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigString(pNode, pcszName, Utf8Str(rBstrValue));
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync}
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync/**
0c94a8282c9042b02f022302a3d987746140eab9vboxsync * Helper that calls CFGMR3InsertBytes and throws an iprt::Error if that fails.
0c94a8282c9042b02f022302a3d987746140eab9vboxsync *
0c94a8282c9042b02f022302a3d987746140eab9vboxsync * @param pNode See CFGMR3InsertBytes.
0c94a8282c9042b02f022302a3d987746140eab9vboxsync * @param pcszName See CFGMR3InsertBytes.
0c94a8282c9042b02f022302a3d987746140eab9vboxsync * @param pvBytes See CFGMR3InsertBytes.
0c94a8282c9042b02f022302a3d987746140eab9vboxsync * @param cbBytes See CFGMR3InsertBytes.
0c94a8282c9042b02f022302a3d987746140eab9vboxsync */
0c94a8282c9042b02f022302a3d987746140eab9vboxsyncstatic void InsertConfigBytes(PCFGMNODE pNode,
0c94a8282c9042b02f022302a3d987746140eab9vboxsync const char *pcszName,
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync const void *pvBytes,
0c94a8282c9042b02f022302a3d987746140eab9vboxsync size_t cbBytes)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync{
0c94a8282c9042b02f022302a3d987746140eab9vboxsync int vrc = CFGMR3InsertBytes(pNode,
0c94a8282c9042b02f022302a3d987746140eab9vboxsync pcszName,
0c94a8282c9042b02f022302a3d987746140eab9vboxsync pvBytes,
0c94a8282c9042b02f022302a3d987746140eab9vboxsync cbBytes);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync if (RT_FAILURE(vrc))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync throw ConfigError("CFGMR3InsertBytes", vrc, pcszName);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync}
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync/**
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * Helper that calls CFGMR3InsertInteger and throws an iprt::Error if that
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * fails.
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync *
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * @param pNode See CFGMR3InsertInteger.
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * @param pcszName See CFGMR3InsertInteger.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * @param u64Integer See CFGMR3InsertInteger.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncstatic void InsertConfigInteger(PCFGMNODE pNode,
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync const char *pcszName,
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync uint64_t u64Integer)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync{
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync int vrc = CFGMR3InsertInteger(pNode,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync pcszName,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync u64Integer);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (RT_FAILURE(vrc))
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync throw ConfigError("CFGMR3InsertInteger", vrc, pcszName);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync}
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync/**
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * Helper that calls CFGMR3InsertNode and throws an iprt::Error if that fails.
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync *
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * @param pNode See CFGMR3InsertNode.
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * @param pcszName See CFGMR3InsertNode.
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * @param ppChild See CFGMR3InsertNode.
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncstatic void InsertConfigNode(PCFGMNODE pNode,
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync const char *pcszName,
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync PCFGMNODE *ppChild)
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync{
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync int vrc = CFGMR3InsertNode(pNode, pcszName, ppChild);
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync if (RT_FAILURE(vrc))
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync throw ConfigError("CFGMR3InsertNode", vrc, pcszName);
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync}
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync/**
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync * Helper that calls CFGMR3RemoveValue and throws an iprt::Error if that fails.
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync *
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync * @param pNode See CFGMR3RemoveValue.
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync * @param pcszName See CFGMR3RemoveValue.
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsyncstatic void RemoveConfigValue(PCFGMNODE pNode,
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync const char *pcszName)
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync{
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync int vrc = CFGMR3RemoveValue(pNode, pcszName);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if (RT_FAILURE(vrc))
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync throw ConfigError("CFGMR3RemoveValue", vrc, pcszName);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync}
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync/**
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync * Construct the VM configuration tree (CFGM).
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync *
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync * This is a callback for VMR3Create() call. It is called from CFGMR3Init()
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync * in the emulation thread (EMT). Any per thread COM/XPCOM initialization
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync * is done here.
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync *
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync * @param pVM VM handle.
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync * @param pvConsole Pointer to the VMPowerUpTask object.
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync * @return VBox status code.
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync *
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync * @note Locks the Console object for writing.
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync */
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsyncDECLCALLBACK(int) Console::configConstructor(PVM pVM, void *pvConsole)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync{
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync LogFlowFuncEnter();
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync PciBusAddress PciAddr;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync bool fFdcEnabled = false;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync BOOL fIs64BitGuest = false;
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync#if !defined(VBOX_WITH_XPCOM)
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync {
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync /* initialize COM */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync HRESULT hrc = CoInitializeEx(NULL,
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE |
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync COINIT_SPEED_OVER_MEMORY);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync LogFlow(("Console::configConstructor(): CoInitializeEx()=%08X\n", hrc));
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync AssertComRCReturn(hrc, VERR_GENERAL_FAILURE);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync#endif
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync AssertReturn(pvConsole, VERR_GENERAL_FAILURE);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync ComObjPtr<Console> pConsole = static_cast<Console *>(pvConsole);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync AutoCaller autoCaller(pConsole);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync /* lock the console because we widely use internal fields and methods */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync AutoWriteLock alock(pConsole COMMA_LOCKVAL_SRC_POS);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync /* Save the VM pointer in the machine object */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync pConsole->mpVM = pVM;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync VMMDev *pVMMDev = pConsole->m_pVMMDev;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync Assert(pVMMDev);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync ComPtr<IMachine> pMachine = pConsole->machine();
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync int rc;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync HRESULT hrc;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync Bstr bstr;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#define H() AssertMsgReturn(!FAILED(hrc), ("hrc=%Rhrc\n", hrc), VERR_GENERAL_FAILURE)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync /*
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * Get necessary objects and frequently used parameters.
0c94a8282c9042b02f022302a3d987746140eab9vboxsync */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync ComPtr<IVirtualBox> virtualBox;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync hrc = pMachine->COMGETTER(Parent)(virtualBox.asOutParam()); H();
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync ComPtr<IHost> host;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync hrc = virtualBox->COMGETTER(Host)(host.asOutParam()); H();
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync ComPtr<ISystemProperties> systemProperties;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync hrc = virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam()); H();
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync ComPtr<IBIOSSettings> biosSettings;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync hrc = pMachine->COMGETTER(BIOSSettings)(biosSettings.asOutParam()); H();
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync hrc = pMachine->COMGETTER(HardwareUUID)(bstr.asOutParam()); H();
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTUUID HardwareUuid;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync rc = RTUuidFromUtf16(&HardwareUuid, bstr.raw());
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync AssertMsgReturn(RT_SUCCESS(rc), ("rc=%Rrc\n", rc), rc);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync ULONG cRamMBs;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync hrc = pMachine->COMGETTER(MemorySize)(&cRamMBs); H();
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#if 0 /* enable to play with lots of memory. */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (RTEnvExist("VBOX_RAM_SIZE"))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync cRamMBs = RTStrToUInt64(RTEnvGet("VBOX_RAM_SIZE"));
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync#endif
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync uint64_t const cbRam = cRamMBs * (uint64_t)_1M;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync uint32_t cbRamHole = MM_RAM_HOLE_SIZE_DEFAULT;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync uint64_t u64McfgBase = 0;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync uint32_t u32McfgLength = 0;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync ChipsetType_T chipsetType;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync hrc = pMachine->COMGETTER(ChipsetType)(&chipsetType); H();
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (chipsetType == ChipsetType_ICH9)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync {
0c94a8282c9042b02f022302a3d987746140eab9vboxsync /* We'd better have 0x10000000 region, to cover 256 buses
0c94a8282c9042b02f022302a3d987746140eab9vboxsync but this put too much load on hypervisor heap */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync u32McfgLength = 0x4000000; //0x10000000;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync cbRamHole += u32McfgLength;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync u64McfgBase = _4G - cbRamHole;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync }
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync ComPtr<BusAssignmentManager> BusMgr =
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync BusAssignmentManager::getInstance(chipsetType);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync ULONG cCpus = 1;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync hrc = pMachine->COMGETTER(CPUCount)(&cCpus); H();
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync ULONG ulCpuExecutionCap = 100;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync hrc = pMachine->COMGETTER(CPUExecutionCap)(&ulCpuExecutionCap); H();
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync Bstr osTypeId;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync hrc = pMachine->COMGETTER(OSTypeId)(osTypeId.asOutParam()); H();
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync BOOL fIOAPIC;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync hrc = biosSettings->COMGETTER(IOAPICEnabled)(&fIOAPIC); H();
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync ComPtr<IGuestOSType> guestOSType;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync hrc = virtualBox->GetGuestOSType(osTypeId.raw(), guestOSType.asOutParam()); H();
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync Bstr guestTypeFamilyId;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync hrc = guestOSType->COMGETTER(FamilyId)(guestTypeFamilyId.asOutParam()); H();
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync BOOL fOsXGuest = guestTypeFamilyId == Bstr("MacOS");
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /*
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * Get root node first.
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * This is the only node in the tree.
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync PCFGMNODE pRoot = CFGMR3GetRoot(pVM);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync Assert(pRoot);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync // InsertConfigString throws
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync try
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /*
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * Set the root (and VMM) level values.
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync hrc = pMachine->COMGETTER(Name)(bstr.asOutParam()); H();
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigString(pRoot, "Name", bstr);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigBytes(pRoot, "UUID", &HardwareUuid, sizeof(HardwareUuid));
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigInteger(pRoot, "RamSize", cbRam);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigInteger(pRoot, "RamHoleSize", cbRamHole);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigInteger(pRoot, "NumCPUs", cCpus);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigInteger(pRoot, "CpuExecutionCap", ulCpuExecutionCap);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigInteger(pRoot, "TimerMillies", 10);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#ifdef VBOX_WITH_RAW_MODE
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigInteger(pRoot, "RawR3Enabled", 1); /* boolean */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigInteger(pRoot, "RawR0Enabled", 1); /* boolean */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /** @todo Config: RawR0, PATMEnabled and CSAMEnabled needs attention later. */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigInteger(pRoot, "PATMEnabled", 1); /* boolean */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigInteger(pRoot, "CSAMEnabled", 1); /* boolean */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#endif
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /* Not necessary, but to make sure these two settings end up in the release log. */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync BOOL fPageFusion = FALSE;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync hrc = pMachine->COMGETTER(PageFusionEnabled)(&fPageFusion); H();
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigInteger(pRoot, "PageFusion", fPageFusion); /* boolean */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync ULONG ulBalloonSize = 0;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync hrc = pMachine->COMGETTER(MemoryBalloonSize)(&ulBalloonSize); H();
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigInteger(pRoot, "MemBalloonSize", ulBalloonSize);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /*
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * CPUM values.
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync PCFGMNODE pCPUM;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigNode(pRoot, "CPUM", &pCPUM);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync /* cpuid leaf overrides. */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync static uint32_t const s_auCpuIdRanges[] =
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync UINT32_C(0x00000000), UINT32_C(0x0000000a),
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync UINT32_C(0x80000000), UINT32_C(0x8000000a)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync };
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync for (unsigned i = 0; i < RT_ELEMENTS(s_auCpuIdRanges); i += 2)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync for (uint32_t uLeaf = s_auCpuIdRanges[i]; uLeaf < s_auCpuIdRanges[i + 1]; uLeaf++)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync ULONG ulEax, ulEbx, ulEcx, ulEdx;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync hrc = pMachine->GetCPUIDLeaf(uLeaf, &ulEax, &ulEbx, &ulEcx, &ulEdx);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (SUCCEEDED(hrc))
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync PCFGMNODE pLeaf;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pCPUM, Utf8StrFmt("HostCPUID/%RX32", uLeaf).c_str(), &pLeaf);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigInteger(pLeaf, "eax", ulEax);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigInteger(pLeaf, "ebx", ulEbx);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pLeaf, "ecx", ulEcx);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigInteger(pLeaf, "edx", ulEdx);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync else if (hrc != E_INVALIDARG) H();
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /* We must limit CPUID count for Windows NT 4, as otherwise it stops
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync with error 0x3e (MULTIPROCESSOR_CONFIGURATION_NOT_SUPPORTED). */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (osTypeId == "WindowsNT4")
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync LogRel(("Limiting CPUID leaf count for NT4 guests\n"));
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigInteger(pCPUM, "NT4LeafLimit", true);
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync }
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /* Expose extended MWAIT features to Mac OS X guests. */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync if (fOsXGuest)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync LogRel(("Using MWAIT extensions\n"));
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigInteger(pCPUM, "MWaitExtensions", true);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync /*
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * Hardware virtualization extensions.
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync BOOL fHWVirtExEnabled;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync BOOL fHwVirtExtForced = false;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#ifdef VBOX_WITH_RAW_MODE
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_Enabled, &fHWVirtExEnabled); H();
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (cCpus > 1) /** @todo SMP: This isn't nice, but things won't work on mac otherwise. */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync fHWVirtExEnabled = TRUE;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync# ifdef RT_OS_DARWIN
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync fHwVirtExtForced = fHWVirtExEnabled;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync# else
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync /* - With more than 4GB PGM will use different RAMRANGE sizes for raw
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync mode and hv mode to optimize lookup times.
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync - With more than one virtual CPU, raw-mode isn't a fallback option. */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync fHwVirtExtForced = fHWVirtExEnabled
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync && ( cbRam + cbRamHole > _4G
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync || cCpus > 1);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync# endif
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#else /* !VBOX_WITH_RAW_MODE */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync fHWVirtExEnabled = fHwVirtExtForced = true;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#endif /* !VBOX_WITH_RAW_MODE */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync /* only honor the property value if there was no other reason to enable it */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (!fHwVirtExtForced)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_Force, &fHwVirtExtForced); H();
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigInteger(pRoot, "HwVirtExtForced", fHwVirtExtForced);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync /*
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * MM values.
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync PCFGMNODE pMM;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigNode(pRoot, "MM", &pMM);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigInteger(pMM, "CanUseLargerHeap", chipsetType == ChipsetType_ICH9);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /*
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * Hardware virtualization settings.
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync PCFGMNODE pHWVirtExt;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigNode(pRoot, "HWVirtExt", &pHWVirtExt);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (fHWVirtExEnabled)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigInteger(pHWVirtExt, "Enabled", 1);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync /* Indicate whether 64-bit guests are supported or not. */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync /** @todo This is currently only forced off on 32-bit hosts only because it
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * makes a lof of difference there (REM and Solaris performance).
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync */
9c9db71d639cf066ed41d49629d46d48bff4be2fvboxsync BOOL fSupportsLongMode = false;
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync hrc = host->GetProcessorFeature(ProcessorFeature_LongMode,
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync &fSupportsLongMode); H();
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync hrc = guestOSType->COMGETTER(Is64Bit)(&fIs64BitGuest); H();
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (fSupportsLongMode && fIs64BitGuest)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigInteger(pHWVirtExt, "64bitEnabled", 1);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#if ARCH_BITS == 32 /* The recompiler must use VBoxREM64 (32-bit host only). */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync PCFGMNODE pREM;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync InsertConfigNode(pRoot, "REM", &pREM);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigInteger(pREM, "64bitEnabled", 1);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#endif
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#if ARCH_BITS == 32 /* 32-bit guests only. */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync else
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigInteger(pHWVirtExt, "64bitEnabled", 0);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#endif
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync /** @todo Not exactly pretty to check strings; VBOXOSTYPE would be better, but that requires quite a bit of API change in Main. */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if ( !fIs64BitGuest
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync && fIOAPIC
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync && ( osTypeId == "WindowsNT4"
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync || osTypeId == "Windows2000"
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync || osTypeId == "WindowsXP"
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync || osTypeId == "Windows2003"))
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync /* Only allow TPR patching for NT, Win2k, XP and Windows Server 2003. (32 bits mode)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * We may want to consider adding more guest OSes (Solaris) later on.
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigInteger(pHWVirtExt, "TPRPatchingEnabled", 1);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync /* HWVirtEx exclusive mode */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync BOOL fHWVirtExExclusive = true;
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_Exclusive, &fHWVirtExExclusive); H();
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigInteger(pHWVirtExt, "Exclusive", fHWVirtExExclusive);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync /* Nested paging (VT-x/AMD-V) */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync BOOL fEnableNestedPaging = false;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_NestedPaging, &fEnableNestedPaging); H();
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigInteger(pHWVirtExt, "EnableNestedPaging", fEnableNestedPaging);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync /* Large pages; requires nested paging */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync BOOL fEnableLargePages = false;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_LargePages, &fEnableLargePages); H();
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigInteger(pHWVirtExt, "EnableLargePages", fEnableLargePages);
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync /* VPID (VT-x) */
9c9db71d639cf066ed41d49629d46d48bff4be2fvboxsync BOOL fEnableVPID = false;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_VPID, &fEnableVPID); H();
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync InsertConfigInteger(pHWVirtExt, "EnableVPID", fEnableVPID);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync /* Physical Address Extension (PAE) */
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync BOOL fEnablePAE = false;
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync hrc = pMachine->GetCPUProperty(CPUPropertyType_PAE, &fEnablePAE); H();
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync InsertConfigInteger(pRoot, "EnablePAE", fEnablePAE);
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync /* Synthetic CPU */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync BOOL fSyntheticCpu = false;
9c9db71d639cf066ed41d49629d46d48bff4be2fvboxsync hrc = pMachine->GetCPUProperty(CPUPropertyType_Synthetic, &fSyntheticCpu); H();
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync InsertConfigInteger(pRoot, "SyntheticCpu", fSyntheticCpu);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync BOOL fPXEDebug;
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync hrc = biosSettings->COMGETTER(PXEDebugEnabled)(&fPXEDebug); H();
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync /*
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync * PDM config.
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * Load drivers in VBoxC.[so|dll]
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync */
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync PCFGMNODE pPDM;
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync PCFGMNODE pDrivers;
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync PCFGMNODE pMod;
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync InsertConfigNode(pRoot, "PDM", &pPDM);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigNode(pPDM, "Drivers", &pDrivers);
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync InsertConfigNode(pDrivers, "VBoxC", &pMod);
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync#ifdef VBOX_WITH_XPCOM
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync // VBoxC is located in the components subdirectory
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync char szPathVBoxC[RTPATH_MAX];
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync rc = RTPathAppPrivateArch(szPathVBoxC, RTPATH_MAX - sizeof("/components/VBoxC")); AssertRC(rc);
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync strcat(szPathVBoxC, "/components/VBoxC");
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync InsertConfigString(pMod, "Path", szPathVBoxC);
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync#else
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync InsertConfigString(pMod, "Path", "VBoxC");
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync#endif
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync /*
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync * I/O settings (cache, max bandwidth, ...).
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync */
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync PCFGMNODE pPDMAc;
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync PCFGMNODE pPDMAcFile;
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync InsertConfigNode(pPDM, "AsyncCompletion", &pPDMAc);
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync InsertConfigNode(pPDMAc, "File", &pPDMAcFile);
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync /* Builtin I/O cache */
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync BOOL fIoCache = true;
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync hrc = pMachine->COMGETTER(IoCacheEnabled)(&fIoCache); H();
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync InsertConfigInteger(pPDMAcFile, "CacheEnabled", fIoCache);
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync /* I/O cache size */
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync ULONG ioCacheSize = 5;
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync hrc = pMachine->COMGETTER(IoCacheSize)(&ioCacheSize); H();
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync InsertConfigInteger(pPDMAcFile, "CacheSize", ioCacheSize * _1M);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync /*
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * Devices
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync PCFGMNODE pDevices = NULL; /* /Devices */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync PCFGMNODE pDev = NULL; /* /Devices/Dev/ */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync PCFGMNODE pInst = NULL; /* /Devices/Dev/0/ */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync PCFGMNODE pCfg = NULL; /* /Devices/Dev/.../Config/ */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PCFGMNODE pLunL0 = NULL; /* /Devices/Dev/0/LUN#0/ */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PCFGMNODE pLunL1 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/ */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PCFGMNODE pLunL2 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/Config/ */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PCFGMNODE pBiosCfg = NULL; /* /Devices/pcbios/0/Config/ */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PCFGMNODE pNetBootCfg = NULL; /* /Devices/pcbios/0/Config/NetBoot/ */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pRoot, "Devices", &pDevices);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * PC Arch.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDevices, "pcarch", &pDev);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDev, "0", &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * The time offset
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync LONG64 timeOffset;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = biosSettings->COMGETTER(TimeOffset)(&timeOffset); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PCFGMNODE pTMNode;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pRoot, "TM", &pTMNode);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pTMNode, "UTCOffset", timeOffset * 1000000);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync /*
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * DMA
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pDevices, "8237A", &pDev);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pDev, "0", &pInst);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync /*
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * PCI buses.
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync uint32_t u32IocPciAddress, u32HbcPciAddress;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync switch (chipsetType)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync default:
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync Assert(false);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync case ChipsetType_PIIX3:
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pDevices, "pci", &pDev);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync u32HbcPciAddress = (0x0 << 16) | 0;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync u32IocPciAddress = (0x1 << 16) | 0; // ISA controller
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case ChipsetType_ICH9:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDevices, "ich9pci", &pDev);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync u32HbcPciAddress = (0x1e << 16) | 0;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync u32IocPciAddress = (0x1f << 16) | 0; // LPC controller
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync break;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pDev, "0", &pInst);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pInst, "Config", &pCfg);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pCfg, "IOAPIC", fIOAPIC);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (chipsetType == ChipsetType_ICH9)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync /* Provide MCFG info */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pCfg, "McfgBase", u64McfgBase);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pCfg, "McfgLength", u32McfgLength);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync /* And register 2 bridges */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pDevices, "ich9pcibridge", &pDev);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pDev, "0", &pInst);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync hrc = BusMgr->assignPciDevice("ich9pcibridge", pInst); H();
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pDev, "1", &pInst);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync hrc = BusMgr->assignPciDevice("ich9pcibridge", pInst); H();
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync#if 0 /* enable this to test PCI bridging */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pDevices, "pcibridge", &pDev);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pDev, "0", &pInst);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pInst, "Config", &pCfg);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pInst, "PCIDeviceNo", 14);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pInst, "PCIFunctionNo", 0);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync rc = CFGMR3InsertInteger(pInst, "PCIBusNo", 0);/* -> pci[0] */ RC_CHECK();
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync InsertConfigNode(pDev, "1", &pInst);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync InsertConfigNode(pInst, "Config", &pCfg);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pInst, "PCIDeviceNo", 1);
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync InsertConfigInteger(pInst, "PCIFunctionNo", 0);
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync rc = CFGMR3InsertInteger(pInst, "PCIBusNo", 1);/* ->pcibridge[0] */ RC_CHECK();
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync InsertConfigNode(pDev, "2", &pInst);
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pInst, "Config", &pCfg);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pInst, "PCIDeviceNo", 3);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pInst, "PCIFunctionNo", 0);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync rc = CFGMR3InsertInteger(pInst, "PCIBusNo", 1);/* ->pcibridge[0] */ RC_CHECK();
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync#endif
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync /*
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * Enable 3 following devices: HPET, SMC, LPC on MacOS X guests
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync /*
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync * High Precision Event Timer (HPET)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync BOOL fHpetEnabled;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync /* Other guests may wish to use HPET too, but MacOS X not functional without it */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync hrc = pMachine->COMGETTER(HpetEnabled)(&fHpetEnabled); H();
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync /* so always enable HPET in extended profile */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync fHpetEnabled |= fOsXGuest;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync /* HPET is always present on ICH9 */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync fHpetEnabled |= (chipsetType == ChipsetType_ICH9);
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync if (fHpetEnabled)
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync {
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync InsertConfigNode(pDevices, "hpet", &pDev);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pDev, "0", &pInst);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync /*
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync * System Management Controller (SMC)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync BOOL fSmcEnabled;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync fSmcEnabled = fOsXGuest;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if (fSmcEnabled)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync InsertConfigNode(pDevices, "smc", &pDev);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pDev, "0", &pInst);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pInst, "Config", &pCfg);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync bool fGetKeyFromRealSMC;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync Bstr bstrKey;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync rc = getSmcDeviceKey(pMachine, bstrKey.asOutParam(), &fGetKeyFromRealSMC);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync AssertMsgReturn(RT_SUCCESS(rc), ("rc=%Rrc\n", rc), rc);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigString(pCfg, "DeviceKey", bstrKey);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pCfg, "GetKeyFromRealSMC", fGetKeyFromRealSMC);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync /*
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * Low Pin Count (LPC) bus
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync BOOL fLpcEnabled;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync /** @todo: implement appropriate getter */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync fLpcEnabled = fOsXGuest || (chipsetType == ChipsetType_ICH9);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (fLpcEnabled)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pDevices, "lpc", &pDev);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pDev, "0", &pInst);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync hrc = BusMgr->assignPciDevice("lpc", pInst); H();
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
e70bda5438c3582164d26f171a8bc8d3d7da1e12vboxsync }
e70bda5438c3582164d26f171a8bc8d3d7da1e12vboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync /*
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * PS/2 keyboard & mouse.
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync */
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync InsertConfigNode(pDevices, "pckbd", &pDev);
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync InsertConfigNode(pDev, "0", &pInst);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigNode(pInst, "Config", &pCfg);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
e70bda5438c3582164d26f171a8bc8d3d7da1e12vboxsync InsertConfigString(pLunL0, "Driver", "KeyboardQueue");
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigInteger(pCfg, "QueueSize", 64);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigString(pLunL1, "Driver", "MainKeyboard");
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync InsertConfigNode(pLunL1, "Config", &pCfg);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync Keyboard *pKeyboard = pConsole->mKeyboard;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync InsertConfigInteger(pCfg, "Object", (uintptr_t)pKeyboard);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync InsertConfigNode(pInst, "LUN#1", &pLunL0);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync InsertConfigString(pLunL0, "Driver", "MouseQueue");
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync InsertConfigInteger(pCfg, "QueueSize", 128);
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync InsertConfigString(pLunL1, "Driver", "MainMouse");
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync InsertConfigNode(pLunL1, "Config", &pCfg);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync Mouse *pMouse = pConsole->mMouse;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync InsertConfigInteger(pCfg, "Object", (uintptr_t)pMouse);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync /*
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync * i8254 Programmable Interval Timer And Dummy Speaker
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync InsertConfigNode(pDevices, "i8254", &pDev);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync InsertConfigNode(pDev, "0", &pInst);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync InsertConfigNode(pInst, "Config", &pCfg);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync#ifdef DEBUG
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync#endif
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync /*
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync * i8259 Programmable Interrupt Controller.
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pDevices, "i8259", &pDev);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync InsertConfigNode(pDev, "0", &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * Advanced Programmable Interrupt Controller.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * SMP: Each CPU has a LAPIC, but we have a single device representing all LAPICs states,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * thus only single insert
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDevices, "apic", &pDev);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDev, "0", &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "IOAPIC", fIOAPIC);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "NumCPUs", cCpus);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (fIOAPIC)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * I/O Advanced Programmable Interrupt Controller.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDevices, "ioapic", &pDev);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pDev, "0", &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * RTC MC146818.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDevices, "mc146818", &pDev);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDev, "0", &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync BOOL fRTCUseUTC;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = pMachine->COMGETTER(RTCUseUTC)(&fRTCUseUTC); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "UseUTC", fRTCUseUTC ? 1 : 0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * VGA.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDevices, "vga", &pDev);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDev, "0", &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = BusMgr->assignPciDevice("vga", pInst); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ULONG cVRamMBs;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = pMachine->COMGETTER(VRAMSize)(&cVRamMBs); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "VRamSize", cVRamMBs * _1M);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ULONG cMonitorCount;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = pMachine->COMGETTER(MonitorCount)(&cMonitorCount); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "MonitorCount", cMonitorCount);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "R0Enabled", fHWVirtExEnabled);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * BIOS logo
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync BOOL fFadeIn;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = biosSettings->COMGETTER(LogoFadeIn)(&fFadeIn); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "FadeIn", fFadeIn ? 1 : 0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync BOOL fFadeOut;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = biosSettings->COMGETTER(LogoFadeOut)(&fFadeOut); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "FadeOut", fFadeOut ? 1: 0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ULONG logoDisplayTime;
8f7ee9e453c60b3b699799538a45950b35266665vboxsync hrc = biosSettings->COMGETTER(LogoDisplayTime)(&logoDisplayTime); H();
8f7ee9e453c60b3b699799538a45950b35266665vboxsync InsertConfigInteger(pCfg, "LogoTime", logoDisplayTime);
8f7ee9e453c60b3b699799538a45950b35266665vboxsync Bstr logoImagePath;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = biosSettings->COMGETTER(LogoImagePath)(logoImagePath.asOutParam()); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pCfg, "LogoFile", Utf8Str(!logoImagePath.isEmpty() ? logoImagePath : "") );
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * Boot menu
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync BIOSBootMenuMode_T eBootMenuMode;
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync int iShowBootMenu;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync biosSettings->COMGETTER(BootMenuMode)(&eBootMenuMode);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync switch (eBootMenuMode)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case BIOSBootMenuMode_Disabled: iShowBootMenu = 0; break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case BIOSBootMenuMode_MenuOnly: iShowBootMenu = 1; break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync default: iShowBootMenu = 2; break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "ShowBootMenu", iShowBootMenu);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* Custom VESA mode list */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync unsigned cModes = 0;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync for (unsigned iMode = 1; iMode <= 16; ++iMode)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync char szExtraDataKey[sizeof("CustomVideoModeXX")];
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTStrPrintf(szExtraDataKey, sizeof(szExtraDataKey), "CustomVideoMode%u", iMode);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = pMachine->GetExtraData(Bstr(szExtraDataKey).raw(), bstr.asOutParam()); H();
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (bstr.isEmpty())
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync break;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigString(pCfg, szExtraDataKey, bstr);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync ++cModes;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigInteger(pCfg, "CustomVideoModes", cModes);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync /* VESA height reduction */
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync ULONG ulHeightReduction;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync IFramebuffer *pFramebuffer = pConsole->getDisplay()->getFramebuffer();
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (pFramebuffer)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync {
8f7ee9e453c60b3b699799538a45950b35266665vboxsync hrc = pFramebuffer->COMGETTER(HeightReduction)(&ulHeightReduction); H();
8f7ee9e453c60b3b699799538a45950b35266665vboxsync }
8f7ee9e453c60b3b699799538a45950b35266665vboxsync else
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync {
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync /* If framebuffer is not available, there is no height reduction. */
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync ulHeightReduction = 0;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigInteger(pCfg, "HeightReduction", ulHeightReduction);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync /* Attach the display. */
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigString(pLunL0, "Driver", "MainDisplay");
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync Display *pDisplay = pConsole->mDisplay;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigInteger(pCfg, "Object", (uintptr_t)pDisplay);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync /*
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync * Firmware.
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync */
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync FirmwareType_T eFwType = FirmwareType_BIOS;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync hrc = pMachine->COMGETTER(FirmwareType)(&eFwType); H();
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync#ifdef VBOX_WITH_EFI
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync BOOL fEfiEnabled = (eFwType >= FirmwareType_EFI) && (eFwType <= FirmwareType_EFIDUAL);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync#else
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync BOOL fEfiEnabled = false;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (!fEfiEnabled)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * PC Bios.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDevices, "pcbios", &pDev);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDev, "0", &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "Config", &pBiosCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pBiosCfg, "RamSize", cbRam);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pBiosCfg, "RamHoleSize", cbRamHole);
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync InsertConfigInteger(pBiosCfg, "NumCPUs", cCpus);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pBiosCfg, "HardDiskDevice", "piix3ide");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pBiosCfg, "FloppyDevice", "i82078");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pBiosCfg, "IOAPIC", fIOAPIC);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pBiosCfg, "PXEDebug", fPXEDebug);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigBytes(pBiosCfg, "UUID", &HardwareUuid,sizeof(HardwareUuid));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pBiosCfg, "NetBoot", &pNetBootCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync DeviceType_T bootDevice;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SchemaDefs::MaxBootPosition > 9)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync AssertMsgFailed(("Too many boot devices %d\n",
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync SchemaDefs::MaxBootPosition));
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return VERR_INVALID_PARAMETER;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync for (ULONG pos = 1; pos <= SchemaDefs::MaxBootPosition; ++pos)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync hrc = pMachine->GetBootOrder(pos, &bootDevice); H();
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync char szParamName[] = "BootDeviceX";
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync szParamName[sizeof(szParamName) - 2] = ((char (pos - 1)) + '0');
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync const char *pszBootDevice;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync switch (bootDevice)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync {
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync case DeviceType_Null:
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync pszBootDevice = "NONE";
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync break;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync case DeviceType_HardDisk:
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync pszBootDevice = "IDE";
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync break;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync case DeviceType_DVD:
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync pszBootDevice = "DVD";
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case DeviceType_Floppy:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync pszBootDevice = "FLOPPY";
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case DeviceType_Network:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync pszBootDevice = "LAN";
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync default:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync AssertMsgFailed(("Invalid bootDevice=%d\n", bootDevice));
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync N_("Invalid boot device '%d'"), bootDevice);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pBiosCfg, szParamName, pszBootDevice);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Utf8Str efiRomFile;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* Autodetect firmware type, basing on guest type */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (eFwType == FirmwareType_EFI)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync eFwType =
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync fIs64BitGuest ?
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync (FirmwareType_T)FirmwareType_EFI64
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync :
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync (FirmwareType_T)FirmwareType_EFI32;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync bool f64BitEntry = eFwType == FirmwareType_EFI64;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = findEfiRom(virtualBox, eFwType, efiRomFile);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync AssertMsgReturn(RT_SUCCESS(rc), ("rc=%Rrc\n", rc), rc);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* Get boot args */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Bstr bootArgs;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiBootArgs").raw(), bootArgs.asOutParam()); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* Get device props */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Bstr deviceProps;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiDeviceProps").raw(), deviceProps.asOutParam()); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* Get GOP mode settings */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint32_t u32GopMode = UINT32_MAX;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiGopMode").raw(), bstr.asOutParam()); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (!bstr.isEmpty())
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync u32GopMode = Utf8Str(bstr).toUInt32();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* UGA mode settings */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint32_t u32UgaHorisontal = 0;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiUgaHorizontalResolution").raw(), bstr.asOutParam()); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (!bstr.isEmpty())
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync u32UgaHorisontal = Utf8Str(bstr).toUInt32();
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint32_t u32UgaVertical = 0;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiUgaVerticalResolution").raw(), bstr.asOutParam()); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (!bstr.isEmpty())
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync u32UgaVertical = Utf8Str(bstr).toUInt32();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * EFI subtree.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDevices, "efi", &pDev);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDev, "0", &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "RamSize", cbRam);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "RamHoleSize", cbRamHole);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "NumCPUs", cCpus);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pCfg, "EfiRom", efiRomFile);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pCfg, "BootArgs", bootArgs);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pCfg, "DeviceProps", deviceProps);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "IOAPIC", fIOAPIC);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync InsertConfigBytes(pCfg, "UUID", &HardwareUuid,sizeof(HardwareUuid));
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync InsertConfigInteger(pCfg, "64BitEntry", f64BitEntry); /* boolean */
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync InsertConfigInteger(pCfg, "GopMode", u32GopMode);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync InsertConfigInteger(pCfg, "UgaHorizontalResolution", u32UgaHorisontal);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync InsertConfigInteger(pCfg, "UgaVerticalResolution", u32UgaVertical);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync /* For OS X guests we'll force passing host's DMI info to the guest */
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync if (fOsXGuest)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync {
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync InsertConfigInteger(pCfg, "DmiUseHostInfo", 1);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync InsertConfigInteger(pCfg, "DmiExposeMemoryTable", 1);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync /*
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync * Storage controllers.
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync */
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync com::SafeIfaceArray<IStorageController> ctrls;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync PCFGMNODE aCtrlNodes[StorageControllerType_LsiLogicSas + 1] = {};
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync hrc = pMachine->COMGETTER(StorageControllers)(ComSafeArrayAsOutParam(ctrls)); H();
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync for (size_t i = 0; i < ctrls.size(); ++i)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync {
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync DeviceType_T *paLedDevType = NULL;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync StorageControllerType_T enmCtrlType;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync rc = ctrls[i]->COMGETTER(ControllerType)(&enmCtrlType); H();
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync AssertRelease((unsigned)enmCtrlType < RT_ELEMENTS(aCtrlNodes));
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync StorageBus_T enmBus;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync rc = ctrls[i]->COMGETTER(Bus)(&enmBus); H();
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync Bstr controllerName;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync rc = ctrls[i]->COMGETTER(Name)(controllerName.asOutParam()); H();
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ULONG ulInstance = 999;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync rc = ctrls[i]->COMGETTER(Instance)(&ulInstance); H();
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync BOOL fUseHostIOCache;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync rc = ctrls[i]->COMGETTER(UseHostIOCache)(&fUseHostIOCache); H();
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* /Devices/<ctrldev>/ */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync const char *pszCtrlDev = pConsole->convertControllerTypeToDev(enmCtrlType);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pDev = aCtrlNodes[enmCtrlType];
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (!pDev)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pDevices, pszCtrlDev, &pDev);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync aCtrlNodes[enmCtrlType] = pDev; /* IDE variants are handled in the switch */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* /Devices/<ctrldev>/<instance>/ */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync PCFGMNODE pCtlInst = NULL;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pDev, Utf8StrFmt("%u", ulInstance).c_str(), &pCtlInst);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Device config: /Devices/<ctrldev>/<instance>/<values> & /ditto/Config/<values> */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCtlInst, "Trusted", 1);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pCtlInst, "Config", &pCfg);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync switch (enmCtrlType)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case StorageControllerType_LsiLogic:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync hrc = BusMgr->assignPciDevice("lsilogic", pCtlInst); H();
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Attach the status driver */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedScsi]);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "First", 0);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Assert(cLedScsi >= 16);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "Last", 15);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync paLedDevType = &pConsole->maStorageDevType[iLedScsi];
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync break;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync case StorageControllerType_BusLogic:
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync {
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync hrc = BusMgr->assignPciDevice("buslogic", pCtlInst); H();
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync /* Attach the status driver */
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedScsi]);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigInteger(pCfg, "First", 0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Assert(cLedScsi >= 16);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigInteger(pCfg, "Last", 15);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync paLedDevType = &pConsole->maStorageDevType[iLedScsi];
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case StorageControllerType_IntelAhci:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync hrc = BusMgr->assignPciDevice("ahci", pCtlInst); H();
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ULONG cPorts = 0;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync hrc = ctrls[i]->COMGETTER(PortCount)(&cPorts); H();
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "PortCount", cPorts);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Needed configuration values for the bios. */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (pBiosCfg)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigString(pBiosCfg, "SataHardDiskDevice", "ahci");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync for (uint32_t j = 0; j < 4; ++j)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync static const char * const s_apszConfig[4] =
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync { "PrimaryMaster", "PrimarySlave", "SecondaryMaster", "SecondarySlave" };
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync static const char * const s_apszBiosConfig[4] =
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync { "SataPrimaryMasterLUN", "SataPrimarySlaveLUN", "SataSecondaryMasterLUN", "SataSecondarySlaveLUN" };
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync LONG lPortNumber = -1;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync hrc = ctrls[i]->GetIDEEmulationPort(j, &lPortNumber); H();
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, s_apszConfig[j], lPortNumber);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (pBiosCfg)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pBiosCfg, s_apszBiosConfig[j], lPortNumber);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Attach the status driver */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync AssertRelease(cPorts <= cLedSata);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedSata]);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "First", 0);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "Last", cPorts - 1);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync paLedDevType = &pConsole->maStorageDevType[iLedSata];
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case StorageControllerType_PIIX3:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case StorageControllerType_PIIX4:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case StorageControllerType_ICH6:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /*
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * IDE (update this when the main interface changes)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync hrc = BusMgr->assignPciDevice("piix3ide", pCtlInst); H();
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigString(pCfg, "Type", controllerString(enmCtrlType));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Attach the status driver */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedIde]);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "First", 0);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Assert(cLedIde >= 4);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "Last", 3);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync paLedDevType = &pConsole->maStorageDevType[iLedIde];
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* IDE flavors */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync aCtrlNodes[StorageControllerType_PIIX3] = pDev;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync aCtrlNodes[StorageControllerType_PIIX4] = pDev;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync aCtrlNodes[StorageControllerType_ICH6] = pDev;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case StorageControllerType_I82078:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /*
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * i82078 Floppy drive controller
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync fFdcEnabled = true;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "IRQ", 6);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "DMA", 2);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "MemMapped", 0 );
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "IOBase", 0x3f0);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Attach the status driver */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedFloppy]);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "First", 0);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Assert(cLedFloppy >= 1);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "Last", 0);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync paLedDevType = &pConsole->maStorageDevType[iLedFloppy];
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case StorageControllerType_LsiLogicSas:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync hrc = BusMgr->assignPciDevice("lsilogicsas", pCtlInst); H();
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigString(pCfg, "ControllerType", "SAS1068");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Attach the status driver */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedSas]);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "First", 0);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Assert(cLedSas >= 8);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "Last", 7);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync paLedDevType = &pConsole->maStorageDevType[iLedSas];
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync default:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync AssertMsgFailedReturn(("invalid storage controller type: %d\n", enmCtrlType), VERR_GENERAL_FAILURE);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Attach the media to the storage controllers. */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync com::SafeIfaceArray<IMediumAttachment> atts;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync hrc = pMachine->GetMediumAttachmentsOfController(controllerName.raw(),
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ComSafeArrayAsOutParam(atts)); H();
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync for (size_t j = 0; j < atts.size(); ++j)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync rc = pConsole->configMediumAttachment(pCtlInst,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pszCtrlDev,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ulInstance,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync enmBus,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync !!fUseHostIOCache,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync false /* fSetupMerge */,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync 0 /* uMergeSource */,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync 0 /* uMergeTarget */,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync atts[j],
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pConsole->mMachineState,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync NULL /* phrc */,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync false /* fAttachDetach */,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync false /* fForceUnmount */,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pVM,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync paLedDevType);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (RT_FAILURE(rc))
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync return rc;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync H();
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync H();
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /*
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * Network adapters
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#ifdef VMWARE_NET_IN_SLOT_11
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync bool fSwapSlots3and11 = false;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#endif
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync PCFGMNODE pDevPCNet = NULL; /* PCNet-type devices */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pDevices, "pcnet", &pDevPCNet);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#ifdef VBOX_WITH_E1000
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync PCFGMNODE pDevE1000 = NULL; /* E1000-type devices */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pDevices, "e1000", &pDevE1000);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#endif
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#ifdef VBOX_WITH_VIRTIO
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync PCFGMNODE pDevVirtioNet = NULL; /* Virtio network devices */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pDevices, "virtio-net", &pDevVirtioNet);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#endif /* VBOX_WITH_VIRTIO */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync std::list<BootNic> llBootNics;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync for (ULONG ulInstance = 0; ulInstance < SchemaDefs::NetworkAdapterCount; ++ulInstance)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ComPtr<INetworkAdapter> networkAdapter;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync hrc = pMachine->GetNetworkAdapter(ulInstance, networkAdapter.asOutParam()); H();
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync BOOL fEnabled = FALSE;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync hrc = networkAdapter->COMGETTER(Enabled)(&fEnabled); H();
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (!fEnabled)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync continue;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /*
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * The virtual hardware type. Create appropriate device first.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync const char *pszAdapterName = "pcnet";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync NetworkAdapterType_T adapterType;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync hrc = networkAdapter->COMGETTER(AdapterType)(&adapterType); H();
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync switch (adapterType)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case NetworkAdapterType_Am79C970A:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case NetworkAdapterType_Am79C973:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pDev = pDevPCNet;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#ifdef VBOX_WITH_E1000
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case NetworkAdapterType_I82540EM:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case NetworkAdapterType_I82543GC:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case NetworkAdapterType_I82545EM:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pDev = pDevE1000;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pszAdapterName = "e1000";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#endif
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#ifdef VBOX_WITH_VIRTIO
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case NetworkAdapterType_Virtio:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pDev = pDevVirtioNet;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pszAdapterName = "virtio-net";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#endif /* VBOX_WITH_VIRTIO */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync default:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync AssertMsgFailed(("Invalid network adapter type '%d' for slot '%d'",
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync adapterType, ulInstance));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync N_("Invalid network adapter type '%d' for slot '%d'"),
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync adapterType, ulInstance);
8f7ee9e453c60b3b699799538a45950b35266665vboxsync }
8f7ee9e453c60b3b699799538a45950b35266665vboxsync
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync InsertConfigNode(pDev, Utf8StrFmt("%u", ulInstance).c_str(), &pInst);
8f7ee9e453c60b3b699799538a45950b35266665vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync /* the first network card gets the PCI ID 3, the next 3 gets 8..10,
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync * next 4 get 16..19. */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync unsigned iPciDeviceNo = 3;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync if (ulInstance)
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync {
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync if (ulInstance < 4)
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync iPciDeviceNo = ulInstance - 1 + 8;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync else
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync iPciDeviceNo = ulInstance - 4 + 16;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync }
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync#ifdef VMWARE_NET_IN_SLOT_11
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync /*
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync * Dirty hack for PCI slot compatibility with VMWare,
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync * it assigns slot 11 to the first network controller.
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync if (iPciDeviceNo == 3 && adapterType == NetworkAdapterType_I82545EM)
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync {
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync iPciDeviceNo = 0x11;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync fSwapSlots3and11 = true;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync }
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync else if (iPciDeviceNo == 0x11 && fSwapSlots3and11)
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync iPciDeviceNo = 3;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync#endif
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync PciAddr = PciBusAddress(0, iPciDeviceNo, 0);
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync hrc = BusMgr->assignPciDevice(pszAdapterName, pInst, PciAddr); H();
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigNode(pInst, "Config", &pCfg);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE /* not safe here yet. */
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (pDev == pDevPCNet)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync {
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigInteger(pCfg, "R0Enabled", false);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync#endif
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync /*
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync * Collect information needed for network booting and add it to the list.
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync */
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync BootNic nic;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync nic.mInstance = ulInstance;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync nic.mPciDev = iPciDeviceNo;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync nic.mPciFn = 0;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync hrc = networkAdapter->COMGETTER(BootPriority)(&nic.mBootPrio); H();
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync llBootNics.push_back(nic);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync /*
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync * The virtual hardware type. PCNet supports two types.
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync */
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync switch (adapterType)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync {
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync case NetworkAdapterType_Am79C970A:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "Am79C973", 0);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync break;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync case NetworkAdapterType_Am79C973:
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync InsertConfigInteger(pCfg, "Am79C973", 1);
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync break;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync case NetworkAdapterType_I82540EM:
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync InsertConfigInteger(pCfg, "AdapterType", 0);
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync break;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync case NetworkAdapterType_I82543GC:
8f7ee9e453c60b3b699799538a45950b35266665vboxsync InsertConfigInteger(pCfg, "AdapterType", 1);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case NetworkAdapterType_I82545EM:
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigInteger(pCfg, "AdapterType", 2);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync /*
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync * Get the MAC address and convert it to binary representation
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync */
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync Bstr macAddr;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync hrc = networkAdapter->COMGETTER(MACAddress)(macAddr.asOutParam()); H();
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync Assert(!macAddr.isEmpty());
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync Utf8Str macAddrUtf8 = macAddr;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync char *macStr = (char*)macAddrUtf8.c_str();
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync Assert(strlen(macStr) == 12);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTMAC Mac;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync memset(&Mac, 0, sizeof(Mac));
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync char *pMac = (char*)&Mac;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync for (uint32_t i = 0; i < 6; ++i)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
9c9db71d639cf066ed41d49629d46d48bff4be2fvboxsync char c1 = *macStr++ - '0';
9c9db71d639cf066ed41d49629d46d48bff4be2fvboxsync if (c1 > 9)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync c1 -= 7;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync char c2 = *macStr++ - '0';
0c94a8282c9042b02f022302a3d987746140eab9vboxsync if (c2 > 9)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync c2 -= 7;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync *pMac++ = ((c1 & 0x0f) << 4) | (c2 & 0x0f);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigBytes(pCfg, "MAC", &Mac, sizeof(Mac));
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync /*
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * Check if the cable is supposed to be unplugged
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync BOOL fCableConnected;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync hrc = networkAdapter->COMGETTER(CableConnected)(&fCableConnected); H();
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigInteger(pCfg, "CableConnected", fCableConnected ? 1 : 0);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync /*
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync * Line speed to report from custom drivers
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync */
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync ULONG ulLineSpeed;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync hrc = networkAdapter->COMGETTER(LineSpeed)(&ulLineSpeed); H();
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigInteger(pCfg, "LineSpeed", ulLineSpeed);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync /*
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * Attach the status driver.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pInst, "LUN#999", &pLunL0);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapNetworkLeds[ulInstance]);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /*
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * Configure the network card now
0c94a8282c9042b02f022302a3d987746140eab9vboxsync */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync rc = pConsole->configNetwork(pszAdapterName,
0c94a8282c9042b02f022302a3d987746140eab9vboxsync ulInstance,
0c94a8282c9042b02f022302a3d987746140eab9vboxsync 0,
0c94a8282c9042b02f022302a3d987746140eab9vboxsync networkAdapter,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pCfg,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync pLunL0,
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync pInst,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync false /*fAttachDetach*/);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync if (RT_FAILURE(rc))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync return rc;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync }
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync /*
0c94a8282c9042b02f022302a3d987746140eab9vboxsync * Build network boot information and transfer it to the BIOS.
0c94a8282c9042b02f022302a3d987746140eab9vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (pNetBootCfg && !llBootNics.empty()) /* NetBoot node doesn't exist for EFI! */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync llBootNics.sort(); /* Sort the list by boot priority. */
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync char achBootIdx[] = "0";
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync unsigned uBootIdx = 0;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync for (std::list<BootNic>::iterator it = llBootNics.begin(); it != llBootNics.end(); ++it)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
0c94a8282c9042b02f022302a3d987746140eab9vboxsync /* A NIC with priority 0 is only used if it's first in the list. */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync if (it->mBootPrio == 0 && uBootIdx != 0)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync break;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync PCFGMNODE pNetBtDevCfg;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync achBootIdx[0] = '0' + uBootIdx++; /* Boot device order. */
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigNode(pNetBootCfg, achBootIdx, &pNetBtDevCfg);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pNetBtDevCfg, "NIC", it->mInstance);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigInteger(pNetBtDevCfg, "PCIDeviceNo", it->mPciDev);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pNetBtDevCfg, "PCIFunctionNo", it->mPciFn);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync /*
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync * Serial (UART) Ports
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync */
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigNode(pDevices, "serial", &pDev);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync for (ULONG ulInstance = 0; ulInstance < SchemaDefs::SerialPortCount; ++ulInstance)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync {
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync ComPtr<ISerialPort> serialPort;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync hrc = pMachine->GetSerialPort(ulInstance, serialPort.asOutParam()); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync BOOL fEnabled = FALSE;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (serialPort)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = serialPort->COMGETTER(Enabled)(&fEnabled); H();
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (!fEnabled)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync continue;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDev, Utf8StrFmt("%u", ulInstance).c_str(), &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ULONG ulIRQ;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = serialPort->COMGETTER(IRQ)(&ulIRQ); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "IRQ", ulIRQ);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ULONG ulIOBase;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = serialPort->COMGETTER(IOBase)(&ulIOBase); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "IOBase", ulIOBase);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync BOOL fServer;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = serialPort->COMGETTER(Server)(&fServer); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = serialPort->COMGETTER(Path)(bstr.asOutParam()); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PortMode_T eHostMode;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = serialPort->COMGETTER(HostMode)(&eHostMode); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (eHostMode != PortMode_Disconnected)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (eHostMode == PortMode_HostPipe)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigString(pLunL0, "Driver", "Char");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync InsertConfigString(pLunL1, "Driver", "NamedPipe");
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync InsertConfigNode(pLunL1, "Config", &pLunL2);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pLunL2, "Location", bstr);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync InsertConfigInteger(pLunL2, "IsServer", fServer);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync }
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync else if (eHostMode == PortMode_HostDevice)
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync {
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync InsertConfigString(pLunL0, "Driver", "Host Serial");
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync InsertConfigNode(pLunL0, "Config", &pLunL1);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync InsertConfigString(pLunL1, "DevicePath", bstr);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync else if (eHostMode == PortMode_RawFile)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync {
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync InsertConfigString(pLunL0, "Driver", "Char");
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync InsertConfigString(pLunL1, "Driver", "RawFile");
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigNode(pLunL1, "Config", &pLunL2);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync InsertConfigString(pLunL2, "Location", bstr);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync /*
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync * Parallel (LPT) Ports
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync */
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigNode(pDevices, "parallel", &pDev);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync for (ULONG ulInstance = 0; ulInstance < SchemaDefs::ParallelPortCount; ++ulInstance)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ComPtr<IParallelPort> parallelPort;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync hrc = pMachine->GetParallelPort(ulInstance, parallelPort.asOutParam()); H();
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync BOOL fEnabled = FALSE;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (parallelPort)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync hrc = parallelPort->COMGETTER(Enabled)(&fEnabled); H();
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (!fEnabled)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync continue;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync InsertConfigNode(pDev, Utf8StrFmt("%u", ulInstance).c_str(), &pInst);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync InsertConfigNode(pInst, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ULONG ulIRQ;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = parallelPort->COMGETTER(IRQ)(&ulIRQ); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "IRQ", ulIRQ);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ULONG ulIOBase;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = parallelPort->COMGETTER(IOBase)(&ulIOBase); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "IOBase", ulIOBase);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pLunL0, "Driver", "HostParallel");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = parallelPort->COMGETTER(Path)(bstr.asOutParam()); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pLunL1, "DevicePath", bstr);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * VMM Device
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDevices, "VMMDev", &pDev);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDev, "0", &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = BusMgr->assignPciDevice("VMMDev", pInst); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Bstr hwVersion;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = pMachine->COMGETTER(HardwareVersion)(hwVersion.asOutParam()); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "RamSize", cbRam);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (hwVersion.compare(Bstr("1").raw()) == 0) /* <= 2.0.x */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "HeapEnabled", 0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Bstr snapshotFolder;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = pMachine->COMGETTER(SnapshotFolder)(snapshotFolder.asOutParam()); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pCfg, "GuestCoreDumpDir", snapshotFolder);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* the VMM device's Main driver */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pLunL0, "Driver", "HGCM");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "Object", (uintptr_t)pVMMDev);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /*
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * Attach the status driver.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync InsertConfigNode(pInst, "LUN#999", &pLunL0);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapSharedFolderLed);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync InsertConfigInteger(pCfg, "First", 0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "Last", 0);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * Audio Sniffer Device
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDevices, "AudioSniffer", &pDev);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDev, "0", &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* the Audio Sniffer device's Main driver */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pLunL0, "Driver", "MainAudioSniffer");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync AudioSniffer *pAudioSniffer = pConsole->mAudioSniffer;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "Object", (uintptr_t)pAudioSniffer);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * AC'97 ICH / SoundBlaster16 audio / Intel HD Audio
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync BOOL fAudioEnabled;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ComPtr<IAudioAdapter> audioAdapter;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = pMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam()); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (audioAdapter)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync hrc = audioAdapter->COMGETTER(Enabled)(&fAudioEnabled); H();
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (fAudioEnabled)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync AudioControllerType_T audioController;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync hrc = audioAdapter->COMGETTER(AudioController)(&audioController); H();
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync switch (audioController)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync case AudioControllerType_AC97:
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /* default: ICH AC97 */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigNode(pDevices, "ichac97", &pDev);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDev, "0", &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = BusMgr->assignPciDevice("ichac97", pInst); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case AudioControllerType_SB16:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* legacy SoundBlaster16 */
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync InsertConfigNode(pDevices, "sb16", &pDev);
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync InsertConfigNode(pDev, "0", &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "IRQ", 5);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync InsertConfigInteger(pCfg, "DMA", 1);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync InsertConfigInteger(pCfg, "DMA16", 5);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "Port", 0x220);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "Version", 0x0405);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync }
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync case AudioControllerType_HDA:
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync {
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync /* Intel HD Audio */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync InsertConfigNode(pDevices, "hda", &pDev);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDev, "0", &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync hrc = BusMgr->assignPciDevice("hda", pInst); H();
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync InsertConfigNode(pInst, "Config", &pCfg);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync }
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync }
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync /* the Audio driver */
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync InsertConfigString(pLunL0, "Driver", "AUDIO");
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync AudioDriverType_T audioDriver;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync hrc = audioAdapter->COMGETTER(AudioDriver)(&audioDriver); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync switch (audioDriver)
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync case AudioDriverType_Null:
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync InsertConfigString(pCfg, "AudioDriver", "null");
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync break;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync }
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#ifdef RT_OS_WINDOWS
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#ifdef VBOX_WITH_WINMM
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case AudioDriverType_WinMM:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pCfg, "AudioDriver", "winmm");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case AudioDriverType_DirectSound:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pCfg, "AudioDriver", "dsound");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#endif /* RT_OS_WINDOWS */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#ifdef RT_OS_SOLARIS
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case AudioDriverType_SolAudio:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pCfg, "AudioDriver", "solaudio");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#ifdef RT_OS_LINUX
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync# ifdef VBOX_WITH_ALSA
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case AudioDriverType_ALSA:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pCfg, "AudioDriver", "alsa");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync# endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync# ifdef VBOX_WITH_PULSE
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case AudioDriverType_Pulse:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pCfg, "AudioDriver", "pulse");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync# endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#endif /* RT_OS_LINUX */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(VBOX_WITH_SOLARIS_OSS)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case AudioDriverType_OSS:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pCfg, "AudioDriver", "oss");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#ifdef RT_OS_FREEBSD
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync# ifdef VBOX_WITH_PULSE
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case AudioDriverType_Pulse:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pCfg, "AudioDriver", "pulse");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync# endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#ifdef RT_OS_DARWIN
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case AudioDriverType_CoreAudio:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pCfg, "AudioDriver", "coreaudio");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = pMachine->COMGETTER(Name)(bstr.asOutParam()); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pCfg, "StreamName", bstr);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * The USB Controller.
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync ComPtr<IUSBController> USBCtlPtr;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync hrc = pMachine->COMGETTER(USBController)(USBCtlPtr.asOutParam());
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync if (USBCtlPtr)
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync {
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync BOOL fOhciEnabled;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync hrc = USBCtlPtr->COMGETTER(Enabled)(&fOhciEnabled); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (fOhciEnabled)
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync {
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync InsertConfigNode(pDevices, "usb-ohci", &pDev);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync InsertConfigNode(pDev, "0", &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "Config", &pCfg);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = BusMgr->assignPciDevice("usb-ohci", pInst); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pLunL0, "Driver", "VUSBRootHub");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * Attach the status driver.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "LUN#999", &pLunL0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapUSBLed[0]);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "First", 0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "Last", 0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#ifdef VBOX_WITH_EHCI
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync BOOL fEhciEnabled;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync hrc = USBCtlPtr->COMGETTER(EnabledEhci)(&fEhciEnabled); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (fEhciEnabled)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDevices, "usb-ehci", &pDev);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDev, "0", &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync hrc = BusMgr->assignPciDevice("usb-ehci", pInst); H();
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pLunL0, "Driver", "VUSBRootHub");
9c9db71d639cf066ed41d49629d46d48bff4be2fvboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync /*
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync * Attach the status driver.
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync */
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync InsertConfigNode(pInst, "LUN#999", &pLunL0);
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapUSBLed[1]);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "First", 0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigInteger(pCfg, "Last", 0);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#endif
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync /*
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * Virtual USB Devices.
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PCFGMNODE pUsbDevices = NULL;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pRoot, "USB", &pUsbDevices);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#ifdef VBOX_WITH_USB
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * Global USB options, currently unused as we'll apply the 2.0 -> 1.1 morphing
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * on a per device level now.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync InsertConfigNode(pUsbDevices, "USBProxy", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pCfg, "GlobalConfig", &pCfg);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync // This globally enables the 2.0 -> 1.1 device morphing of proxied devices to keep windows quiet.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync //InsertConfigInteger(pCfg, "Force11Device", true);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync // The following breaks stuff, but it makes MSDs work in vista. (I include it here so
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync // that it's documented somewhere.) Users needing it can use:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync // VBoxManage setextradata "myvm" "VBoxInternal/USB/USBProxy/GlobalConfig/Force11PacketSize" 1
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync //InsertConfigInteger(pCfg, "Force11PacketSize", true);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync# if 0 /* Virtual MSD*/
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pUsbDevices, "Msd", &pDev);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pDev, "0", &pInst);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync InsertConfigString(pLunL0, "Driver", "SCSI");
0c94a8282c9042b02f022302a3d987746140eab9vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync InsertConfigString(pLunL1, "Driver", "Block");
0c94a8282c9042b02f022302a3d987746140eab9vboxsync InsertConfigNode(pLunL1, "Config", &pCfg);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync InsertConfigString(pCfg, "Type", "HardDisk");
0c94a8282c9042b02f022302a3d987746140eab9vboxsync InsertConfigInteger(pCfg, "Mountable", 0);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync InsertConfigNode(pLunL1, "AttachedDriver", &pLunL2);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pLunL2, "Driver", "VD");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigNode(pLunL2, "Config", &pCfg);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pCfg, "Path", "/Volumes/DataHFS/bird/VDIs/linux.vdi");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync InsertConfigString(pCfg, "Format", "VDI");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync# endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
/* Virtual USB Mouse/Tablet */
PointingHidType_T aPointingHid;
hrc = pMachine->COMGETTER(PointingHidType)(&aPointingHid); H();
if (aPointingHid == PointingHidType_USBMouse || aPointingHid == PointingHidType_USBTablet)
{
InsertConfigNode(pUsbDevices, "HidMouse", &pDev);
InsertConfigNode(pDev, "0", &pInst);
InsertConfigNode(pInst, "Config", &pCfg);
if (aPointingHid == PointingHidType_USBTablet)
{
InsertConfigInteger(pCfg, "Absolute", 1);
}
else
{
InsertConfigInteger(pCfg, "Absolute", 0);
}
InsertConfigNode(pInst, "LUN#0", &pLunL0);
InsertConfigString(pLunL0, "Driver", "MouseQueue");
InsertConfigNode(pLunL0, "Config", &pCfg);
InsertConfigInteger(pCfg, "QueueSize", 128);
InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
InsertConfigString(pLunL1, "Driver", "MainMouse");
InsertConfigNode(pLunL1, "Config", &pCfg);
pMouse = pConsole->mMouse;
InsertConfigInteger(pCfg, "Object", (uintptr_t)pMouse);
}
/* Virtual USB Keyboard */
KeyboardHidType_T aKbdHid;
hrc = pMachine->COMGETTER(KeyboardHidType)(&aKbdHid); H();
if (aKbdHid == KeyboardHidType_USBKeyboard)
{
InsertConfigNode(pUsbDevices, "HidKeyboard", &pDev);
InsertConfigNode(pDev, "0", &pInst);
InsertConfigNode(pInst, "Config", &pCfg);
InsertConfigNode(pInst, "LUN#0", &pLunL0);
InsertConfigString(pLunL0, "Driver", "KeyboardQueue");
InsertConfigNode(pLunL0, "Config", &pCfg);
InsertConfigInteger(pCfg, "QueueSize", 64);
InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
InsertConfigString(pLunL1, "Driver", "MainKeyboard");
InsertConfigNode(pLunL1, "Config", &pCfg);
pKeyboard = pConsole->mKeyboard;
InsertConfigInteger(pCfg, "Object", (uintptr_t)pKeyboard);
}
}
}
/*
* Clipboard
*/
{
ClipboardMode_T mode = ClipboardMode_Disabled;
hrc = pMachine->COMGETTER(ClipboardMode)(&mode); H();
if (mode != ClipboardMode_Disabled)
{
/* Load the service */
rc = pVMMDev->hgcmLoadService("VBoxSharedClipboard", "VBoxSharedClipboard");
if (RT_FAILURE(rc))
{
LogRel(("VBoxSharedClipboard is not available. rc = %Rrc\n", rc));
/* That is not a fatal failure. */
rc = VINF_SUCCESS;
}
else
{
/* Setup the service. */
VBOXHGCMSVCPARM parm;
parm.type = VBOX_HGCM_SVC_PARM_32BIT;
switch (mode)
{
default:
case ClipboardMode_Disabled:
{
LogRel(("VBoxSharedClipboard mode: Off\n"));
parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_OFF;
break;
}
case ClipboardMode_GuestToHost:
{
LogRel(("VBoxSharedClipboard mode: Guest to Host\n"));
parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST;
break;
}
case ClipboardMode_HostToGuest:
{
LogRel(("VBoxSharedClipboard mode: Host to Guest\n"));
parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_HOST_TO_GUEST;
break;
}
case ClipboardMode_Bidirectional:
{
LogRel(("VBoxSharedClipboard mode: Bidirectional\n"));
parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL;
break;
}
}
pVMMDev->hgcmHostCall("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm);
Log(("Set VBoxSharedClipboard mode\n"));
}
}
}
#ifdef VBOX_WITH_CROGL
/*
* crOpenGL
*/
{
BOOL fEnabled = false;
hrc = pMachine->COMGETTER(Accelerate3DEnabled)(&fEnabled); H();
if (fEnabled)
{
/* Load the service */
rc = pVMMDev->hgcmLoadService("VBoxSharedCrOpenGL", "VBoxSharedCrOpenGL");
if (RT_FAILURE(rc))
{
LogRel(("Failed to load Shared OpenGL service %Rrc\n", rc));
/* That is not a fatal failure. */
rc = VINF_SUCCESS;
}
else
{
LogRel(("Shared crOpenGL service loaded.\n"));
/* Setup the service. */
VBOXHGCMSVCPARM parm;
parm.type = VBOX_HGCM_SVC_PARM_PTR;
parm.u.pointer.addr = (IConsole*) (Console*) pConsole;
parm.u.pointer.size = sizeof(IConsole *);
rc = pVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_CONSOLE, SHCRGL_CPARMS_SET_CONSOLE, &parm);
if (!RT_SUCCESS(rc))
AssertMsgFailed(("SHCRGL_HOST_FN_SET_CONSOLE failed with %Rrc\n", rc));
parm.u.pointer.addr = pVM;
parm.u.pointer.size = sizeof(pVM);
rc = pVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_VM, SHCRGL_CPARMS_SET_VM, &parm);
if (!RT_SUCCESS(rc))
AssertMsgFailed(("SHCRGL_HOST_FN_SET_VM failed with %Rrc\n", rc));
}
}
}
#endif
#ifdef VBOX_WITH_GUEST_PROPS
/*
* Guest property service
*/
rc = configGuestProperties(pConsole);
#endif /* VBOX_WITH_GUEST_PROPS defined */
#ifdef VBOX_WITH_GUEST_CONTROL
/*
* Guest control service
*/
rc = configGuestControl(pConsole);
#endif /* VBOX_WITH_GUEST_CONTROL defined */
/*
* ACPI
*/
BOOL fACPI;
hrc = biosSettings->COMGETTER(ACPIEnabled)(&fACPI); H();
if (fACPI)
{
BOOL fCpuHotPlug = false;
BOOL fShowCpu = fOsXGuest;
/* Always show the CPU leafs when we have multiple VCPUs or when the IO-APIC is enabled.
* The Windows SMP kernel needs a CPU leaf or else its idle loop will burn cpu cycles; the
* intelppm driver refuses to register an idle state handler.
*/
if ((cCpus > 1) || fIOAPIC)
fShowCpu = true;
hrc = pMachine->COMGETTER(CPUHotPlugEnabled)(&fCpuHotPlug); H();
InsertConfigNode(pDevices, "acpi", &pDev);
InsertConfigNode(pDev, "0", &pInst);
InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
InsertConfigNode(pInst, "Config", &pCfg);
hrc = BusMgr->assignPciDevice("acpi", pInst); H();
InsertConfigInteger(pCfg, "RamSize", cbRam);
InsertConfigInteger(pCfg, "RamHoleSize", cbRamHole);
InsertConfigInteger(pCfg, "NumCPUs", cCpus);
InsertConfigInteger(pCfg, "IOAPIC", fIOAPIC);
InsertConfigInteger(pCfg, "FdcEnabled", fFdcEnabled);
InsertConfigInteger(pCfg, "HpetEnabled", fHpetEnabled);
InsertConfigInteger(pCfg, "SmcEnabled", fSmcEnabled);
InsertConfigInteger(pCfg, "ShowRtc", fOsXGuest);
if (fOsXGuest && !llBootNics.empty())
{
BootNic aNic = llBootNics.front();
uint32_t u32NicPciAddr = (aNic.mPciDev << 16) | aNic.mPciFn;
InsertConfigInteger(pCfg, "NicPciAddress", u32NicPciAddr);
}
if (fOsXGuest && fAudioEnabled)
{
PciBusAddress Address;
if (BusMgr->findPciAddress("hda", 0, Address))
{
uint32_t u32AudioPciAddr = (Address.iDevice << 16) | Address.iFn;
InsertConfigInteger(pCfg, "AudioPciAddress", u32AudioPciAddr);
}
}
InsertConfigInteger(pCfg, "IocPciAddress", u32IocPciAddress);
if (chipsetType == ChipsetType_ICH9)
{
InsertConfigInteger(pCfg, "McfgBase", u64McfgBase);
InsertConfigInteger(pCfg, "McfgLength", u32McfgLength);
}
InsertConfigInteger(pCfg, "HostBusPciAddress", u32HbcPciAddress);
InsertConfigInteger(pCfg, "ShowCpu", fShowCpu);
InsertConfigInteger(pCfg, "CpuHotPlug", fCpuHotPlug);
InsertConfigNode(pInst, "LUN#0", &pLunL0);
InsertConfigString(pLunL0, "Driver", "ACPIHost");
InsertConfigNode(pLunL0, "Config", &pCfg);
/* Attach the dummy CPU drivers */
for (ULONG iCpuCurr = 1; iCpuCurr < cCpus; iCpuCurr++)
{
BOOL fCpuAttached = true;
if (fCpuHotPlug)
{
hrc = pMachine->GetCPUStatus(iCpuCurr, &fCpuAttached); H();
}
if (fCpuAttached)
{
InsertConfigNode(pInst, Utf8StrFmt("LUN#%u", iCpuCurr).c_str(), &pLunL0);
InsertConfigString(pLunL0, "Driver", "ACPICpu");
InsertConfigNode(pLunL0, "Config", &pCfg);
}
}
}
/*
* CFGM overlay handling.
*
* Here we check the extra data entries for CFGM values
* and create the nodes and insert the values on the fly. Existing
* values will be removed and reinserted. CFGM is typed, so by default
* we will guess whether it's a string or an integer (byte arrays are
* not currently supported). It's possible to override this autodetection
* by adding "string:", "integer:" or "bytes:" (future).
*
* We first perform a run on global extra data, then on the machine
* extra data to support global settings with local overrides.
*/
/** @todo add support for removing nodes and byte blobs. */
SafeArray<BSTR> aGlobalExtraDataKeys;
SafeArray<BSTR> aMachineExtraDataKeys;
/*
* Get the next key
*/
if (FAILED(hrc = virtualBox->GetExtraDataKeys(ComSafeArrayAsOutParam(aGlobalExtraDataKeys))))
AssertMsgFailed(("VirtualBox::GetExtraDataKeys failed with %Rrc\n", hrc));
// remember the no. of global values so we can call the correct method below
size_t cGlobalValues = aGlobalExtraDataKeys.size();
if (FAILED(hrc = pMachine->GetExtraDataKeys(ComSafeArrayAsOutParam(aMachineExtraDataKeys))))
AssertMsgFailed(("IMachine::GetExtraDataKeys failed with %Rrc\n", hrc));
// build a combined list from global keys...
std::list<Utf8Str> llExtraDataKeys;
for (size_t i = 0; i < aGlobalExtraDataKeys.size(); ++i)
llExtraDataKeys.push_back(Utf8Str(aGlobalExtraDataKeys[i]));
// ... and machine keys
for (size_t i = 0; i < aMachineExtraDataKeys.size(); ++i)
llExtraDataKeys.push_back(Utf8Str(aMachineExtraDataKeys[i]));
size_t i2 = 0;
for (std::list<Utf8Str>::const_iterator it = llExtraDataKeys.begin();
it != llExtraDataKeys.end();
++it, ++i2)
{
const Utf8Str &strKey = *it;
/*
* We only care about keys starting with "VBoxInternal/" (skip "G:" or "M:")
*/
if (!strKey.startsWith("VBoxInternal/"))
continue;
const char *pszExtraDataKey = strKey.c_str() + sizeof("VBoxInternal/") - 1;
// get the value
Bstr bstrExtraDataValue;
if (i2 < cGlobalValues)
// this is still one of the global values:
hrc = virtualBox->GetExtraData(Bstr(strKey).raw(),
bstrExtraDataValue.asOutParam());
else
hrc = pMachine->GetExtraData(Bstr(strKey).raw(),
bstrExtraDataValue.asOutParam());
if (FAILED(hrc))
LogRel(("Warning: Cannot get extra data key %s, rc = %Rrc\n", strKey.c_str(), hrc));
/*
* The key will be in the format "Node1/Node2/Value" or simply "Value".
* Split the two and get the node, delete the value and create the node
* if necessary.
*/
PCFGMNODE pNode;
const char *pszCFGMValueName = strrchr(pszExtraDataKey, '/');
if (pszCFGMValueName)
{
/* terminate the node and advance to the value (Utf8Str might not
offically like this but wtf) */
*(char*)pszCFGMValueName = '\0';
++pszCFGMValueName;
/* does the node already exist? */
pNode = CFGMR3GetChild(pRoot, pszExtraDataKey);
if (pNode)
CFGMR3RemoveValue(pNode, pszCFGMValueName);
else
{
/* create the node */
rc = CFGMR3InsertNode(pRoot, pszExtraDataKey, &pNode);
if (RT_FAILURE(rc))
{
AssertLogRelMsgRC(rc, ("failed to insert node '%s'\n", pszExtraDataKey));
continue;
}
Assert(pNode);
}
}
else
{
/* root value (no node path). */
pNode = pRoot;
pszCFGMValueName = pszExtraDataKey;
pszExtraDataKey--;
CFGMR3RemoveValue(pNode, pszCFGMValueName);
}
/*
* Now let's have a look at the value.
* Empty strings means that we should remove the value, which we've
* already done above.
*/
Utf8Str strCFGMValueUtf8(bstrExtraDataValue);
if (!strCFGMValueUtf8.isEmpty())
{
uint64_t u64Value;
/* check for type prefix first. */
if (!strncmp(strCFGMValueUtf8.c_str(), "string:", sizeof("string:") - 1))
InsertConfigString(pNode, pszCFGMValueName, strCFGMValueUtf8.c_str() + sizeof("string:") - 1);
else if (!strncmp(strCFGMValueUtf8.c_str(), "integer:", sizeof("integer:") - 1))
{
rc = RTStrToUInt64Full(strCFGMValueUtf8.c_str() + sizeof("integer:") - 1, 0, &u64Value);
if (RT_SUCCESS(rc))
rc = CFGMR3InsertInteger(pNode, pszCFGMValueName, u64Value);
}
else if (!strncmp(strCFGMValueUtf8.c_str(), "bytes:", sizeof("bytes:") - 1))
rc = VERR_NOT_IMPLEMENTED;
/* auto detect type. */
else if (RT_SUCCESS(RTStrToUInt64Full(strCFGMValueUtf8.c_str(), 0, &u64Value)))
rc = CFGMR3InsertInteger(pNode, pszCFGMValueName, u64Value);
else
InsertConfigString(pNode, pszCFGMValueName, strCFGMValueUtf8);
AssertLogRelMsgRC(rc, ("failed to insert CFGM value '%s' to key '%s'\n", strCFGMValueUtf8.c_str(), pszExtraDataKey));
}
}
}
catch (ConfigError &x)
{
// InsertConfig threw something:
return x.m_vrc;
}
#undef H
#ifdef VBOX_WITH_EXTPACK
/*
* Call the extension pack hooks if everything went well thus far.
*/
if (RT_SUCCESS(rc))
rc = pConsole->mptrExtPackManager->callAllVmConfigureVmmHooks(pConsole, pVM);
#endif
/*
* Register VM state change handler.
*/
int rc2 = VMR3AtStateRegister(pVM, Console::vmstateChangeCallback, pConsole);
AssertRC(rc2);
if (RT_SUCCESS(rc))
rc = rc2;
/*
* Register VM runtime error handler.
*/
rc2 = VMR3AtRuntimeErrorRegister(pVM, Console::setVMRuntimeErrorCallback, pConsole);
AssertRC(rc2);
if (RT_SUCCESS(rc))
rc = rc2;
LogFlowFunc(("vrc = %Rrc\n", rc));
LogFlowFuncLeave();
return rc;
}
/**
* Ellipsis to va_list wrapper for calling setVMRuntimeErrorCallback.
*/
/*static*/
void Console::setVMRuntimeErrorCallbackF(PVM pVM, void *pvConsole, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
{
va_list va;
va_start(va, pszFormat);
setVMRuntimeErrorCallback(pVM, pvConsole, fFlags, pszErrorId, pszFormat, va);
va_end(va);
}
/* XXX introduce RT format specifier */
static uint64_t formatDiskSize(uint64_t u64Size, const char **pszUnit)
{
if (u64Size > INT64_C(5000)*_1G)
{
*pszUnit = "TB";
return u64Size / _1T;
}
else if (u64Size > INT64_C(5000)*_1M)
{
*pszUnit = "GB";
return u64Size / _1G;
}
else
{
*pszUnit = "MB";
return u64Size / _1M;
}
}
int Console::configMediumAttachment(PCFGMNODE pCtlInst,
const char *pcszDevice,
unsigned uInstance,
StorageBus_T enmBus,
bool fUseHostIOCache,
bool fSetupMerge,
unsigned uMergeSource,
unsigned uMergeTarget,
IMediumAttachment *pMediumAtt,
MachineState_T aMachineState,
HRESULT *phrc,
bool fAttachDetach,
bool fForceUnmount,
PVM pVM,
DeviceType_T *paLedDevType)
{
// InsertConfig* throws
try
{
int rc = VINF_SUCCESS;
HRESULT hrc;
Bstr bstr;
// #define RC_CHECK() AssertMsgReturn(RT_SUCCESS(rc), ("rc=%Rrc\n", rc), rc)
#define H() AssertMsgReturn(!FAILED(hrc), ("hrc=%Rhrc\n", hrc), VERR_GENERAL_FAILURE)
LONG lDev;
hrc = pMediumAtt->COMGETTER(Device)(&lDev); H();
LONG lPort;
hrc = pMediumAtt->COMGETTER(Port)(&lPort); H();
DeviceType_T lType;
hrc = pMediumAtt->COMGETTER(Type)(&lType); H();
unsigned uLUN;
PCFGMNODE pLunL0 = NULL;
PCFGMNODE pCfg = NULL;
hrc = Console::convertBusPortDeviceToLun(enmBus, lPort, lDev, uLUN); H();
/* First check if the LUN already exists. */
pLunL0 = CFGMR3GetChildF(pCtlInst, "LUN#%u", uLUN);
if (pLunL0)
{
if (fAttachDetach)
{
if (lType != DeviceType_HardDisk)
{
/* Unmount existing media only for floppy and DVD drives. */
PPDMIBASE pBase;
rc = PDMR3QueryLun(pVM, pcszDevice, uInstance, uLUN, &pBase);
if (RT_FAILURE(rc))
{
if (rc == VERR_PDM_LUN_NOT_FOUND || rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN)
rc = VINF_SUCCESS;
AssertRC(rc);
}
else
{
PPDMIMOUNT pIMount = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMOUNT);
AssertReturn(pIMount, VERR_INVALID_POINTER);
/* Unmount the media. */
rc = pIMount->pfnUnmount(pIMount, fForceUnmount);
if (rc == VERR_PDM_MEDIA_NOT_MOUNTED)
rc = VINF_SUCCESS;
}
}
rc = PDMR3DeviceDetach(pVM, pcszDevice, 0, uLUN, PDM_TACH_FLAGS_NOT_HOT_PLUG);
if (rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN)
rc = VINF_SUCCESS;
AssertMsgReturn(RT_SUCCESS(rc), ("rc=%Rrc\n", rc), rc);
CFGMR3RemoveNode(pLunL0);
}
else
AssertFailedReturn(VERR_INTERNAL_ERROR);
}
InsertConfigNode(pCtlInst, Utf8StrFmt("LUN#%u", uLUN).c_str(), &pLunL0);
/* SCSI has a another driver between device and block. */
if (enmBus == StorageBus_SCSI || enmBus == StorageBus_SAS)
{
InsertConfigString(pLunL0, "Driver", "SCSI");
InsertConfigNode(pLunL0, "Config", &pCfg);
InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
}
ComPtr<IMedium> pMedium;
hrc = pMediumAtt->COMGETTER(Medium)(pMedium.asOutParam()); H();
/*
* 1. Only check this for hard disk images.
* 2. Only check during VM creation and not later, especially not during
* taking an online snapshot!
*/
if ( lType == DeviceType_HardDisk
&& ( aMachineState == MachineState_Starting
|| aMachineState == MachineState_Restoring))
{
/*
* Some sanity checks.
*/
ComPtr<IMediumFormat> pMediumFormat;
hrc = pMedium->COMGETTER(MediumFormat)(pMediumFormat.asOutParam()); H();
ULONG uCaps;
hrc = pMediumFormat->COMGETTER(Capabilities)(&uCaps); H();
if (uCaps & MediumFormatCapabilities_File)
{
Bstr strFile;
hrc = pMedium->COMGETTER(Location)(strFile.asOutParam()); H();
Utf8Str utfFile = Utf8Str(strFile);
Bstr strSnap;
ComPtr<IMachine> pMachine = machine();
hrc = pMachine->COMGETTER(SnapshotFolder)(strSnap.asOutParam()); H();
Utf8Str utfSnap = Utf8Str(strSnap);
RTFSTYPE enmFsTypeFile = RTFSTYPE_UNKNOWN;
RTFSTYPE enmFsTypeSnap = RTFSTYPE_UNKNOWN;
int rc2 = RTFsQueryType(utfFile.c_str(), &enmFsTypeFile);
AssertMsgRCReturn(rc2, ("Querying the file type of '%s' failed!\n", utfFile.c_str()), rc2);
/* Ignore the error code. On error, the file system type is still 'unknown' so
* none of the following paths are taken. This can happen for new VMs which
* still don't have a snapshot folder. */
(void)RTFsQueryType(utfSnap.c_str(), &enmFsTypeSnap);
LogRel(("File system of '%s' is %s\n", utfFile.c_str(), RTFsTypeName(enmFsTypeFile)));
LONG64 i64Size;
hrc = pMedium->COMGETTER(LogicalSize)(&i64Size); H();
#ifdef RT_OS_WINDOWS
if ( enmFsTypeFile == RTFSTYPE_FAT
&& i64Size >= _4G)
{
const char *pszUnit;
uint64_t u64Print = formatDiskSize((uint64_t)i64Size, &pszUnit);
setVMRuntimeErrorCallbackF(pVM, this, 0,
"FatPartitionDetected",
N_("The medium '%ls' has a logical size of %RU64%s "
"but the file system the medium is located on seems "
"to be FAT(32) which cannot handle files bigger than 4GB.\n"
"We strongly recommend to put all your virtual disk images and "
"the snapshot folder onto an NTFS partition"),
strFile.raw(), u64Print, pszUnit);
}
#else /* !RT_OS_WINDOWS */
if ( enmFsTypeFile == RTFSTYPE_FAT
|| enmFsTypeFile == RTFSTYPE_EXT
|| enmFsTypeFile == RTFSTYPE_EXT2
|| enmFsTypeFile == RTFSTYPE_EXT3
|| enmFsTypeFile == RTFSTYPE_EXT4)
{
RTFILE file;
rc = RTFileOpen(&file, utfFile.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
if (RT_SUCCESS(rc))
{
RTFOFF maxSize;
/* Careful: This function will work only on selected local file systems! */
rc = RTFileGetMaxSizeEx(file, &maxSize);
RTFileClose(file);
if ( RT_SUCCESS(rc)
&& maxSize > 0
&& i64Size > (LONG64)maxSize)
{
const char *pszUnitSiz;
const char *pszUnitMax;
uint64_t u64PrintSiz = formatDiskSize((LONG64)i64Size, &pszUnitSiz);
uint64_t u64PrintMax = formatDiskSize(maxSize, &pszUnitMax);
setVMRuntimeErrorCallbackF(pVM, this, 0,
"FatPartitionDetected", /* <= not exact but ... */
N_("The medium '%ls' has a logical size of %RU64%s "
"but the file system the medium is located on can "
"only handle files up to %RU64%s in theory.\n"
"We strongly recommend to put all your virtual disk "
"images and the snapshot folder onto a proper "
"file system (e.g. ext3) with a sufficient size"),
strFile.raw(), u64PrintSiz, pszUnitSiz, u64PrintMax, pszUnitMax);
}
}
}
#endif /* !RT_OS_WINDOWS */
/*
* Snapshot folder:
* Here we test only for a FAT partition as we had to create a dummy file otherwise
*/
if ( enmFsTypeSnap == RTFSTYPE_FAT
&& i64Size >= _4G
&& !mfSnapshotFolderSizeWarningShown)
{
const char *pszUnit;
uint64_t u64Print = formatDiskSize(i64Size, &pszUnit);
setVMRuntimeErrorCallbackF(pVM, this, 0,
"FatPartitionDetected",
#ifdef RT_OS_WINDOWS
N_("The snapshot folder of this VM '%ls' seems to be located on "
"a FAT(32) file system. The logical size of the medium '%ls' "
"(%RU64%s) is bigger than the maximum file size this file "
"system can handle (4GB).\n"
"We strongly recommend to put all your virtual disk images and "
"the snapshot folder onto an NTFS partition"),
#else
N_("The snapshot folder of this VM '%ls' seems to be located on "
"a FAT(32) file system. The logical size of the medium '%ls' "
"(%RU64%s) is bigger than the maximum file size this file "
"system can handle (4GB).\n"
"We strongly recommend to put all your virtual disk images and "
"the snapshot folder onto a proper file system (e.g. ext3)"),
#endif
strSnap.raw(), strFile.raw(), u64Print, pszUnit);
/* Show this particular warning only once */
mfSnapshotFolderSizeWarningShown = true;
}
#ifdef RT_OS_LINUX
/*
* Ext4 bug: Check if the host I/O cache is disabled and the disk image is located
* on an ext4 partition. Later we have to check the Linux kernel version!
* This bug apparently applies to the XFS file system as well.
* Linux 2.6.36 is known to be fixed (tested with 2.6.36-rc4).
*/
char szOsRelease[128];
rc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szOsRelease, sizeof(szOsRelease));
bool fKernelHasODirectBug = RT_FAILURE(rc)
|| (RTStrVersionCompare(szOsRelease, "2.6.36-rc4") < 0);
if ( (uCaps & MediumFormatCapabilities_Asynchronous)
&& !fUseHostIOCache
&& fKernelHasODirectBug)
{
if ( enmFsTypeFile == RTFSTYPE_EXT4
|| enmFsTypeFile == RTFSTYPE_XFS)
{
setVMRuntimeErrorCallbackF(pVM, this, 0,
"Ext4PartitionDetected",
N_("The host I/O cache for at least one controller is disabled "
"and the medium '%ls' for this VM "
"is located on an %s partition. There is a known Linux "
"kernel bug which can lead to the corruption of the virtual "
"disk image under these conditions.\n"
"Either enable the host I/O cache permanently in the VM "
"settings or put the disk image and the snapshot folder "
"onto a different file system.\n"
"The host I/O cache will now be enabled for this medium"),
strFile.raw(), enmFsTypeFile == RTFSTYPE_EXT4 ? "ext4" : "xfs");
fUseHostIOCache = true;
}
else if ( ( enmFsTypeSnap == RTFSTYPE_EXT4
|| enmFsTypeSnap == RTFSTYPE_XFS)
&& !mfSnapshotFolderExt4WarningShown)
{
setVMRuntimeErrorCallbackF(pVM, this, 0,
"Ext4PartitionDetected",
N_("The host I/O cache for at least one controller is disabled "
"and the snapshot folder for this VM "
"is located on an %s partition. There is a known Linux "
"kernel bug which can lead to the corruption of the virtual "
"disk image under these conditions.\n"
"Either enable the host I/O cache permanently in the VM "
"settings or put the disk image and the snapshot folder "
"onto a different file system.\n"
"The host I/O cache will now be enabled for this medium"),
enmFsTypeSnap == RTFSTYPE_EXT4 ? "ext4" : "xfs");
fUseHostIOCache = true;
mfSnapshotFolderExt4WarningShown = true;
}
}
#endif
}
}
BOOL fPassthrough;
hrc = pMediumAtt->COMGETTER(Passthrough)(&fPassthrough); H();
rc = configMedium(pLunL0,
!!fPassthrough,
lType,
fUseHostIOCache,
fSetupMerge,
uMergeSource,
uMergeTarget,
pMedium,
aMachineState,
phrc);
if (RT_FAILURE(rc))
return rc;
if (fAttachDetach)
{
/* Attach the new driver. */
rc = PDMR3DeviceAttach(pVM, pcszDevice, 0, uLUN,
PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/);
AssertMsgReturn(RT_SUCCESS(rc), ("rc=%Rrc\n", rc), rc);
/* There is no need to handle removable medium mounting, as we
* unconditionally replace everthing including the block driver level.
* This means the new medium will be picked up automatically. */
}
if (paLedDevType)
paLedDevType[uLUN] = lType;
}
catch (ConfigError &x)
{
// InsertConfig threw something:
return x.m_vrc;
}
#undef H
return VINF_SUCCESS;;
}
int Console::configMedium(PCFGMNODE pLunL0,
bool fPassthrough,
DeviceType_T enmType,
bool fUseHostIOCache,
bool fSetupMerge,
unsigned uMergeSource,
unsigned uMergeTarget,
IMedium *pMedium,
MachineState_T aMachineState,
HRESULT *phrc)
{
// InsertConfig* throws
try
{
int rc = VINF_SUCCESS;
HRESULT hrc;
Bstr bstr;
#define H() AssertMsgReturnStmt(!FAILED(hrc), ("hrc=%Rhrc\n", hrc), if (phrc) *phrc = hrc, VERR_GENERAL_FAILURE)
PCFGMNODE pLunL1 = NULL;
PCFGMNODE pCfg = NULL;
BOOL fHostDrive = FALSE;
MediumType_T mediumType = MediumType_Normal;
if (pMedium)
{
hrc = pMedium->COMGETTER(HostDrive)(&fHostDrive); H();
hrc = pMedium->COMGETTER(Type)(&mediumType); H();
}
if (fHostDrive)
{
Assert(pMedium);
if (enmType == DeviceType_DVD)
{
InsertConfigString(pLunL0, "Driver", "HostDVD");
InsertConfigNode(pLunL0, "Config", &pCfg);
hrc = pMedium->COMGETTER(Location)(bstr.asOutParam()); H();
InsertConfigString(pCfg, "Path", bstr);
InsertConfigInteger(pCfg, "Passthrough", fPassthrough);
}
else if (enmType == DeviceType_Floppy)
{
InsertConfigString(pLunL0, "Driver", "HostFloppy");
InsertConfigNode(pLunL0, "Config", &pCfg);
hrc = pMedium->COMGETTER(Location)(bstr.asOutParam()); H();
InsertConfigString(pCfg, "Path", bstr);
}
}
else
{
InsertConfigString(pLunL0, "Driver", "Block");
InsertConfigNode(pLunL0, "Config", &pCfg);
switch (enmType)
{
case DeviceType_DVD:
InsertConfigString(pCfg, "Type", "DVD");
InsertConfigInteger(pCfg, "Mountable", 1);
break;
case DeviceType_Floppy:
InsertConfigString(pCfg, "Type", "Floppy 1.44");
InsertConfigInteger(pCfg, "Mountable", 1);
break;
case DeviceType_HardDisk:
default:
InsertConfigString(pCfg, "Type", "HardDisk");
InsertConfigInteger(pCfg, "Mountable", 0);
}
if ( pMedium
&& ( enmType == DeviceType_DVD
|| enmType == DeviceType_Floppy
))
{
// if this medium represents an ISO image and this image is inaccessible,
// the ignore it instead of causing a failure; this can happen when we
// restore a VM state and the ISO has disappeared, e.g. because the Guest
// Additions were mounted and the user upgraded VirtualBox. Previously
// we failed on startup, but that's not good because the only way out then
// would be to discard the VM state...
MediumState_T mediumState;
rc = pMedium->RefreshState(&mediumState);
AssertMsgReturn(RT_SUCCESS(rc), ("rc=%Rrc\n", rc), rc);
if (mediumState == MediumState_Inaccessible)
{
Bstr loc;
rc = pMedium->COMGETTER(Location)(loc.asOutParam());
if (FAILED(rc)) return rc;
setVMRuntimeErrorCallbackF(mpVM,
this,
0,
"DvdOrFloppyImageInaccessible",
"The image file '%ls' is inaccessible and is being ignored. Please select a different image file for the virtual %s drive.",
loc.raw(),
(enmType == DeviceType_DVD) ? "DVD" : "floppy");
pMedium = NULL;
}
}
if (pMedium)
{
/* Start with length of parent chain, as the list is reversed */
unsigned uImage = 0;
IMedium *pTmp = pMedium;
while (pTmp)
{
uImage++;
hrc = pTmp->COMGETTER(Parent)(&pTmp); H();
}
/* Index of last image */
uImage--;
#if 0 /* Enable for I/O debugging */
InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
InsertConfigString(pLunL0, "Driver", "DiskIntegrity");
InsertConfigNode(pLunL0, "Config", &pCfg);
InsertConfigInteger(pCfg, "CheckConsistency", 0);
InsertConfigInteger(pCfg, "CheckDoubleCompletions", 1);
#endif
InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
InsertConfigString(pLunL1, "Driver", "VD");
InsertConfigNode(pLunL1, "Config", &pCfg);
hrc = pMedium->COMGETTER(Location)(bstr.asOutParam()); H();
InsertConfigString(pCfg, "Path", bstr);
hrc = pMedium->COMGETTER(Format)(bstr.asOutParam()); H();
InsertConfigString(pCfg, "Format", bstr);
if (mediumType == MediumType_Readonly)
{
InsertConfigInteger(pCfg, "ReadOnly", 1);
}
else if (enmType == DeviceType_Floppy)
{
InsertConfigInteger(pCfg, "MaybeReadOnly", 1);
}
/* Start without exclusive write access to the images. */
/** @todo Live Migration: I don't quite like this, we risk screwing up when
* we're resuming the VM if some 3rd dude have any of the VDIs open
* with write sharing denied. However, if the two VMs are sharing a
* image it really is necessary....
*
* So, on the "lock-media" command, the target teleporter should also
* make DrvVD undo TempReadOnly. It gets interesting if we fail after
* that. Grumble. */
if ( enmType == DeviceType_HardDisk
&& ( aMachineState == MachineState_TeleportingIn
|| aMachineState == MachineState_FaultTolerantSyncing))
{
InsertConfigInteger(pCfg, "TempReadOnly", 1);
}
/* Flag for opening the medium for sharing between VMs. This
* is done at the moment only for the first (and only) medium
* in the chain, as shared media can have no diffs. */
if (mediumType == MediumType_Shareable)
{
InsertConfigInteger(pCfg, "Shareable", 1);
}
if (!fUseHostIOCache)
{
InsertConfigInteger(pCfg, "UseNewIo", 1);
}
if (fSetupMerge)
{
InsertConfigInteger(pCfg, "SetupMerge", 1);
if (uImage == uMergeSource)
{
InsertConfigInteger(pCfg, "MergeSource", 1);
}
else if (uImage == uMergeTarget)
{
InsertConfigInteger(pCfg, "MergeTarget", 1);
}
}
switch (enmType)
{
case DeviceType_DVD:
InsertConfigString(pCfg, "Type", "DVD");
break;
case DeviceType_Floppy:
InsertConfigString(pCfg, "Type", "Floppy");
break;
case DeviceType_HardDisk:
default:
InsertConfigString(pCfg, "Type", "HardDisk");
}
/* Pass all custom parameters. */
bool fHostIP = true;
SafeArray<BSTR> names;
SafeArray<BSTR> values;
hrc = pMedium->GetProperties(NULL,
ComSafeArrayAsOutParam(names),
ComSafeArrayAsOutParam(values)); H();
if (names.size() != 0)
{
PCFGMNODE pVDC;
InsertConfigNode(pCfg, "VDConfig", &pVDC);
for (size_t ii = 0; ii < names.size(); ++ii)
{
if (values[ii] && *values[ii])
{
Utf8Str name = names[ii];
Utf8Str value = values[ii];
InsertConfigString(pVDC, name.c_str(), value);
if ( name.compare("HostIPStack") == 0
&& value.compare("0") == 0)
fHostIP = false;
}
}
}
/* Create an inverted list of parents. */
uImage--;
IMedium *pParentMedium = pMedium;
for (PCFGMNODE pParent = pCfg;; uImage--)
{
hrc = pParentMedium->COMGETTER(Parent)(&pMedium); H();
if (!pMedium)
break;
PCFGMNODE pCur;
InsertConfigNode(pParent, "Parent", &pCur);
hrc = pMedium->COMGETTER(Location)(bstr.asOutParam()); H();
InsertConfigString(pCur, "Path", bstr);
hrc = pMedium->COMGETTER(Format)(bstr.asOutParam()); H();
InsertConfigString(pCur, "Format", bstr);
if (fSetupMerge)
{
if (uImage == uMergeSource)
{
InsertConfigInteger(pCur, "MergeSource", 1);
}
else if (uImage == uMergeTarget)
{
InsertConfigInteger(pCur, "MergeTarget", 1);
}
}
/* Pass all custom parameters. */
SafeArray<BSTR> aNames;
SafeArray<BSTR> aValues;
hrc = pMedium->GetProperties(NULL,
ComSafeArrayAsOutParam(aNames),
ComSafeArrayAsOutParam(aValues)); H();
if (aNames.size() != 0)
{
PCFGMNODE pVDC;
InsertConfigNode(pCur, "VDConfig", &pVDC);
for (size_t ii = 0; ii < aNames.size(); ++ii)
{
if (aValues[ii] && *aValues[ii])
{
Utf8Str name = aNames[ii];
Utf8Str value = aValues[ii];
InsertConfigString(pVDC, name.c_str(), value);
if ( name.compare("HostIPStack") == 0
&& value.compare("0") == 0)
fHostIP = false;
}
}
}
/* Custom code: put marker to not use host IP stack to driver
* configuration node. Simplifies life of DrvVD a bit. */
if (!fHostIP)
{
InsertConfigInteger(pCfg, "HostIPStack", 0);
}
/* next */
pParent = pCur;
pParentMedium = pMedium;
}
}
}
}
catch (ConfigError &x)
{
// InsertConfig threw something:
return x.m_vrc;
}
#undef H
return VINF_SUCCESS;
}
/**
* Construct the Network configuration tree
*
* @returns VBox status code.
*
* @param pszDevice The PDM device name.
* @param uInstance The PDM device instance.
* @param uLun The PDM LUN number of the drive.
* @param aNetworkAdapter The network adapter whose attachment needs to be changed
* @param pCfg Configuration node for the device
* @param pLunL0 To store the pointer to the LUN#0.
* @param pInst The instance CFGM node
* @param fAttachDetach To determine if the network attachment should
* be attached/detached after/before
* configuration.
*
* @note Locks this object for writing.
*/
int Console::configNetwork(const char *pszDevice,
unsigned uInstance,
unsigned uLun,
INetworkAdapter *aNetworkAdapter,
PCFGMNODE pCfg,
PCFGMNODE pLunL0,
PCFGMNODE pInst,
bool fAttachDetach)
{
AutoCaller autoCaller(this);
AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED);
// InsertConfig* throws
try
{
int rc = VINF_SUCCESS;
HRESULT hrc;
Bstr bstr;
#define H() AssertMsgReturn(!FAILED(hrc), ("hrc=%Rhrc\n", hrc), VERR_GENERAL_FAILURE)
/*
* Locking the object before doing VMR3* calls is quite safe here, since
* we're on EMT. Write lock is necessary because we indirectly modify the
* meAttachmentType member.
*/
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
PVM pVM = mpVM;
ComPtr<IMachine> pMachine = machine();
ComPtr<IVirtualBox> virtualBox;
hrc = pMachine->COMGETTER(Parent)(virtualBox.asOutParam());
H();
ComPtr<IHost> host;
hrc = virtualBox->COMGETTER(Host)(host.asOutParam());
H();
BOOL fSniffer;
hrc = aNetworkAdapter->COMGETTER(TraceEnabled)(&fSniffer);
H();
if (fAttachDetach && fSniffer)
{
const char *pszNetDriver = "IntNet";
if (meAttachmentType[uInstance] == NetworkAttachmentType_NAT)
pszNetDriver = "NAT";
#if !defined(VBOX_WITH_NETFLT) && defined(RT_OS_LINUX)
if (meAttachmentType[uInstance] == NetworkAttachmentType_Bridged)
pszNetDriver = "HostInterface";
#endif
rc = PDMR3DriverDetach(pVM, pszDevice, uInstance, uLun, pszNetDriver, 0, 0 /*fFlags*/);
if (rc == VINF_PDM_NO_DRIVER_ATTACHED_TO_LUN)
rc = VINF_SUCCESS;
AssertLogRelRCReturn(rc, rc);
pLunL0 = CFGMR3GetChildF(pInst, "LUN#%u", uLun);
PCFGMNODE pLunAD = CFGMR3GetChildF(pLunL0, "AttachedDriver");
if (pLunAD)
{
CFGMR3RemoveNode(pLunAD);
}
else
{
CFGMR3RemoveNode(pLunL0);
InsertConfigNode(pInst, "LUN#0", &pLunL0);
InsertConfigString(pLunL0, "Driver", "NetSniffer");
InsertConfigNode(pLunL0, "Config", &pCfg);
hrc = aNetworkAdapter->COMGETTER(TraceFile)(bstr.asOutParam()); H();
if (!bstr.isEmpty()) /* check convention for indicating default file. */
InsertConfigString(pCfg, "File", bstr);
}
}
else if (fAttachDetach && !fSniffer)
{
rc = PDMR3DeviceDetach(pVM, pszDevice, uInstance, uLun, 0 /*fFlags*/);
if (rc == VINF_PDM_NO_DRIVER_ATTACHED_TO_LUN)
rc = VINF_SUCCESS;
AssertLogRelRCReturn(rc, rc);
/* nuke anything which might have been left behind. */
CFGMR3RemoveNode(CFGMR3GetChildF(pInst, "LUN#%u", uLun));
}
else if (!fAttachDetach && fSniffer)
{
/* insert the sniffer filter driver. */
InsertConfigNode(pInst, "LUN#0", &pLunL0);
InsertConfigString(pLunL0, "Driver", "NetSniffer");
InsertConfigNode(pLunL0, "Config", &pCfg);
hrc = aNetworkAdapter->COMGETTER(TraceFile)(bstr.asOutParam()); H();
if (!bstr.isEmpty()) /* check convention for indicating default file. */
InsertConfigString(pCfg, "File", bstr);
}
Bstr networkName, trunkName, trunkType;
NetworkAttachmentType_T eAttachmentType;
hrc = aNetworkAdapter->COMGETTER(AttachmentType)(&eAttachmentType); H();
switch (eAttachmentType)
{
case NetworkAttachmentType_Null:
break;
case NetworkAttachmentType_NAT:
{
ComPtr<INATEngine> natDriver;
hrc = aNetworkAdapter->COMGETTER(NatDriver)(natDriver.asOutParam()); H();
if (fSniffer)
InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
else
InsertConfigNode(pInst, "LUN#0", &pLunL0);
InsertConfigString(pLunL0, "Driver", "NAT");
InsertConfigNode(pLunL0, "Config", &pCfg);
/* Configure TFTP prefix and boot filename. */
hrc = virtualBox->COMGETTER(HomeFolder)(bstr.asOutParam()); H();
if (!bstr.isEmpty())
InsertConfigString(pCfg, "TFTPPrefix", Utf8StrFmt("%ls%c%s", bstr.raw(), RTPATH_DELIMITER, "TFTP"));
hrc = pMachine->COMGETTER(Name)(bstr.asOutParam()); H();
InsertConfigString(pCfg, "BootFile", Utf8StrFmt("%ls.pxe", bstr.raw()));
hrc = natDriver->COMGETTER(Network)(bstr.asOutParam()); H();
if (!bstr.isEmpty())
InsertConfigString(pCfg, "Network", bstr);
else
{
ULONG uSlot;
hrc = aNetworkAdapter->COMGETTER(Slot)(&uSlot); H();
InsertConfigString(pCfg, "Network", Utf8StrFmt("10.0.%d.0/24", uSlot+2));
}
hrc = natDriver->COMGETTER(HostIP)(bstr.asOutParam()); H();
if (!bstr.isEmpty())
InsertConfigString(pCfg, "BindIP", bstr);
ULONG mtu = 0;
ULONG sockSnd = 0;
ULONG sockRcv = 0;
ULONG tcpSnd = 0;
ULONG tcpRcv = 0;
hrc = natDriver->GetNetworkSettings(&mtu, &sockSnd, &sockRcv, &tcpSnd, &tcpRcv); H();
if (mtu)
InsertConfigInteger(pCfg, "SlirpMTU", mtu);
if (sockRcv)
InsertConfigInteger(pCfg, "SockRcv", sockRcv);
if (sockSnd)
InsertConfigInteger(pCfg, "SockSnd", sockSnd);
if (tcpRcv)
InsertConfigInteger(pCfg, "TcpRcv", tcpRcv);
if (tcpSnd)
InsertConfigInteger(pCfg, "TcpSnd", tcpSnd);
hrc = natDriver->COMGETTER(TftpPrefix)(bstr.asOutParam()); H();
if (!bstr.isEmpty())
{
RemoveConfigValue(pCfg, "TFTPPrefix");
InsertConfigString(pCfg, "TFTPPrefix", bstr);
}
hrc = natDriver->COMGETTER(TftpBootFile)(bstr.asOutParam()); H();
if (!bstr.isEmpty())
{
RemoveConfigValue(pCfg, "BootFile");
InsertConfigString(pCfg, "BootFile", bstr);
}
hrc = natDriver->COMGETTER(TftpNextServer)(bstr.asOutParam()); H();
if (!bstr.isEmpty())
InsertConfigString(pCfg, "NextServer", bstr);
BOOL fDnsFlag;
hrc = natDriver->COMGETTER(DnsPassDomain)(&fDnsFlag); H();
InsertConfigInteger(pCfg, "PassDomain", fDnsFlag);
hrc = natDriver->COMGETTER(DnsProxy)(&fDnsFlag); H();
InsertConfigInteger(pCfg, "DNSProxy", fDnsFlag);
hrc = natDriver->COMGETTER(DnsUseHostResolver)(&fDnsFlag); H();
InsertConfigInteger(pCfg, "UseHostResolver", fDnsFlag);
ULONG aliasMode;
hrc = natDriver->COMGETTER(AliasMode)(&aliasMode); H();
InsertConfigInteger(pCfg, "AliasMode", aliasMode);
/* port-forwarding */
SafeArray<BSTR> pfs;
hrc = natDriver->COMGETTER(Redirects)(ComSafeArrayAsOutParam(pfs)); H();
PCFGMNODE pPF = NULL; /* /Devices/Dev/.../Config/PF#0/ */
for (unsigned int i = 0; i < pfs.size(); ++i)
{
uint16_t port = 0;
BSTR r = pfs[i];
Utf8Str utf = Utf8Str(r);
Utf8Str strName;
Utf8Str strProto;
Utf8Str strHostPort;
Utf8Str strHostIP;
Utf8Str strGuestPort;
Utf8Str strGuestIP;
size_t pos, ppos;
pos = ppos = 0;
#define ITERATE_TO_NEXT_TERM(res, str, pos, ppos) \
do { \
pos = str.find(",", ppos); \
if (pos == Utf8Str::npos) \
{ \
Log(( #res " extracting from %s is failed\n", str.c_str())); \
continue; \
} \
res = str.substr(ppos, pos - ppos); \
Log2((#res " %s pos:%d, ppos:%d\n", res.c_str(), pos, ppos)); \
ppos = pos + 1; \
} while (0)
ITERATE_TO_NEXT_TERM(strName, utf, pos, ppos);
ITERATE_TO_NEXT_TERM(strProto, utf, pos, ppos);
ITERATE_TO_NEXT_TERM(strHostIP, utf, pos, ppos);
ITERATE_TO_NEXT_TERM(strHostPort, utf, pos, ppos);
ITERATE_TO_NEXT_TERM(strGuestIP, utf, pos, ppos);
strGuestPort = utf.substr(ppos, utf.length() - ppos);
#undef ITERATE_TO_NEXT_TERM
uint32_t proto = strProto.toUInt32();
bool fValid = true;
switch (proto)
{
case NATProtocol_UDP:
strProto = "UDP";
break;
case NATProtocol_TCP:
strProto = "TCP";
break;
default:
fValid = false;
}
/* continue with next rule if no valid proto was passed */
if (!fValid)
continue;
InsertConfigNode(pCfg, strName.c_str(), &pPF);
InsertConfigString(pPF, "Protocol", strProto);
if (!strHostIP.isEmpty())
InsertConfigString(pPF, "BindIP", strHostIP);
if (!strGuestIP.isEmpty())
InsertConfigString(pPF, "GuestIP", strGuestIP);
port = RTStrToUInt16(strHostPort.c_str());
if (port)
InsertConfigInteger(pPF, "HostPort", port);
port = RTStrToUInt16(strGuestPort.c_str());
if (port)
InsertConfigInteger(pPF, "GuestPort", port);
}
break;
}
case NetworkAttachmentType_Bridged:
{
#if (defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)) && !defined(VBOX_WITH_NETFLT)
hrc = attachToTapInterface(aNetworkAdapter);
if (FAILED(hrc))
{
switch (hrc)
{
case VERR_ACCESS_DENIED:
return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
"Failed to open '/dev/net/tun' for read/write access. Please check the "
"permissions of that node. Either run 'chmod 0666 /dev/net/tun' or "
"change the group of that node and make yourself a member of that group. Make "
"sure that these changes are permanent, especially if you are "
"using udev"));
default:
AssertMsgFailed(("Could not attach to host interface! Bad!\n"));
return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
"Failed to initialize Host Interface Networking"));
}
}
Assert((int)maTapFD[uInstance] >= 0);
if ((int)maTapFD[uInstance] >= 0)
{
if (fSniffer)
{
InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
}
else
{
InsertConfigNode(pInst, "LUN#0", &pLunL0);
}
InsertConfigString(pLunL0, "Driver", "HostInterface");
InsertConfigNode(pLunL0, "Config", &pCfg);
InsertConfigInteger(pCfg, "FileHandle", maTapFD[uInstance]);
}
#elif defined(VBOX_WITH_NETFLT)
/*
* This is the new VBoxNetFlt+IntNet stuff.
*/
if (fSniffer)
{
InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
}
else
{
InsertConfigNode(pInst, "LUN#0", &pLunL0);
}
Bstr HifName;
hrc = aNetworkAdapter->COMGETTER(HostInterface)(HifName.asOutParam());
if (FAILED(hrc))
{
LogRel(("NetworkAttachmentType_Bridged: COMGETTER(HostInterface) failed, hrc (0x%x)", hrc));
H();
}
Utf8Str HifNameUtf8(HifName);
const char *pszHifName = HifNameUtf8.c_str();
# if defined(RT_OS_DARWIN)
/* The name is on the form 'ifX: long name', chop it off at the colon. */
char szTrunk[8];
strncpy(szTrunk, pszHifName, sizeof(szTrunk));
char *pszColon = (char *)memchr(szTrunk, ':', sizeof(szTrunk));
if (!pszColon)
{
/*
* Dynamic changing of attachment causes an attempt to configure
* network with invalid host adapter (as it is must be changed before
* the attachment), calling Detach here will cause a deadlock.
* See #4750.
* hrc = aNetworkAdapter->Detach(); H();
*/
return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
N_("Malformed host interface networking name '%ls'"),
HifName.raw());
}
*pszColon = '\0';
const char *pszTrunk = szTrunk;
# elif defined(RT_OS_SOLARIS)
/* The name is on the form format 'ifX[:1] - long name, chop it off at space. */
char szTrunk[256];
strlcpy(szTrunk, pszHifName, sizeof(szTrunk));
char *pszSpace = (char *)memchr(szTrunk, ' ', sizeof(szTrunk));
/*
* Currently don't bother about malformed names here for the sake of people using
* VBoxManage and setting only the NIC name from there. If there is a space we
* chop it off and proceed, otherwise just use whatever we've got.
*/
if (pszSpace)
*pszSpace = '\0';
/* Chop it off at the colon (zone naming eg: e1000g:1 we need only the e1000g) */
char *pszColon = (char *)memchr(szTrunk, ':', sizeof(szTrunk));
if (pszColon)
*pszColon = '\0';
const char *pszTrunk = szTrunk;
# elif defined(RT_OS_WINDOWS)
ComPtr<IHostNetworkInterface> hostInterface;
hrc = host->FindHostNetworkInterfaceByName(HifName.raw(),
hostInterface.asOutParam());
if (!SUCCEEDED(hrc))
{
AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: FindByName failed, rc=%Rhrc (0x%x)", hrc, hrc));
return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
N_("Nonexistent host networking interface, name '%ls'"),
HifName.raw());
}
HostNetworkInterfaceType_T eIfType;
hrc = hostInterface->COMGETTER(InterfaceType)(&eIfType);
if (FAILED(hrc))
{
LogRel(("NetworkAttachmentType_Bridged: COMGETTER(InterfaceType) failed, hrc (0x%x)", hrc));
H();
}
if (eIfType != HostNetworkInterfaceType_Bridged)
{
return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
N_("Interface ('%ls') is not a Bridged Adapter interface"),
HifName.raw());
}
hrc = hostInterface->COMGETTER(Id)(bstr.asOutParam());
if (FAILED(hrc))
{
LogRel(("NetworkAttachmentType_Bridged: COMGETTER(Id) failed, hrc (0x%x)", hrc));
H();
}
Guid hostIFGuid(bstr);
INetCfg *pNc;
ComPtr<INetCfgComponent> pAdaptorComponent;
LPWSTR pszApp;
int rc = VERR_INTNET_FLT_IF_NOT_FOUND;
hrc = VBoxNetCfgWinQueryINetCfg(FALSE /*fGetWriteLock*/,
L"VirtualBox",
&pNc,
&pszApp);
Assert(hrc == S_OK);
if (hrc == S_OK)
{
/* get the adapter's INetCfgComponent*/
hrc = VBoxNetCfgWinGetComponentByGuid(pNc, &GUID_DEVCLASS_NET, (GUID*)hostIFGuid.raw(), pAdaptorComponent.asOutParam());
if (hrc != S_OK)
{
VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
LogRel(("NetworkAttachmentType_Bridged: VBoxNetCfgWinGetComponentByGuid failed, hrc (0x%x)", hrc));
H();
}
}
#define VBOX_WIN_BINDNAME_PREFIX "\\DEVICE\\"
char szTrunkName[INTNET_MAX_TRUNK_NAME];
char *pszTrunkName = szTrunkName;
wchar_t * pswzBindName;
hrc = pAdaptorComponent->GetBindName(&pswzBindName);
Assert(hrc == S_OK);
if (hrc == S_OK)
{
int cwBindName = (int)wcslen(pswzBindName) + 1;
int cbFullBindNamePrefix = sizeof(VBOX_WIN_BINDNAME_PREFIX);
if (sizeof(szTrunkName) > cbFullBindNamePrefix + cwBindName)
{
strcpy(szTrunkName, VBOX_WIN_BINDNAME_PREFIX);
pszTrunkName += cbFullBindNamePrefix-1;
if (!WideCharToMultiByte(CP_ACP, 0, pswzBindName, cwBindName, pszTrunkName,
sizeof(szTrunkName) - cbFullBindNamePrefix + 1, NULL, NULL))
{
DWORD err = GetLastError();
hrc = HRESULT_FROM_WIN32(err);
AssertMsgFailed(("%hrc=%Rhrc %#x\n", hrc, hrc));
AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: WideCharToMultiByte failed, hr=%Rhrc (0x%x) err=%u\n", hrc, hrc, err));
}
}
else
{
AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: insufficient szTrunkName buffer space\n"));
/** @todo set appropriate error code */
hrc = E_FAIL;
}
if (hrc != S_OK)
{
AssertFailed();
CoTaskMemFree(pswzBindName);
VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
H();
}
/* we're not freeing the bind name since we'll use it later for detecting wireless*/
}
else
{
VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: VBoxNetCfgWinGetComponentByGuid failed, hrc (0x%x)", hrc));
H();
}
const char *pszTrunk = szTrunkName;
/* we're not releasing the INetCfg stuff here since we use it later to figure out whether it is wireless */
# elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
# if defined(RT_OS_FREEBSD)
/*
* If we bridge to a tap interface open it the `old' direct way.
* This works and performs better than bridging a physical
* interface via the current FreeBSD vboxnetflt implementation.
*/
if (!strncmp(pszHifName, "tap", sizeof "tap" - 1)) {
hrc = attachToTapInterface(aNetworkAdapter);
if (FAILED(hrc))
{
switch (hrc)
{
case VERR_ACCESS_DENIED:
return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
"Failed to open '/dev/%s' for read/write access. Please check the "
"permissions of that node, and that the net.link.tap.user_open "
"sysctl is set. Either run 'chmod 0666 /dev/%s' or "
"change the group of that node to vboxusers and make yourself "
"a member of that group. Make sure that these changes are permanent."), pszHifName, pszHifName);
default:
AssertMsgFailed(("Could not attach to tap interface! Bad!\n"));
return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
"Failed to initialize Host Interface Networking"));
}
}
Assert((int)maTapFD[uInstance] >= 0);
if ((int)maTapFD[uInstance] >= 0)
{
InsertConfigString(pLunL0, "Driver", "HostInterface");
InsertConfigNode(pLunL0, "Config", &pCfg);
InsertConfigInteger(pCfg, "FileHandle", maTapFD[uInstance]);
}
break;
}
# endif
/** @todo Check for malformed names. */
const char *pszTrunk = pszHifName;
/* Issue a warning if the interface is down */
{
int iSock = socket(AF_INET, SOCK_DGRAM, 0);
if (iSock >= 0)
{
struct ifreq Req;
memset(&Req, 0, sizeof(Req));
strncpy(Req.ifr_name, pszHifName, sizeof(Req.ifr_name) - 1);
if (ioctl(iSock, SIOCGIFFLAGS, &Req) >= 0)
if ((Req.ifr_flags & IFF_UP) == 0)
{
setVMRuntimeErrorCallbackF(pVM, this, 0, "BridgedInterfaceDown", "Bridged interface %s is down. Guest will not be able to use this interface", pszHifName);
}
close(iSock);
}
}
# else
# error "PORTME (VBOX_WITH_NETFLT)"
# endif
InsertConfigString(pLunL0, "Driver", "IntNet");
InsertConfigNode(pLunL0, "Config", &pCfg);
InsertConfigString(pCfg, "Trunk", pszTrunk);
InsertConfigInteger(pCfg, "TrunkType", kIntNetTrunkType_NetFlt);
char szNetwork[INTNET_MAX_NETWORK_NAME];
RTStrPrintf(szNetwork, sizeof(szNetwork), "HostInterfaceNetworking-%s", pszHifName);
InsertConfigString(pCfg, "Network", szNetwork);
networkName = Bstr(szNetwork);
trunkName = Bstr(pszTrunk);
trunkType = Bstr(TRUNKTYPE_NETFLT);
# if defined(RT_OS_DARWIN)
/** @todo Come up with a better deal here. Problem is that IHostNetworkInterface is completely useless here. */
if ( strstr(pszHifName, "Wireless")
|| strstr(pszHifName, "AirPort" ))
InsertConfigInteger(pCfg, "SharedMacOnWire", true);
# elif defined(RT_OS_LINUX)
int iSock = socket(AF_INET, SOCK_DGRAM, 0);
if (iSock >= 0)
{
struct iwreq WRq;
memset(&WRq, 0, sizeof(WRq));
strncpy(WRq.ifr_name, pszHifName, IFNAMSIZ);
bool fSharedMacOnWire = ioctl(iSock, SIOCGIWNAME, &WRq) >= 0;
close(iSock);
if (fSharedMacOnWire)
{
InsertConfigInteger(pCfg, "SharedMacOnWire", true);
Log(("Set SharedMacOnWire\n"));
}
else
Log(("Failed to get wireless name\n"));
}
else
Log(("Failed to open wireless socket\n"));
# elif defined(RT_OS_FREEBSD)
int iSock = socket(AF_INET, SOCK_DGRAM, 0);
if (iSock >= 0)
{
struct ieee80211req WReq;
uint8_t abData[32];
memset(&WReq, 0, sizeof(WReq));
strncpy(WReq.i_name, pszHifName, sizeof(WReq.i_name));
WReq.i_type = IEEE80211_IOC_SSID;
WReq.i_val = -1;
WReq.i_data = abData;
WReq.i_len = sizeof(abData);
bool fSharedMacOnWire = ioctl(iSock, SIOCG80211, &WReq) >= 0;
close(iSock);
if (fSharedMacOnWire)
{
InsertConfigInteger(pCfg, "SharedMacOnWire", true);
Log(("Set SharedMacOnWire\n"));
}
else
Log(("Failed to get wireless name\n"));
}
else
Log(("Failed to open wireless socket\n"));
# elif defined(RT_OS_WINDOWS)
# define DEVNAME_PREFIX L"\\\\.\\"
/* we are getting the medium type via IOCTL_NDIS_QUERY_GLOBAL_STATS Io Control
* there is a pretty long way till there though since we need to obtain the symbolic link name
* for the adapter device we are going to query given the device Guid */
/* prepend the "\\\\.\\" to the bind name to obtain the link name */
wchar_t FileName[MAX_PATH];
wcscpy(FileName, DEVNAME_PREFIX);
wcscpy((wchar_t*)(((char*)FileName) + sizeof(DEVNAME_PREFIX) - sizeof(FileName[0])), pswzBindName);
/* open the device */
HANDLE hDevice = CreateFile(FileName,
GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hDevice != INVALID_HANDLE_VALUE)
{
bool fSharedMacOnWire = false;
/* now issue the OID_GEN_PHYSICAL_MEDIUM query */
DWORD Oid = OID_GEN_PHYSICAL_MEDIUM;
NDIS_PHYSICAL_MEDIUM PhMedium;
DWORD cbResult;
if (DeviceIoControl(hDevice,
IOCTL_NDIS_QUERY_GLOBAL_STATS,
&Oid,
sizeof(Oid),
&PhMedium,
sizeof(PhMedium),
&cbResult,
NULL))
{
/* that was simple, now examine PhMedium */
if ( PhMedium == NdisPhysicalMediumWirelessWan
|| PhMedium == NdisPhysicalMediumWirelessLan
|| PhMedium == NdisPhysicalMediumNative802_11
|| PhMedium == NdisPhysicalMediumBluetooth)
fSharedMacOnWire = true;
}
else
{
int winEr = GetLastError();
LogRel(("Console::configNetwork: DeviceIoControl failed, err (0x%x), ignoring\n", winEr));
Assert(winEr == ERROR_INVALID_PARAMETER || winEr == ERROR_NOT_SUPPORTED || winEr == ERROR_BAD_COMMAND);
}
CloseHandle(hDevice);
if (fSharedMacOnWire)
{
Log(("this is a wireless adapter"));
InsertConfigInteger(pCfg, "SharedMacOnWire", true);
Log(("Set SharedMacOnWire\n"));
}
else
Log(("this is NOT a wireless adapter"));
}
else
{
int winEr = GetLastError();
AssertLogRelMsgFailed(("Console::configNetwork: CreateFile failed, err (0x%x), ignoring\n", winEr));
}
CoTaskMemFree(pswzBindName);
pAdaptorComponent.setNull();
/* release the pNc finally */
VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
# else
/** @todo PORTME: wireless detection */
# endif
# if defined(RT_OS_SOLARIS)
# if 0 /* bird: this is a bit questionable and might cause more trouble than its worth. */
/* Zone access restriction, don't allow snooping the global zone. */
zoneid_t ZoneId = getzoneid();
if (ZoneId != GLOBAL_ZONEID)
{
InsertConfigInteger(pCfg, "IgnoreAllPromisc", true);
}
# endif
# endif
#elif defined(RT_OS_WINDOWS) /* not defined NetFlt */
/* NOTHING TO DO HERE */
#elif defined(RT_OS_LINUX)
/// @todo aleksey: is there anything to be done here?
#elif defined(RT_OS_FREEBSD)
/** @todo FreeBSD: Check out this later (HIF networking). */
#else
# error "Port me"
#endif
break;
}
case NetworkAttachmentType_Internal:
{
hrc = aNetworkAdapter->COMGETTER(InternalNetwork)(bstr.asOutParam()); H();
if (!bstr.isEmpty())
{
if (fSniffer)
InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
else
InsertConfigNode(pInst, "LUN#0", &pLunL0);
InsertConfigString(pLunL0, "Driver", "IntNet");
InsertConfigNode(pLunL0, "Config", &pCfg);
InsertConfigString(pCfg, "Network", bstr);
InsertConfigInteger(pCfg, "TrunkType", kIntNetTrunkType_WhateverNone);
networkName = bstr;
trunkType = Bstr(TRUNKTYPE_WHATEVER);
}
break;
}
case NetworkAttachmentType_HostOnly:
{
if (fSniffer)
InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
else
InsertConfigNode(pInst, "LUN#0", &pLunL0);
InsertConfigString(pLunL0, "Driver", "IntNet");
InsertConfigNode(pLunL0, "Config", &pCfg);
Bstr HifName;
hrc = aNetworkAdapter->COMGETTER(HostInterface)(HifName.asOutParam());
if (FAILED(hrc))
{
LogRel(("NetworkAttachmentType_HostOnly: COMGETTER(HostInterface) failed, hrc (0x%x)\n", hrc));
H();
}
Utf8Str HifNameUtf8(HifName);
const char *pszHifName = HifNameUtf8.c_str();
ComPtr<IHostNetworkInterface> hostInterface;
rc = host->FindHostNetworkInterfaceByName(HifName.raw(),
hostInterface.asOutParam());
if (!SUCCEEDED(rc))
{
LogRel(("NetworkAttachmentType_HostOnly: FindByName failed, rc (0x%x)\n", rc));
return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
N_("Nonexistent host networking interface, name '%ls'"),
HifName.raw());
}
char szNetwork[INTNET_MAX_NETWORK_NAME];
RTStrPrintf(szNetwork, sizeof(szNetwork), "HostInterfaceNetworking-%s", pszHifName);
#if defined(RT_OS_WINDOWS)
# ifndef VBOX_WITH_NETFLT
hrc = E_NOTIMPL;
LogRel(("NetworkAttachmentType_HostOnly: Not Implemented\n"));
H();
# else /* defined VBOX_WITH_NETFLT*/
/** @todo r=bird: Put this in a function. */
HostNetworkInterfaceType_T eIfType;
hrc = hostInterface->COMGETTER(InterfaceType)(&eIfType);
if (FAILED(hrc))
{
LogRel(("NetworkAttachmentType_HostOnly: COMGETTER(InterfaceType) failed, hrc (0x%x)\n", hrc));
H();
}
if (eIfType != HostNetworkInterfaceType_HostOnly)
return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
N_("Interface ('%ls') is not a Host-Only Adapter interface"),
HifName.raw());
hrc = hostInterface->COMGETTER(Id)(bstr.asOutParam());
if (FAILED(hrc))
{
LogRel(("NetworkAttachmentType_HostOnly: COMGETTER(Id) failed, hrc (0x%x)\n", hrc));
H();
}
Guid hostIFGuid(bstr);
INetCfg *pNc;
ComPtr<INetCfgComponent> pAdaptorComponent;
LPWSTR pszApp;
rc = VERR_INTNET_FLT_IF_NOT_FOUND;
hrc = VBoxNetCfgWinQueryINetCfg(FALSE,
L"VirtualBox",
&pNc,
&pszApp);
Assert(hrc == S_OK);
if (hrc == S_OK)
{
/* get the adapter's INetCfgComponent*/
hrc = VBoxNetCfgWinGetComponentByGuid(pNc, &GUID_DEVCLASS_NET, (GUID*)hostIFGuid.raw(), pAdaptorComponent.asOutParam());
if (hrc != S_OK)
{
VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
LogRel(("NetworkAttachmentType_HostOnly: VBoxNetCfgWinGetComponentByGuid failed, hrc=%Rhrc (0x%x)\n", hrc, hrc));
H();
}
}
#define VBOX_WIN_BINDNAME_PREFIX "\\DEVICE\\"
char szTrunkName[INTNET_MAX_TRUNK_NAME];
char *pszTrunkName = szTrunkName;
wchar_t * pswzBindName;
hrc = pAdaptorComponent->GetBindName(&pswzBindName);
Assert(hrc == S_OK);
if (hrc == S_OK)
{
int cwBindName = (int)wcslen(pswzBindName) + 1;
int cbFullBindNamePrefix = sizeof(VBOX_WIN_BINDNAME_PREFIX);
if (sizeof(szTrunkName) > cbFullBindNamePrefix + cwBindName)
{
strcpy(szTrunkName, VBOX_WIN_BINDNAME_PREFIX);
pszTrunkName += cbFullBindNamePrefix-1;
if (!WideCharToMultiByte(CP_ACP, 0, pswzBindName, cwBindName, pszTrunkName,
sizeof(szTrunkName) - cbFullBindNamePrefix + 1, NULL, NULL))
{
DWORD err = GetLastError();
hrc = HRESULT_FROM_WIN32(err);
AssertLogRelMsgFailed(("NetworkAttachmentType_HostOnly: WideCharToMultiByte failed, hr=%Rhrc (0x%x) err=%u\n", hrc, hrc, err));
}
}
else
{
AssertLogRelMsgFailed(("NetworkAttachmentType_HostOnly: insufficient szTrunkName buffer space\n"));
/** @todo set appropriate error code */
hrc = E_FAIL;
}
if (hrc != S_OK)
{
AssertFailed();
CoTaskMemFree(pswzBindName);
VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
H();
}
}
else
{
VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
AssertLogRelMsgFailed(("NetworkAttachmentType_HostOnly: VBoxNetCfgWinGetComponentByGuid failed, hrc=%Rhrc (0x%x)\n", hrc, hrc));
H();
}
CoTaskMemFree(pswzBindName);
pAdaptorComponent.setNull();
/* release the pNc finally */
VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
const char *pszTrunk = szTrunkName;
InsertConfigInteger(pCfg, "TrunkType", kIntNetTrunkType_NetAdp);
InsertConfigString(pCfg, "Trunk", pszTrunk);
InsertConfigString(pCfg, "Network", szNetwork);
networkName = Bstr(szNetwork);
trunkName = Bstr(pszTrunk);
trunkType = TRUNKTYPE_NETADP;
# endif /* defined VBOX_WITH_NETFLT*/
#elif defined(RT_OS_DARWIN)
InsertConfigString(pCfg, "Trunk", pszHifName);
InsertConfigString(pCfg, "Network", szNetwork);
InsertConfigInteger(pCfg, "TrunkType", kIntNetTrunkType_NetAdp);
networkName = Bstr(szNetwork);
trunkName = Bstr(pszHifName);
trunkType = TRUNKTYPE_NETADP;
#else
InsertConfigString(pCfg, "Trunk", pszHifName);
InsertConfigString(pCfg, "Network", szNetwork);
InsertConfigInteger(pCfg, "TrunkType", kIntNetTrunkType_NetFlt);
networkName = Bstr(szNetwork);
trunkName = Bstr(pszHifName);
trunkType = TRUNKTYPE_NETFLT;
#endif
#if !defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
Bstr tmpAddr, tmpMask;
hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPAddress",
pszHifName).raw(),
tmpAddr.asOutParam());
if (SUCCEEDED(hrc) && !tmpAddr.isEmpty())
{
hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPNetMask",
pszHifName).raw(),
tmpMask.asOutParam());
if (SUCCEEDED(hrc) && !tmpMask.isEmpty())
hrc = hostInterface->EnableStaticIpConfig(tmpAddr.raw(),
tmpMask.raw());
else
hrc = hostInterface->EnableStaticIpConfig(tmpAddr.raw(),
Bstr(VBOXNET_IPV4MASK_DEFAULT).raw());
}
else
{
/* Grab the IP number from the 'vboxnetX' instance number (see netif.h) */
hrc = hostInterface->EnableStaticIpConfig(getDefaultIPv4Address(Bstr(pszHifName)).raw(),
Bstr(VBOXNET_IPV4MASK_DEFAULT).raw());
}
ComAssertComRC(hrc); /** @todo r=bird: Why this isn't fatal? (H()) */
hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6Address",
pszHifName).raw(),
tmpAddr.asOutParam());
if (SUCCEEDED(hrc))
hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6NetMask", pszHifName).raw(),
tmpMask.asOutParam());
if (SUCCEEDED(hrc) && !tmpAddr.isEmpty() && !tmpMask.isEmpty())
{
hrc = hostInterface->EnableStaticIpConfigV6(tmpAddr.raw(),
Utf8Str(tmpMask).toUInt32());
ComAssertComRC(hrc); /** @todo r=bird: Why this isn't fatal? (H()) */
}
#endif
break;
}
#if defined(VBOX_WITH_VDE)
case NetworkAttachmentType_VDE:
{
hrc = aNetworkAdapter->COMGETTER(VDENetwork)(bstr.asOutParam()); H();
InsertConfigNode(pInst, "LUN#0", &pLunL0);
InsertConfigString(pLunL0, "Driver", "VDE");
InsertConfigNode(pLunL0, "Config", &pCfg);
if (!bstr.isEmpty())
{
InsertConfigString(pCfg, "Network", bstr);
networkName = bstr;
}
break;
}
#endif
default:
AssertMsgFailed(("should not get here!\n"));
break;
}
/*
* Attempt to attach the driver.
*/
switch (eAttachmentType)
{
case NetworkAttachmentType_Null:
break;
case NetworkAttachmentType_Bridged:
case NetworkAttachmentType_Internal:
case NetworkAttachmentType_HostOnly:
case NetworkAttachmentType_NAT:
#if defined(VBOX_WITH_VDE)
case NetworkAttachmentType_VDE:
#endif
{
if (SUCCEEDED(hrc) && SUCCEEDED(rc))
{
if (fAttachDetach)
{
rc = PDMR3DriverAttach(pVM, pszDevice, uInstance, uLun, 0 /*fFlags*/, NULL /* ppBase */);
//AssertRC(rc);
}
{
/** @todo pritesh: get the dhcp server name from the
* previous network configuration and then stop the server
* else it may conflict with the dhcp server running with
* the current attachment type
*/
/* Stop the hostonly DHCP Server */
}
if (!networkName.isEmpty())
{
/*
* Until we implement service reference counters DHCP Server will be stopped
* by DHCPServerRunner destructor.
*/
ComPtr<IDHCPServer> dhcpServer;
hrc = virtualBox->FindDHCPServerByNetworkName(networkName.raw(),
dhcpServer.asOutParam());
if (SUCCEEDED(hrc))
{
/* there is a DHCP server available for this network */
BOOL fEnabled;
hrc = dhcpServer->COMGETTER(Enabled)(&fEnabled);
if (FAILED(hrc))
{
LogRel(("DHCP svr: COMGETTER(Enabled) failed, hrc (%Rhrc)", hrc));
H();
}
if (fEnabled)
hrc = dhcpServer->Start(networkName.raw(),
trunkName.raw(),
trunkType.raw());
}
else
hrc = S_OK;
}
}
break;
}
default:
AssertMsgFailed(("should not get here!\n"));
break;
}
meAttachmentType[uInstance] = eAttachmentType;
}
catch (ConfigError &x)
{
// InsertConfig threw something:
return x.m_vrc;
}
#undef H
return VINF_SUCCESS;
}
#ifdef VBOX_WITH_GUEST_PROPS
/**
* Set an array of guest properties
*/
static void configSetProperties(VMMDev * const pVMMDev,
void *names,
void *values,
void *timestamps,
void *flags)
{
VBOXHGCMSVCPARM parms[4];
parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
parms[0].u.pointer.addr = names;
parms[0].u.pointer.size = 0; /* We don't actually care. */
parms[1].type = VBOX_HGCM_SVC_PARM_PTR;
parms[1].u.pointer.addr = values;
parms[1].u.pointer.size = 0; /* We don't actually care. */
parms[2].type = VBOX_HGCM_SVC_PARM_PTR;
parms[2].u.pointer.addr = timestamps;
parms[2].u.pointer.size = 0; /* We don't actually care. */
parms[3].type = VBOX_HGCM_SVC_PARM_PTR;
parms[3].u.pointer.addr = flags;
parms[3].u.pointer.size = 0; /* We don't actually care. */
pVMMDev->hgcmHostCall("VBoxGuestPropSvc",
guestProp::SET_PROPS_HOST,
4,
&parms[0]);
}
/**
* Set a single guest property
*/
static void configSetProperty(VMMDev * const pVMMDev,
const char *pszName,
const char *pszValue,
const char *pszFlags)
{
VBOXHGCMSVCPARM parms[4];
AssertPtrReturnVoid(pszName);
AssertPtrReturnVoid(pszValue);
AssertPtrReturnVoid(pszFlags);
parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
parms[0].u.pointer.addr = (void *)pszName;
parms[0].u.pointer.size = strlen(pszName) + 1;
parms[1].type = VBOX_HGCM_SVC_PARM_PTR;
parms[1].u.pointer.addr = (void *)pszValue;
parms[1].u.pointer.size = strlen(pszValue) + 1;
parms[2].type = VBOX_HGCM_SVC_PARM_PTR;
parms[2].u.pointer.addr = (void *)pszFlags;
parms[2].u.pointer.size = strlen(pszFlags) + 1;
pVMMDev->hgcmHostCall("VBoxGuestPropSvc", guestProp::SET_PROP_HOST, 3,
&parms[0]);
}
/**
* Set the global flags value by calling the service
* @returns the status returned by the call to the service
*
* @param pTable the service instance handle
* @param eFlags the flags to set
*/
int configSetGlobalPropertyFlags(VMMDev * const pVMMDev,
guestProp::ePropFlags eFlags)
{
VBOXHGCMSVCPARM paParm;
paParm.setUInt32(eFlags);
int rc = pVMMDev->hgcmHostCall("VBoxGuestPropSvc",
guestProp::SET_GLOBAL_FLAGS_HOST, 1,
&paParm);
if (RT_FAILURE(rc))
{
char szFlags[guestProp::MAX_FLAGS_LEN];
if (RT_FAILURE(writeFlags(eFlags, szFlags)))
Log(("Failed to set the global flags.\n"));
else
Log(("Failed to set the global flags \"%s\".\n", szFlags));
}
return rc;
}
#endif /* VBOX_WITH_GUEST_PROPS */
/**
* Set up the Guest Property service, populate it with properties read from
* the machine XML and set a couple of initial properties.
*/
/* static */ int Console::configGuestProperties(void *pvConsole)
{
#ifdef VBOX_WITH_GUEST_PROPS
AssertReturn(pvConsole, VERR_GENERAL_FAILURE);
ComObjPtr<Console> pConsole = static_cast<Console *>(pvConsole);
AssertReturn(pConsole->m_pVMMDev, VERR_GENERAL_FAILURE);
/* Load the service */
int rc = pConsole->m_pVMMDev->hgcmLoadService("VBoxGuestPropSvc", "VBoxGuestPropSvc");
if (RT_FAILURE(rc))
{
LogRel(("VBoxGuestPropSvc is not available. rc = %Rrc\n", rc));
/* That is not a fatal failure. */
rc = VINF_SUCCESS;
}
else
{
/*
* Initialize built-in properties that can be changed and saved.
*
* These are typically transient properties that the guest cannot
* change.
*/
/* Sysprep execution by VBoxService. */
configSetProperty(pConsole->m_pVMMDev,
"/VirtualBox/HostGuest/SysprepExec", "",
"TRANSIENT, RDONLYGUEST");
configSetProperty(pConsole->m_pVMMDev,
"/VirtualBox/HostGuest/SysprepArgs", "",
"TRANSIENT, RDONLYGUEST");
/*
* Pull over the properties from the server.
*/
SafeArray<BSTR> namesOut;
SafeArray<BSTR> valuesOut;
SafeArray<LONG64> timestampsOut;
SafeArray<BSTR> flagsOut;
HRESULT hrc;
hrc = pConsole->mControl->PullGuestProperties(ComSafeArrayAsOutParam(namesOut),
ComSafeArrayAsOutParam(valuesOut),
ComSafeArrayAsOutParam(timestampsOut),
ComSafeArrayAsOutParam(flagsOut));
AssertMsgReturn(SUCCEEDED(hrc), ("hrc=%Rrc\n", hrc), VERR_GENERAL_FAILURE);
size_t cProps = namesOut.size();
size_t cAlloc = cProps + 1;
if ( valuesOut.size() != cProps
|| timestampsOut.size() != cProps
|| flagsOut.size() != cProps
)
AssertFailedReturn(VERR_INVALID_PARAMETER);
char **papszNames, **papszValues, **papszFlags;
char szEmpty[] = "";
LONG64 *pai64Timestamps;
papszNames = (char **)RTMemTmpAllocZ(sizeof(void *) * cAlloc);
papszValues = (char **)RTMemTmpAllocZ(sizeof(void *) * cAlloc);
pai64Timestamps = (LONG64 *)RTMemTmpAllocZ(sizeof(LONG64) * cAlloc);
papszFlags = (char **)RTMemTmpAllocZ(sizeof(void *) * cAlloc);
if (papszNames && papszValues && pai64Timestamps && 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;
pai64Timestamps[i] = timestampsOut[i];
if (flagsOut[i])
rc = RTUtf16ToUtf8(flagsOut[i], &papszFlags[i]);
else
papszFlags[i] = szEmpty;
}
if (RT_SUCCESS(rc))
configSetProperties(pConsole->m_pVMMDev,
(void *)papszNames,
(void *)papszValues,
(void *)pai64Timestamps,
(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(pai64Timestamps);
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->m_pVMMDev, "/VirtualBox/HostInfo/VBoxVer",
VBOX_VERSION_STRING, "TRANSIENT, RDONLYGUEST");
/* Set the VBox SVN revision as a guest property */
configSetProperty(pConsole->m_pVMMDev, "/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 */
}
/**
* Set up the Guest Control service.
*/
/* static */ int Console::configGuestControl(void *pvConsole)
{
#ifdef VBOX_WITH_GUEST_CONTROL
AssertReturn(pvConsole, VERR_GENERAL_FAILURE);
ComObjPtr<Console> pConsole = static_cast<Console *>(pvConsole);
/* Load the service */
int rc = pConsole->m_pVMMDev->hgcmLoadService("VBoxGuestControlSvc", "VBoxGuestControlSvc");
if (RT_FAILURE(rc))
{
LogRel(("VBoxGuestControlSvc is not available. rc = %Rrc\n", rc));
/* That is not a fatal failure. */
rc = VINF_SUCCESS;
}
else
{
HGCMSVCEXTHANDLE hDummy;
rc = HGCMHostRegisterServiceExtension(&hDummy, "VBoxGuestControlSvc",
&Guest::doGuestCtrlNotification,
pConsole->getGuest());
if (RT_FAILURE(rc))
Log(("Cannot register VBoxGuestControlSvc extension!\n"));
else
Log(("VBoxGuestControlSvc loaded\n"));
}
return rc;
#else /* !VBOX_WITH_GUEST_CONTROL */
return VERR_NOT_SUPPORTED;
#endif /* !VBOX_WITH_GUEST_CONTROL */
}