ConsoleImpl2.cpp revision d1d4bf58f99da14d0aaa7bcc728a359c8a7eb7bd
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/* $Id$ */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/** @file
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * VBox Console COM Class implementation
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync *
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @remark We've split out the code that the 64-bit VC++ v8 compiler finds
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * problematic to optimize so we can disable optimizations and later,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * perhaps, find a real solution for it (like rewriting the code and
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * to stop resemble a tonne of spaghetti).
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Copyright (C) 2006-2010 Oracle Corporation
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync *
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * available from http://www.virtualbox.org. This file is free software;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * you can redistribute it and/or modify it under the terms of the GNU
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * General Public License (GPL) as published by the Free Software
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/*******************************************************************************
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync* Header Files *
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync*******************************************************************************/
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync// for some reason Windows burns in sdk\...\winsock.h if this isn't included first
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync#include "VBox/com/ptr.h"
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync#include "ConsoleImpl.h"
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync#include "DisplayImpl.h"
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#ifdef VBOX_WITH_GUEST_CONTROL
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include "GuestImpl.h"
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include "VMMDev.h"
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include "Global.h"
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#ifdef VBOX_WITH_PCI_PASSTHROUGH
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include "PciRawDevImpl.h"
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync// generated header
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include "SchemaDefs.h"
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include "AutoCaller.h"
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include "Logging.h"
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <iprt/buildconfig.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <iprt/ctype.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <iprt/dir.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <iprt/file.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <iprt/param.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <iprt/path.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <iprt/string.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <iprt/system.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <iprt/cpp/exception.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#if 0 /* enable to play with lots of memory. */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <iprt/env.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <iprt/stream.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <VBox/vmm/vmapi.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <VBox/err.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <VBox/param.h>
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync#include <VBox/vmm/pdmapi.h> /* For PDMR3DriverAttach/PDMR3DriverDetach */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <VBox/version.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <VBox/HostServices/VBoxClipboardSvc.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#ifdef VBOX_WITH_CROGL
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <VBox/HostServices/VBoxCrOpenGLSvc.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#ifdef VBOX_WITH_GUEST_PROPS
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <VBox/HostServices/GuestPropertySvc.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <VBox/com/defs.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <VBox/com/array.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include "HGCM.h" /** @todo it should be possible to register a service
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * extension using a VMMDev callback. */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <vector>
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync#endif /* VBOX_WITH_GUEST_PROPS */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include <VBox/intnet.h>
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#include <VBox/com/com.h>
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#include <VBox/com/string.h>
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#include <VBox/com/array.h>
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#ifdef VBOX_WITH_NETFLT
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# if defined(RT_OS_SOLARIS)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <zone.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# elif defined(RT_OS_LINUX)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <unistd.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <sys/ioctl.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <sys/socket.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <linux/types.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <linux/if.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <linux/wireless.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# elif defined(RT_OS_FREEBSD)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <unistd.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <sys/types.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <sys/ioctl.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <sys/socket.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <net/if.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <net80211/ieee80211_ioctl.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# endif
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# if defined(RT_OS_WINDOWS)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <VBox/WinNetConfig.h>
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync# include <Ntddndis.h>
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync# include <devguid.h>
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync# else
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync# include <HostNetworkInterfaceImpl.h>
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync# include <netif.h>
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync# include <stdlib.h>
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync# endif
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif /* VBOX_WITH_NETFLT */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include "DHCPServerRunner.h"
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#include "BusAssignmentManager.h"
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#ifdef VBOX_WITH_EXTPACK
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync# include "ExtPackManagerImpl.h"
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#if defined(RT_OS_DARWIN)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync# include "IOKit/IOKitLib.h"
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncstatic int DarwinSmcKey(char *pabKey, uint32_t cbKey)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Method as described in Amit Singh's article:
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * http://osxbook.com/book/bonus/chapter7/tpmdrmmyth/
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync typedef struct
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uint32_t key;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uint8_t pad0[22];
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync uint32_t datasize;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uint8_t pad1[10];
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uint8_t cmd;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uint32_t pad2;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uint8_t data[32];
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync } AppleSMCBuffer;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync AssertReturn(cbKey >= 65, VERR_INTERNAL_ERROR);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync IOServiceMatching("AppleSMC"));
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (!service)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return VERR_NOT_FOUND;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync io_connect_t port = (io_connect_t)0;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync kern_return_t kr = IOServiceOpen(service, mach_task_self(), 0, &port);
d1cbcedef8f8eb139111351e183add8c0b7d3645vboxsync IOObjectRelease(service);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (kr != kIOReturnSuccess)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return RTErrConvertFromDarwin(kr);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync AppleSMCBuffer inputStruct = { 0, {0}, 32, {0}, 5, };
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync AppleSMCBuffer outputStruct;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync size_t cbOutputStruct = sizeof(outputStruct);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync for (int i = 0; i < 2; i++)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync inputStruct.key = (uint32_t)((i == 0) ? 'OSK0' : 'OSK1');
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync kr = IOConnectCallStructMethod((mach_port_t)port,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync (uint32_t)2,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync (const void *)&inputStruct,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync sizeof(inputStruct),
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync (void *)&outputStruct,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync &cbOutputStruct);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (kr != kIOReturnSuccess)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync IOServiceClose(port);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return RTErrConvertFromDarwin(kr);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync for (int j = 0; j < 32; j++)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pabKey[j + i*32] = outputStruct.data[j];
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync IOServiceClose(port);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pabKey[64] = 0;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return VINF_SUCCESS;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif /* RT_OS_DARWIN */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/* Darwin compile kludge */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#undef PVM
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/* Comment out the following line to remove VMWare compatibility hack. */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#define VMWARE_NET_IN_SLOT_11
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/**
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Translate IDE StorageControllerType_T to string representation.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncconst char* controllerString(StorageControllerType_T enmType)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync switch (enmType)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync case StorageControllerType_PIIX3:
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return "PIIX3";
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync case StorageControllerType_PIIX4:
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return "PIIX4";
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync case StorageControllerType_ICH6:
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return "ICH6";
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync default:
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return "Unknown";
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/**
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Simple class for storing network boot information.
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncstruct BootNic
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ULONG mInstance;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PciBusAddress mPciAddress;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ULONG mBootPrio;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync bool operator < (const BootNic &rhs) const
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ULONG lval = mBootPrio - 1; /* 0 will wrap around and get the lowest priority. */
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync ULONG rval = rhs.mBootPrio - 1;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return lval < rval; /* Zero compares as highest number (lowest prio). */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync};
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncstatic int findEfiRom(IVirtualBox* vbox, FirmwareType_T aFirmwareType, Utf8Str *pEfiRomFile)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Bstr aFilePath, empty;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync BOOL fPresent = FALSE;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync HRESULT hrc = vbox->CheckFirmwarePresent(aFirmwareType, empty.raw(),
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync empty.asOutParam(), aFilePath.asOutParam(), &fPresent);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync AssertComRCReturn(hrc, Global::vboxStatusCodeFromCOM(hrc));
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (!fPresent)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return VERR_FILE_NOT_FOUND;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync *pEfiRomFile = Utf8Str(aFilePath);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return VINF_SUCCESS;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncstatic int getSmcDeviceKey(IMachine *pMachine, BSTR *aKey, bool *pfGetKeyFromRealSMC)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync *pfGetKeyFromRealSMC = false;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * The extra data takes precedence (if non-zero).
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync HRESULT hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/SmcDeviceKey").raw(),
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync aKey);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (FAILED(hrc))
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return Global::vboxStatusCodeFromCOM(hrc);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if ( SUCCEEDED(hrc)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync && *aKey
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync && **aKey)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return VINF_SUCCESS;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#ifdef RT_OS_DARWIN
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Query it here and now.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync char abKeyBuf[65];
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync int rc = DarwinSmcKey(abKeyBuf, sizeof(abKeyBuf));
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (SUCCEEDED(rc))
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Bstr(abKeyBuf).detachTo(aKey);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return rc;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync LogRel(("Warning: DarwinSmcKey failed with rc=%Rrc!\n", rc));
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#else
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Is it apple hardware in bootcamp?
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /** @todo implement + test RTSYSDMISTR_MANUFACTURER on all hosts.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Currently falling back on the product name. */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync char szManufacturer[256];
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync szManufacturer[0] = '\0';
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync RTSystemQueryDmiString(RTSYSDMISTR_MANUFACTURER, szManufacturer, sizeof(szManufacturer));
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync if (szManufacturer[0] != '\0')
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if ( !strcmp(szManufacturer, "Apple Computer, Inc.")
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync || !strcmp(szManufacturer, "Apple Inc.")
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync )
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync *pfGetKeyFromRealSMC = true;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync else
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync char szProdName[256];
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync szProdName[0] = '\0';
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync RTSystemQueryDmiString(RTSYSDMISTR_PRODUCT_NAME, szProdName, sizeof(szProdName));
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if ( ( !strncmp(szProdName, "Mac", 3)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync || !strncmp(szProdName, "iMac", 4)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync || !strncmp(szProdName, "iMac", 4)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync || !strncmp(szProdName, "Xserve", 6)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync )
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync && !strchr(szProdName, ' ') /* no spaces */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync && RT_C_IS_DIGIT(szProdName[strlen(szProdName) - 1]) /* version number */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync )
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync *pfGetKeyFromRealSMC = true;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync int rc = VINF_SUCCESS;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return rc;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * VC++ 8 / amd64 has some serious trouble with the next functions.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * As a temporary measure, we'll drop global optimizations.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync#if defined(_MSC_VER) && defined(RT_ARCH_AMD64)
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync# pragma optimize("g", off)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync#endif
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncclass ConfigError : public iprt::Error
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncpublic:
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ConfigError(const char *pcszFunction,
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync int vrc,
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync const char *pcszName)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync : iprt::Error(Utf8StrFmt("%s failed: rc=%Rrc, pcszName=%s", pcszFunction, vrc, pcszName)),
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync m_vrc(vrc)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync AssertMsgFailed(("%s\n", what())); // in strict mode, hit a breakpoint here
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync int m_vrc;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync};
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync/**
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * Helper that calls CFGMR3InsertString and throws an iprt::Error if that
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * fails (C-string variant).
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * @param pParent See CFGMR3InsertStringN.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * @param pcszNodeName See CFGMR3InsertStringN.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * @param pcszValue The string value.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncstatic void InsertConfigString(PCFGMNODE pNode,
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync const char *pcszName,
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync const char *pcszValue)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync{
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync int vrc = CFGMR3InsertString(pNode,
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync pcszName,
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync pcszValue);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (RT_FAILURE(vrc))
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync throw ConfigError("CFGMR3InsertString", vrc, pcszName);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync}
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync/**
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * Helper that calls CFGMR3InsertString and throws an iprt::Error if that
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * fails (Utf8Str variant).
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * @param pParent See CFGMR3InsertStringN.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * @param pcszNodeName See CFGMR3InsertStringN.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * @param rStrValue The string value.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsyncstatic void InsertConfigString(PCFGMNODE pNode,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync const char *pcszName,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync const Utf8Str &rStrValue)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync int vrc = CFGMR3InsertStringN(pNode,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pcszName,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync rStrValue.c_str(),
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync rStrValue.length());
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (RT_FAILURE(vrc))
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync throw ConfigError("CFGMR3InsertStringLengthKnown", vrc, pcszName);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/**
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Helper that calls CFGMR3InsertString and throws an iprt::Error if that
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * fails (Bstr variant).
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync *
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param pParent See CFGMR3InsertStringN.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param pcszNodeName See CFGMR3InsertStringN.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param rBstrValue The string value.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncstatic void InsertConfigString(PCFGMNODE pNode,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync const char *pcszName,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync const Bstr &rBstrValue)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigString(pNode, pcszName, Utf8Str(rBstrValue));
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/**
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Helper that calls CFGMR3InsertBytes and throws an iprt::Error if that fails.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync *
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param pNode See CFGMR3InsertBytes.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param pcszName See CFGMR3InsertBytes.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param pvBytes See CFGMR3InsertBytes.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param cbBytes See CFGMR3InsertBytes.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncstatic void InsertConfigBytes(PCFGMNODE pNode,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync const char *pcszName,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync const void *pvBytes,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync size_t cbBytes)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync int vrc = CFGMR3InsertBytes(pNode,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pcszName,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pvBytes,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync cbBytes);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (RT_FAILURE(vrc))
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync throw ConfigError("CFGMR3InsertBytes", vrc, pcszName);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/**
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Helper that calls CFGMR3InsertInteger and throws an iprt::Error if that
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * fails.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync *
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param pNode See CFGMR3InsertInteger.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param pcszName See CFGMR3InsertInteger.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param u64Integer See CFGMR3InsertInteger.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncstatic void InsertConfigInteger(PCFGMNODE pNode,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync const char *pcszName,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uint64_t u64Integer)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync int vrc = CFGMR3InsertInteger(pNode,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pcszName,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync u64Integer);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (RT_FAILURE(vrc))
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync throw ConfigError("CFGMR3InsertInteger", vrc, pcszName);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/**
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Helper that calls CFGMR3InsertNode and throws an iprt::Error if that fails.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync *
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param pNode See CFGMR3InsertNode.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param pcszName See CFGMR3InsertNode.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param ppChild See CFGMR3InsertNode.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncstatic void InsertConfigNode(PCFGMNODE pNode,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync const char *pcszName,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PCFGMNODE *ppChild)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync int vrc = CFGMR3InsertNode(pNode, pcszName, ppChild);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (RT_FAILURE(vrc))
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync throw ConfigError("CFGMR3InsertNode", vrc, pcszName);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/**
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Helper that calls CFGMR3RemoveValue and throws an iprt::Error if that fails.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync *
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param pNode See CFGMR3RemoveValue.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param pcszName See CFGMR3RemoveValue.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncstatic void RemoveConfigValue(PCFGMNODE pNode,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync const char *pcszName)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync int vrc = CFGMR3RemoveValue(pNode, pcszName);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (RT_FAILURE(vrc))
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync throw ConfigError("CFGMR3RemoveValue", vrc, pcszName);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#ifdef VBOX_WITH_PCI_PASSTHROUGH
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncstatic HRESULT attachRawPciDevices(BusAssignmentManager* BusMgr,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PCFGMNODE pDevices,
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Console* pConsole)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync HRESULT hrc = S_OK;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PCFGMNODE pDev, pInst, pCfg, pLunL0;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync SafeIfaceArray<IPciDeviceAttachment> assignments;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ComPtr<IMachine> aMachine = pConsole->machine();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = aMachine->COMGETTER(PciDeviceAssignments)(ComSafeArrayAsOutParam(assignments));
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (hrc != S_OK)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return hrc;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync for (size_t iDev = 0; iDev < assignments.size(); iDev++)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PciBusAddress HostPciAddress, GuestPciAddress;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ComPtr<IPciDeviceAttachment> assignment = assignments[iDev];
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync LONG host, guest;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Bstr aDevName;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync assignment->COMGETTER(HostAddress)(&host);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync assignment->COMGETTER(GuestAddress)(&guest);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync assignment->COMGETTER(Name)(aDevName.asOutParam());
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDevices, "pciraw", &pDev);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDev, Utf8StrFmt("%d", iDev).c_str(), &pInst);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pInst, "Trusted", 1);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync HostPciAddress.fromLong(host);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Assert(HostPciAddress.valid());
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pInst, "Config", &pCfg);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigString(pCfg, "DeviceName", aDevName);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "HostPCIBusNo", HostPciAddress.iBus);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "HostPCIDeviceNo", HostPciAddress.iDevice);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "HostPCIFunctionNo", HostPciAddress.iFn);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync GuestPciAddress.fromLong(guest);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Assert(GuestPciAddress.valid());
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = BusMgr->assignPciDevice("pciraw", pInst, GuestPciAddress, true);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (hrc != S_OK)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return hrc;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "GuestPCIBusNo", GuestPciAddress.iBus);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "GuestPCIDeviceNo", GuestPciAddress.iDevice);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "GuestPCIFunctionNo", GuestPciAddress.iFn);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* the Main driver */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PciRawDev* pMainDev = new PciRawDev(pConsole);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigString(pLunL0, "Driver", "PciRawMain");
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pLunL0, "Config" , &pCfg);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "Object", (uintptr_t)pMainDev);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return hrc;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync/**
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Construct the VM configuration tree (CFGM).
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync *
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * This is a callback for VMR3Create() call. It is called from CFGMR3Init()
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * in the emulation thread (EMT). Any per thread COM/XPCOM initialization
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync * is done here.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync *
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param pVM VM handle.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param pvConsole Pointer to the VMPowerUpTask object.
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync * @return VBox status code.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync *
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @note Locks the Console object for writing.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncDECLCALLBACK(int) Console::configConstructor(PVM pVM, void *pvConsole)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync LogFlowFuncEnter();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#if !defined(VBOX_WITH_XPCOM)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* initialize COM */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync HRESULT hrc = CoInitializeEx(NULL,
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE |
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync COINIT_SPEED_OVER_MEMORY);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync LogFlow(("Console::configConstructor(): CoInitializeEx()=%08X\n", hrc));
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync AssertComRCReturn(hrc, VERR_GENERAL_FAILURE);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync AssertReturn(pvConsole, VERR_GENERAL_FAILURE);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ComObjPtr<Console> pConsole = static_cast<Console *>(pvConsole);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync AutoCaller autoCaller(pConsole);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* lock the console because we widely use internal fields and methods */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync AutoWriteLock alock(pConsole COMMA_LOCKVAL_SRC_POS);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Set the VM handle and do the rest of the job in an worker method so we
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * can easily reset the VM handle on failure.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PUVM pUVM = pConsole->mpUVM = VMR3GetUVM(pVM);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync VMR3RetainUVM(pUVM);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync int vrc = pConsole->configConstructorInner(pVM, &alock);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync if (RT_FAILURE(vrc))
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pConsole->mpUVM = NULL;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync VMR3ReleaseUVM(pUVM);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync return vrc;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync}
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync/**
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Worker for configConstructor.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync *
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @return VBox status code.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * @param pVM The VM handle.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsyncint Console::configConstructorInner(PVM pVM, AutoWriteLock *pAlock)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync{
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync VMMDev *pVMMDev = m_pVMMDev;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Assert(pVMMDev);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ComPtr<IMachine> pMachine = machine();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync int rc;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync HRESULT hrc;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Bstr bstr;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#define H() AssertMsgReturn(!FAILED(hrc), ("hrc=%Rhrc\n", hrc), VERR_GENERAL_FAILURE)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Get necessary objects and frequently used parameters.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ComPtr<IVirtualBox> virtualBox;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = pMachine->COMGETTER(Parent)(virtualBox.asOutParam()); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ComPtr<IHost> host;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = virtualBox->COMGETTER(Host)(host.asOutParam()); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ComPtr<ISystemProperties> systemProperties;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam()); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ComPtr<IBIOSSettings> biosSettings;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = pMachine->COMGETTER(BIOSSettings)(biosSettings.asOutParam()); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = pMachine->COMGETTER(HardwareUUID)(bstr.asOutParam()); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync RTUUID HardwareUuid;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync rc = RTUuidFromUtf16(&HardwareUuid, bstr.raw());
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync AssertRCReturn(rc, rc);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ULONG cRamMBs;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = pMachine->COMGETTER(MemorySize)(&cRamMBs); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#if 0 /* enable to play with lots of memory. */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (RTEnvExist("VBOX_RAM_SIZE"))
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync cRamMBs = RTStrToUInt64(RTEnvGet("VBOX_RAM_SIZE"));
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uint64_t const cbRam = cRamMBs * (uint64_t)_1M;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uint32_t cbRamHole = MM_RAM_HOLE_SIZE_DEFAULT;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uint64_t uMcfgBase = 0;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uint32_t cbMcfgLength = 0;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ChipsetType_T chipsetType;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = pMachine->COMGETTER(ChipsetType)(&chipsetType); H();
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync if (chipsetType == ChipsetType_ICH9)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* We'd better have 0x10000000 region, to cover 256 buses
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync but this put too much load on hypervisor heap */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync cbMcfgLength = 0x4000000; //0x10000000;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync cbRamHole += cbMcfgLength;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uMcfgBase = _4G - cbRamHole;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync BusAssignmentManager* BusMgr = mBusMgr = BusAssignmentManager::createInstance(chipsetType);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync ULONG cCpus = 1;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->COMGETTER(CPUCount)(&cCpus); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync ULONG ulCpuExecutionCap = 100;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->COMGETTER(CPUExecutionCap)(&ulCpuExecutionCap); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync Bstr osTypeId;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->COMGETTER(OSTypeId)(osTypeId.asOutParam()); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync BOOL fIOAPIC;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = biosSettings->COMGETTER(IOAPICEnabled)(&fIOAPIC); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync ComPtr<IGuestOSType> guestOSType;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = virtualBox->GetGuestOSType(osTypeId.raw(), guestOSType.asOutParam()); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync Bstr guestTypeFamilyId;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = guestOSType->COMGETTER(FamilyId)(guestTypeFamilyId.asOutParam()); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync BOOL fOsXGuest = guestTypeFamilyId == Bstr("MacOS");
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /*
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * Get root node first.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * This is the only node in the tree.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync PCFGMNODE pRoot = CFGMR3GetRoot(pVM);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync Assert(pRoot);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync // InsertConfigString throws
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync try
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /*
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * Set the root (and VMM) level values.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->COMGETTER(Name)(bstr.asOutParam()); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigString(pRoot, "Name", bstr);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigBytes(pRoot, "UUID", &HardwareUuid, sizeof(HardwareUuid));
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pRoot, "RamSize", cbRam);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pRoot, "RamHoleSize", cbRamHole);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pRoot, "NumCPUs", cCpus);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pRoot, "CpuExecutionCap", ulCpuExecutionCap);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pRoot, "TimerMillies", 10);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync#ifdef VBOX_WITH_RAW_MODE
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pRoot, "RawR3Enabled", 1); /* boolean */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pRoot, "RawR0Enabled", 1); /* boolean */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /** @todo Config: RawR0, PATMEnabled and CSAMEnabled needs attention later. */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pRoot, "PATMEnabled", 1); /* boolean */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pRoot, "CSAMEnabled", 1); /* boolean */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync#endif
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /* Not necessary, but to make sure these two settings end up in the release log. */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync BOOL fPageFusion = FALSE;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->COMGETTER(PageFusionEnabled)(&fPageFusion); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pRoot, "PageFusion", fPageFusion); /* boolean */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync ULONG ulBalloonSize = 0;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->COMGETTER(MemoryBalloonSize)(&ulBalloonSize); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pRoot, "MemBalloonSize", ulBalloonSize);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /*
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * CPUM values.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync PCFGMNODE pCPUM;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pRoot, "CPUM", &pCPUM);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /* cpuid leaf overrides. */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync static uint32_t const s_auCpuIdRanges[] =
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync UINT32_C(0x00000000), UINT32_C(0x0000000a),
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync UINT32_C(0x80000000), UINT32_C(0x8000000a)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync };
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync for (unsigned i = 0; i < RT_ELEMENTS(s_auCpuIdRanges); i += 2)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync for (uint32_t uLeaf = s_auCpuIdRanges[i]; uLeaf < s_auCpuIdRanges[i + 1]; uLeaf++)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync ULONG ulEax, ulEbx, ulEcx, ulEdx;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->GetCPUIDLeaf(uLeaf, &ulEax, &ulEbx, &ulEcx, &ulEdx);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (SUCCEEDED(hrc))
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync PCFGMNODE pLeaf;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pCPUM, Utf8StrFmt("HostCPUID/%RX32", uLeaf).c_str(), &pLeaf);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pLeaf, "eax", ulEax);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pLeaf, "ebx", ulEbx);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pLeaf, "ecx", ulEcx);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pLeaf, "edx", ulEdx);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync else if (hrc != E_INVALIDARG) H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /* We must limit CPUID count for Windows NT 4, as otherwise it stops
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync with error 0x3e (MULTIPROCESSOR_CONFIGURATION_NOT_SUPPORTED). */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (osTypeId == "WindowsNT4")
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync LogRel(("Limiting CPUID leaf count for NT4 guests\n"));
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCPUM, "NT4LeafLimit", true);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /* Expose extended MWAIT features to Mac OS X guests. */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (fOsXGuest)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync LogRel(("Using MWAIT extensions\n"));
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCPUM, "MWaitExtensions", true);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /*
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * Hardware virtualization extensions.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync BOOL fHWVirtExEnabled;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync BOOL fHwVirtExtForced = false;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync#ifdef VBOX_WITH_RAW_MODE
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_Enabled, &fHWVirtExEnabled); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (cCpus > 1) /** @todo SMP: This isn't nice, but things won't work on mac otherwise. */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync fHWVirtExEnabled = TRUE;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync# ifdef RT_OS_DARWIN
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync fHwVirtExtForced = fHWVirtExEnabled;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync# else
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /* - With more than 4GB PGM will use different RAMRANGE sizes for raw
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync mode and hv mode to optimize lookup times.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync - With more than one virtual CPU, raw-mode isn't a fallback option. */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync fHwVirtExtForced = fHWVirtExEnabled
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync && ( cbRam + cbRamHole > _4G
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync || cCpus > 1);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync# endif
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync#else /* !VBOX_WITH_RAW_MODE */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync fHWVirtExEnabled = fHwVirtExtForced = true;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync#endif /* !VBOX_WITH_RAW_MODE */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /* only honor the property value if there was no other reason to enable it */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (!fHwVirtExtForced)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_Force, &fHwVirtExtForced); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pRoot, "HwVirtExtForced", fHwVirtExtForced);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /*
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * MM values.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync PCFGMNODE pMM;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pRoot, "MM", &pMM);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pMM, "CanUseLargerHeap", chipsetType == ChipsetType_ICH9);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /*
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * Hardware virtualization settings.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync BOOL fIsGuest64Bit = false;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync PCFGMNODE pHWVirtExt;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pRoot, "HWVirtExt", &pHWVirtExt);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (fHWVirtExEnabled)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pHWVirtExt, "Enabled", 1);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /* Indicate whether 64-bit guests are supported or not. */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /** @todo This is currently only forced off on 32-bit hosts only because it
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * makes a lof of difference there (REM and Solaris performance).
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync BOOL fSupportsLongMode = false;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = host->GetProcessorFeature(ProcessorFeature_LongMode,
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync &fSupportsLongMode); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = guestOSType->COMGETTER(Is64Bit)(&fIsGuest64Bit); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (fSupportsLongMode && fIsGuest64Bit)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pHWVirtExt, "64bitEnabled", 1);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync#if ARCH_BITS == 32 /* The recompiler must use VBoxREM64 (32-bit host only). */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync PCFGMNODE pREM;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pRoot, "REM", &pREM);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pREM, "64bitEnabled", 1);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync#endif
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync#if ARCH_BITS == 32 /* 32-bit guests only. */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync else
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pHWVirtExt, "64bitEnabled", 0);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync#endif
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /** @todo Not exactly pretty to check strings; VBOXOSTYPE would be better, but that requires quite a bit of API change in Main. */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if ( !fIsGuest64Bit
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync && fIOAPIC
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync && ( osTypeId == "WindowsNT4"
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync || osTypeId == "Windows2000"
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync || osTypeId == "WindowsXP"
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync || osTypeId == "Windows2003"))
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /* Only allow TPR patching for NT, Win2k, XP and Windows Server 2003. (32 bits mode)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * We may want to consider adding more guest OSes (Solaris) later on.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigInteger(pHWVirtExt, "TPRPatchingEnabled", 1);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* HWVirtEx exclusive mode */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync BOOL fHWVirtExExclusive = true;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_Exclusive, &fHWVirtExExclusive); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pHWVirtExt, "Exclusive", fHWVirtExExclusive);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* Nested paging (VT-x/AMD-V) */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync BOOL fEnableNestedPaging = false;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_NestedPaging, &fEnableNestedPaging); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pHWVirtExt, "EnableNestedPaging", fEnableNestedPaging);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* Large pages; requires nested paging */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync BOOL fEnableLargePages = false;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_LargePages, &fEnableLargePages); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pHWVirtExt, "EnableLargePages", fEnableLargePages);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* VPID (VT-x) */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync BOOL fEnableVPID = false;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_VPID, &fEnableVPID); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pHWVirtExt, "EnableVPID", fEnableVPID);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* Physical Address Extension (PAE) */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync BOOL fEnablePAE = false;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = pMachine->GetCPUProperty(CPUPropertyType_PAE, &fEnablePAE); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pRoot, "EnablePAE", fEnablePAE);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* Synthetic CPU */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync BOOL fSyntheticCpu = false;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->GetCPUProperty(CPUPropertyType_Synthetic, &fSyntheticCpu); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCPUM, "SyntheticCpu", fSyntheticCpu);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync BOOL fPXEDebug;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = biosSettings->COMGETTER(PXEDebugEnabled)(&fPXEDebug); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /*
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * PDM config.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * Load drivers in VBoxC.[so|dll]
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync PCFGMNODE pPDM;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync PCFGMNODE pNode;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync PCFGMNODE pMod;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pRoot, "PDM", &pPDM);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pPDM, "Devices", &pNode);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pPDM, "Drivers", &pNode);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pNode, "VBoxC", &pMod);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync#ifdef VBOX_WITH_XPCOM
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync // VBoxC is located in the components subdirectory
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync char szPathVBoxC[RTPATH_MAX];
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync rc = RTPathAppPrivateArch(szPathVBoxC, RTPATH_MAX - sizeof("/components/VBoxC")); AssertRC(rc);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync strcat(szPathVBoxC, "/components/VBoxC");
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigString(pMod, "Path", szPathVBoxC);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync#else
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigString(pMod, "Path", "VBoxC");
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync#endif
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Block cache settings.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync PCFGMNODE pPDMBlkCache;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pPDM, "BlkCache", &pPDMBlkCache);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* I/O cache size */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ULONG ioCacheSize = 5;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = pMachine->COMGETTER(IoCacheSize)(&ioCacheSize); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pPDMBlkCache, "CacheSize", ioCacheSize * _1M);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Bandwidth groups.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync PCFGMNODE pAc;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PCFGMNODE pAcFile;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PCFGMNODE pAcFileBwGroups;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ComPtr<IBandwidthControl> bwCtrl;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync com::SafeIfaceArray<IBandwidthGroup> bwGroups;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = pMachine->COMGETTER(BandwidthControl)(bwCtrl.asOutParam()); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = bwCtrl->GetAllBandwidthGroups(ComSafeArrayAsOutParam(bwGroups)); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync InsertConfigNode(pPDM, "AsyncCompletion", &pAc);
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync InsertConfigNode(pAc, "File", &pAcFile);
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync InsertConfigNode(pAcFile, "BwGroups", &pAcFileBwGroups);
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync for (size_t i = 0; i < bwGroups.size(); i++)
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Bstr strName;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ULONG cMaxMbPerSec;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync BandwidthGroupType_T enmType;
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync hrc = bwGroups[i]->COMGETTER(Name)(strName.asOutParam()); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = bwGroups[i]->COMGETTER(Type)(&enmType); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = bwGroups[i]->COMGETTER(MaxMbPerSec)(&cMaxMbPerSec); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (enmType == BandwidthGroupType_Disk)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PCFGMNODE pBwGroup;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pAcFileBwGroups, Utf8Str(strName).c_str(), &pBwGroup);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pBwGroup, "Max", cMaxMbPerSec * _1M);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pBwGroup, "Start", cMaxMbPerSec * _1M);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pBwGroup, "Step", 0);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync * Devices
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PCFGMNODE pDevices = NULL; /* /Devices */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PCFGMNODE pDev = NULL; /* /Devices/Dev/ */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PCFGMNODE pInst = NULL; /* /Devices/Dev/0/ */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PCFGMNODE pCfg = NULL; /* /Devices/Dev/.../Config/ */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PCFGMNODE pLunL0 = NULL; /* /Devices/Dev/0/LUN#0/ */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PCFGMNODE pLunL1 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/ */
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync PCFGMNODE pLunL2 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/Config/ */
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync PCFGMNODE pBiosCfg = NULL; /* /Devices/pcbios/0/Config/ */
66a94fee6b0acc21c078369f49d97020cc03ab11vboxsync PCFGMNODE pNetBootCfg = NULL; /* /Devices/pcbios/0/Config/NetBoot/ */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pRoot, "Devices", &pDevices);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * PC Arch.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDevices, "pcarch", &pDev);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDev, "0", &pInst);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pInst, "Config", &pCfg);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * The time offset
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync LONG64 timeOffset;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = biosSettings->COMGETTER(TimeOffset)(&timeOffset); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PCFGMNODE pTMNode;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pRoot, "TM", &pTMNode);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pTMNode, "UTCOffset", timeOffset * 1000000);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * DMA
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDevices, "8237A", &pDev);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDev, "0", &pInst);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync * PCI buses.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uint32_t uIocPciAddress, uHbcPciAddress;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync switch (chipsetType)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync default:
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Assert(false);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync case ChipsetType_PIIX3:
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDevices, "pci", &pDev);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uHbcPciAddress = (0x0 << 16) | 0;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uIocPciAddress = (0x1 << 16) | 0; // ISA controller
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync break;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync case ChipsetType_ICH9:
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDevices, "ich9pci", &pDev);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uHbcPciAddress = (0x1e << 16) | 0;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync uIocPciAddress = (0x1f << 16) | 0; // LPC controller
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync break;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDev, "0", &pInst);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pInst, "Config", &pCfg);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "IOAPIC", fIOAPIC);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (chipsetType == ChipsetType_ICH9)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* Provide MCFG info */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "McfgBase", uMcfgBase);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "McfgLength", cbMcfgLength);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* And register 2 bridges */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDevices, "ich9pcibridge", &pDev);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDev, "0", &pInst);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = BusMgr->assignPciDevice("ich9pcibridge", pInst); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDev, "1", &pInst);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = BusMgr->assignPciDevice("ich9pcibridge", pInst); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#ifdef VBOX_WITH_PCI_PASSTHROUGH
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* Add PCI passthrough devices */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = attachRawPciDevices(BusMgr, pDevices, this); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * Enable 3 following devices: HPET, SMC, LPC on MacOS X guests or on ICH9 chipset
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * High Precision Event Timer (HPET)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync BOOL fHpetEnabled;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync /* Other guests may wish to use HPET too, but MacOS X not functional without it */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = pMachine->COMGETTER(HpetEnabled)(&fHpetEnabled); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* so always enable HPET in extended profile */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync fHpetEnabled |= fOsXGuest;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* HPET is always present on ICH9 */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync fHpetEnabled |= (chipsetType == ChipsetType_ICH9);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (fHpetEnabled)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDevices, "hpet", &pDev);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDev, "0", &pInst);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync * System Management Controller (SMC)
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync */
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync BOOL fSmcEnabled;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync fSmcEnabled = fOsXGuest;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync if (fSmcEnabled)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigNode(pDevices, "smc", &pDev);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigNode(pDev, "0", &pInst);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigNode(pInst, "Config", &pCfg);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync bool fGetKeyFromRealSMC;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync Bstr bstrKey;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync rc = getSmcDeviceKey(pMachine, bstrKey.asOutParam(), &fGetKeyFromRealSMC);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync AssertRCReturn(rc, rc);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigString(pCfg, "DeviceKey", bstrKey);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigInteger(pCfg, "GetKeyFromRealSMC", fGetKeyFromRealSMC);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync }
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync /*
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync * Low Pin Count (LPC) bus
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync */
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync BOOL fLpcEnabled;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /** @todo: implement appropriate getter */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync fLpcEnabled = fOsXGuest || (chipsetType == ChipsetType_ICH9);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync if (fLpcEnabled)
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync {
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigNode(pDevices, "lpc", &pDev);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigNode(pDev, "0", &pInst);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync hrc = BusMgr->assignPciDevice("lpc", pInst); H();
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync BOOL fShowRtc;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync fShowRtc = fOsXGuest || (chipsetType == ChipsetType_ICH9);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
8238dbee2b0c21592e6af0fafcdb2e56cf3a791cvboxsync * PS/2 keyboard & mouse.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDevices, "pckbd", &pDev);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDev, "0", &pInst);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
8238dbee2b0c21592e6af0fafcdb2e56cf3a791cvboxsync InsertConfigNode(pInst, "Config", &pCfg);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigString(pLunL0, "Driver", "KeyboardQueue");
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "QueueSize", 64);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigString(pLunL1, "Driver", "MainKeyboard");
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pLunL1, "Config", &pCfg);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Keyboard *pKeyboard = mKeyboard;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "Object", (uintptr_t)pKeyboard);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pInst, "LUN#1", &pLunL0);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigString(pLunL0, "Driver", "MouseQueue");
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "QueueSize", 128);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigString(pLunL1, "Driver", "MainMouse");
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pLunL1, "Config", &pCfg);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync Mouse *pMouse = mMouse;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "Object", (uintptr_t)pMouse);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * i8254 Programmable Interval Timer And Dummy Speaker
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDevices, "i8254", &pDev);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDev, "0", &pInst);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pInst, "Config", &pCfg);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync#ifdef DEBUG
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * i8259 Programmable Interrupt Controller.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDevices, "i8259", &pDev);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDev, "0", &pInst);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pInst, "Config", &pCfg);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * Advanced Programmable Interrupt Controller.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * SMP: Each CPU has a LAPIC, but we have a single device representing all LAPICs states,
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync * thus only single insert
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDevices, "apic", &pDev);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDev, "0", &pInst);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigNode(pInst, "Config", &pCfg);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "IOAPIC", fIOAPIC);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "NumCPUs", cCpus);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync if (fIOAPIC)
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /*
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync * I/O Advanced Programmable Interrupt Controller.
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync */
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigNode(pDevices, "ioapic", &pDev);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigNode(pDev, "0", &pInst);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
9333def4f76dd01eea8300d59512d421200e5db7vboxsync InsertConfigNode(pInst, "Config", &pCfg);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigInteger(pCfg, "NumCPUs", cCpus);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync }
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync /*
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync * RTC MC146818.
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync */
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigNode(pDevices, "mc146818", &pDev);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigNode(pDev, "0", &pInst);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigNode(pInst, "Config", &pCfg);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync BOOL fRTCUseUTC;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync hrc = pMachine->COMGETTER(RTCUseUTC)(&fRTCUseUTC); H();
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigInteger(pCfg, "UseUTC", fRTCUseUTC ? 1 : 0);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * VGA.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDevices, "vga", &pDev);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDev, "0", &pInst);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = BusMgr->assignPciDevice("vga", pInst); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pInst, "Config", &pCfg);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ULONG cVRamMBs;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync hrc = pMachine->COMGETTER(VRAMSize)(&cVRamMBs); H();
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigInteger(pCfg, "VRamSize", cVRamMBs * _1M);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync ULONG cMonitorCount;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync hrc = pMachine->COMGETTER(MonitorCount)(&cMonitorCount); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "MonitorCount", cMonitorCount);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigInteger(pCfg, "R0Enabled", fHWVirtExEnabled);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync /*
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync * BIOS logo
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync */
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync BOOL fFadeIn;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync hrc = biosSettings->COMGETTER(LogoFadeIn)(&fFadeIn); H();
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigInteger(pCfg, "FadeIn", fFadeIn ? 1 : 0);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync BOOL fFadeOut;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync hrc = biosSettings->COMGETTER(LogoFadeOut)(&fFadeOut); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "FadeOut", fFadeOut ? 1: 0);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ULONG logoDisplayTime;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = biosSettings->COMGETTER(LogoDisplayTime)(&logoDisplayTime); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "LogoTime", logoDisplayTime);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Bstr logoImagePath;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = biosSettings->COMGETTER(LogoImagePath)(logoImagePath.asOutParam()); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigString(pCfg, "LogoFile", Utf8Str(!logoImagePath.isEmpty() ? logoImagePath : "") );
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync /*
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync * Boot menu
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync */
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync BIOSBootMenuMode_T eBootMenuMode;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync int iShowBootMenu;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync biosSettings->COMGETTER(BootMenuMode)(&eBootMenuMode);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync switch (eBootMenuMode)
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync case BIOSBootMenuMode_Disabled: iShowBootMenu = 0; break;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync case BIOSBootMenuMode_MenuOnly: iShowBootMenu = 1; break;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync default: iShowBootMenu = 2; break;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "ShowBootMenu", iShowBootMenu);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync /* Custom VESA mode list */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync unsigned cModes = 0;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync for (unsigned iMode = 1; iMode <= 16; ++iMode)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync char szExtraDataKey[sizeof("CustomVideoModeXX")];
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync RTStrPrintf(szExtraDataKey, sizeof(szExtraDataKey), "CustomVideoMode%u", iMode);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync hrc = pMachine->GetExtraData(Bstr(szExtraDataKey).raw(), bstr.asOutParam()); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (bstr.isEmpty())
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync break;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigString(pCfg, szExtraDataKey, bstr);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ++cModes;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigInteger(pCfg, "CustomVideoModes", cModes);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* VESA height reduction */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ULONG ulHeightReduction;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync IFramebuffer *pFramebuffer = getDisplay()->getFramebuffer();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (pFramebuffer)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = pFramebuffer->COMGETTER(HeightReduction)(&ulHeightReduction); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync else
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* If framebuffer is not available, there is no height reduction. */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ulHeightReduction = 0;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "HeightReduction", ulHeightReduction);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* Attach the display. */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigString(pLunL0, "Driver", "MainDisplay");
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Display *pDisplay = mDisplay;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "Object", (uintptr_t)pDisplay);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * Firmware.
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync FirmwareType_T eFwType = FirmwareType_BIOS;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = pMachine->COMGETTER(FirmwareType)(&eFwType); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#ifdef VBOX_WITH_EFI
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync BOOL fEfiEnabled = (eFwType >= FirmwareType_EFI) && (eFwType <= FirmwareType_EFIDUAL);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#else
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync BOOL fEfiEnabled = false;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync#endif
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (!fEfiEnabled)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync /*
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync * PC Bios.
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync */
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigNode(pDevices, "pcbios", &pDev);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDev, "0", &pInst);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pInst, "Config", &pBiosCfg);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigInteger(pBiosCfg, "RamSize", cbRam);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pBiosCfg, "RamHoleSize", cbRamHole);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pBiosCfg, "NumCPUs", cCpus);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigString(pBiosCfg, "HardDiskDevice", "piix3ide");
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigString(pBiosCfg, "FloppyDevice", "i82078");
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pBiosCfg, "IOAPIC", fIOAPIC);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pBiosCfg, "PXEDebug", fPXEDebug);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigBytes(pBiosCfg, "UUID", &HardwareUuid,sizeof(HardwareUuid));
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pBiosCfg, "NetBoot", &pNetBootCfg);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pBiosCfg, "McfgBase", uMcfgBase);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pBiosCfg, "McfgLength", cbMcfgLength);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync DeviceType_T bootDevice;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (SchemaDefs::MaxBootPosition > 9)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync AssertMsgFailed(("Too many boot devices %d\n",
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync SchemaDefs::MaxBootPosition));
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync return VERR_INVALID_PARAMETER;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync for (ULONG pos = 1; pos <= SchemaDefs::MaxBootPosition; ++pos)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->GetBootOrder(pos, &bootDevice); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync char szParamName[] = "BootDeviceX";
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync szParamName[sizeof(szParamName) - 2] = ((char (pos - 1)) + '0');
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync const char *pszBootDevice;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync switch (bootDevice)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync case DeviceType_Null:
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync pszBootDevice = "NONE";
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync break;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync case DeviceType_HardDisk:
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync pszBootDevice = "IDE";
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync break;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync case DeviceType_DVD:
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync pszBootDevice = "DVD";
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync break;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync case DeviceType_Floppy:
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync pszBootDevice = "FLOPPY";
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync break;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync case DeviceType_Network:
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync pszBootDevice = "LAN";
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync break;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync default:
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync AssertMsgFailed(("Invalid bootDevice=%d\n", bootDevice));
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync N_("Invalid boot device '%d'"), bootDevice);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigString(pBiosCfg, szParamName, pszBootDevice);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync else
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /* Autodetect firmware type, basing on guest type */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (eFwType == FirmwareType_EFI)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync eFwType = fIsGuest64Bit
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync ? (FirmwareType_T)FirmwareType_EFI64
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync : (FirmwareType_T)FirmwareType_EFI32;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync bool const f64BitEntry = eFwType == FirmwareType_EFI64;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync Utf8Str efiRomFile;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync rc = findEfiRom(virtualBox, eFwType, &efiRomFile);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync AssertRCReturn(rc, rc);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /* Get boot args */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync Bstr bootArgs;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiBootArgs").raw(), bootArgs.asOutParam()); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /* Get device props */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync Bstr deviceProps;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiDeviceProps").raw(), deviceProps.asOutParam()); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /* Get GOP mode settings */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync uint32_t u32GopMode = UINT32_MAX;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiGopMode").raw(), bstr.asOutParam()); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (!bstr.isEmpty())
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync u32GopMode = Utf8Str(bstr).toUInt32();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /* UGA mode settings */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync uint32_t u32UgaHorisontal = 0;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiUgaHorizontalResolution").raw(), bstr.asOutParam()); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (!bstr.isEmpty())
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync u32UgaHorisontal = Utf8Str(bstr).toUInt32();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync uint32_t u32UgaVertical = 0;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiUgaVerticalResolution").raw(), bstr.asOutParam()); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (!bstr.isEmpty())
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync u32UgaVertical = Utf8Str(bstr).toUInt32();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /*
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * EFI subtree.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pDevices, "efi", &pDev);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pDev, "0", &pInst);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pInst, "Config", &pCfg);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "RamSize", cbRam);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "RamHoleSize", cbRamHole);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "NumCPUs", cCpus);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigString(pCfg, "EfiRom", efiRomFile);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigString(pCfg, "BootArgs", bootArgs);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigString(pCfg, "DeviceProps", deviceProps);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "IOAPIC", fIOAPIC);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigBytes(pCfg, "UUID", &HardwareUuid,sizeof(HardwareUuid));
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "64BitEntry", f64BitEntry); /* boolean */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "GopMode", u32GopMode);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "UgaHorizontalResolution", u32UgaHorisontal);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "UgaVerticalResolution", u32UgaVertical);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /* For OS X guests we'll force passing host's DMI info to the guest */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (fOsXGuest)
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "DmiUseHostInfo", 1);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "DmiExposeMemoryTable", 1);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /*
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * Storage controllers.
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync com::SafeIfaceArray<IStorageController> ctrls;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync PCFGMNODE aCtrlNodes[StorageControllerType_LsiLogicSas + 1] = {};
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync hrc = pMachine->COMGETTER(StorageControllers)(ComSafeArrayAsOutParam(ctrls)); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync bool fFdcEnabled = false;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync for (size_t i = 0; i < ctrls.size(); ++i)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync DeviceType_T *paLedDevType = NULL;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync StorageControllerType_T enmCtrlType;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync rc = ctrls[i]->COMGETTER(ControllerType)(&enmCtrlType); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync AssertRelease((unsigned)enmCtrlType < RT_ELEMENTS(aCtrlNodes));
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync StorageBus_T enmBus;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync rc = ctrls[i]->COMGETTER(Bus)(&enmBus); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Bstr controllerName;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync rc = ctrls[i]->COMGETTER(Name)(controllerName.asOutParam()); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync ULONG ulInstance = 999;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync rc = ctrls[i]->COMGETTER(Instance)(&ulInstance); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync BOOL fUseHostIOCache;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync rc = ctrls[i]->COMGETTER(UseHostIOCache)(&fUseHostIOCache); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
a61d11f3152f6e51d5210d4d38be612a60131c06vboxsync BOOL fBootable;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync rc = ctrls[i]->COMGETTER(Bootable)(&fBootable); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* /Devices/<ctrldev>/ */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync const char *pszCtrlDev = convertControllerTypeToDev(enmCtrlType);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync pDev = aCtrlNodes[enmCtrlType];
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync if (!pDev)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pDevices, pszCtrlDev, &pDev);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync aCtrlNodes[enmCtrlType] = pDev; /* IDE variants are handled in the switch */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* /Devices/<ctrldev>/<instance>/ */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync PCFGMNODE pCtlInst = NULL;
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigNode(pDev, Utf8StrFmt("%u", ulInstance).c_str(), &pCtlInst);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* Device config: /Devices/<ctrldev>/<instance>/<values> & /ditto/Config/<values> */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCtlInst, "Trusted", 1);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pCtlInst, "Config", &pCfg);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync switch (enmCtrlType)
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync case StorageControllerType_LsiLogic:
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = BusMgr->assignPciDevice("lsilogic", pCtlInst); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "Bootable", fBootable);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* Attach the status driver */
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapStorageLeds[iLedScsi]);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "First", 0);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Assert(cLedScsi >= 16);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "Last", 15);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync paLedDevType = &maStorageDevType[iLedScsi];
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync break;
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync }
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync case StorageControllerType_BusLogic:
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync {
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync hrc = BusMgr->assignPciDevice("buslogic", pCtlInst); H();
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "Bootable", fBootable);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync /* Attach the status driver */
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapStorageLeds[iLedScsi]);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "First", 0);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync Assert(cLedScsi >= 16);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync InsertConfigInteger(pCfg, "Last", 15);
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync paLedDevType = &maStorageDevType[iLedScsi];
96a93b5e6bd7da64f6be955c9fd7569b80c8ae2evboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case StorageControllerType_IntelAhci:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = BusMgr->assignPciDevice("ahci", pCtlInst); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync ULONG cPorts = 0;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = ctrls[i]->COMGETTER(PortCount)(&cPorts); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "PortCount", cPorts);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "Bootable", fBootable);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* Needed configuration values for the bios, only first controller. */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync if (!BusMgr->hasPciDevice("ahci", 1))
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync if (pBiosCfg)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pBiosCfg, "SataHardDiskDevice", "ahci");
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync for (uint32_t j = 0; j < 4; ++j)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync static const char * const s_apszConfig[4] =
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync { "PrimaryMaster", "PrimarySlave", "SecondaryMaster", "SecondarySlave" };
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync static const char * const s_apszBiosConfig[4] =
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync { "SataPrimaryMasterLUN", "SataPrimarySlaveLUN", "SataSecondaryMasterLUN", "SataSecondarySlaveLUN" };
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync LONG lPortNumber = -1;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = ctrls[i]->GetIDEEmulationPort(j, &lPortNumber); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, s_apszConfig[j], lPortNumber);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync if (pBiosCfg)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pBiosCfg, s_apszBiosConfig[j], lPortNumber);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* Attach the status driver */
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync AssertRelease(cPorts <= cLedSata);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapStorageLeds[iLedSata]);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "First", 0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "Last", cPorts - 1);
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync paLedDevType = &maStorageDevType[iLedSata];
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case StorageControllerType_PIIX3:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case StorageControllerType_PIIX4:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case StorageControllerType_ICH6:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /*
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync * IDE (update this when the main interface changes)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = BusMgr->assignPciDevice("piix3ide", pCtlInst); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pCfg, "Type", controllerString(enmCtrlType));
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* Attach the status driver */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapStorageLeds[iLedIde]);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "First", 0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync Assert(cLedIde >= 4);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "Last", 3);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync paLedDevType = &maStorageDevType[iLedIde];
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* IDE flavors */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync aCtrlNodes[StorageControllerType_PIIX3] = pDev;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync aCtrlNodes[StorageControllerType_PIIX4] = pDev;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync aCtrlNodes[StorageControllerType_ICH6] = pDev;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case StorageControllerType_I82078:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /*
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync * i82078 Floppy drive controller
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync fFdcEnabled = true;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "IRQ", 6);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "DMA", 2);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "MemMapped", 0 );
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "IOBase", 0x3f0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* Attach the status driver */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapStorageLeds[iLedFloppy]);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "First", 0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync Assert(cLedFloppy >= 1);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "Last", 0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync paLedDevType = &maStorageDevType[iLedFloppy];
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case StorageControllerType_LsiLogicSas:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = BusMgr->assignPciDevice("lsilogicsas", pCtlInst); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pCfg, "ControllerType", "SAS1068");
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "Bootable", fBootable);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* Attach the status driver */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapStorageLeds[iLedSas]);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "First", 0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync Assert(cLedSas >= 8);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "Last", 7);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync paLedDevType = &maStorageDevType[iLedSas];
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync default:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync AssertMsgFailedReturn(("invalid storage controller type: %d\n", enmCtrlType), VERR_GENERAL_FAILURE);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* Attach the media to the storage controllers. */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync com::SafeIfaceArray<IMediumAttachment> atts;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = pMachine->GetMediumAttachmentsOfController(controllerName.raw(),
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync ComSafeArrayAsOutParam(atts)); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* Builtin I/O cache - per device setting. */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync BOOL fBuiltinIoCache = true;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = pMachine->COMGETTER(IoCacheEnabled)(&fBuiltinIoCache); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync for (size_t j = 0; j < atts.size(); ++j)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync rc = configMediumAttachment(pCtlInst,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync pszCtrlDev,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync ulInstance,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync enmBus,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync !!fUseHostIOCache,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync !!fBuiltinIoCache,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync false /* fSetupMerge */,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync 0 /* uMergeSource */,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync 0 /* uMergeTarget */,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync atts[j],
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync mMachineState,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync NULL /* phrc */,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync false /* fAttachDetach */,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync false /* fForceUnmount */,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync pVM,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync paLedDevType);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync if (RT_FAILURE(rc))
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync return rc;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /*
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync * Network adapters
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#ifdef VMWARE_NET_IN_SLOT_11
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync bool fSwapSlots3and11 = false;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#endif
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync PCFGMNODE pDevPCNet = NULL; /* PCNet-type devices */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pDevices, "pcnet", &pDevPCNet);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#ifdef VBOX_WITH_E1000
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync PCFGMNODE pDevE1000 = NULL; /* E1000-type devices */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pDevices, "e1000", &pDevE1000);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#endif
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#ifdef VBOX_WITH_VIRTIO
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync PCFGMNODE pDevVirtioNet = NULL; /* Virtio network devices */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pDevices, "virtio-net", &pDevVirtioNet);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#endif /* VBOX_WITH_VIRTIO */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync std::list<BootNic> llBootNics;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync for (ULONG ulInstance = 0; ulInstance < SchemaDefs::NetworkAdapterCount; ++ulInstance)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync ComPtr<INetworkAdapter> networkAdapter;
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync hrc = pMachine->GetNetworkAdapter(ulInstance, networkAdapter.asOutParam()); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync BOOL fEnabled = FALSE;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = networkAdapter->COMGETTER(Enabled)(&fEnabled); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync if (!fEnabled)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync continue;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /*
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync * The virtual hardware type. Create appropriate device first.
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync const char *pszAdapterName = "pcnet";
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync NetworkAdapterType_T adapterType;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = networkAdapter->COMGETTER(AdapterType)(&adapterType); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync switch (adapterType)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync case NetworkAdapterType_Am79C970A:
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync case NetworkAdapterType_Am79C973:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync pDev = pDevPCNet;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#ifdef VBOX_WITH_E1000
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case NetworkAdapterType_I82540EM:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case NetworkAdapterType_I82543GC:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case NetworkAdapterType_I82545EM:
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync pDev = pDevE1000;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync pszAdapterName = "e1000";
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#endif
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync#ifdef VBOX_WITH_VIRTIO
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case NetworkAdapterType_Virtio:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync pDev = pDevVirtioNet;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync pszAdapterName = "virtio-net";
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#endif /* VBOX_WITH_VIRTIO */
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync default:
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync AssertMsgFailed(("Invalid network adapter type '%d' for slot '%d'",
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync adapterType, ulInstance));
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync N_("Invalid network adapter type '%d' for slot '%d'"),
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync adapterType, ulInstance);
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pDev, Utf8StrFmt("%u", ulInstance).c_str(), &pInst);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* the first network card gets the PCI ID 3, the next 3 gets 8..10,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync * next 4 get 16..19. */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync int iPciDeviceNo;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync switch (ulInstance)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case 0:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync iPciDeviceNo = 3;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case 1: case 2: case 3:
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync iPciDeviceNo = ulInstance - 1 + 8;
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case 4: case 5: case 6: case 7:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync iPciDeviceNo = ulInstance - 4 + 16;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync default:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* auto assignment */
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync iPciDeviceNo = -1;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#ifdef VMWARE_NET_IN_SLOT_11
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /*
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync * Dirty hack for PCI slot compatibility with VMWare,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync * it assigns slot 11 to the first network controller.
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync if (iPciDeviceNo == 3 && adapterType == NetworkAdapterType_I82545EM)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync iPciDeviceNo = 0x11;
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync fSwapSlots3and11 = true;
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync }
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync else if (iPciDeviceNo == 0x11 && fSwapSlots3and11)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync iPciDeviceNo = 3;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#endif
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync PciBusAddress PciAddr = PciBusAddress(0, iPciDeviceNo, 0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = BusMgr->assignPciDevice(pszAdapterName, pInst, PciAddr); H();
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync InsertConfigNode(pInst, "Config", &pCfg);
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE /* not safe here yet. */
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync if (pDev == pDevPCNet)
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync {
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync InsertConfigInteger(pCfg, "R0Enabled", false);
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync }
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync#endif
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync /*
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync * Collect information needed for network booting and add it to the list.
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync */
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync BootNic nic;
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync nic.mInstance = ulInstance;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* Could be updated by reference, if auto assigned */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync nic.mPciAddress = PciAddr;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = networkAdapter->COMGETTER(BootPriority)(&nic.mBootPrio); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync llBootNics.push_back(nic);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /*
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync * The virtual hardware type. PCNet supports two types.
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync switch (adapterType)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case NetworkAdapterType_Am79C970A:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "Am79C973", 0);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case NetworkAdapterType_Am79C973:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "Am79C973", 1);
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case NetworkAdapterType_I82540EM:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "AdapterType", 0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync case NetworkAdapterType_I82543GC:
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync InsertConfigInteger(pCfg, "AdapterType", 1);
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync break;
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync case NetworkAdapterType_I82545EM:
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync InsertConfigInteger(pCfg, "AdapterType", 2);
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync break;
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync }
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync /*
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync * Get the MAC address and convert it to binary representation
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync Bstr macAddr;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = networkAdapter->COMGETTER(MACAddress)(macAddr.asOutParam()); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync Assert(!macAddr.isEmpty());
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync Utf8Str macAddrUtf8 = macAddr;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync char *macStr = (char*)macAddrUtf8.c_str();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync Assert(strlen(macStr) == 12);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync RTMAC Mac;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync memset(&Mac, 0, sizeof(Mac));
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync char *pMac = (char*)&Mac;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync for (uint32_t i = 0; i < 6; ++i)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync char c1 = *macStr++ - '0';
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync if (c1 > 9)
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync c1 -= 7;
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync char c2 = *macStr++ - '0';
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync if (c2 > 9)
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync c2 -= 7;
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync *pMac++ = ((c1 & 0x0f) << 4) | (c2 & 0x0f);
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync }
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync InsertConfigBytes(pCfg, "MAC", &Mac, sizeof(Mac));
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync /*
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync * Check if the cable is supposed to be unplugged
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync */
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync BOOL fCableConnected;
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync hrc = networkAdapter->COMGETTER(CableConnected)(&fCableConnected); H();
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync InsertConfigInteger(pCfg, "CableConnected", fCableConnected ? 1 : 0);
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync /*
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync * Line speed to report from custom drivers
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync ULONG ulLineSpeed;
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync hrc = networkAdapter->COMGETTER(LineSpeed)(&ulLineSpeed); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "LineSpeed", ulLineSpeed);
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /*
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync * Attach the status driver.
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync */
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync InsertConfigNode(pInst, "LUN#999", &pLunL0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapNetworkLeds[ulInstance]);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /*
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * Configure the network card now
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync bool fIgnoreConnectFailure = mMachineState == MachineState_Restoring;
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync rc = configNetwork(pszAdapterName,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync ulInstance,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync 0,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync networkAdapter,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync pCfg,
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync pLunL0,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync pInst,
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync false /*fAttachDetach*/,
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync fIgnoreConnectFailure);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync if (RT_FAILURE(rc))
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync return rc;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync /*
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync * Build network boot information and transfer it to the BIOS.
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync */
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync if (pNetBootCfg && !llBootNics.empty()) /* NetBoot node doesn't exist for EFI! */
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync {
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync llBootNics.sort(); /* Sort the list by boot priority. */
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync char achBootIdx[] = "0";
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync unsigned uBootIdx = 0;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync for (std::list<BootNic>::iterator it = llBootNics.begin(); it != llBootNics.end(); ++it)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* A NIC with priority 0 is only used if it's first in the list. */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync if (it->mBootPrio == 0 && uBootIdx != 0)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync PCFGMNODE pNetBtDevCfg;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync achBootIdx[0] = '0' + uBootIdx++; /* Boot device order. */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pNetBootCfg, achBootIdx, &pNetBtDevCfg);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pNetBtDevCfg, "NIC", it->mInstance);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pNetBtDevCfg, "PCIBusNo", it->mPciAddress.iBus);
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync InsertConfigInteger(pNetBtDevCfg, "PCIDeviceNo", it->mPciAddress.iDevice);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pNetBtDevCfg, "PCIFunctionNo", it->mPciAddress.iFn);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /*
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * Serial (UART) Ports
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /* serial enabled mask to be passed to dev ACPI */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync uint16_t auSerialIoPortBase[SchemaDefs::SerialPortCount] = {0};
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync uint8_t auSerialIrq[SchemaDefs::SerialPortCount] = {0};
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pDevices, "serial", &pDev);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync for (ULONG ulInstance = 0; ulInstance < SchemaDefs::SerialPortCount; ++ulInstance)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync ComPtr<ISerialPort> serialPort;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->GetSerialPort(ulInstance, serialPort.asOutParam()); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync BOOL fEnabled = FALSE;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (serialPort)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = serialPort->COMGETTER(Enabled)(&fEnabled); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (!fEnabled)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync continue;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync InsertConfigNode(pDev, Utf8StrFmt("%u", ulInstance).c_str(), &pInst);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pInst, "Config", &pCfg);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync ULONG ulIRQ;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = serialPort->COMGETTER(IRQ)(&ulIRQ); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "IRQ", ulIRQ);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync auSerialIrq[ulInstance] = (uint8_t)ulIRQ;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync ULONG ulIOBase;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = serialPort->COMGETTER(IOBase)(&ulIOBase); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "IOBase", ulIOBase);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync auSerialIoPortBase[ulInstance] = (uint16_t)ulIOBase;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync BOOL fServer;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = serialPort->COMGETTER(Server)(&fServer); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = serialPort->COMGETTER(Path)(bstr.asOutParam()); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync PortMode_T eHostMode;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = serialPort->COMGETTER(HostMode)(&eHostMode); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (eHostMode != PortMode_Disconnected)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (eHostMode == PortMode_HostPipe)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigString(pLunL0, "Driver", "Char");
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigString(pLunL1, "Driver", "NamedPipe");
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pLunL1, "Config", &pLunL2);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigString(pLunL2, "Location", bstr);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pLunL2, "IsServer", fServer);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync else if (eHostMode == PortMode_HostDevice)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigString(pLunL0, "Driver", "Host Serial");
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pLunL0, "Config", &pLunL1);
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync InsertConfigString(pLunL1, "DevicePath", bstr);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync else if (eHostMode == PortMode_RawFile)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigString(pLunL0, "Driver", "Char");
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigString(pLunL1, "Driver", "RawFile");
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pLunL1, "Config", &pLunL2);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigString(pLunL2, "Location", bstr);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync /*
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync * Parallel (LPT) Ports
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync */
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pDevices, "parallel", &pDev);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync for (ULONG ulInstance = 0; ulInstance < SchemaDefs::ParallelPortCount; ++ulInstance)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync ComPtr<IParallelPort> parallelPort;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = pMachine->GetParallelPort(ulInstance, parallelPort.asOutParam()); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync BOOL fEnabled = FALSE;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (parallelPort)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync {
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = parallelPort->COMGETTER(Enabled)(&fEnabled); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync }
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync if (!fEnabled)
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync continue;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync InsertConfigNode(pDev, Utf8StrFmt("%u", ulInstance).c_str(), &pInst);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pInst, "Config", &pCfg);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync ULONG ulIRQ;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = parallelPort->COMGETTER(IRQ)(&ulIRQ); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "IRQ", ulIRQ);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync ULONG ulIOBase;
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync hrc = parallelPort->COMGETTER(IOBase)(&ulIOBase); H();
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigInteger(pCfg, "IOBase", ulIOBase);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync InsertConfigString(pLunL0, "Driver", "HostParallel");
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = parallelPort->COMGETTER(Path)(bstr.asOutParam()); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pLunL1, "DevicePath", bstr);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync /*
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync * VMM Device
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pDevices, "VMMDev", &pDev);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pDev, "0", &pInst);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pInst, "Config", &pCfg);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = BusMgr->assignPciDevice("VMMDev", pInst); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync Bstr hwVersion;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = pMachine->COMGETTER(HardwareVersion)(hwVersion.asOutParam()); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "RamSize", cbRam);
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync if (hwVersion.compare(Bstr("1").raw()) == 0) /* <= 2.0.x */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "HeapEnabled", 0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync Bstr snapshotFolder;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = pMachine->COMGETTER(SnapshotFolder)(snapshotFolder.asOutParam()); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pCfg, "GuestCoreDumpDir", snapshotFolder);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* the VMM device's Main driver */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pLunL0, "Driver", "HGCM");
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "Object", (uintptr_t)pVMMDev);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /*
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync * Attach the status driver.
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pInst, "LUN#999", &pLunL0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pLunL0, "Driver", "MainStatus");
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapSharedFolderLed);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "First", 0);
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync InsertConfigInteger(pCfg, "Last", 0);
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync /*
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync * Audio Sniffer Device
5060d2375aca9a234bf38465a6502e9eb454a2c5vboxsync */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pDevices, "AudioSniffer", &pDev);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pDev, "0", &pInst);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pInst, "Config", &pCfg);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* the Audio Sniffer device's Main driver */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pLunL0, "Driver", "MainAudioSniffer");
8be5264d31d6a6ec949ff2285764c9af57298b52vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
8be5264d31d6a6ec949ff2285764c9af57298b52vboxsync AudioSniffer *pAudioSniffer = mAudioSniffer;
8be5264d31d6a6ec949ff2285764c9af57298b52vboxsync InsertConfigInteger(pCfg, "Object", (uintptr_t)pAudioSniffer);
8be5264d31d6a6ec949ff2285764c9af57298b52vboxsync
8be5264d31d6a6ec949ff2285764c9af57298b52vboxsync /*
8be5264d31d6a6ec949ff2285764c9af57298b52vboxsync * AC'97 ICH / SoundBlaster16 audio / Intel HD Audio
8be5264d31d6a6ec949ff2285764c9af57298b52vboxsync */
8be5264d31d6a6ec949ff2285764c9af57298b52vboxsync BOOL fAudioEnabled;
8be5264d31d6a6ec949ff2285764c9af57298b52vboxsync ComPtr<IAudioAdapter> audioAdapter;
8be5264d31d6a6ec949ff2285764c9af57298b52vboxsync hrc = pMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam()); H();
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync if (audioAdapter)
8be5264d31d6a6ec949ff2285764c9af57298b52vboxsync hrc = audioAdapter->COMGETTER(Enabled)(&fAudioEnabled); H();
8be5264d31d6a6ec949ff2285764c9af57298b52vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync if (fAudioEnabled)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync AudioControllerType_T audioController;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = audioAdapter->COMGETTER(AudioController)(&audioController); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync switch (audioController)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case AudioControllerType_AC97:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* default: ICH AC97 */
8be5264d31d6a6ec949ff2285764c9af57298b52vboxsync InsertConfigNode(pDevices, "ichac97", &pDev);
8be5264d31d6a6ec949ff2285764c9af57298b52vboxsync InsertConfigNode(pDev, "0", &pInst);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = BusMgr->assignPciDevice("ichac97", pInst); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pInst, "Config", &pCfg);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case AudioControllerType_SB16:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* legacy SoundBlaster16 */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pDevices, "sb16", &pDev);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pDev, "0", &pInst);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pInst, "Config", &pCfg);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "IRQ", 5);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "DMA", 1);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "DMA16", 5);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "Port", 0x220);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pCfg, "Version", 0x0405);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case AudioControllerType_HDA:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* Intel HD Audio */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pDevices, "hda", &pDev);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pDev, "0", &pInst);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = BusMgr->assignPciDevice("hda", pInst); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pInst, "Config", &pCfg);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
1ede9a25697f3a01a4362525e84330a7940b508fvboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync /* the Audio driver */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pInst, "LUN#0", &pLunL0);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pLunL0, "Driver", "AUDIO");
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigNode(pLunL0, "Config", &pCfg);
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync AudioDriverType_T audioDriver;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync hrc = audioAdapter->COMGETTER(AudioDriver)(&audioDriver); H();
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync switch (audioDriver)
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case AudioDriverType_Null:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pCfg, "AudioDriver", "null");
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#ifdef RT_OS_WINDOWS
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#ifdef VBOX_WITH_WINMM
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case AudioDriverType_WinMM:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pCfg, "AudioDriver", "winmm");
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#endif
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case AudioDriverType_DirectSound:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pCfg, "AudioDriver", "dsound");
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#endif /* RT_OS_WINDOWS */
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#ifdef RT_OS_SOLARIS
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync case AudioDriverType_SolAudio:
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync {
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync InsertConfigString(pCfg, "AudioDriver", "solaudio");
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync break;
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync }
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync#endif
#ifdef RT_OS_LINUX
# ifdef VBOX_WITH_ALSA
case AudioDriverType_ALSA:
{
InsertConfigString(pCfg, "AudioDriver", "alsa");
break;
}
# endif
# ifdef VBOX_WITH_PULSE
case AudioDriverType_Pulse:
{
InsertConfigString(pCfg, "AudioDriver", "pulse");
break;
}
# endif
#endif /* RT_OS_LINUX */
#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(VBOX_WITH_SOLARIS_OSS)
case AudioDriverType_OSS:
{
InsertConfigString(pCfg, "AudioDriver", "oss");
break;
}
#endif
#ifdef RT_OS_FREEBSD
# ifdef VBOX_WITH_PULSE
case AudioDriverType_Pulse:
{
InsertConfigString(pCfg, "AudioDriver", "pulse");
break;
}
# endif
#endif
#ifdef RT_OS_DARWIN
case AudioDriverType_CoreAudio:
{
InsertConfigString(pCfg, "AudioDriver", "coreaudio");
break;
}
#endif
}
hrc = pMachine->COMGETTER(Name)(bstr.asOutParam()); H();
InsertConfigString(pCfg, "StreamName", bstr);
}
/*
* The USB Controller.
*/
ComPtr<IUSBController> USBCtlPtr;
hrc = pMachine->COMGETTER(USBController)(USBCtlPtr.asOutParam());
if (USBCtlPtr)
{
BOOL fOhciEnabled;
hrc = USBCtlPtr->COMGETTER(Enabled)(&fOhciEnabled); H();
if (fOhciEnabled)
{
InsertConfigNode(pDevices, "usb-ohci", &pDev);
InsertConfigNode(pDev, "0", &pInst);
InsertConfigNode(pInst, "Config", &pCfg);
InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
hrc = BusMgr->assignPciDevice("usb-ohci", pInst); H();
InsertConfigNode(pInst, "LUN#0", &pLunL0);
InsertConfigString(pLunL0, "Driver", "VUSBRootHub");
InsertConfigNode(pLunL0, "Config", &pCfg);
/*
* Attach the status driver.
*/
InsertConfigNode(pInst, "LUN#999", &pLunL0);
InsertConfigString(pLunL0, "Driver", "MainStatus");
InsertConfigNode(pLunL0, "Config", &pCfg);
InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapUSBLed[0]);
InsertConfigInteger(pCfg, "First", 0);
InsertConfigInteger(pCfg, "Last", 0);
#ifdef VBOX_WITH_EHCI
BOOL fEhciEnabled;
hrc = USBCtlPtr->COMGETTER(EnabledEhci)(&fEhciEnabled); H();
if (fEhciEnabled)
{
/*
* USB 2.0 is only available if the proper ExtPack is installed.
*
* Note. Configuring EHCI here and providing messages about
* the missing extpack isn't exactly clean, but it is a
* necessary evil to patch over legacy compatability issues
* introduced by the new distribution model.
*/
static const char *s_pszUsbExtPackName = "Oracle VM VirtualBox Extension Pack";
# ifdef VBOX_WITH_EXTPACK
if (mptrExtPackManager->isExtPackUsable(s_pszUsbExtPackName))
# endif
{
InsertConfigNode(pDevices, "usb-ehci", &pDev);
InsertConfigNode(pDev, "0", &pInst);
InsertConfigNode(pInst, "Config", &pCfg);
InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
hrc = BusMgr->assignPciDevice("usb-ehci", pInst); H();
InsertConfigNode(pInst, "LUN#0", &pLunL0);
InsertConfigString(pLunL0, "Driver", "VUSBRootHub");
InsertConfigNode(pLunL0, "Config", &pCfg);
/*
* Attach the status driver.
*/
InsertConfigNode(pInst, "LUN#999", &pLunL0);
InsertConfigString(pLunL0, "Driver", "MainStatus");
InsertConfigNode(pLunL0, "Config", &pCfg);
InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapUSBLed[1]);
InsertConfigInteger(pCfg, "First", 0);
InsertConfigInteger(pCfg, "Last", 0);
}
# ifdef VBOX_WITH_EXTPACK
else
{
/* Fatal if a saved state is being restored, otherwise ignorable. */
if (mMachineState == MachineState_Restoring)
return VMSetError(pVM, VERR_NOT_FOUND, RT_SRC_POS,
N_("Implementation of the USB 2.0 controller not found!\n"
"Because the USB 2.0 controller state is part of the saved "
"VM state, the VM cannot be started. To fix "
"this problem, either install the '%s' or disable USB 2.0 "
"support in the VM settings"),
s_pszUsbExtPackName);
setVMRuntimeErrorCallbackF(pVM, this, 0, "ExtPackNoEhci",
N_("Implementation of the USB 2.0 controller not found!\n"
"The device will be disabled. You can ignore this warning "
"but there will be no USB 2.0 support in your VM. To fix "
"this issue, either install the '%s' or disable USB 2.0 "
"support in the VM settings"),
s_pszUsbExtPackName);
}
# endif
}
#endif
/*
* Virtual USB Devices.
*/
PCFGMNODE pUsbDevices = NULL;
InsertConfigNode(pRoot, "USB", &pUsbDevices);
#ifdef VBOX_WITH_USB
{
/*
* Global USB options, currently unused as we'll apply the 2.0 -> 1.1 morphing
* on a per device level now.
*/
InsertConfigNode(pUsbDevices, "USBProxy", &pCfg);
InsertConfigNode(pCfg, "GlobalConfig", &pCfg);
// This globally enables the 2.0 -> 1.1 device morphing of proxied devices to keep windows quiet.
//InsertConfigInteger(pCfg, "Force11Device", true);
// The following breaks stuff, but it makes MSDs work in vista. (I include it here so
// that it's documented somewhere.) Users needing it can use:
// VBoxManage setextradata "myvm" "VBoxInternal/USB/USBProxy/GlobalConfig/Force11PacketSize" 1
//InsertConfigInteger(pCfg, "Force11PacketSize", true);
}
#endif
# if 0 /* Virtual MSD*/
InsertConfigNode(pUsbDevices, "Msd", &pDev);
InsertConfigNode(pDev, "0", &pInst);
InsertConfigNode(pInst, "Config", &pCfg);
InsertConfigNode(pInst, "LUN#0", &pLunL0);
InsertConfigString(pLunL0, "Driver", "SCSI");
InsertConfigNode(pLunL0, "Config", &pCfg);
InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
InsertConfigString(pLunL1, "Driver", "Block");
InsertConfigNode(pLunL1, "Config", &pCfg);
InsertConfigString(pCfg, "Type", "HardDisk");
InsertConfigInteger(pCfg, "Mountable", 0);
InsertConfigNode(pLunL1, "AttachedDriver", &pLunL2);
InsertConfigString(pLunL2, "Driver", "VD");
InsertConfigNode(pLunL2, "Config", &pCfg);
InsertConfigString(pCfg, "Path", "/Volumes/DataHFS/bird/VDIs/linux.vdi");
InsertConfigString(pCfg, "Format", "VDI");
# endif
/* 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 = 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 = 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 *)this;
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(this);
#endif /* VBOX_WITH_GUEST_PROPS defined */
#ifdef VBOX_WITH_GUEST_CONTROL
/*
* Guest control service
*/
rc = configGuestControl(this);
#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", fShowRtc);
if (fOsXGuest && !llBootNics.empty())
{
BootNic aNic = llBootNics.front();
uint32_t u32NicPciAddr = (aNic.mPciAddress.iDevice << 16) | aNic.mPciAddress.iFn;
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", uIocPciAddress);
if (chipsetType == ChipsetType_ICH9)
{
InsertConfigInteger(pCfg, "McfgBase", uMcfgBase);
InsertConfigInteger(pCfg, "McfgLength", cbMcfgLength);
}
InsertConfigInteger(pCfg, "HostBusPciAddress", uHbcPciAddress);
InsertConfigInteger(pCfg, "ShowCpu", fShowCpu);
InsertConfigInteger(pCfg, "CpuHotPlug", fCpuHotPlug);
InsertConfigInteger(pCfg, "Serial0IoPortBase", auSerialIoPortBase[0]);
InsertConfigInteger(pCfg, "Serial0Irq", auSerialIrq[0]);
InsertConfigInteger(pCfg, "Serial1IoPortBase", auSerialIoPortBase[1]);
InsertConfigInteger(pCfg, "Serial1Irq", auSerialIrq[1]);
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);
}
}
}
}
catch (ConfigError &x)
{
// InsertConfig threw something:
return x.m_vrc;
}
#ifdef VBOX_WITH_EXTPACK
/*
* Call the extension pack hooks if everything went well thus far.
*/
if (RT_SUCCESS(rc))
{
pAlock->release();
rc = mptrExtPackManager->callAllVmConfigureVmmHooks(this, pVM);
pAlock->acquire();
}
#endif
/*
* Apply the CFGM overlay.
*/
if (RT_SUCCESS(rc))
rc = configCfgmOverlay(pVM, virtualBox, pMachine);
#undef H
/*
* Register VM state change handler.
*/
int rc2 = VMR3AtStateRegister(pVM, Console::vmstateChangeCallback, this);
AssertRC(rc2);
if (RT_SUCCESS(rc))
rc = rc2;
/*
* Register VM runtime error handler.
*/
rc2 = VMR3AtRuntimeErrorRegister(pVM, Console::setVMRuntimeErrorCallback, this);
AssertRC(rc2);
if (RT_SUCCESS(rc))
rc = rc2;
LogFlowFunc(("vrc = %Rrc\n", rc));
LogFlowFuncLeave();
return rc;
}
/**
* Applies the CFGM overlay as specified by /VBoxInternal/XXX extra data
* values.
*
* @returns VBox status code.
* @param pVM The VM handle.
* @param pVirtualBox Pointer to the IVirtualBox interface.
* @param pMachine Pointer to the IMachine interface.
*/
/* static */
int Console::configCfgmOverlay(PVM pVM, IVirtualBox *pVirtualBox, IMachine *pMachine)
{
/*
* 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.
*/
PCFGMNODE pRoot = CFGMR3GetRoot(pVM);
int rc = VINF_SUCCESS;
try
{
/** @todo add support for removing nodes and byte blobs. */
/*
* Get the next key
*/
SafeArray<BSTR> aGlobalExtraDataKeys;
SafeArray<BSTR> aMachineExtraDataKeys;
HRESULT hrc = pVirtualBox->GetExtraDataKeys(ComSafeArrayAsOutParam(aGlobalExtraDataKeys));
AssertMsg(SUCCEEDED(hrc), ("VirtualBox::GetExtraDataKeys failed with %Rhrc\n", hrc));
// remember the no. of global values so we can call the correct method below
size_t cGlobalValues = aGlobalExtraDataKeys.size();
hrc = pMachine->GetExtraDataKeys(ComSafeArrayAsOutParam(aMachineExtraDataKeys));
AssertMsg(SUCCEEDED(hrc), ("VirtualBox::GetExtraDataKeys failed with %Rhrc\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 = pVirtualBox->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);
AssertLogRelMsgRCBreak(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;
}
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 fBuiltinIoCache,
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 (but do not eject the medium!) */
rc = pIMount->pfnUnmount(pIMount, fForceUnmount, false /*=fEject*/);
if (rc == VERR_PDM_MEDIA_NOT_MOUNTED)
rc = VINF_SUCCESS;
/* for example if the medium is locked */
else if (RT_FAILURE(rc))
return rc;
}
}
rc = PDMR3DeviceDetach(pVM, pcszDevice, 0, uLUN, PDM_TACH_FLAGS_NOT_HOT_PLUG);
if (rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN)
rc = VINF_SUCCESS;
AssertRCReturn(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);
if (!mfSnapshotFolderDiskTypeShown)
{
LogRel(("File system of '%s' (snapshots) is %s\n", utfSnap.c_str(), RTFsTypeName(enmFsTypeSnap)));
mfSnapshotFolderDiskTypeShown = true;
}
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();
ComObjPtr<IBandwidthGroup> pBwGroup;
Bstr strBwGroup;
hrc = pMediumAtt->COMGETTER(BandwidthGroup)(pBwGroup.asOutParam()); H();
if (!pBwGroup.isNull())
{
hrc = pBwGroup->COMGETTER(Name)(strBwGroup.asOutParam()); H();
}
rc = configMedium(pLunL0,
!!fPassthrough,
lType,
fUseHostIOCache,
fBuiltinIoCache,
fSetupMerge,
uMergeSource,
uMergeTarget,
strBwGroup.isEmpty() ? NULL : Utf8Str(strBwGroup).c_str(),
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*/);
AssertRCReturn(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 fBuiltinIoCache,
bool fSetupMerge,
unsigned uMergeSource,
unsigned uMergeTarget,
const char *pcszBwGroup,
IMedium *pMedium,
MachineState_T aMachineState,
HRESULT *phrc)
{
// InsertConfig* throws
try
{
int rc = VINF_SUCCESS;
HRESULT hrc;
Bstr bstr;
PCFGMNODE pLunL1 = NULL;
PCFGMNODE pCfg = NULL;
#define H() \
AssertMsgReturnStmt(SUCCEEDED(hrc), ("hrc=%Rhrc\n", hrc), if (phrc) *phrc = hrc, Global::vboxStatusCodeFromCOM(hrc))
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;
hrc = pMedium->RefreshState(&mediumState); H();
if (mediumState == MediumState_Inaccessible)
{
Bstr loc;
hrc = pMedium->COMGETTER(Location)(loc.asOutParam()); H();
setVMRuntimeErrorCallbackF(VMR3GetVM(mpUVM),
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);
/*
* Activate the builtin I/O cache for harddisks only.
* It caches writes only which doesn't make sense for DVD drives
* and just increases the overhead.
*/
if ( fBuiltinIoCache
&& (enmType == DeviceType_HardDisk))
InsertConfigInteger(pCfg, "BlockCache", 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");
}
if (pcszBwGroup)
InsertConfigString(pCfg, "BwGroup", pcszBwGroup);
/* 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;
}
}
}
/* next */
pParent = pCur;
pParentMedium = pMedium;
}
/* 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);
}
}
#undef H
}
catch (ConfigError &x)
{
// InsertConfig threw something:
return x.m_vrc;
}
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.
* @param fIgnoreConnectFailure
* True if connection failures should be ignored
* (makes only sense for bridged/host-only networks).
*
* @note Locks this object for writing.
* @thread EMT
*/
int Console::configNetwork(const char *pszDevice,
unsigned uInstance,
unsigned uLun,
INetworkAdapter *aNetworkAdapter,
PCFGMNODE pCfg,
PCFGMNODE pLunL0,
PCFGMNODE pInst,
bool fAttachDetach,
bool fIgnoreConnectFailure)
{
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 = VMR3GetVM(mpUVM); /* We're on an EMT, so this is safe. */
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];
RTStrCopy(szTrunk, sizeof(szTrunk), pszHifName);
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;
hrc = VBoxNetCfgWinQueryINetCfg(FALSE /*fGetWriteLock*/,
L"VirtualBox",
&pNc,
&pszApp);
Assert(hrc == S_OK);
if (hrc != S_OK)
{
LogRel(("NetworkAttachmentType_Bridged: Failed to get NetCfg, hrc=%Rhrc (0x%x)\n", hrc, hrc));
H();
}
/* 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;
RT_ZERO(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);
InsertConfigInteger(pCfg, "IgnoreConnectFailure", (uint64_t)fIgnoreConnectFailure);
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;
hrc = VBoxNetCfgWinQueryINetCfg(FALSE,
L"VirtualBox",
&pNc,
&pszApp);
Assert(hrc == S_OK);
if (hrc != S_OK)
{
LogRel(("NetworkAttachmentType_HostOnly: Failed to get NetCfg, hrc=%Rhrc (0x%x)\n", hrc, hrc));
H();
}
/* 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);
InsertConfigInteger(pCfg, "IgnoreConnectFailure", (uint64_t)fIgnoreConnectFailure);
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->m_pVMMDev,
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 */
}