ConsoleImpl2.cpp revision 0b7e860321d9c3303714ee5d27315add187d8a1a
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** $Id$ */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** @file
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * VBox Console COM Class implementation
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @remark We've split out the code that the 64-bit VC++ v8 compiler
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * finds problematic to optimize so we can disable optimizations
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * and later, perhaps, find a real solution for it.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/*
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Copyright (C) 2006-2007 innotek GmbH
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * available from http://www.virtualbox.org. This file is free software;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * you can redistribute it and/or modify it under the terms of the GNU
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * General Public License (GPL) as published by the Free Software
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
772269936494ffaddd0750ba9e28e805ba81398cvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync/*******************************************************************************
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync* Header Files *
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync*******************************************************************************/
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "ConsoleImpl.h"
aae15a3015041f7ed6043344bf4939736254acf6vboxsync#include "DisplayImpl.h"
aae15a3015041f7ed6043344bf4939736254acf6vboxsync#include "VMMDev.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// generated header
fe282a5e69dc51ede2f6ab6f067ae9868ba6a205vboxsync#include "SchemaDefs.h"
fe282a5e69dc51ede2f6ab6f067ae9868ba6a205vboxsync
fe282a5e69dc51ede2f6ab6f067ae9868ba6a205vboxsync#include "Logging.h"
fe282a5e69dc51ede2f6ab6f067ae9868ba6a205vboxsync
fe282a5e69dc51ede2f6ab6f067ae9868ba6a205vboxsync#include <iprt/string.h>
fe282a5e69dc51ede2f6ab6f067ae9868ba6a205vboxsync#include <iprt/path.h>
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync#include <iprt/dir.h>
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync#include <iprt/param.h>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include <VBox/vmapi.h>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include <VBox/err.h>
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync#include <VBox/version.h>
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync#include <VBox/HostServices/VBoxClipboardSvc.h>
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/*
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * VC++ 8 / amd64 has some serious trouble with this function.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * As a temporary measure, we'll drop global optimizations.
91afe8a45492af90be74e8b56d46c8659f827b0bvboxsync */
e068057c82b010bc7cc663e8f57ac3ef1890a33cvboxsync#if defined(_MSC_VER) && defined(RT_ARCH_AMD64)
a5f487d264b5aebe8d28ad35d0353630bd2b77cdvboxsync# pragma optimize("g", off)
a5f487d264b5aebe8d28ad35d0353630bd2b77cdvboxsync#endif
0412c212ede05017a46044b407f58c82374f6fe4vboxsync
de4b88070eed3a77d1e5b285a6373124450f8fccvboxsync/**
aae15a3015041f7ed6043344bf4939736254acf6vboxsync * Construct the VM configuration tree (CFGM).
e5d3b7a3187d8f891f55aa8fcb5ad3dee90b1e68vboxsync *
ba44972d4fba964e9794fb07b869741c42aa7d35vboxsync * This is a callback for VMR3Create() call. It is called from CFGMR3Init()
ba44972d4fba964e9794fb07b869741c42aa7d35vboxsync * in the emulation thread (EMT). Any per thread COM/XPCOM initialization
ba44972d4fba964e9794fb07b869741c42aa7d35vboxsync * is done here.
aae15a3015041f7ed6043344bf4939736254acf6vboxsync *
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync * @param pVM VM handle.
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync * @param pvConsole Pointer to the VMPowerUpTask object.
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync * @return VBox status code.
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync *
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync * @note Locks the Console object for writing.
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync */
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsyncDECLCALLBACK(int) Console::configConstructor(PVM pVM, void *pvConsole)
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync{
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync LogFlowFuncEnter();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync /* Note: hardcoded assumption about number of slots; see rom bios */
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync bool afPciDeviceNo[15] = {false};
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync#if !defined (VBOX_WITH_XPCOM)
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync {
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync /* initialize COM */
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync HRESULT hrc = CoInitializeEx(NULL,
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE |
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync COINIT_SPEED_OVER_MEMORY);
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync LogFlow (("Console::configConstructor(): CoInitializeEx()=%08X\n", hrc));
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync AssertComRCReturn (hrc, VERR_GENERAL_FAILURE);
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync }
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync#endif
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync AssertReturn (pvConsole, VERR_GENERAL_FAILURE);
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync ComObjPtr <Console> pConsole = static_cast <Console *> (pvConsole);
ddd5bf03356cc0515b0f42ed9048a6364e7eb1e2vboxsync
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync AutoCaller autoCaller (pConsole);
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync AssertComRCReturn (autoCaller.rc(), VERR_ACCESS_DENIED);
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync /* lock the console because we widely use internal fields and methods */
ffa06e5b007c5b2f57341d90088189ce5f99c091vboxsync AutoLock alock (pConsole);
ffa06e5b007c5b2f57341d90088189ce5f99c091vboxsync
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync ComPtr <IMachine> pMachine = pConsole->machine();
de4b88070eed3a77d1e5b285a6373124450f8fccvboxsync
10ca321f3be6e9e0ad484f4684cab6532bea20e2vboxsync int rc;
10ca321f3be6e9e0ad484f4684cab6532bea20e2vboxsync HRESULT hrc;
047755364a4a04102a05bb7866966db1ea00110dvboxsync char *psz = NULL;
75bdcd627a7ab8dfa25135d5d75ec5998962d705vboxsync BSTR str = NULL;
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync
10ca321f3be6e9e0ad484f4684cab6532bea20e2vboxsync#define STR_CONV() do { rc = RTUtf16ToUtf8(str, &psz); RC_CHECK(); } while (0)
10ca321f3be6e9e0ad484f4684cab6532bea20e2vboxsync#define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } if (psz) { RTStrFree(psz); psz = NULL; } } while (0)
10ca321f3be6e9e0ad484f4684cab6532bea20e2vboxsync#define RC_CHECK() do { if (VBOX_FAILURE(rc)) { AssertMsgFailed(("rc=%Vrc\n", rc)); STR_FREE(); return rc; } } while (0)
10ca321f3be6e9e0ad484f4684cab6532bea20e2vboxsync#define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%#x\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0)
e4bbd9d26beb3e1b2403ce02e8be7740ead622afvboxsync
48729babf1ff9fab8098654bc8c465b5ede56fe7vboxsync /*
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync * Get necessary objects and frequently used parameters.
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync */
48729babf1ff9fab8098654bc8c465b5ede56fe7vboxsync ComPtr<IVirtualBox> virtualBox;
384478d3896257fbce9ceb8c01e74040b969e6d7vboxsync hrc = pMachine->COMGETTER(Parent)(virtualBox.asOutParam()); H();
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync
11f7445114bfc5dc0da9287b950c36658da79236vboxsync ComPtr<IHost> host;
384478d3896257fbce9ceb8c01e74040b969e6d7vboxsync hrc = virtualBox->COMGETTER(Host)(host.asOutParam()); H();
384478d3896257fbce9ceb8c01e74040b969e6d7vboxsync
384478d3896257fbce9ceb8c01e74040b969e6d7vboxsync ComPtr <ISystemProperties> systemProperties;
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync hrc = virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam()); H();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ComPtr<IBIOSSettings> biosSettings;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hrc = pMachine->COMGETTER(BIOSSettings)(biosSettings.asOutParam()); H();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Guid uuid;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hrc = pMachine->COMGETTER(Id)(uuid.asOutParam()); H();
762fe54a6432c5fed423102dcd8f072a9e5e9cb9vboxsync PCRTUUID pUuid = uuid.raw();
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync
04b02ffb8824a60fd37777bc1f7d2f35104a274cvboxsync ULONG cRamMBs;
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync hrc = pMachine->COMGETTER(MemorySize)(&cRamMBs); H();
762fe54a6432c5fed423102dcd8f072a9e5e9cb9vboxsync
d55a27219d1a4cf241ff0cc0f8ac3a97b40e1ad3vboxsync
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync /*
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync * Get root node first.
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync * This is the only node in the tree.
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync */
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync PCFGMNODE pRoot = CFGMR3GetRoot(pVM);
de4b88070eed3a77d1e5b285a6373124450f8fccvboxsync Assert(pRoot);
de4b88070eed3a77d1e5b285a6373124450f8fccvboxsync
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync /*
04b02ffb8824a60fd37777bc1f7d2f35104a274cvboxsync * Set the root level values.
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync */
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync hrc = pMachine->COMGETTER(Name)(&str); H();
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync STR_CONV();
384478d3896257fbce9ceb8c01e74040b969e6d7vboxsync rc = CFGMR3InsertString(pRoot, "Name", psz); RC_CHECK();
11f7445114bfc5dc0da9287b950c36658da79236vboxsync STR_FREE();
384478d3896257fbce9ceb8c01e74040b969e6d7vboxsync rc = CFGMR3InsertBytes(pRoot, "UUID", pUuid, sizeof(*pUuid)); RC_CHECK();
384478d3896257fbce9ceb8c01e74040b969e6d7vboxsync rc = CFGMR3InsertInteger(pRoot, "RamSize", cRamMBs * _1M); RC_CHECK();
384478d3896257fbce9ceb8c01e74040b969e6d7vboxsync rc = CFGMR3InsertInteger(pRoot, "TimerMillies", 10); RC_CHECK();
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync rc = CFGMR3InsertInteger(pRoot, "RawR3Enabled", 1); /* boolean */ RC_CHECK();
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync rc = CFGMR3InsertInteger(pRoot, "RawR0Enabled", 1); /* boolean */ RC_CHECK();
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync /** @todo Config: RawR0, PATMEnabled and CASMEnabled needs attention later. */
762fe54a6432c5fed423102dcd8f072a9e5e9cb9vboxsync rc = CFGMR3InsertInteger(pRoot, "PATMEnabled", 1); /* boolean */ RC_CHECK();
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync rc = CFGMR3InsertInteger(pRoot, "CSAMEnabled", 1); /* boolean */ RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync /* hardware virtualization extensions */
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync TSBool_T hwVirtExEnabled;
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync BOOL fHWVirtExEnabled;
f9dd063f9fc5484ce7c1dffbd47b6ca9913a51b7vboxsync hrc = pMachine->COMGETTER(HWVirtExEnabled)(&hwVirtExEnabled); H();
e068057c82b010bc7cc663e8f57ac3ef1890a33cvboxsync if (hwVirtExEnabled == TSBool_Default)
a5f487d264b5aebe8d28ad35d0353630bd2b77cdvboxsync {
b9b1a758d233ec99707a143ebb72e26724e8b709vboxsync /* check the default value */
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync hrc = systemProperties->COMGETTER(HWVirtExEnabled)(&fHWVirtExEnabled); H();
2b4e84aa037ca3dc4cc8e5532c05bd13b5551ac3vboxsync }
ff51619417d2186ce33b43d4a43b26fd774fda69vboxsync else
de4b88070eed3a77d1e5b285a6373124450f8fccvboxsync fHWVirtExEnabled = (hwVirtExEnabled == TSBool_True);
de4b88070eed3a77d1e5b285a6373124450f8fccvboxsync#ifndef RT_OS_DARWIN /** @todo Implement HWVirtExt on darwin. See #1865. */
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync if (fHWVirtExEnabled)
769108208fb3edf0f765132bc7104f93399db77avboxsync {
2609df5222cfcceb51ec536b2e3173b7227a232avboxsync PCFGMNODE pHWVirtExt;
769108208fb3edf0f765132bc7104f93399db77avboxsync rc = CFGMR3InsertNode(pRoot, "HWVirtExt", &pHWVirtExt); RC_CHECK();
384478d3896257fbce9ceb8c01e74040b969e6d7vboxsync rc = CFGMR3InsertInteger(pHWVirtExt, "Enabled", 1); RC_CHECK();
384478d3896257fbce9ceb8c01e74040b969e6d7vboxsync }
384478d3896257fbce9ceb8c01e74040b969e6d7vboxsync#endif
384478d3896257fbce9ceb8c01e74040b969e6d7vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync BOOL fIOAPIC;
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync hrc = biosSettings->COMGETTER(IOAPICEnabled)(&fIOAPIC); H();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync BOOL fPXEDebug;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync hrc = biosSettings->COMGETTER(PXEDebugEnabled)(&fPXEDebug); H();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync /*
aae15a3015041f7ed6043344bf4939736254acf6vboxsync * Virtual IDE controller type.
81578c6df6541d965dcfe32dd0e0decb64a42284vboxsync */
f350d4fb2d12fd22c0905fe9c7a121499da7b52dvboxsync IDEControllerType_T controllerType;
81578c6df6541d965dcfe32dd0e0decb64a42284vboxsync BOOL fPIIX4;
81578c6df6541d965dcfe32dd0e0decb64a42284vboxsync hrc = biosSettings->COMGETTER(IDEControllerType)(&controllerType); H();
81578c6df6541d965dcfe32dd0e0decb64a42284vboxsync switch (controllerType)
81578c6df6541d965dcfe32dd0e0decb64a42284vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case IDEControllerType_PIIX3:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fPIIX4 = FALSE;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync break;
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync case IDEControllerType_PIIX4:
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync fPIIX4 = TRUE;
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync break;
e5d3b7a3187d8f891f55aa8fcb5ad3dee90b1e68vboxsync default:
ba44972d4fba964e9794fb07b869741c42aa7d35vboxsync AssertMsgFailed(("Invalid IDE controller type '%d'", controllerType));
ba44972d4fba964e9794fb07b869741c42aa7d35vboxsync return VERR_INVALID_PARAMETER;
ba44972d4fba964e9794fb07b869741c42aa7d35vboxsync }
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync /*
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync * PDM config.
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync * Load drivers in VBoxC.[so|dll]
b9a6f7db9362492be8b058a52ccf9e52d1eabb67vboxsync */
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync PCFGMNODE pPDM;
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync PCFGMNODE pDrivers;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync PCFGMNODE pMod;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pRoot, "PDM", &pPDM); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pPDM, "Drivers", &pDrivers); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pDrivers, "VBoxC", &pMod); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync#ifdef VBOX_WITH_XPCOM
aae15a3015041f7ed6043344bf4939736254acf6vboxsync // VBoxC is located in the components subdirectory
aae15a3015041f7ed6043344bf4939736254acf6vboxsync char szPathVBoxC[RTPATH_MAX];
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = RTPathAppPrivateArch(szPathVBoxC, RTPATH_MAX - sizeof("/components/VBoxC")); AssertRC(rc);
aae15a3015041f7ed6043344bf4939736254acf6vboxsync strcat(szPathVBoxC, "/components/VBoxC");
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertString(pMod, "Path", szPathVBoxC); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync#else
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertString(pMod, "Path", "VBoxC"); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync#endif
aae15a3015041f7ed6043344bf4939736254acf6vboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync /*
aae15a3015041f7ed6043344bf4939736254acf6vboxsync * Devices
aae15a3015041f7ed6043344bf4939736254acf6vboxsync */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync PCFGMNODE pDevices = NULL; /* /Devices */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync PCFGMNODE pDev = NULL; /* /Devices/Dev/ */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync PCFGMNODE pInst = NULL; /* /Devices/Dev/0/ */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync PCFGMNODE pCfg = NULL; /* /Devices/Dev/.../Config/ */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync PCFGMNODE pLunL0 = NULL; /* /Devices/Dev/0/LUN#0/ */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync PCFGMNODE pLunL1 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/ */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync PCFGMNODE pLunL2 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/Config/ */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync PCFGMNODE pIdeInst = NULL; /* /Devices/piix3ide/0/ */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync PCFGMNODE pSataInst = NULL; /* /Devices/ahci/0/ */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync PCFGMNODE pBiosCfg = NULL; /* /Devices/pcbios/0/Config/ */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pRoot, "Devices", &pDevices); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync /*
aae15a3015041f7ed6043344bf4939736254acf6vboxsync * PC Arch.
8a5e0b7c43d7ee861689984edc2abd86b9ed4456vboxsync */
ca551aca153d6df494985b5281c573ba2e3eb474vboxsync rc = CFGMR3InsertNode(pDevices, "pcarch", &pDev); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync /*
aae15a3015041f7ed6043344bf4939736254acf6vboxsync * PC Bios.
aae15a3015041f7ed6043344bf4939736254acf6vboxsync */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pDevices, "pcbios", &pDev); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pBiosCfg); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pBiosCfg, "RamSize", cRamMBs * _1M); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertString(pBiosCfg, "HardDiskDevice", "piix3ide"); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertString(pBiosCfg, "FloppyDevice", "i82078"); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pBiosCfg, "IOAPIC", fIOAPIC); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pBiosCfg, "PXEDebug", fPXEDebug); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertBytes(pBiosCfg, "UUID", pUuid, sizeof(*pUuid)); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync DeviceType_T bootDevice;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync if (SchemaDefs::MaxBootPosition > 9)
aae15a3015041f7ed6043344bf4939736254acf6vboxsync {
aae15a3015041f7ed6043344bf4939736254acf6vboxsync AssertMsgFailed (("Too many boot devices %d\n",
aae15a3015041f7ed6043344bf4939736254acf6vboxsync SchemaDefs::MaxBootPosition));
aae15a3015041f7ed6043344bf4939736254acf6vboxsync return VERR_INVALID_PARAMETER;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync }
aae15a3015041f7ed6043344bf4939736254acf6vboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync for (ULONG pos = 1; pos <= SchemaDefs::MaxBootPosition; pos ++)
aae15a3015041f7ed6043344bf4939736254acf6vboxsync {
aae15a3015041f7ed6043344bf4939736254acf6vboxsync hrc = pMachine->GetBootOrder(pos, &bootDevice); H();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync char szParamName[] = "BootDeviceX";
aae15a3015041f7ed6043344bf4939736254acf6vboxsync szParamName[sizeof (szParamName) - 2] = ((char (pos - 1)) + '0');
aae15a3015041f7ed6043344bf4939736254acf6vboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync const char *pszBootDevice;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync switch (bootDevice)
aae15a3015041f7ed6043344bf4939736254acf6vboxsync {
aae15a3015041f7ed6043344bf4939736254acf6vboxsync case DeviceType_Null:
aae15a3015041f7ed6043344bf4939736254acf6vboxsync pszBootDevice = "NONE";
aae15a3015041f7ed6043344bf4939736254acf6vboxsync break;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync case DeviceType_HardDisk:
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync pszBootDevice = "IDE";
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync break;
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync case DeviceType_DVD:
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync pszBootDevice = "DVD";
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync break;
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync case DeviceType_Floppy:
04b02ffb8824a60fd37777bc1f7d2f35104a274cvboxsync pszBootDevice = "FLOPPY";
762fe54a6432c5fed423102dcd8f072a9e5e9cb9vboxsync break;
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync case DeviceType_Network:
04b02ffb8824a60fd37777bc1f7d2f35104a274cvboxsync pszBootDevice = "LAN";
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync break;
762fe54a6432c5fed423102dcd8f072a9e5e9cb9vboxsync default:
d55a27219d1a4cf241ff0cc0f8ac3a97b40e1ad3vboxsync AssertMsgFailed(("Invalid bootDevice=%d\n", bootDevice));
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync return VERR_INVALID_PARAMETER;
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync }
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync rc = CFGMR3InsertString(pBiosCfg, szParamName, pszBootDevice); RC_CHECK();
762fe54a6432c5fed423102dcd8f072a9e5e9cb9vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync /*
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync * The time offset
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync LONG64 timeOffset;
f9dd063f9fc5484ce7c1dffbd47b6ca9913a51b7vboxsync hrc = biosSettings->COMGETTER(TimeOffset)(&timeOffset); H();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync PCFGMNODE pTMNode;
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync rc = CFGMR3InsertNode(pRoot, "TM", &pTMNode); RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync rc = CFGMR3InsertInteger(pTMNode, "UTCOffset", timeOffset * 1000000); RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync /*
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync * ACPI
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync BOOL fACPI;
b40c3fa94b8a873f7f2eca1558e0de367a276687vboxsync hrc = biosSettings->COMGETTER(ACPIEnabled)(&fACPI); H();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync if (fACPI)
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync rc = CFGMR3InsertNode(pDevices, "acpi", &pDev); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync rc = CFGMR3InsertInteger(pCfg, "RamSize", cRamMBs * _1M); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 7); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync Assert(!afPciDeviceNo[7]);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync afPciDeviceNo[7] = true;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "ACPIHost"); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync }
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync /*
aae15a3015041f7ed6043344bf4939736254acf6vboxsync * DMA
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync */
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertNode(pDevices, "8237A", &pDev); RC_CHECK();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync /*
aae15a3015041f7ed6043344bf4939736254acf6vboxsync * PCI bus.
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pDevices, "pci", &pDev); /* piix3 */ RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
f9dd063f9fc5484ce7c1dffbd47b6ca9913a51b7vboxsync rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync
e5d3b7a3187d8f891f55aa8fcb5ad3dee90b1e68vboxsync /*
ba44972d4fba964e9794fb07b869741c42aa7d35vboxsync * PS/2 keyboard & mouse.
ba44972d4fba964e9794fb07b869741c42aa7d35vboxsync */
ba44972d4fba964e9794fb07b869741c42aa7d35vboxsync rc = CFGMR3InsertNode(pDevices, "pckbd", &pDev); RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "KeyboardQueue"); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pCfg, "QueueSize", 64); RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertString(pLunL1, "Driver", "MainKeyboard"); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync Keyboard *pKeyboard = pConsole->mKeyboard;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pKeyboard); RC_CHECK();
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync rc = CFGMR3InsertNode(pInst, "LUN#1", &pLunL0); RC_CHECK();
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MouseQueue"); RC_CHECK();
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync rc = CFGMR3InsertInteger(pCfg, "QueueSize", 128); RC_CHECK();
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync
99f34065aa871a12e9afacbaf27bd9dc9ff8d0bbvboxsync rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
762fe54a6432c5fed423102dcd8f072a9e5e9cb9vboxsync rc = CFGMR3InsertString(pLunL1, "Driver", "MainMouse"); RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
04b02ffb8824a60fd37777bc1f7d2f35104a274cvboxsync Mouse *pMouse = pConsole->mMouse;
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pMouse); RC_CHECK();
762fe54a6432c5fed423102dcd8f072a9e5e9cb9vboxsync
d55a27219d1a4cf241ff0cc0f8ac3a97b40e1ad3vboxsync /*
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync * i82078 Floppy drive controller
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync */
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync ComPtr<IFloppyDrive> floppyDrive;
762fe54a6432c5fed423102dcd8f072a9e5e9cb9vboxsync hrc = pMachine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam()); H();
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync BOOL fFloppyEnabled;
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync hrc = floppyDrive->COMGETTER(Enabled)(&fFloppyEnabled); H();
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync if (fFloppyEnabled)
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync {
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync rc = CFGMR3InsertNode(pDevices, "i82078", &pDev); RC_CHECK();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
f9dd063f9fc5484ce7c1dffbd47b6ca9913a51b7vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); RC_CHECK();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync rc = CFGMR3InsertInteger(pCfg, "IRQ", 6); RC_CHECK();
f9dd063f9fc5484ce7c1dffbd47b6ca9913a51b7vboxsync rc = CFGMR3InsertInteger(pCfg, "DMA", 2); RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync rc = CFGMR3InsertInteger(pCfg, "MemMapped", 0 ); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pCfg, "IOBase", 0x3f0); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync /* Attach the status driver */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapFDLeds[0]); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync ComPtr<IFloppyImage> floppyImage;
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync hrc = floppyDrive->GetImage(floppyImage.asOutParam()); H();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync if (floppyImage)
aae15a3015041f7ed6043344bf4939736254acf6vboxsync {
aae15a3015041f7ed6043344bf4939736254acf6vboxsync pConsole->meFloppyState = DriveState_ImageMounted;
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertString(pCfg, "Type", "Floppy 1.44"); RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync rc = CFGMR3InsertString(pLunL1, "Driver", "RawImage"); RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync hrc = floppyImage->COMGETTER(FilePath)(&str); H();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync STR_CONV();
e5d3b7a3187d8f891f55aa8fcb5ad3dee90b1e68vboxsync rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
ba44972d4fba964e9794fb07b869741c42aa7d35vboxsync STR_FREE();
ba44972d4fba964e9794fb07b869741c42aa7d35vboxsync }
ba44972d4fba964e9794fb07b869741c42aa7d35vboxsync else
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync {
8f0a8248a277021da955c40eaef0c6799bf082cdvboxsync ComPtr<IHostFloppyDrive> hostFloppyDrive;
8f0a8248a277021da955c40eaef0c6799bf082cdvboxsync hrc = floppyDrive->GetHostDrive(hostFloppyDrive.asOutParam()); H();
8f0a8248a277021da955c40eaef0c6799bf082cdvboxsync if (hostFloppyDrive)
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync {
aae15a3015041f7ed6043344bf4939736254acf6vboxsync pConsole->meFloppyState = DriveState_HostDriveCaptured;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "HostFloppy"); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync hrc = hostFloppyDrive->COMGETTER(Name)(&str); H();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync STR_CONV();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync STR_FREE();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync }
aae15a3015041f7ed6043344bf4939736254acf6vboxsync else
aae15a3015041f7ed6043344bf4939736254acf6vboxsync {
aae15a3015041f7ed6043344bf4939736254acf6vboxsync pConsole->meFloppyState = DriveState_NotMounted;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertString(pCfg, "Type", "Floppy 1.44"); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync }
aae15a3015041f7ed6043344bf4939736254acf6vboxsync }
aae15a3015041f7ed6043344bf4939736254acf6vboxsync }
aae15a3015041f7ed6043344bf4939736254acf6vboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync /*
aae15a3015041f7ed6043344bf4939736254acf6vboxsync * i8254 Programmable Interval Timer And Dummy Speaker
aae15a3015041f7ed6043344bf4939736254acf6vboxsync */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pDevices, "i8254", &pDev); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync#ifdef DEBUG
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync#endif
aae15a3015041f7ed6043344bf4939736254acf6vboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync /*
aae15a3015041f7ed6043344bf4939736254acf6vboxsync * i8259 Programmable Interrupt Controller.
aae15a3015041f7ed6043344bf4939736254acf6vboxsync */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pDevices, "i8259", &pDev); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
ca551aca153d6df494985b5281c573ba2e3eb474vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
6e7c344fc7cdb580356704e8201207b394d367bbvboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync /*
aae15a3015041f7ed6043344bf4939736254acf6vboxsync * Advanced Programmable Interrupt Controller.
aae15a3015041f7ed6043344bf4939736254acf6vboxsync */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pDevices, "apic", &pDev); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync if (fIOAPIC)
aae15a3015041f7ed6043344bf4939736254acf6vboxsync {
c5fbfff2c6f46db681b0c092d69e6c163917806avboxsync /*
c5fbfff2c6f46db681b0c092d69e6c163917806avboxsync * I/O Advanced Programmable Interrupt Controller.
c5fbfff2c6f46db681b0c092d69e6c163917806avboxsync */
c5fbfff2c6f46db681b0c092d69e6c163917806avboxsync rc = CFGMR3InsertNode(pDevices, "ioapic", &pDev); RC_CHECK();
e4bbd9d26beb3e1b2403ce02e8be7740ead622afvboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync }
aae15a3015041f7ed6043344bf4939736254acf6vboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync /*
aae15a3015041f7ed6043344bf4939736254acf6vboxsync * RTC MC146818.
aae15a3015041f7ed6043344bf4939736254acf6vboxsync */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pDevices, "mc146818", &pDev); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync /*
aae15a3015041f7ed6043344bf4939736254acf6vboxsync * VGA.
aae15a3015041f7ed6043344bf4939736254acf6vboxsync */
c5fbfff2c6f46db681b0c092d69e6c163917806avboxsync rc = CFGMR3InsertNode(pDevices, "vga", &pDev); RC_CHECK();
c5fbfff2c6f46db681b0c092d69e6c163917806avboxsync rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
c5fbfff2c6f46db681b0c092d69e6c163917806avboxsync rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
e4bbd9d26beb3e1b2403ce02e8be7740ead622afvboxsync rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 2); RC_CHECK();
22779f914326d58cfd205ee44c1100323fd59821vboxsync Assert(!afPciDeviceNo[2]);
f74dc240a0d264675cd342aeae29a624aa5b91efvboxsync afPciDeviceNo[2] = true;
22779f914326d58cfd205ee44c1100323fd59821vboxsync rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
04b02ffb8824a60fd37777bc1f7d2f35104a274cvboxsync rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
f74dc240a0d264675cd342aeae29a624aa5b91efvboxsync hrc = pMachine->COMGETTER(VRAMSize)(&cRamMBs); H();
22779f914326d58cfd205ee44c1100323fd59821vboxsync rc = CFGMR3InsertInteger(pCfg, "VRamSize", cRamMBs * _1M); RC_CHECK();
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync /*
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync * BIOS logo
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync */
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync BOOL fFadeIn;
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync hrc = biosSettings->COMGETTER(LogoFadeIn)(&fFadeIn); H();
c5fbfff2c6f46db681b0c092d69e6c163917806avboxsync rc = CFGMR3InsertInteger(pCfg, "FadeIn", fFadeIn ? 1 : 0); RC_CHECK();
c5fbfff2c6f46db681b0c092d69e6c163917806avboxsync BOOL fFadeOut;
c5fbfff2c6f46db681b0c092d69e6c163917806avboxsync hrc = biosSettings->COMGETTER(LogoFadeOut)(&fFadeOut); H();
c5fbfff2c6f46db681b0c092d69e6c163917806avboxsync rc = CFGMR3InsertInteger(pCfg, "FadeOut", fFadeOut ? 1: 0); RC_CHECK();
c5fbfff2c6f46db681b0c092d69e6c163917806avboxsync ULONG logoDisplayTime;
c5fbfff2c6f46db681b0c092d69e6c163917806avboxsync hrc = biosSettings->COMGETTER(LogoDisplayTime)(&logoDisplayTime); H();
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync rc = CFGMR3InsertInteger(pCfg, "LogoTime", logoDisplayTime); RC_CHECK();
762fe54a6432c5fed423102dcd8f072a9e5e9cb9vboxsync Bstr logoImagePath;
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync hrc = biosSettings->COMGETTER(LogoImagePath)(logoImagePath.asOutParam()); H();
04b02ffb8824a60fd37777bc1f7d2f35104a274cvboxsync rc = CFGMR3InsertString(pCfg, "LogoFile", logoImagePath ? Utf8Str(logoImagePath) : ""); RC_CHECK();
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync
762fe54a6432c5fed423102dcd8f072a9e5e9cb9vboxsync /*
d55a27219d1a4cf241ff0cc0f8ac3a97b40e1ad3vboxsync * Boot menu
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync */
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync BIOSBootMenuMode_T bootMenuMode;
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync int value;
762fe54a6432c5fed423102dcd8f072a9e5e9cb9vboxsync biosSettings->COMGETTER(BootMenuMode)(&bootMenuMode);
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync switch (bootMenuMode)
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync {
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync case BIOSBootMenuMode_Disabled:
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync value = 0;
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case BIOSBootMenuMode_MenuOnly:
f9dd063f9fc5484ce7c1dffbd47b6ca9913a51b7vboxsync value = 1;
f9dd063f9fc5484ce7c1dffbd47b6ca9913a51b7vboxsync break;
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync default:
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync value = 2;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync rc = CFGMR3InsertInteger(pCfg, "ShowBootMenu", value); RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync /* Custom VESA mode list */
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync unsigned cModes = 0;
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync for (unsigned iMode = 1; iMode <= 16; iMode++)
aae15a3015041f7ed6043344bf4939736254acf6vboxsync {
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync char szExtraDataKey[sizeof("CustomVideoModeXX")];
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync RTStrPrintf(szExtraDataKey, sizeof(szExtraDataKey), "CustomVideoMode%d", iMode);
aae15a3015041f7ed6043344bf4939736254acf6vboxsync hrc = pMachine->GetExtraData(Bstr(szExtraDataKey), &str); H();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync if (!str || !*str)
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync break;
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync STR_CONV();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertString(pCfg, szExtraDataKey, psz);
aae15a3015041f7ed6043344bf4939736254acf6vboxsync STR_FREE();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync cModes++;
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync }
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pCfg, "CustomVideoModes", cModes);
aae15a3015041f7ed6043344bf4939736254acf6vboxsync
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync /* VESA height reduction */
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync ULONG ulHeightReduction;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync IFramebuffer *pFramebuffer = pConsole->getDisplay()->getFramebuffer();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync if (pFramebuffer)
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync {
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync hrc = pFramebuffer->COMGETTER(HeightReduction)(&ulHeightReduction); H();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync }
aae15a3015041f7ed6043344bf4939736254acf6vboxsync else
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync {
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync /* If framebuffer is not available, there is no height reduction. */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync ulHeightReduction = 0;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync }
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertInteger(pCfg, "HeightReduction", ulHeightReduction); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync /* Attach the display. */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MainDisplay"); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync Display *pDisplay = pConsole->mDisplay;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pDisplay); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync /*
aae15a3015041f7ed6043344bf4939736254acf6vboxsync * IDE (update this when the main interface changes)
aae15a3015041f7ed6043344bf4939736254acf6vboxsync */
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertNode(pDevices, "piix3ide", &pDev); /* piix3 */ RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertNode(pDev, "0", &pIdeInst); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pIdeInst, "Trusted", 1); /* boolean */ RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pIdeInst, "PCIDeviceNo", 1); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync Assert(!afPciDeviceNo[1]);
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync afPciDeviceNo[1] = true;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pIdeInst, "PCIFunctionNo", 1); RC_CHECK();
f350d4fb2d12fd22c0905fe9c7a121499da7b52dvboxsync rc = CFGMR3InsertNode(pIdeInst, "Config", &pCfg); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertInteger(pCfg, "PIIX4", fPIIX4); /* boolean */ RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync /* Attach the status driver */
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertNode(pIdeInst, "LUN#999", &pLunL0); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapIDELeds[0]);RC_CHECK();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync rc = CFGMR3InsertInteger(pCfg, "Last", 3); RC_CHECK();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync
aae15a3015041f7ed6043344bf4939736254acf6vboxsync /*
aae15a3015041f7ed6043344bf4939736254acf6vboxsync * SATA controller
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync */
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync ComPtr<ISATAController> sataController;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync hrc = pMachine->COMGETTER(SATAController)(sataController.asOutParam());
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync BOOL enabled = FALSE;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (sataController)
cbb0f4da6089c4359e31e8028d94850b833cab17vboxsync {
cbb0f4da6089c4359e31e8028d94850b833cab17vboxsync hrc = sataController->COMGETTER(Enabled)(&enabled); H();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
cbb0f4da6089c4359e31e8028d94850b833cab17vboxsync if (enabled)
e068057c82b010bc7cc663e8f57ac3ef1890a33cvboxsync {
a5f487d264b5aebe8d28ad35d0353630bd2b77cdvboxsync rc = CFGMR3InsertNode(pDevices, "ahci", &pDev); RC_CHECK();
a5f487d264b5aebe8d28ad35d0353630bd2b77cdvboxsync rc = CFGMR3InsertNode(pDev, "0", &pSataInst); RC_CHECK();
0412c212ede05017a46044b407f58c82374f6fe4vboxsync rc = CFGMR3InsertInteger(pSataInst, "Trusted", 1); RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync rc = CFGMR3InsertInteger(pSataInst, "PCIDeviceNo", 13); RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync Assert(!afPciDeviceNo[13]);
e5d3b7a3187d8f891f55aa8fcb5ad3dee90b1e68vboxsync afPciDeviceNo[13] = true;
ba44972d4fba964e9794fb07b869741c42aa7d35vboxsync rc = CFGMR3InsertInteger(pSataInst, "PCIFunctionNo", 0); RC_CHECK();
ba44972d4fba964e9794fb07b869741c42aa7d35vboxsync rc = CFGMR3InsertNode(pSataInst, "Config", &pCfg); RC_CHECK();
ba44972d4fba964e9794fb07b869741c42aa7d35vboxsync
cbb0f4da6089c4359e31e8028d94850b833cab17vboxsync ULONG cPorts = 0;
aae15a3015041f7ed6043344bf4939736254acf6vboxsync hrc = sataController->COMGETTER(PortCount)(&cPorts); H();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync rc = CFGMR3InsertInteger(pCfg, "PortCount", cPorts); RC_CHECK();
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync
ffa06e5b007c5b2f57341d90088189ce5f99c091vboxsync /* Needed configuration values for the bios. */
ffa06e5b007c5b2f57341d90088189ce5f99c091vboxsync rc = CFGMR3InsertString(pBiosCfg, "SataHardDiskDevice", "ahci"); RC_CHECK();
cbb0f4da6089c4359e31e8028d94850b833cab17vboxsync
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync for (uint32_t i = 0; i < 4; i++)
f9dd063f9fc5484ce7c1dffbd47b6ca9913a51b7vboxsync {
f9dd063f9fc5484ce7c1dffbd47b6ca9913a51b7vboxsync static const char *s_apszConfig[4] =
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync { "PrimaryMaster", "PrimarySlave", "SecondaryMaster", "SecondarySlave" };
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync static const char *s_apszBiosConfig[4] =
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync { "SataPrimaryMasterLUN", "SataPrimarySlaveLUN", "SataSecondaryMasterLUN", "SataSecondarySlaveLUN" };
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync LONG lPortNumber = -1;
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync hrc = sataController->GetIDEEmulationPort(i, &lPortNumber); H();
d10b60270f0c0eeb87f45002a010cff8ba2126b1vboxsync rc = CFGMR3InsertInteger(pCfg, s_apszConfig[i], lPortNumber); RC_CHECK();
04b02ffb8824a60fd37777bc1f7d2f35104a274cvboxsync rc = CFGMR3InsertInteger(pBiosCfg, s_apszBiosConfig[i], lPortNumber); RC_CHECK();
762fe54a6432c5fed423102dcd8f072a9e5e9cb9vboxsync }
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync
04b02ffb8824a60fd37777bc1f7d2f35104a274cvboxsync /* Attach the status driver */
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync rc = CFGMR3InsertNode(pSataInst,"LUN#999", &pLunL0); RC_CHECK();
762fe54a6432c5fed423102dcd8f072a9e5e9cb9vboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
d55a27219d1a4cf241ff0cc0f8ac3a97b40e1ad3vboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync AssertRelease(cPorts <= RT_ELEMENTS(pConsole->mapSATALeds));
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapSATALeds[0]); RC_CHECK();
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync rc = CFGMR3InsertInteger(pCfg, "Last", cPorts - 1); RC_CHECK();
67927207a2d6bb545eb655ef14cdb090b1957120vboxsync }
762fe54a6432c5fed423102dcd8f072a9e5e9cb9vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync /* Attach the harddisks */
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync ComPtr<IHardDiskAttachmentCollection> hdaColl;
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync hrc = pMachine->COMGETTER(HardDiskAttachments)(hdaColl.asOutParam()); H();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ComPtr<IHardDiskAttachmentEnumerator> hdaEnum;
f9dd063f9fc5484ce7c1dffbd47b6ca9913a51b7vboxsync hrc = hdaColl->Enumerate(hdaEnum.asOutParam()); H();
e068057c82b010bc7cc663e8f57ac3ef1890a33cvboxsync
a5f487d264b5aebe8d28ad35d0353630bd2b77cdvboxsync BOOL fMore = FALSE;
b9b1a758d233ec99707a143ebb72e26724e8b709vboxsync while ( SUCCEEDED(hrc = hdaEnum->HasMore(&fMore))
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync && fMore)
2b4e84aa037ca3dc4cc8e5532c05bd13b5551ac3vboxsync {
f9dd063f9fc5484ce7c1dffbd47b6ca9913a51b7vboxsync PCFGMNODE pHardDiskCtl;
f9dd063f9fc5484ce7c1dffbd47b6ca9913a51b7vboxsync ComPtr<IHardDiskAttachment> hda;
cbb0f4da6089c4359e31e8028d94850b833cab17vboxsync hrc = hdaEnum->GetNext(hda.asOutParam()); H();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ComPtr<IHardDisk> hardDisk;
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync hrc = hda->COMGETTER(HardDisk)(hardDisk.asOutParam()); H();
f9dd063f9fc5484ce7c1dffbd47b6ca9913a51b7vboxsync StorageBus_T enmBus;
a48399c41d6eb8b66ad69c050ad263af36873e9cvboxsync hrc = hda->COMGETTER(Bus)(&enmBus); H();
aae15a3015041f7ed6043344bf4939736254acf6vboxsync LONG lDev;
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync hrc = hda->COMGETTER(Device)(&lDev); H();
6a0a658a7d69e5730cdf36b4f717fea42fee6b4cvboxsync LONG lChannel;
772269936494ffaddd0750ba9e28e805ba81398cvboxsync hrc = hda->COMGETTER(Channel)(&lChannel); H();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
int iLUN;
switch (enmBus)
{
case StorageBus_IDE:
{
if (lChannel >= 2 || lChannel < 0)
{
AssertMsgFailed(("invalid controller channel number: %d\n", lChannel));
return VERR_GENERAL_FAILURE;
}
if (lDev >= 2 || lDev < 0)
{
AssertMsgFailed(("invalid controller device number: %d\n", lDev));
return VERR_GENERAL_FAILURE;
}
iLUN = 2*lChannel + lDev;
pHardDiskCtl = pIdeInst;
}
break;
case StorageBus_SATA:
iLUN = lChannel;
pHardDiskCtl = enabled ? pSataInst : NULL;
break;
default:
AssertMsgFailed(("invalid disk controller type: %d\n", enmBus));
return VERR_GENERAL_FAILURE;
}
/* Can be NULL if SATA controller is not enabled and current hard disk is attached to SATA controller. */
if (pHardDiskCtl)
{
char szLUN[16];
RTStrPrintf(szLUN, sizeof(szLUN), "LUN#%d", iLUN);
rc = CFGMR3InsertNode(pHardDiskCtl, szLUN, &pLunL0); RC_CHECK();
rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
rc = CFGMR3InsertString(pCfg, "Type", "HardDisk"); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "Mountable", 0); RC_CHECK();
HardDiskStorageType_T hddType;
hardDisk->COMGETTER(StorageType)(&hddType);
if (hddType == HardDiskStorageType_VirtualDiskImage)
{
ComPtr<IVirtualDiskImage> vdiDisk = hardDisk;
AssertBreak (!vdiDisk.isNull(), hrc = E_FAIL);
rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
rc = CFGMR3InsertString(pLunL1, "Driver", "VBoxHDD"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
hrc = vdiDisk->COMGETTER(FilePath)(&str); H();
STR_CONV();
rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
STR_FREE();
/* Create an inversed tree of parents. */
ComPtr<IHardDisk> parentHardDisk = hardDisk;
for (PCFGMNODE pParent = pCfg;;)
{
ComPtr<IHardDisk> curHardDisk;
hrc = parentHardDisk->COMGETTER(Parent)(curHardDisk.asOutParam()); H();
if (!curHardDisk)
break;
vdiDisk = curHardDisk;
AssertBreak (!vdiDisk.isNull(), hrc = E_FAIL);
PCFGMNODE pCur;
rc = CFGMR3InsertNode(pParent, "Parent", &pCur); RC_CHECK();
hrc = vdiDisk->COMGETTER(FilePath)(&str); H();
STR_CONV();
rc = CFGMR3InsertString(pCur, "Path", psz); RC_CHECK();
STR_FREE();
rc = CFGMR3InsertInteger(pCur, "ReadOnly", 1); RC_CHECK();
/* next */
pParent = pCur;
parentHardDisk = curHardDisk;
}
}
else if (hddType == HardDiskStorageType_ISCSIHardDisk)
{
ComPtr<IISCSIHardDisk> iSCSIDisk = hardDisk;
AssertBreak (!iSCSIDisk.isNull(), hrc = E_FAIL);
rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
rc = CFGMR3InsertString(pLunL1, "Driver", "iSCSI"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
/* Set up the iSCSI initiator driver configuration. */
hrc = iSCSIDisk->COMGETTER(Target)(&str); H();
STR_CONV();
rc = CFGMR3InsertString(pCfg, "TargetName", psz); RC_CHECK();
STR_FREE();
// @todo currently there is no Initiator name config.
rc = CFGMR3InsertString(pCfg, "InitiatorName", "iqn.2006-02.de.innotek.initiator"); RC_CHECK();
ULONG64 lun;
hrc = iSCSIDisk->COMGETTER(Lun)(&lun); H();
rc = CFGMR3InsertInteger(pCfg, "LUN", lun); RC_CHECK();
hrc = iSCSIDisk->COMGETTER(Server)(&str); H();
STR_CONV();
USHORT port;
hrc = iSCSIDisk->COMGETTER(Port)(&port); H();
if (port != 0)
{
char *pszTN;
RTStrAPrintf(&pszTN, "%s:%u", psz, port);
rc = CFGMR3InsertString(pCfg, "TargetAddress", pszTN); RC_CHECK();
RTStrFree(pszTN);
}
else
{
rc = CFGMR3InsertString(pCfg, "TargetAddress", psz); RC_CHECK();
}
STR_FREE();
hrc = iSCSIDisk->COMGETTER(UserName)(&str); H();
if (str)
{
STR_CONV();
rc = CFGMR3InsertString(pCfg, "InitiatorUsername", psz); RC_CHECK();
STR_FREE();
}
hrc = iSCSIDisk->COMGETTER(Password)(&str); H();
if (str)
{
STR_CONV();
rc = CFGMR3InsertString(pCfg, "InitiatorSecret", psz); RC_CHECK();
STR_FREE();
}
// @todo currently there is no target username config.
//rc = CFGMR3InsertString(pCfg, "TargetUsername", ""); RC_CHECK();
// @todo currently there is no target password config.
//rc = CFGMR3InsertString(pCfg, "TargetSecret", ""); RC_CHECK();
/* The iSCSI initiator needs an attached iSCSI transport driver. */
rc = CFGMR3InsertNode(pLunL1, "AttachedDriver", &pLunL2); RC_CHECK();
rc = CFGMR3InsertString(pLunL2, "Driver", "iSCSITCP"); RC_CHECK();
/* Currently the transport driver has no config options. */
}
else if (hddType == HardDiskStorageType_VMDKImage)
{
ComPtr<IVMDKImage> vmdkDisk = hardDisk;
AssertBreak (!vmdkDisk.isNull(), hrc = E_FAIL);
rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
#if 1 /* Enable new VD container code (and new VMDK), as the bugs are fixed. */
rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK();
#else
rc = CFGMR3InsertString(pLunL1, "Driver", "VmdkHDD"); RC_CHECK();
#endif
rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
hrc = vmdkDisk->COMGETTER(FilePath)(&str); H();
STR_CONV();
rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
STR_FREE();
rc = CFGMR3InsertString(pCfg, "Format", "VMDK"); RC_CHECK();
}
else if (hddType == HardDiskStorageType_CustomHardDisk)
{
ComPtr<ICustomHardDisk> customHardDisk = hardDisk;
AssertBreak (!customHardDisk.isNull(), hrc = E_FAIL);
rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
hrc = customHardDisk->COMGETTER(Location)(&str); H();
STR_CONV();
rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
STR_FREE();
hrc = customHardDisk->COMGETTER(Format)(&str); H();
STR_CONV();
rc = CFGMR3InsertString(pCfg, "Format", psz); RC_CHECK();
STR_FREE();
}
else if (hddType == HardDiskStorageType_VHDImage)
{
ComPtr<IVHDImage> vhdDisk = hardDisk;
AssertBreak (!vhdDisk.isNull(), hrc = E_FAIL);
rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
hrc = vhdDisk->COMGETTER(FilePath)(&str); H();
STR_CONV();
rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
rc = CFGMR3InsertString(pCfg, "Format", "VHD"); RC_CHECK();
STR_FREE();
}
else
AssertFailed();
}
}
H();
ComPtr<IDVDDrive> dvdDrive;
hrc = pMachine->COMGETTER(DVDDrive)(dvdDrive.asOutParam()); H();
if (dvdDrive)
{
// ASSUME: DVD drive is always attached to LUN#2 (i.e. secondary IDE master)
rc = CFGMR3InsertNode(pIdeInst, "LUN#2", &pLunL0); RC_CHECK();
ComPtr<IHostDVDDrive> hostDvdDrive;
hrc = dvdDrive->GetHostDrive(hostDvdDrive.asOutParam()); H();
if (hostDvdDrive)
{
pConsole->meDVDState = DriveState_HostDriveCaptured;
rc = CFGMR3InsertString(pLunL0, "Driver", "HostDVD"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
hrc = hostDvdDrive->COMGETTER(Name)(&str); H();
STR_CONV();
rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
STR_FREE();
BOOL fPassthrough;
hrc = dvdDrive->COMGETTER(Passthrough)(&fPassthrough); H();
rc = CFGMR3InsertInteger(pCfg, "Passthrough", !!fPassthrough); RC_CHECK();
}
else
{
pConsole->meDVDState = DriveState_NotMounted;
rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
rc = CFGMR3InsertString(pCfg, "Type", "DVD"); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK();
ComPtr<IDVDImage> dvdImage;
hrc = dvdDrive->GetImage(dvdImage.asOutParam()); H();
if (dvdImage)
{
pConsole->meDVDState = DriveState_ImageMounted;
rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
rc = CFGMR3InsertString(pLunL1, "Driver", "MediaISO"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
hrc = dvdImage->COMGETTER(FilePath)(&str); H();
STR_CONV();
rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
STR_FREE();
}
}
}
/*
* Network adapters
*/
PCFGMNODE pDevPCNet = NULL; /* PCNet-type devices */
rc = CFGMR3InsertNode(pDevices, "pcnet", &pDevPCNet); RC_CHECK();
#ifdef VBOX_WITH_E1000
PCFGMNODE pDevE1000 = NULL; /* E1000-type devices */
rc = CFGMR3InsertNode(pDevices, "e1000", &pDevE1000); RC_CHECK();
#endif
for (ULONG ulInstance = 0; ulInstance < SchemaDefs::NetworkAdapterCount; ulInstance++)
{
ComPtr<INetworkAdapter> networkAdapter;
hrc = pMachine->GetNetworkAdapter(ulInstance, networkAdapter.asOutParam()); H();
BOOL fEnabled = FALSE;
hrc = networkAdapter->COMGETTER(Enabled)(&fEnabled); H();
if (!fEnabled)
continue;
/*
* The virtual hardware type. Create appropriate device first.
*/
NetworkAdapterType_T adapterType;
hrc = networkAdapter->COMGETTER(AdapterType)(&adapterType); H();
switch (adapterType)
{
case NetworkAdapterType_Am79C970A:
case NetworkAdapterType_Am79C973:
pDev = pDevPCNet;
break;
#ifdef VBOX_WITH_E1000
case NetworkAdapterType_I82540EM:
pDev = pDevE1000;
break;
#endif
default:
AssertMsgFailed(("Invalid network adapter type '%d' for slot '%d'",
adapterType, ulInstance));
return VERR_GENERAL_FAILURE;
}
char szInstance[4]; Assert(ulInstance <= 999);
RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance);
rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK();
rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
/* the first network card gets the PCI ID 3, the next 3 gets 8..10. */
const unsigned iPciDeviceNo = !ulInstance ? 3 : ulInstance - 1 + 8;
rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", iPciDeviceNo); RC_CHECK();
Assert(!afPciDeviceNo[iPciDeviceNo]);
afPciDeviceNo[iPciDeviceNo] = true;
rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
/*
* The virtual hardware type. PCNet supports two types.
*/
switch (adapterType)
{
case NetworkAdapterType_Am79C970A:
rc = CFGMR3InsertInteger(pCfg, "Am79C973", 0); RC_CHECK();
break;
case NetworkAdapterType_Am79C973:
rc = CFGMR3InsertInteger(pCfg, "Am79C973", 1); RC_CHECK();
break;
}
/*
* Get the MAC address and convert it to binary representation
*/
Bstr macAddr;
hrc = networkAdapter->COMGETTER(MACAddress)(macAddr.asOutParam()); H();
Assert(macAddr);
Utf8Str macAddrUtf8 = macAddr;
char *macStr = (char*)macAddrUtf8.raw();
Assert(strlen(macStr) == 12);
PDMMAC Mac;
memset(&Mac, 0, sizeof(Mac));
char *pMac = (char*)&Mac;
for (uint32_t i = 0; i < 6; i++)
{
char c1 = *macStr++ - '0';
if (c1 > 9)
c1 -= 7;
char c2 = *macStr++ - '0';
if (c2 > 9)
c2 -= 7;
*pMac++ = ((c1 & 0x0f) << 4) | (c2 & 0x0f);
}
rc = CFGMR3InsertBytes(pCfg, "MAC", &Mac, sizeof(Mac)); RC_CHECK();
/*
* Check if the cable is supposed to be unplugged
*/
BOOL fCableConnected;
hrc = networkAdapter->COMGETTER(CableConnected)(&fCableConnected); H();
rc = CFGMR3InsertInteger(pCfg, "CableConnected", fCableConnected ? 1 : 0); RC_CHECK();
/*
* Line speed to report from custom drivers
*/
ULONG ulLineSpeed;
hrc = networkAdapter->COMGETTER(LineSpeed)(&ulLineSpeed); H();
rc = CFGMR3InsertInteger(pCfg, "LineSpeed", ulLineSpeed); RC_CHECK();
/*
* Attach the status driver.
*/
rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapNetworkLeds[ulInstance]); RC_CHECK();
/*
* Enable the packet sniffer if requested.
*/
BOOL fSniffer;
hrc = networkAdapter->COMGETTER(TraceEnabled)(&fSniffer); H();
if (fSniffer)
{
/* insert the sniffer filter driver. */
rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
rc = CFGMR3InsertString(pLunL0, "Driver", "NetSniffer"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
hrc = networkAdapter->COMGETTER(TraceFile)(&str); H();
if (str) /* check convention for indicating default file. */
{
STR_CONV();
rc = CFGMR3InsertString(pCfg, "File", psz); RC_CHECK();
STR_FREE();
}
}
NetworkAttachmentType_T networkAttachment;
hrc = networkAdapter->COMGETTER(AttachmentType)(&networkAttachment); H();
switch (networkAttachment)
{
case NetworkAttachmentType_Null:
break;
case NetworkAttachmentType_NAT:
{
if (fSniffer)
{
rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
}
else
{
rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
}
rc = CFGMR3InsertString(pLunL0, "Driver", "NAT"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
/* (Port forwarding goes here.) */
/* Configure TFTP prefix and boot filename. */
hrc = virtualBox->COMGETTER(HomeFolder)(&str); H();
STR_CONV();
if (psz && *psz)
{
char *pszTFTPPrefix = NULL;
RTStrAPrintf(&pszTFTPPrefix, "%s%c%s", psz, RTPATH_DELIMITER, "TFTP");
rc = CFGMR3InsertString(pCfg, "TFTPPrefix", pszTFTPPrefix); RC_CHECK();
RTStrFree(pszTFTPPrefix);
}
STR_FREE();
hrc = pMachine->COMGETTER(Name)(&str); H();
STR_CONV();
char *pszBootFile = NULL;
RTStrAPrintf(&pszBootFile, "%s.pxe", psz);
STR_FREE();
rc = CFGMR3InsertString(pCfg, "BootFile", pszBootFile); RC_CHECK();
RTStrFree(pszBootFile);
break;
}
case NetworkAttachmentType_HostInterface:
{
/*
* Perform the attachment if required (don't return on error!)
*/
hrc = pConsole->attachToHostInterface(networkAdapter);
if (SUCCEEDED(hrc))
{
#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
Assert (pConsole->maTapFD[ulInstance] >= 0);
if (pConsole->maTapFD[ulInstance] >= 0)
{
if (fSniffer)
{
rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
}
else
{
rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
}
rc = CFGMR3InsertString(pLunL0, "Driver", "HostInterface"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
# if defined(RT_OS_SOLARIS)
/* Device name/number is required for Solaris as we need it for TAP PPA. */
Bstr tapDeviceName;
networkAdapter->COMGETTER(HostInterface)(tapDeviceName.asOutParam());
if (!tapDeviceName.isEmpty())
rc = CFGMR3InsertString(pCfg, "Device", Utf8Str(tapDeviceName)); RC_CHECK();
/* TAP setup application/script */
Bstr tapSetupApp;
networkAdapter->COMGETTER(TAPSetupApplication)(tapSetupApp.asOutParam());
if (!tapSetupApp.isEmpty())
rc = CFGMR3InsertString(pCfg, "TAPSetupApplication", Utf8Str(tapSetupApp)); RC_CHECK();
/* TAP terminate application/script */
Bstr tapTerminateApp;
networkAdapter->COMGETTER(TAPTerminateApplication)(tapTerminateApp.asOutParam());
if (!tapTerminateApp.isEmpty())
rc = CFGMR3InsertString(pCfg, "TAPTerminateApplication", Utf8Str(tapTerminateApp)); RC_CHECK();
/* "FileHandle" must NOT be inserted here, it is done in DrvTAP.cpp */
# ifdef VBOX_WITH_CROSSBOW
/* Crossbow: needs the MAC address for setting up TAP. */
rc = CFGMR3InsertBytes(pCfg, "MAC", &Mac, sizeof(Mac)); RC_CHECK();
# endif
# else
rc = CFGMR3InsertInteger(pCfg, "FileHandle", pConsole->maTapFD[ulInstance]); RC_CHECK();
# endif
}
#elif defined(RT_OS_WINDOWS)
if (fSniffer)
{
rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
}
else
{
rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
}
Bstr hostInterfaceName;
hrc = networkAdapter->COMGETTER(HostInterface)(hostInterfaceName.asOutParam()); H();
ComPtr<IHostNetworkInterfaceCollection> coll;
hrc = host->COMGETTER(NetworkInterfaces)(coll.asOutParam()); H();
ComPtr<IHostNetworkInterface> hostInterface;
rc = coll->FindByName(hostInterfaceName, hostInterface.asOutParam());
if (!SUCCEEDED(rc))
{
AssertMsgFailed(("Cannot get GUID for host interface '%ls'\n", hostInterfaceName));
hrc = networkAdapter->Detach(); H();
}
else
{
rc = CFGMR3InsertString(pLunL0, "Driver", "HostInterface"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
rc = CFGMR3InsertString(pCfg, "HostInterfaceName", Utf8Str(hostInterfaceName)); RC_CHECK();
Guid hostIFGuid;
hrc = hostInterface->COMGETTER(Id)(hostIFGuid.asOutParam()); H();
char szDriverGUID[256] = {0};
/* add curly brackets */
szDriverGUID[0] = '{';
strcpy(szDriverGUID + 1, hostIFGuid.toString().raw());
strcat(szDriverGUID, "}");
rc = CFGMR3InsertBytes(pCfg, "GUID", szDriverGUID, sizeof(szDriverGUID)); RC_CHECK();
}
#else
# error "Port me"
#endif
}
else
{
switch (hrc)
{
#ifdef RT_OS_LINUX
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"));
#endif /* RT_OS_LINUX */
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"));
}
}
break;
}
case NetworkAttachmentType_Internal:
{
hrc = networkAdapter->COMGETTER(InternalNetwork)(&str); H();
STR_CONV();
if (psz && *psz)
{
if (fSniffer)
{
rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
}
else
{
rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
}
rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
rc = CFGMR3InsertString(pCfg, "Network", psz); RC_CHECK();
}
STR_FREE();
break;
}
default:
AssertMsgFailed(("should not get here!\n"));
break;
}
}
/*
* Serial (UART) Ports
*/
rc = CFGMR3InsertNode(pDevices, "serial", &pDev); RC_CHECK();
for (ULONG ulInstance = 0; ulInstance < SchemaDefs::SerialPortCount; ulInstance++)
{
ComPtr<ISerialPort> serialPort;
hrc = pMachine->GetSerialPort (ulInstance, serialPort.asOutParam()); H();
BOOL fEnabled = FALSE;
if (serialPort)
hrc = serialPort->COMGETTER(Enabled)(&fEnabled); H();
if (!fEnabled)
continue;
char szInstance[4]; Assert(ulInstance <= 999);
RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance);
rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK();
rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
ULONG ulIRQ, ulIOBase;
PortMode_T HostMode;
Bstr path;
BOOL fServer;
hrc = serialPort->COMGETTER(HostMode)(&HostMode); H();
hrc = serialPort->COMGETTER(IRQ)(&ulIRQ); H();
hrc = serialPort->COMGETTER(IOBase)(&ulIOBase); H();
hrc = serialPort->COMGETTER(Path)(path.asOutParam()); H();
hrc = serialPort->COMGETTER(Server)(&fServer); H();
rc = CFGMR3InsertInteger(pCfg, "IRQ", ulIRQ); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "IOBase", ulIOBase); RC_CHECK();
if (HostMode != PortMode_Disconnected)
{
rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
if (HostMode == PortMode_HostPipe)
{
rc = CFGMR3InsertString(pLunL0, "Driver", "Char"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
rc = CFGMR3InsertString(pLunL1, "Driver", "NamedPipe"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL1, "Config", &pLunL2); RC_CHECK();
rc = CFGMR3InsertString(pLunL2, "Location", Utf8Str(path)); RC_CHECK();
rc = CFGMR3InsertInteger(pLunL2, "IsServer", fServer); RC_CHECK();
}
else if (HostMode == PortMode_HostDevice)
{
rc = CFGMR3InsertString(pLunL0, "Driver", "Host Serial"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pLunL1); RC_CHECK();
rc = CFGMR3InsertString(pLunL1, "DevicePath", Utf8Str(path)); RC_CHECK();
}
}
}
/*
* Parallel (LPT) Ports
*/
rc = CFGMR3InsertNode(pDevices, "parallel", &pDev); RC_CHECK();
for (ULONG ulInstance = 0; ulInstance < SchemaDefs::ParallelPortCount; ulInstance++)
{
ComPtr<IParallelPort> parallelPort;
hrc = pMachine->GetParallelPort (ulInstance, parallelPort.asOutParam()); H();
BOOL fEnabled = FALSE;
if (parallelPort)
hrc = parallelPort->COMGETTER(Enabled)(&fEnabled); H();
if (!fEnabled)
continue;
char szInstance[4]; Assert(ulInstance <= 999);
RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance);
rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK();
rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
ULONG ulIRQ, ulIOBase;
Bstr DevicePath;
hrc = parallelPort->COMGETTER(IRQ)(&ulIRQ); H();
hrc = parallelPort->COMGETTER(IOBase)(&ulIOBase); H();
hrc = parallelPort->COMGETTER(Path)(DevicePath.asOutParam()); H();
rc = CFGMR3InsertInteger(pCfg, "IRQ", ulIRQ); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "IOBase", ulIOBase); RC_CHECK();
rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
rc = CFGMR3InsertString(pLunL0, "Driver", "HostParallel"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
rc = CFGMR3InsertString(pLunL1, "DevicePath", Utf8Str(DevicePath)); RC_CHECK();
}
/*
* VMM Device
*/
rc = CFGMR3InsertNode(pDevices, "VMMDev", &pDev); RC_CHECK();
rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 4); RC_CHECK();
Assert(!afPciDeviceNo[4]);
afPciDeviceNo[4] = true;
rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
/* the VMM device's Main driver */
rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
rc = CFGMR3InsertString(pLunL0, "Driver", "MainVMMDev"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
VMMDev *pVMMDev = pConsole->mVMMDev;
rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pVMMDev); RC_CHECK();
/*
* Attach the status driver.
*/
rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapSharedFolderLed); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
/*
* Audio Sniffer Device
*/
rc = CFGMR3InsertNode(pDevices, "AudioSniffer", &pDev); RC_CHECK();
rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
/* the Audio Sniffer device's Main driver */
rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
rc = CFGMR3InsertString(pLunL0, "Driver", "MainAudioSniffer"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
AudioSniffer *pAudioSniffer = pConsole->mAudioSniffer;
rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pAudioSniffer); RC_CHECK();
/*
* AC'97 ICH / SoundBlaster16 audio
*/
ComPtr<IAudioAdapter> audioAdapter;
hrc = pMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam()); H();
if (audioAdapter)
hrc = audioAdapter->COMGETTER(Enabled)(&enabled); H();
if (enabled)
{
AudioControllerType_T audioController;
hrc = audioAdapter->COMGETTER(AudioController)(&audioController); H();
switch (audioController)
{
case AudioControllerType_AC97:
{
/* default: ICH AC97 */
rc = CFGMR3InsertNode(pDevices, "ichac97", &pDev); RC_CHECK();
rc = CFGMR3InsertNode(pDev, "0", &pInst);
rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 5); RC_CHECK();
Assert(!afPciDeviceNo[5]);
afPciDeviceNo[5] = true;
rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
break;
}
case AudioControllerType_SB16:
{
/* legacy SoundBlaster16 */
rc = CFGMR3InsertNode(pDevices, "sb16", &pDev); RC_CHECK();
rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "IRQ", 5); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "DMA", 1); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "DMA16", 5); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "Port", 0x220); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "Version", 0x0405); RC_CHECK();
break;
}
}
/* the Audio driver */
rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
rc = CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
AudioDriverType_T audioDriver;
hrc = audioAdapter->COMGETTER(AudioDriver)(&audioDriver); H();
switch (audioDriver)
{
case AudioDriverType_Null:
{
rc = CFGMR3InsertString(pCfg, "AudioDriver", "null"); RC_CHECK();
break;
}
#ifdef RT_OS_WINDOWS
#ifdef VBOX_WITH_WINMM
case AudioDriverType_WinMM:
{
rc = CFGMR3InsertString(pCfg, "AudioDriver", "winmm"); RC_CHECK();
break;
}
#endif
case AudioDriverType_DirectSound:
{
rc = CFGMR3InsertString(pCfg, "AudioDriver", "dsound"); RC_CHECK();
break;
}
#endif /* RT_OS_WINDOWS */
#ifdef RT_OS_SOLARIS
case AudioDriverType_SolAudio:
{
rc = CFGMR3InsertString(pCfg, "AudioDriver", "solaudio"); RC_CHECK();
break;
}
#endif
#ifdef RT_OS_LINUX
case AudioDriverType_OSS:
{
rc = CFGMR3InsertString(pCfg, "AudioDriver", "oss"); RC_CHECK();
break;
}
# ifdef VBOX_WITH_ALSA
case AudioDriverType_ALSA:
{
rc = CFGMR3InsertString(pCfg, "AudioDriver", "alsa"); RC_CHECK();
break;
}
# endif
# ifdef VBOX_WITH_PULSE
case AudioDriverType_Pulse:
{
rc = CFGMR3InsertString(pCfg, "AudioDriver", "pulse"); RC_CHECK();
break;
}
# endif
#endif /* RT_OS_LINUX */
#ifdef RT_OS_DARWIN
case AudioDriverType_CoreAudio:
{
rc = CFGMR3InsertString(pCfg, "AudioDriver", "coreaudio"); RC_CHECK();
break;
}
#endif
}
hrc = pMachine->COMGETTER(Name)(&str); H();
STR_CONV();
rc = CFGMR3InsertString(pCfg, "StreamName", psz); RC_CHECK();
STR_FREE();
}
/*
* The USB Controller.
*/
ComPtr<IUSBController> USBCtlPtr;
hrc = pMachine->COMGETTER(USBController)(USBCtlPtr.asOutParam());
if (USBCtlPtr)
{
BOOL fEnabled;
hrc = USBCtlPtr->COMGETTER(Enabled)(&fEnabled); H();
if (fEnabled)
{
rc = CFGMR3InsertNode(pDevices, "usb-ohci", &pDev); RC_CHECK();
rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 6); RC_CHECK();
Assert(!afPciDeviceNo[6]);
afPciDeviceNo[6] = true;
rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
rc = CFGMR3InsertString(pLunL0, "Driver", "VUSBRootHub"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
/*
* Attach the status driver.
*/
rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapUSBLed);RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
#ifdef VBOX_WITH_EHCI
hrc = USBCtlPtr->COMGETTER(EnabledEhci)(&fEnabled); H();
if (fEnabled)
{
rc = CFGMR3InsertNode(pDevices, "usb-ehci", &pDev); RC_CHECK();
rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 11); RC_CHECK();
Assert(!afPciDeviceNo[11]);
afPciDeviceNo[11] = true;
rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
rc = CFGMR3InsertString(pLunL0, "Driver", "VUSBRootHub"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
/*
* Attach the status driver.
*/
rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapUSBLed);RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
}
else
#endif
{
/*
* Enable the 2.0 -> 1.1 device morphing of proxied devies to keep windows quiet.
*/
rc = CFGMR3InsertNode(pRoot, "USB", &pCfg); RC_CHECK();
rc = CFGMR3InsertNode(pCfg, "USBProxy", &pCfg); RC_CHECK();
rc = CFGMR3InsertNode(pCfg, "GlobalConfig", &pCfg); RC_CHECK();
rc = CFGMR3InsertInteger(pCfg, "Force11Device", true); RC_CHECK();
// The following breaks stuff, but it makes MSDs work in vista. (I include it here so
// that it's documented somewhere.) Users needing it can use:
// VBoxManage setextradata "myvm" "VBoxInternal/USB/USBProxy/GlobalConfig/Force11PacketSize" 1
//rc = CFGMR3InsertInteger(pCfg, "Force11PacketSize", true); RC_CHECK();
}
}
}
/*
* Clipboard
*/
{
ClipboardMode_T mode = ClipboardMode_Disabled;
hrc = pMachine->COMGETTER(ClipboardMode) (&mode); H();
if (mode != ClipboardMode_Disabled)
{
/* Load the service */
rc = pConsole->mVMMDev->hgcmLoadService ("VBoxSharedClipboard", "VBoxSharedClipboard");
if (VBOX_FAILURE (rc))
{
LogRel(("VBoxSharedClipboard is not available. rc = %Vrc\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;
}
}
pConsole->mVMMDev->hgcmHostCall ("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm);
Log(("Set VBoxSharedClipboard mode\n"));
}
}
}
/*
* 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. If a value is a valid number,
* it will be inserted as a number, otherwise as a string.
*
* We first perform a run on global extra data, then on the machine
* extra data to support global settings with local overrides.
*
*/
Bstr strExtraDataKey;
bool fGlobalExtraData = true;
for (;;)
{
Bstr strNextExtraDataKey;
Bstr strExtraDataValue;
/* get the next key */
if (fGlobalExtraData)
hrc = virtualBox->GetNextExtraDataKey(strExtraDataKey, strNextExtraDataKey.asOutParam(),
strExtraDataValue.asOutParam());
else
hrc = pMachine->GetNextExtraDataKey(strExtraDataKey, strNextExtraDataKey.asOutParam(),
strExtraDataValue.asOutParam());
/* stop if for some reason there's nothing more to request */
if (FAILED(hrc) || !strNextExtraDataKey)
{
/* if we're out of global keys, continue with machine, otherwise we're done */
if (fGlobalExtraData)
{
fGlobalExtraData = false;
strExtraDataKey.setNull();
continue;
}
break;
}
strExtraDataKey = strNextExtraDataKey;
Utf8Str strExtraDataKeyUtf8 = Utf8Str(strExtraDataKey);
/* we only care about keys starting with "VBoxInternal/" */
if (strncmp(strExtraDataKeyUtf8.raw(), "VBoxInternal/", 13) != 0)
continue;
char *pszExtraDataKey = (char*)strExtraDataKeyUtf8.raw() + 13;
/* the key will be in the format "Node1/Node2/Value" or simply "Value". */
PCFGMNODE pNode;
char *pszCFGMValueName = strrchr(pszExtraDataKey, '/');
if (pszCFGMValueName)
{
/* terminate the node and advance to the value */
*pszCFGMValueName = '\0';
pszCFGMValueName++;
/* does the node already exist? */
pNode = CFGMR3GetChild(pRoot, pszExtraDataKey);
if (pNode)
{
/* the value might already exist, remove it to be safe */
CFGMR3RemoveValue(pNode, pszCFGMValueName);
}
else
{
/* create the node */
rc = CFGMR3InsertNode(pRoot, pszExtraDataKey, &pNode);
AssertMsgRC(rc, ("failed to insert node '%s'\n", pszExtraDataKey));
if (VBOX_FAILURE(rc) || !pNode)
continue;
}
}
else
{
pNode = pRoot;
pszCFGMValueName = pszExtraDataKey;
pszExtraDataKey--;
/* the value might already exist, remove it to be safe */
CFGMR3RemoveValue(pNode, pszCFGMValueName);
}
/* now let's have a look at the value */
Utf8Str strCFGMValueUtf8 = Utf8Str(strExtraDataValue);
const char *pszCFGMValue = strCFGMValueUtf8.raw();
/* empty value means remove value which we've already done */
if (pszCFGMValue && *pszCFGMValue)
{
/* if it's a valid number, we'll insert it as such, otherwise string */
uint64_t u64Value;
char *pszNext = NULL;
if ( RTStrToUInt64Ex(pszCFGMValue, &pszNext, 0, &u64Value) == VINF_SUCCESS
&& (!pszNext || *pszNext == '\0') /* check if the _whole_ string is a valid number */
)
{
rc = CFGMR3InsertInteger(pNode, pszCFGMValueName, u64Value);
}
else
{
rc = CFGMR3InsertString(pNode, pszCFGMValueName, pszCFGMValue);
}
AssertMsgRC(rc, ("failed to insert CFGM value '%s' to key '%s'\n", pszCFGMValue, pszExtraDataKey));
}
}
#undef H
#undef RC_CHECK
#undef STR_FREE
#undef STR_CONV
/* Register VM state change handler */
int rc2 = VMR3AtStateRegister (pVM, Console::vmstateChangeCallback, pConsole);
AssertRC (rc2);
if (VBOX_SUCCESS (rc))
rc = rc2;
/* Register VM runtime error handler */
rc2 = VMR3AtRuntimeErrorRegister (pVM, Console::setVMRuntimeErrorCallback, pConsole);
AssertRC (rc2);
if (VBOX_SUCCESS (rc))
rc = rc2;
/* Save the VM pointer in the machine object */
pConsole->mpVM = pVM;
LogFlowFunc (("vrc = %Vrc\n", rc));
LogFlowFuncLeave();
return rc;
}