VirtualBox

source: vbox/trunk/src/VBox/Main/ConsoleImpl2.cpp@ 26553

Last change on this file since 26553 was 26553, checked in by vboxsync, 15 years ago

Main: backing out r57728 + r57730 which burn on windows

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 149.8 KB
Line 
1/* $Id: ConsoleImpl2.cpp 26553 2010-02-15 17:34:29Z vboxsync $ */
2/** @file
3 * VBox Console COM Class implementation
4 *
5 * @remark We've split out the code that the 64-bit VC++ v8 compiler finds
6 * problematic to optimize so we can disable optimizations and later,
7 * perhaps, find a real solution for it (like rewriting the code and
8 * to stop resemble a tonne of spaghetti).
9 */
10
11/*
12 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
13 *
14 * This file is part of VirtualBox Open Source Edition (OSE), as
15 * available from http://www.virtualbox.org. This file is free software;
16 * you can redistribute it and/or modify it under the terms of the GNU
17 * General Public License (GPL) as published by the Free Software
18 * Foundation, in version 2 as it comes in the "COPYING" file of the
19 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
20 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
21 *
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23 * Clara, CA 95054 USA or visit http://www.sun.com if you need
24 * additional information or have any questions.
25 */
26
27/*******************************************************************************
28* Header Files *
29*******************************************************************************/
30#include "ConsoleImpl.h"
31#include "DisplayImpl.h"
32#include "VMMDev.h"
33
34// generated header
35#include "SchemaDefs.h"
36
37#include "AutoCaller.h"
38#include "Logging.h"
39
40#include <iprt/buildconfig.h>
41#include <iprt/string.h>
42#include <iprt/path.h>
43#include <iprt/dir.h>
44#include <iprt/param.h>
45#if 0 /* enable to play with lots of memory. */
46# include <iprt/env.h>
47#endif
48#include <iprt/file.h>
49
50#include <VBox/vmapi.h>
51#include <VBox/err.h>
52#include <VBox/version.h>
53#include <VBox/HostServices/VBoxClipboardSvc.h>
54#ifdef VBOX_WITH_CROGL
55#include <VBox/HostServices/VBoxCrOpenGLSvc.h>
56#endif
57#ifdef VBOX_WITH_GUEST_PROPS
58# include <VBox/HostServices/GuestPropertySvc.h>
59# include <VBox/com/defs.h>
60# include <VBox/com/array.h>
61# include <hgcm/HGCM.h> /** @todo it should be possible to register a service
62 * extension using a VMMDev callback. */
63# include <vector>
64#endif /* VBOX_WITH_GUEST_PROPS */
65#include <VBox/intnet.h>
66
67#include <VBox/com/com.h>
68#include <VBox/com/string.h>
69#include <VBox/com/array.h>
70
71#if defined(RT_OS_SOLARIS) && defined(VBOX_WITH_NETFLT)
72# include <zone.h>
73#endif
74
75#if defined(RT_OS_LINUX) && defined(VBOX_WITH_NETFLT)
76# include <unistd.h>
77# include <sys/ioctl.h>
78# include <sys/socket.h>
79# include <linux/types.h>
80# include <linux/if.h>
81# include <linux/wireless.h>
82#endif
83
84#if defined(RT_OS_FREEBSD) && defined(VBOX_WITH_NETFLT)
85# include <unistd.h>
86# include <sys/types.h>
87# include <sys/ioctl.h>
88# include <sys/socket.h>
89# include <net/if.h>
90# include <net80211/ieee80211_ioctl.h>
91#endif
92
93#if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
94# include <VBox/WinNetConfig.h>
95# include <Ntddndis.h>
96# include <devguid.h>
97#endif
98
99#if !defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
100# include <HostNetworkInterfaceImpl.h>
101# include <netif.h>
102# include <stdlib.h>
103#endif
104
105#include "DHCPServerRunner.h"
106
107#include <VBox/param.h>
108#include <VBox/pdmapi.h> /* For PDMR3DriverAttach/PDMR3DriverDetach */
109
110#if defined(RT_OS_DARWIN) && !defined(VBOX_OSE)
111
112# include "IOKit/IOKitLib.h"
113
114int DarwinSmcKey(char* aKey, uint32_t iKeySize)
115{
116 /*
117 * Method as described in Amit Singh's article:
118 * http://osxbook.com/book/bonus/chapter7/tpmdrmmyth/
119 */
120 typedef struct {
121 uint32_t key;
122 uint8_t pad0[22];
123 uint32_t datasize;
124 uint8_t pad1[10];
125 uint8_t cmd;
126 uint32_t pad2;
127 uint8_t data[32];
128 } AppleSMCBuffer;
129
130
131 if (iKeySize < 65)
132 return VERR_INTERNAL_ERROR;
133
134 io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault,
135 IOServiceMatching("AppleSMC"));
136 if (!service)
137 return VERR_INTERNAL_ERROR;
138
139 io_connect_t port = (io_connect_t)0;
140 kern_return_t kr = IOServiceOpen(service, mach_task_self(), 0, &port);
141 IOObjectRelease(service);
142
143 if (kr != kIOReturnSuccess)
144 return VERR_INTERNAL_ERROR;
145
146 AppleSMCBuffer inputStruct = { 0, {0}, 32, {0}, 5, }, outputStruct;
147 size_t outputStructCnt = sizeof(outputStruct);
148
149 for (int i = 0; i < 2; i++)
150 {
151 inputStruct.key = (uint32_t)((i == 0) ? 'OSK0' : 'OSK1');
152 kr = IOConnectCallStructMethod((mach_port_t)port,
153 (uint32_t)2,
154 (const void*)&inputStruct,
155 sizeof(inputStruct),
156 (void*)&outputStruct,
157 &outputStructCnt);
158 if (kr != kIOReturnSuccess)
159 return VERR_INTERNAL_ERROR;
160
161 for (int j=0; j<32; j++)
162 aKey[j + i*32] = outputStruct.data[j];
163 }
164
165 IOServiceClose(port);
166
167 aKey[64] = 0;
168
169 return VINF_SUCCESS;
170}
171
172#endif
173
174#undef PVM
175
176/* Comment out the following line to remove VMWare compatibility hack. */
177#define VMWARE_NET_IN_SLOT_11
178
179/**
180 * Translate IDE StorageControllerType_T to string representation.
181 */
182const char* controllerString(StorageControllerType_T enmType)
183{
184 switch (enmType)
185 {
186 case StorageControllerType_PIIX3:
187 return "PIIX3";
188 case StorageControllerType_PIIX4:
189 return "PIIX4";
190 case StorageControllerType_ICH6:
191 return "ICH6";
192 default:
193 return "Unknown";
194 }
195}
196
197/*
198 * VC++ 8 / amd64 has some serious trouble with this function.
199 * As a temporary measure, we'll drop global optimizations.
200 */
201#if defined(_MSC_VER) && defined(RT_ARCH_AMD64)
202# pragma optimize("g", off)
203#endif
204
205static int findEfiRom(IVirtualBox* vbox, FirmwareType_T aFirmwareType, Utf8Str& aEfiRomFile)
206{
207 int rc;
208 BOOL fPresent = FALSE;
209 Bstr aFilePath, empty;
210
211 rc = vbox->CheckFirmwarePresent(aFirmwareType, empty,
212 empty.asOutParam(), aFilePath.asOutParam(), &fPresent);
213 if (RT_FAILURE(rc))
214 AssertComRCReturn (rc, VERR_FILE_NOT_FOUND);
215
216 if (!fPresent)
217 return VERR_FILE_NOT_FOUND;
218
219 aEfiRomFile = Utf8Str(aFilePath);
220
221 return S_OK;
222}
223
224static int getSmcDeviceKey(IMachine* pMachine, BSTR * aKey)
225{
226 int rc;
227
228# if defined(RT_OS_DARWIN) && !defined(VBOX_OSE)
229 char aKeyBuf[65];
230
231 rc = DarwinSmcKey(aKeyBuf, sizeof aKeyBuf);
232 if (SUCCEEDED(rc))
233 {
234 Bstr(aKeyBuf).detachTo(aKey);
235 return rc;
236 }
237#endif
238
239 return pMachine->GetExtraData(Bstr("VBoxInternal2/SmcDeviceKey"), aKey);
240}
241
242/**
243 * Construct the VM configuration tree (CFGM).
244 *
245 * This is a callback for VMR3Create() call. It is called from CFGMR3Init()
246 * in the emulation thread (EMT). Any per thread COM/XPCOM initialization
247 * is done here.
248 *
249 * @param pVM VM handle.
250 * @param pvConsole Pointer to the VMPowerUpTask object.
251 * @return VBox status code.
252 *
253 * @note Locks the Console object for writing.
254 */
255DECLCALLBACK(int) Console::configConstructor(PVM pVM, void *pvConsole)
256{
257 LogFlowFuncEnter();
258 /* Note: hardcoded assumption about number of slots; see rom bios */
259 bool afPciDeviceNo[32] = {false};
260 bool fFdcEnabled = false;
261 BOOL fIs64BitGuest = false;
262
263#if !defined (VBOX_WITH_XPCOM)
264 {
265 /* initialize COM */
266 HRESULT hrc = CoInitializeEx(NULL,
267 COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE |
268 COINIT_SPEED_OVER_MEMORY);
269 LogFlow (("Console::configConstructor(): CoInitializeEx()=%08X\n", hrc));
270 AssertComRCReturn (hrc, VERR_GENERAL_FAILURE);
271 }
272#endif
273
274 AssertReturn(pvConsole, VERR_GENERAL_FAILURE);
275 ComObjPtr<Console> pConsole = static_cast <Console *> (pvConsole);
276
277 AutoCaller autoCaller(pConsole);
278 AssertComRCReturn (autoCaller.rc(), VERR_ACCESS_DENIED);
279
280 /* lock the console because we widely use internal fields and methods */
281 AutoWriteLock alock(pConsole COMMA_LOCKVAL_SRC_POS);
282
283 /* Save the VM pointer in the machine object */
284 pConsole->mpVM = pVM;
285
286 ComPtr<IMachine> pMachine = pConsole->machine();
287
288 int rc;
289 HRESULT hrc;
290 BSTR str = NULL;
291
292#define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } } while (0)
293#define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0)
294#define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%#x\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0)
295
296 /*
297 * Get necessary objects and frequently used parameters.
298 */
299 ComPtr<IVirtualBox> virtualBox;
300 hrc = pMachine->COMGETTER(Parent)(virtualBox.asOutParam()); H();
301
302 ComPtr<IHost> host;
303 hrc = virtualBox->COMGETTER(Host)(host.asOutParam()); H();
304
305 ComPtr<ISystemProperties> systemProperties;
306 hrc = virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam()); H();
307
308 ComPtr<IBIOSSettings> biosSettings;
309 hrc = pMachine->COMGETTER(BIOSSettings)(biosSettings.asOutParam()); H();
310
311 hrc = pMachine->COMGETTER(HardwareUUID)(&str); H();
312 RTUUID HardwareUuid;
313 rc = RTUuidFromUtf16(&HardwareUuid, str); RC_CHECK();
314 STR_FREE();
315
316 ULONG cRamMBs;
317 hrc = pMachine->COMGETTER(MemorySize)(&cRamMBs); H();
318#if 0 /* enable to play with lots of memory. */
319 if (RTEnvExist("VBOX_RAM_SIZE"))
320 cRamMBs = RTStrToUInt64(RTEnvGet("VBOX_RAM_SIZE"));
321#endif
322 uint64_t const cbRam = cRamMBs * (uint64_t)_1M;
323 uint32_t const cbRamHole = MM_RAM_HOLE_SIZE_DEFAULT;
324
325 ULONG cCpus = 1;
326 hrc = pMachine->COMGETTER(CPUCount)(&cCpus); H();
327
328 Bstr osTypeId;
329 hrc = pMachine->COMGETTER(OSTypeId)(osTypeId.asOutParam()); H();
330
331 BOOL fIOAPIC;
332 hrc = biosSettings->COMGETTER(IOAPICEnabled)(&fIOAPIC); H();
333
334 ComPtr<IGuestOSType> guestOSType;
335 hrc = virtualBox->GetGuestOSType(osTypeId, guestOSType.asOutParam()); H();
336
337 /*
338 * Get root node first.
339 * This is the only node in the tree.
340 */
341 PCFGMNODE pRoot = CFGMR3GetRoot(pVM);
342 Assert(pRoot);
343
344 /*
345 * Set the root (and VMM) level values.
346 */
347 hrc = pMachine->COMGETTER(Name)(&str); H();
348 rc = CFGMR3InsertStringW(pRoot, "Name", str); RC_CHECK();
349 rc = CFGMR3InsertBytes(pRoot, "UUID", &HardwareUuid, sizeof(HardwareUuid)); RC_CHECK();
350 rc = CFGMR3InsertInteger(pRoot, "RamSize", cbRam); RC_CHECK();
351 rc = CFGMR3InsertInteger(pRoot, "RamHoleSize", cbRamHole); RC_CHECK();
352 rc = CFGMR3InsertInteger(pRoot, "NumCPUs", cCpus); RC_CHECK();
353 rc = CFGMR3InsertInteger(pRoot, "TimerMillies", 10); RC_CHECK();
354#ifdef VBOX_WITH_RAW_MODE
355 rc = CFGMR3InsertInteger(pRoot, "RawR3Enabled", 1); /* boolean */ RC_CHECK();
356 rc = CFGMR3InsertInteger(pRoot, "RawR0Enabled", 1); /* boolean */ RC_CHECK();
357 /** @todo Config: RawR0, PATMEnabled and CSAMEnabled needs attention later. */
358 rc = CFGMR3InsertInteger(pRoot, "PATMEnabled", 1); /* boolean */ RC_CHECK();
359 rc = CFGMR3InsertInteger(pRoot, "CSAMEnabled", 1); /* boolean */ RC_CHECK();
360#endif
361
362 /* cpuid leaf overrides. */
363 static uint32_t const s_auCpuIdRanges[] =
364 {
365 UINT32_C(0x00000000), UINT32_C(0x0000000a),
366 UINT32_C(0x80000000), UINT32_C(0x8000000a)
367 };
368 for (unsigned i = 0; i < RT_ELEMENTS(s_auCpuIdRanges); i += 2)
369 for (uint32_t uLeaf = s_auCpuIdRanges[i]; uLeaf < s_auCpuIdRanges[i + 1]; uLeaf++)
370 {
371 ULONG ulEax, ulEbx, ulEcx, ulEdx;
372 hrc = pMachine->GetCpuIdLeaf(uLeaf, &ulEax, &ulEbx, &ulEcx, &ulEdx);
373 if (SUCCEEDED(hrc))
374 {
375 PCFGMNODE pLeaf;
376 rc = CFGMR3InsertNodeF(pRoot, &pLeaf, "CPUM/HostCPUID/%RX32", uLeaf); RC_CHECK();
377
378 rc = CFGMR3InsertInteger(pLeaf, "eax", ulEax); RC_CHECK();
379 rc = CFGMR3InsertInteger(pLeaf, "ebx", ulEbx); RC_CHECK();
380 rc = CFGMR3InsertInteger(pLeaf, "ecx", ulEcx); RC_CHECK();
381 rc = CFGMR3InsertInteger(pLeaf, "edx", ulEdx); RC_CHECK();
382 }
383 else if (hrc != E_INVALIDARG) H();
384 }
385
386 if (osTypeId == "WindowsNT4")
387 {
388 /*
389 * We must limit CPUID count for Windows NT 4, as otherwise it stops
390 * with error 0x3e (MULTIPROCESSOR_CONFIGURATION_NOT_SUPPORTED).
391 */
392 LogRel(("Limiting CPUID leaf count for NT4 guests\n"));
393 PCFGMNODE pCPUM;
394 rc = CFGMR3InsertNode(pRoot, "CPUM", &pCPUM); RC_CHECK();
395 rc = CFGMR3InsertInteger(pCPUM, "NT4LeafLimit", true); RC_CHECK();
396 }
397
398 /* hardware virtualization extensions */
399 BOOL fHWVirtExEnabled;
400 BOOL fHwVirtExtForced;
401#ifdef VBOX_WITH_RAW_MODE
402 hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_Enabled, &fHWVirtExEnabled); H();
403 if (cCpus > 1) /** @todo SMP: This isn't nice, but things won't work on mac otherwise. */
404 fHWVirtExEnabled = TRUE;
405# ifdef RT_OS_DARWIN
406 fHwVirtExtForced = fHWVirtExEnabled;
407# else
408 /* - With more than 4GB PGM will use different RAMRANGE sizes for raw
409 mode and hv mode to optimize lookup times.
410 - With more than one virtual CPU, raw-mode isn't a fallback option. */
411 fHwVirtExtForced = fHWVirtExEnabled
412 && ( cbRam > (_4G - cbRamHole)
413 || cCpus > 1);
414# endif
415#else /* !VBOX_WITH_RAW_MODE */
416 fHWVirtExEnabled = fHwVirtExtForced = TRUE;
417#endif /* !VBOX_WITH_RAW_MODE */
418 rc = CFGMR3InsertInteger(pRoot, "HwVirtExtForced", fHwVirtExtForced); RC_CHECK();
419
420 PCFGMNODE pHWVirtExt;
421 rc = CFGMR3InsertNode(pRoot, "HWVirtExt", &pHWVirtExt); RC_CHECK();
422 if (fHWVirtExEnabled)
423 {
424 rc = CFGMR3InsertInteger(pHWVirtExt, "Enabled", 1); RC_CHECK();
425
426 /* Indicate whether 64-bit guests are supported or not. */
427 /** @todo This is currently only forced off on 32-bit hosts only because it
428 * makes a lof of difference there (REM and Solaris performance).
429 */
430 BOOL fSupportsLongMode = false;
431 hrc = host->GetProcessorFeature(ProcessorFeature_LongMode,
432 &fSupportsLongMode); H();
433 hrc = guestOSType->COMGETTER(Is64Bit)(&fIs64BitGuest); H();
434
435 if (fSupportsLongMode && fIs64BitGuest)
436 {
437 rc = CFGMR3InsertInteger(pHWVirtExt, "64bitEnabled", 1); RC_CHECK();
438#if ARCH_BITS == 32 /* The recompiler must use VBoxREM64 (32-bit host only). */
439 PCFGMNODE pREM;
440 rc = CFGMR3InsertNode(pRoot, "REM", &pREM); RC_CHECK();
441 rc = CFGMR3InsertInteger(pREM, "64bitEnabled", 1); RC_CHECK();
442#endif
443 }
444#if ARCH_BITS == 32 /* 32-bit guests only. */
445 else
446 {
447 rc = CFGMR3InsertInteger(pHWVirtExt, "64bitEnabled", 0); RC_CHECK();
448 }
449#endif
450
451 /** @todo Not exactly pretty to check strings; VBOXOSTYPE would be better, but that requires quite a bit of API change in Main. */
452 if ( !fIs64BitGuest
453 && fIOAPIC
454 && ( osTypeId == "WindowsNT4"
455 || osTypeId == "Windows2000"
456 || osTypeId == "WindowsXP"
457 || osTypeId == "Windows2003"))
458 {
459 /* Only allow TPR patching for NT, Win2k, XP and Windows Server 2003. (32 bits mode)
460 * We may want to consider adding more guest OSes (Solaris) later on.
461 */
462 rc = CFGMR3InsertInteger(pHWVirtExt, "TPRPatchingEnabled", 1); RC_CHECK();
463 }
464 }
465
466 /* HWVirtEx exclusive mode */
467 BOOL fHWVirtExExclusive = true;
468 hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_Exclusive, &fHWVirtExExclusive); H();
469 rc = CFGMR3InsertInteger(pHWVirtExt, "Exclusive", fHWVirtExExclusive); RC_CHECK();
470
471 /* Nested paging (VT-x/AMD-V) */
472 BOOL fEnableNestedPaging = false;
473 hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_NestedPaging, &fEnableNestedPaging); H();
474 rc = CFGMR3InsertInteger(pHWVirtExt, "EnableNestedPaging", fEnableNestedPaging); RC_CHECK();
475
476 /* VPID (VT-x) */
477 BOOL fEnableVPID = false;
478 hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_VPID, &fEnableVPID); H();
479 rc = CFGMR3InsertInteger(pHWVirtExt, "EnableVPID", fEnableVPID); RC_CHECK();
480
481 /* Physical Address Extension (PAE) */
482 BOOL fEnablePAE = false;
483 hrc = pMachine->GetCpuProperty(CpuPropertyType_PAE, &fEnablePAE); H();
484 rc = CFGMR3InsertInteger(pRoot, "EnablePAE", fEnablePAE); RC_CHECK();
485
486 /* Synthetic CPU */
487 BOOL fSyntheticCpu = false;
488 hrc = pMachine->GetCpuProperty(CpuPropertyType_Synthetic, &fSyntheticCpu); H();
489 rc = CFGMR3InsertInteger(pRoot, "SyntheticCpu", fSyntheticCpu); RC_CHECK();
490
491 BOOL fPXEDebug;
492 hrc = biosSettings->COMGETTER(PXEDebugEnabled)(&fPXEDebug); H();
493
494 /*
495 * PDM config.
496 * Load drivers in VBoxC.[so|dll]
497 */
498 PCFGMNODE pPDM;
499 PCFGMNODE pDrivers;
500 PCFGMNODE pMod;
501 rc = CFGMR3InsertNode(pRoot, "PDM", &pPDM); RC_CHECK();
502 rc = CFGMR3InsertNode(pPDM, "Drivers", &pDrivers); RC_CHECK();
503 rc = CFGMR3InsertNode(pDrivers, "VBoxC", &pMod); RC_CHECK();
504#ifdef VBOX_WITH_XPCOM
505 // VBoxC is located in the components subdirectory
506 char szPathVBoxC[RTPATH_MAX];
507 rc = RTPathAppPrivateArch(szPathVBoxC, RTPATH_MAX - sizeof("/components/VBoxC")); AssertRC(rc);
508 strcat(szPathVBoxC, "/components/VBoxC");
509 rc = CFGMR3InsertString(pMod, "Path", szPathVBoxC); RC_CHECK();
510#else
511 rc = CFGMR3InsertString(pMod, "Path", "VBoxC"); RC_CHECK();
512#endif
513
514 /*
515 * Devices
516 */
517 PCFGMNODE pDevices = NULL; /* /Devices */
518 PCFGMNODE pDev = NULL; /* /Devices/Dev/ */
519 PCFGMNODE pInst = NULL; /* /Devices/Dev/0/ */
520 PCFGMNODE pCfg = NULL; /* /Devices/Dev/.../Config/ */
521 PCFGMNODE pLunL0 = NULL; /* /Devices/Dev/0/LUN#0/ */
522 PCFGMNODE pLunL1 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/ */
523 PCFGMNODE pLunL2 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/Config/ */
524 PCFGMNODE pBiosCfg = NULL; /* /Devices/pcbios/0/Config/ */
525
526 rc = CFGMR3InsertNode(pRoot, "Devices", &pDevices); RC_CHECK();
527
528 /*
529 * PC Arch.
530 */
531 rc = CFGMR3InsertNode(pDevices, "pcarch", &pDev); RC_CHECK();
532 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
533 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
534 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
535
536 /*
537 * The time offset
538 */
539 LONG64 timeOffset;
540 hrc = biosSettings->COMGETTER(TimeOffset)(&timeOffset); H();
541 PCFGMNODE pTMNode;
542 rc = CFGMR3InsertNode(pRoot, "TM", &pTMNode); RC_CHECK();
543 rc = CFGMR3InsertInteger(pTMNode, "UTCOffset", timeOffset * 1000000); RC_CHECK();
544
545 /*
546 * DMA
547 */
548 rc = CFGMR3InsertNode(pDevices, "8237A", &pDev); RC_CHECK();
549 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
550 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
551
552 /*
553 * PCI buses.
554 */
555 rc = CFGMR3InsertNode(pDevices, "pci", &pDev); /* piix3 */ RC_CHECK();
556 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
557 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
558 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
559 rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
560
561#if 0 /* enable this to test PCI bridging */
562 rc = CFGMR3InsertNode(pDevices, "pcibridge", &pDev); RC_CHECK();
563 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
564 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
565 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
566 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 14); RC_CHECK();
567 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
568 rc = CFGMR3InsertInteger(pInst, "PCIBusNo", 0);/* -> pci[0] */ RC_CHECK();
569
570 rc = CFGMR3InsertNode(pDev, "1", &pInst); RC_CHECK();
571 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
572 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
573 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 1); RC_CHECK();
574 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
575 rc = CFGMR3InsertInteger(pInst, "PCIBusNo", 1);/* ->pcibridge[0] */ RC_CHECK();
576
577 rc = CFGMR3InsertNode(pDev, "2", &pInst); RC_CHECK();
578 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
579 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
580 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 3); RC_CHECK();
581 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
582 rc = CFGMR3InsertInteger(pInst, "PCIBusNo", 1);/* ->pcibridge[0] */ RC_CHECK();
583#endif
584
585 Bstr tmpStr2;
586 hrc = guestOSType->COMGETTER(FamilyId)(tmpStr2.asOutParam()); H();
587 /*
588 * Enable 3 following devices: HPET, SMC, LPC on MacOS X guests
589 */
590 BOOL fExtProfile = tmpStr2 == Bstr("MacOS");
591
592 /*
593 * High Precision Event Timer (HPET)
594 */
595 BOOL fHpetEnabled;
596#ifdef VBOX_WITH_HPET
597 /* Other guests may wish to use HPET too, but MacOS X not functional without it */
598 hrc = pMachine->COMGETTER(HpetEnabled)(&fHpetEnabled); H();
599 /* so always enable HPET in extended profile */
600 fHpetEnabled |= fExtProfile;
601#else
602 fHpetEnabled = false;
603#endif
604 if (fHpetEnabled)
605 {
606 rc = CFGMR3InsertNode(pDevices, "hpet", &pDev); RC_CHECK();
607 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
608 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
609 }
610
611 /*
612 * System Management Controller (SMC)
613 */
614 BOOL fSmcEnabled;
615#ifdef VBOX_WITH_SMC
616 fSmcEnabled = fExtProfile;
617#else
618 fSmcEnabled = false;
619#endif
620 if (fSmcEnabled)
621 {
622 rc = CFGMR3InsertNode(pDevices, "smc", &pDev); RC_CHECK();
623 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
624 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
625 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
626 rc = getSmcDeviceKey(pMachine, tmpStr2.asOutParam()); RC_CHECK();
627 rc = CFGMR3InsertString(pCfg, "DeviceKey", Utf8Str(tmpStr2).raw());RC_CHECK();
628 }
629
630 /*
631 * Low Pin Count (LPC) bus
632 */
633 BOOL fLpcEnabled;
634 /** @todo: implement appropriate getter */
635#ifdef VBOX_WITH_LPC
636 fLpcEnabled = fExtProfile;
637#else
638 fLpcEnabled = false;
639#endif
640 if (fLpcEnabled)
641 {
642 rc = CFGMR3InsertNode(pDevices, "lpc", &pDev); RC_CHECK();
643 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
644 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
645 }
646
647 /*
648 * PS/2 keyboard & mouse.
649 */
650 rc = CFGMR3InsertNode(pDevices, "pckbd", &pDev); RC_CHECK();
651 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
652 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
653 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
654
655 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
656 rc = CFGMR3InsertString(pLunL0, "Driver", "KeyboardQueue"); RC_CHECK();
657 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
658 rc = CFGMR3InsertInteger(pCfg, "QueueSize", 64); RC_CHECK();
659
660 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
661 rc = CFGMR3InsertString(pLunL1, "Driver", "MainKeyboard"); RC_CHECK();
662 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
663 Keyboard *pKeyboard = pConsole->mKeyboard;
664 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pKeyboard); RC_CHECK();
665
666 rc = CFGMR3InsertNode(pInst, "LUN#1", &pLunL0); RC_CHECK();
667 rc = CFGMR3InsertString(pLunL0, "Driver", "MouseQueue"); RC_CHECK();
668 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
669 rc = CFGMR3InsertInteger(pCfg, "QueueSize", 128); RC_CHECK();
670
671 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
672 rc = CFGMR3InsertString(pLunL1, "Driver", "MainMouse"); RC_CHECK();
673 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
674 Mouse *pMouse = pConsole->mMouse;
675 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pMouse); RC_CHECK();
676
677 /*
678 * i8254 Programmable Interval Timer And Dummy Speaker
679 */
680 rc = CFGMR3InsertNode(pDevices, "i8254", &pDev); RC_CHECK();
681 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
682 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
683#ifdef DEBUG
684 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
685#endif
686
687 /*
688 * i8259 Programmable Interrupt Controller.
689 */
690 rc = CFGMR3InsertNode(pDevices, "i8259", &pDev); RC_CHECK();
691 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
692 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
693 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
694
695 /*
696 * Advanced Programmable Interrupt Controller.
697 * SMP: Each CPU has a LAPIC, but we have a single device representing all LAPICs states,
698 * thus only single insert
699 */
700 rc = CFGMR3InsertNode(pDevices, "apic", &pDev); RC_CHECK();
701 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
702 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
703 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
704 rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
705 rc = CFGMR3InsertInteger(pCfg, "NumCPUs", cCpus); RC_CHECK();
706
707 if (fIOAPIC)
708 {
709 /*
710 * I/O Advanced Programmable Interrupt Controller.
711 */
712 rc = CFGMR3InsertNode(pDevices, "ioapic", &pDev); RC_CHECK();
713 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
714 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
715 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
716 }
717
718 /*
719 * RTC MC146818.
720 */
721 rc = CFGMR3InsertNode(pDevices, "mc146818", &pDev); RC_CHECK();
722 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
723 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
724 BOOL fRTCUseUTC;
725 hrc = pMachine->COMGETTER(RTCUseUTC)(&fRTCUseUTC); H();
726 rc = CFGMR3InsertInteger(pCfg, "UseUTC", fRTCUseUTC ? 1 : 0);
727
728 /*
729 * VGA.
730 */
731 rc = CFGMR3InsertNode(pDevices, "vga", &pDev); RC_CHECK();
732 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
733 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
734 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 2); RC_CHECK();
735 Assert(!afPciDeviceNo[2]);
736 afPciDeviceNo[2] = true;
737 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
738 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
739 ULONG cVRamMBs;
740 hrc = pMachine->COMGETTER(VRAMSize)(&cVRamMBs); H();
741 rc = CFGMR3InsertInteger(pCfg, "VRamSize", cVRamMBs * _1M); RC_CHECK();
742 ULONG cMonitorCount;
743 hrc = pMachine->COMGETTER(MonitorCount)(&cMonitorCount); H();
744 rc = CFGMR3InsertInteger(pCfg, "MonitorCount", cMonitorCount); RC_CHECK();
745#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE /* not safe here yet. */ /** @todo this needs fixing !!! No wonder VGA is slooooooooow on 32-bit darwin! */
746 rc = CFGMR3InsertInteger(pCfg, "R0Enabled", fHWVirtExEnabled); RC_CHECK();
747#endif
748
749 /*
750 * BIOS logo
751 */
752 BOOL fFadeIn;
753 hrc = biosSettings->COMGETTER(LogoFadeIn)(&fFadeIn); H();
754 rc = CFGMR3InsertInteger(pCfg, "FadeIn", fFadeIn ? 1 : 0); RC_CHECK();
755 BOOL fFadeOut;
756 hrc = biosSettings->COMGETTER(LogoFadeOut)(&fFadeOut); H();
757 rc = CFGMR3InsertInteger(pCfg, "FadeOut", fFadeOut ? 1: 0); RC_CHECK();
758 ULONG logoDisplayTime;
759 hrc = biosSettings->COMGETTER(LogoDisplayTime)(&logoDisplayTime); H();
760 rc = CFGMR3InsertInteger(pCfg, "LogoTime", logoDisplayTime); RC_CHECK();
761 Bstr logoImagePath;
762 hrc = biosSettings->COMGETTER(LogoImagePath)(logoImagePath.asOutParam()); H();
763 rc = CFGMR3InsertString(pCfg, "LogoFile", logoImagePath ? Utf8Str(logoImagePath).c_str() : ""); RC_CHECK();
764
765 /*
766 * Boot menu
767 */
768 BIOSBootMenuMode_T eBootMenuMode;
769 int iShowBootMenu;
770 biosSettings->COMGETTER(BootMenuMode)(&eBootMenuMode);
771 switch (eBootMenuMode)
772 {
773 case BIOSBootMenuMode_Disabled: iShowBootMenu = 0; break;
774 case BIOSBootMenuMode_MenuOnly: iShowBootMenu = 1; break;
775 default: iShowBootMenu = 2; break;
776 }
777 rc = CFGMR3InsertInteger(pCfg, "ShowBootMenu", iShowBootMenu); RC_CHECK();
778
779 /* Custom VESA mode list */
780 unsigned cModes = 0;
781 for (unsigned iMode = 1; iMode <= 16; ++iMode)
782 {
783 char szExtraDataKey[sizeof("CustomVideoModeXX")];
784 RTStrPrintf(szExtraDataKey, sizeof(szExtraDataKey), "CustomVideoMode%u", iMode);
785 hrc = pMachine->GetExtraData(Bstr(szExtraDataKey), &str); H();
786 if (!str || !*str)
787 break;
788 rc = CFGMR3InsertStringW(pCfg, szExtraDataKey, str); RC_CHECK();
789 STR_FREE();
790 ++cModes;
791 }
792 STR_FREE();
793 rc = CFGMR3InsertInteger(pCfg, "CustomVideoModes", cModes);
794
795 /* VESA height reduction */
796 ULONG ulHeightReduction;
797 IFramebuffer *pFramebuffer = pConsole->getDisplay()->getFramebuffer();
798 if (pFramebuffer)
799 {
800 hrc = pFramebuffer->COMGETTER(HeightReduction)(&ulHeightReduction); H();
801 }
802 else
803 {
804 /* If framebuffer is not available, there is no height reduction. */
805 ulHeightReduction = 0;
806 }
807 rc = CFGMR3InsertInteger(pCfg, "HeightReduction", ulHeightReduction); RC_CHECK();
808
809 /* Attach the display. */
810 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
811 rc = CFGMR3InsertString(pLunL0, "Driver", "MainDisplay"); RC_CHECK();
812 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
813 Display *pDisplay = pConsole->mDisplay;
814 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pDisplay); RC_CHECK();
815
816
817 /*
818 * Firmware.
819 */
820 FirmwareType_T eFwType = FirmwareType_BIOS;
821 hrc = pMachine->COMGETTER(FirmwareType)(&eFwType); H();
822
823#ifdef VBOX_WITH_EFI
824 BOOL fEfiEnabled = (eFwType >= FirmwareType_EFI) && (eFwType <= FirmwareType_EFIDUAL);
825#else
826 BOOL fEfiEnabled = false;
827#endif
828 if (!fEfiEnabled)
829 {
830 /*
831 * PC Bios.
832 */
833 rc = CFGMR3InsertNode(pDevices, "pcbios", &pDev); RC_CHECK();
834 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
835 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
836 rc = CFGMR3InsertNode(pInst, "Config", &pBiosCfg); RC_CHECK();
837 rc = CFGMR3InsertInteger(pBiosCfg, "RamSize", cbRam); RC_CHECK();
838 rc = CFGMR3InsertInteger(pBiosCfg, "RamHoleSize", cbRamHole); RC_CHECK();
839 rc = CFGMR3InsertInteger(pBiosCfg, "NumCPUs", cCpus); RC_CHECK();
840 rc = CFGMR3InsertString(pBiosCfg, "HardDiskDevice", "piix3ide"); RC_CHECK();
841 rc = CFGMR3InsertString(pBiosCfg, "FloppyDevice", "i82078"); RC_CHECK();
842 rc = CFGMR3InsertInteger(pBiosCfg, "IOAPIC", fIOAPIC); RC_CHECK();
843 rc = CFGMR3InsertInteger(pBiosCfg, "PXEDebug", fPXEDebug); RC_CHECK();
844 rc = CFGMR3InsertBytes(pBiosCfg, "UUID", &HardwareUuid,sizeof(HardwareUuid));RC_CHECK();
845
846 DeviceType_T bootDevice;
847 if (SchemaDefs::MaxBootPosition > 9)
848 {
849 AssertMsgFailed (("Too many boot devices %d\n",
850 SchemaDefs::MaxBootPosition));
851 return VERR_INVALID_PARAMETER;
852 }
853
854 for (ULONG pos = 1; pos <= SchemaDefs::MaxBootPosition; ++pos)
855 {
856 hrc = pMachine->GetBootOrder(pos, &bootDevice); H();
857
858 char szParamName[] = "BootDeviceX";
859 szParamName[sizeof (szParamName) - 2] = ((char (pos - 1)) + '0');
860
861 const char *pszBootDevice;
862 switch (bootDevice)
863 {
864 case DeviceType_Null:
865 pszBootDevice = "NONE";
866 break;
867 case DeviceType_HardDisk:
868 pszBootDevice = "IDE";
869 break;
870 case DeviceType_DVD:
871 pszBootDevice = "DVD";
872 break;
873 case DeviceType_Floppy:
874 pszBootDevice = "FLOPPY";
875 break;
876 case DeviceType_Network:
877 pszBootDevice = "LAN";
878 break;
879 default:
880 AssertMsgFailed(("Invalid bootDevice=%d\n", bootDevice));
881 return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
882 N_("Invalid boot device '%d'"), bootDevice);
883 }
884 rc = CFGMR3InsertString(pBiosCfg, szParamName, pszBootDevice); RC_CHECK();
885 }
886 }
887 else
888 {
889 Utf8Str efiRomFile;
890
891 /* Autodetect firmware type, basing on guest type */
892 if (eFwType == FirmwareType_EFI)
893 {
894 eFwType =
895 fIs64BitGuest ?
896 (FirmwareType_T)FirmwareType_EFI64
897 :
898 (FirmwareType_T)FirmwareType_EFI32;
899 }
900 bool f64BitEntry = eFwType == FirmwareType_EFI64;
901
902 rc = findEfiRom(virtualBox, eFwType, efiRomFile); RC_CHECK();
903
904 /* Get boot args */
905 Bstr bootArgs;
906 hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiBootArgs"), bootArgs.asOutParam()); H();
907
908 /* Get device props */
909 Bstr deviceProps;
910 hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiDeviceProps"), deviceProps.asOutParam()); H();
911 /* Get GOP mode settings */
912 STR_FREE();
913 uint32_t u32GopMode = UINT32_MAX;
914 hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiGopMode"), &str); H();
915 if (str && *str)
916 {
917 u32GopMode = Utf8Str(str).toUInt32();
918 }
919 /* UGA mode settings */
920 STR_FREE();
921 uint32_t u32UgaHorisontal = 0;
922 hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiUgaHorizontalResolution"), &str); H();
923 if (str && *str)
924 {
925 u32UgaHorisontal = Utf8Str(str).toUInt32();
926 }
927
928 STR_FREE();
929 uint32_t u32UgaVertical = 0;
930 hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EfiUgaVerticalResolution"), &str); H();
931 if (str && *str)
932 {
933 u32UgaVertical = Utf8Str(str).toUInt32();
934 }
935 STR_FREE();
936
937 /*
938 * EFI subtree.
939 */
940 rc = CFGMR3InsertNode(pDevices, "efi", &pDev); RC_CHECK();
941 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
942 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
943 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
944 rc = CFGMR3InsertInteger(pCfg, "RamSize", cbRam); RC_CHECK();
945 rc = CFGMR3InsertInteger(pCfg, "RamHoleSize", cbRamHole); RC_CHECK();
946 rc = CFGMR3InsertInteger(pCfg, "NumCPUs", cCpus); RC_CHECK();
947 rc = CFGMR3InsertString(pCfg, "EfiRom", efiRomFile.raw()); RC_CHECK();
948 rc = CFGMR3InsertString(pCfg, "BootArgs", Utf8Str(bootArgs).raw());RC_CHECK();
949 rc = CFGMR3InsertString(pCfg, "DeviceProps", Utf8Str(deviceProps).raw());RC_CHECK();
950 rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
951 rc = CFGMR3InsertBytes(pCfg, "UUID", &HardwareUuid,sizeof(HardwareUuid));RC_CHECK();
952 rc = CFGMR3InsertInteger(pCfg, "64BitEntry", f64BitEntry); /* boolean */ RC_CHECK();
953 rc = CFGMR3InsertInteger(pCfg, "GopMode", u32GopMode); RC_CHECK();
954 rc = CFGMR3InsertInteger(pCfg, "UgaHorizontalResolution", u32UgaHorisontal); RC_CHECK();
955 rc = CFGMR3InsertInteger(pCfg, "UgaVerticalResolution", u32UgaVertical); RC_CHECK();
956 }
957
958 /*
959 * Storage controllers.
960 */
961 com::SafeIfaceArray<IStorageController> ctrls;
962 PCFGMNODE aCtrlNodes[StorageControllerType_LsiLogicSas + 1] = {};
963 hrc = pMachine->COMGETTER(StorageControllers)(ComSafeArrayAsOutParam(ctrls)); H();
964
965 for (size_t i = 0; i < ctrls.size(); ++ i)
966 {
967 DeviceType_T *paLedDevType = NULL;
968
969 StorageControllerType_T enmCtrlType;
970 rc = ctrls[i]->COMGETTER(ControllerType)(&enmCtrlType); H();
971 AssertRelease((unsigned)enmCtrlType < RT_ELEMENTS(aCtrlNodes));
972
973 StorageBus_T enmBus;
974 rc = ctrls[i]->COMGETTER(Bus)(&enmBus); H();
975
976 Bstr controllerName;
977 rc = ctrls[i]->COMGETTER(Name)(controllerName.asOutParam()); H();
978
979 ULONG ulInstance = 999;
980 rc = ctrls[i]->COMGETTER(Instance)(&ulInstance); H();
981
982 /* /Devices/<ctrldev>/ */
983 const char *pszCtrlDev = pConsole->convertControllerTypeToDev(enmCtrlType);
984 pDev = aCtrlNodes[enmCtrlType];
985 if (!pDev)
986 {
987 rc = CFGMR3InsertNode(pDevices, pszCtrlDev, &pDev); RC_CHECK();
988 aCtrlNodes[enmCtrlType] = pDev; /* IDE variants are handled in the switch */
989 }
990
991 /* /Devices/<ctrldev>/<instance>/ */
992 PCFGMNODE pCtlInst = NULL;
993 rc = CFGMR3InsertNodeF(pDev, &pCtlInst, "%u", ulInstance); RC_CHECK();
994
995 /* Device config: /Devices/<ctrldev>/<instance>/<values> & /ditto/Config/<values> */
996 rc = CFGMR3InsertInteger(pCtlInst, "Trusted", 1); RC_CHECK();
997 rc = CFGMR3InsertNode(pCtlInst, "Config", &pCfg); RC_CHECK();
998
999 switch (enmCtrlType)
1000 {
1001 case StorageControllerType_LsiLogic:
1002 {
1003 rc = CFGMR3InsertInteger(pCtlInst, "PCIDeviceNo", 20); RC_CHECK();
1004 Assert(!afPciDeviceNo[20]);
1005 afPciDeviceNo[20] = true;
1006 rc = CFGMR3InsertInteger(pCtlInst, "PCIFunctionNo", 0); RC_CHECK();
1007
1008 /* Attach the status driver */
1009 rc = CFGMR3InsertNode(pCtlInst, "LUN#999", &pLunL0); RC_CHECK();
1010 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1011 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1012 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedScsi]); RC_CHECK();
1013 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1014 Assert(cLedScsi >= 16);
1015 rc = CFGMR3InsertInteger(pCfg, "Last", 15); RC_CHECK();
1016 paLedDevType = &pConsole->maStorageDevType[iLedScsi];
1017 break;
1018 }
1019
1020 case StorageControllerType_BusLogic:
1021 {
1022 rc = CFGMR3InsertInteger(pCtlInst, "PCIDeviceNo", 21); RC_CHECK();
1023 Assert(!afPciDeviceNo[21]);
1024 afPciDeviceNo[21] = true;
1025 rc = CFGMR3InsertInteger(pCtlInst, "PCIFunctionNo", 0); RC_CHECK();
1026
1027 /* Attach the status driver */
1028 rc = CFGMR3InsertNode(pCtlInst, "LUN#999", &pLunL0); RC_CHECK();
1029 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1030 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1031 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedScsi]); RC_CHECK();
1032 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1033 Assert(cLedScsi >= 16);
1034 rc = CFGMR3InsertInteger(pCfg, "Last", 15); RC_CHECK();
1035 paLedDevType = &pConsole->maStorageDevType[iLedScsi];
1036 break;
1037 }
1038
1039 case StorageControllerType_IntelAhci:
1040 {
1041 rc = CFGMR3InsertInteger(pCtlInst, "PCIDeviceNo", 13); RC_CHECK();
1042 Assert(!afPciDeviceNo[13]);
1043 afPciDeviceNo[13] = true;
1044 rc = CFGMR3InsertInteger(pCtlInst, "PCIFunctionNo", 0); RC_CHECK();
1045
1046 ULONG cPorts = 0;
1047 hrc = ctrls[i]->COMGETTER(PortCount)(&cPorts); H();
1048 rc = CFGMR3InsertInteger(pCfg, "PortCount", cPorts); RC_CHECK();
1049
1050 /* Needed configuration values for the bios. */
1051 if (pBiosCfg)
1052 {
1053 rc = CFGMR3InsertString(pBiosCfg, "SataHardDiskDevice", "ahci"); RC_CHECK();
1054 }
1055
1056 for (uint32_t j = 0; j < 4; ++j)
1057 {
1058 static const char * const s_apszConfig[4] =
1059 { "PrimaryMaster", "PrimarySlave", "SecondaryMaster", "SecondarySlave" };
1060 static const char * const s_apszBiosConfig[4] =
1061 { "SataPrimaryMasterLUN", "SataPrimarySlaveLUN", "SataSecondaryMasterLUN", "SataSecondarySlaveLUN" };
1062
1063 LONG lPortNumber = -1;
1064 hrc = ctrls[i]->GetIDEEmulationPort(j, &lPortNumber); H();
1065 rc = CFGMR3InsertInteger(pCfg, s_apszConfig[j], lPortNumber); RC_CHECK();
1066 if (pBiosCfg)
1067 {
1068 rc = CFGMR3InsertInteger(pBiosCfg, s_apszBiosConfig[j], lPortNumber); RC_CHECK();
1069 }
1070 }
1071
1072 /* Attach the status driver */
1073 rc = CFGMR3InsertNode(pCtlInst, "LUN#999", &pLunL0); RC_CHECK();
1074 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1075 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1076 AssertRelease(cPorts <= cLedSata);
1077 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedSata]); RC_CHECK();
1078 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1079 rc = CFGMR3InsertInteger(pCfg, "Last", cPorts - 1); RC_CHECK();
1080 paLedDevType = &pConsole->maStorageDevType[iLedSata];
1081 break;
1082 }
1083
1084 case StorageControllerType_PIIX3:
1085 case StorageControllerType_PIIX4:
1086 case StorageControllerType_ICH6:
1087 {
1088 /*
1089 * IDE (update this when the main interface changes)
1090 */
1091 rc = CFGMR3InsertInteger(pCtlInst, "PCIDeviceNo", 1); RC_CHECK();
1092 Assert(!afPciDeviceNo[1]);
1093 afPciDeviceNo[1] = true;
1094 rc = CFGMR3InsertInteger(pCtlInst, "PCIFunctionNo", 1); RC_CHECK();
1095 rc = CFGMR3InsertString(pCfg, "Type", controllerString(enmCtrlType)); RC_CHECK();
1096
1097 /* Attach the status driver */
1098 rc = CFGMR3InsertNode(pCtlInst, "LUN#999", &pLunL0); RC_CHECK();
1099 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1100 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1101 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedIde]); RC_CHECK();
1102 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1103 Assert(cLedIde >= 4);
1104 rc = CFGMR3InsertInteger(pCfg, "Last", 3); RC_CHECK();
1105 paLedDevType = &pConsole->maStorageDevType[iLedIde];
1106
1107 /* IDE flavors */
1108 aCtrlNodes[StorageControllerType_PIIX3] = pDev;
1109 aCtrlNodes[StorageControllerType_PIIX4] = pDev;
1110 aCtrlNodes[StorageControllerType_ICH6] = pDev;
1111 break;
1112 }
1113
1114 case StorageControllerType_I82078:
1115 {
1116 /*
1117 * i82078 Floppy drive controller
1118 */
1119 fFdcEnabled = true;
1120 rc = CFGMR3InsertInteger(pCfg, "IRQ", 6); RC_CHECK();
1121 rc = CFGMR3InsertInteger(pCfg, "DMA", 2); RC_CHECK();
1122 rc = CFGMR3InsertInteger(pCfg, "MemMapped", 0 ); RC_CHECK();
1123 rc = CFGMR3InsertInteger(pCfg, "IOBase", 0x3f0); RC_CHECK();
1124
1125 /* Attach the status driver */
1126 rc = CFGMR3InsertNode(pCtlInst, "LUN#999", &pLunL0); RC_CHECK();
1127 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1128 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1129 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedFloppy]); RC_CHECK();
1130 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1131 Assert(cLedFloppy >= 1);
1132 rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
1133 paLedDevType = &pConsole->maStorageDevType[iLedFloppy];
1134 break;
1135 }
1136
1137 case StorageControllerType_LsiLogicSas:
1138 {
1139 rc = CFGMR3InsertInteger(pCtlInst, "PCIDeviceNo", 21); RC_CHECK();
1140 Assert(!afPciDeviceNo[21]);
1141 afPciDeviceNo[21] = true;
1142 rc = CFGMR3InsertInteger(pCtlInst, "PCIFunctionNo", 0); RC_CHECK();
1143
1144 rc = CFGMR3InsertString(pCfg, "ControllerType", "SAS1068"); RC_CHECK();
1145
1146 /* Attach the status driver */
1147 rc = CFGMR3InsertNode(pCtlInst, "LUN#999", &pLunL0); RC_CHECK();
1148 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1149 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1150 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapStorageLeds[iLedScsi]); RC_CHECK();
1151 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1152 Assert(cLedScsi >= 16);
1153 rc = CFGMR3InsertInteger(pCfg, "Last", 15) ; RC_CHECK();
1154 paLedDevType = &pConsole->maStorageDevType[iLedScsi];
1155 break;
1156 }
1157
1158 default:
1159 AssertMsgFailedReturn(("invalid storage controller type: %d\n", enmCtrlType), VERR_GENERAL_FAILURE);
1160 }
1161
1162 /* Attach the media to the storage controllers. */
1163 com::SafeIfaceArray<IMediumAttachment> atts;
1164 hrc = pMachine->GetMediumAttachmentsOfController(controllerName,
1165 ComSafeArrayAsOutParam(atts)); H();
1166
1167 for (size_t j = 0; j < atts.size(); ++j)
1168 {
1169 ComPtr<IMedium> medium;
1170 hrc = atts[j]->COMGETTER(Medium)(medium.asOutParam()); H();
1171 LONG lDev;
1172 hrc = atts[j]->COMGETTER(Device)(&lDev); H();
1173 LONG lPort;
1174 hrc = atts[j]->COMGETTER(Port)(&lPort); H();
1175 DeviceType_T lType;
1176 hrc = atts[j]->COMGETTER(Type)(&lType); H();
1177
1178 unsigned uLUN;
1179 hrc = pConsole->convertBusPortDeviceToLun(enmBus, lPort, lDev, uLUN); H();
1180 rc = CFGMR3InsertNodeF(pCtlInst, &pLunL0, "LUN#%u", uLUN); RC_CHECK();
1181
1182 /* SCSI has a another driver between device and block. */
1183 if (enmBus == StorageBus_SCSI || enmBus == StorageBus_SAS)
1184 {
1185 rc = CFGMR3InsertString(pLunL0, "Driver", "SCSI"); RC_CHECK();
1186 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1187
1188 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
1189 }
1190
1191 BOOL fHostDrive = FALSE;
1192 if (!medium.isNull())
1193 {
1194 hrc = medium->COMGETTER(HostDrive)(&fHostDrive); H();
1195 }
1196
1197 if (fHostDrive)
1198 {
1199 Assert(!medium.isNull());
1200 if (lType == DeviceType_DVD)
1201 {
1202 rc = CFGMR3InsertString(pLunL0, "Driver", "HostDVD"); RC_CHECK();
1203 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1204
1205 hrc = medium->COMGETTER(Location)(&str); H();
1206 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK();
1207 STR_FREE();
1208
1209 BOOL fPassthrough;
1210 hrc = atts[j]->COMGETTER(Passthrough)(&fPassthrough); H();
1211 rc = CFGMR3InsertInteger(pCfg, "Passthrough", !!fPassthrough); RC_CHECK();
1212 }
1213 else if (lType == DeviceType_Floppy)
1214 {
1215 rc = CFGMR3InsertString(pLunL0, "Driver", "HostFloppy"); RC_CHECK();
1216 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1217
1218 hrc = medium->COMGETTER(Location)(&str); H();
1219 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK();
1220 STR_FREE();
1221 }
1222 }
1223 else
1224 {
1225 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
1226 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1227 switch (lType)
1228 {
1229 case DeviceType_DVD:
1230 rc = CFGMR3InsertString(pCfg, "Type", "DVD"); RC_CHECK();
1231 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK();
1232 break;
1233 case DeviceType_Floppy:
1234 rc = CFGMR3InsertString(pCfg, "Type", "Floppy 1.44"); RC_CHECK();
1235 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK();
1236 break;
1237 case DeviceType_HardDisk:
1238 default:
1239 rc = CFGMR3InsertString(pCfg, "Type", "HardDisk"); RC_CHECK();
1240 rc = CFGMR3InsertInteger(pCfg, "Mountable", 0); RC_CHECK();
1241 }
1242
1243 if (!medium.isNull())
1244 {
1245 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
1246 rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK();
1247 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
1248
1249 hrc = medium->COMGETTER(Location)(&str); H();
1250 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK();
1251 STR_FREE();
1252
1253 hrc = medium->COMGETTER(Format)(&str); H();
1254 rc = CFGMR3InsertStringW(pCfg, "Format", str); RC_CHECK();
1255 STR_FREE();
1256
1257 /* DVDs are always readonly */
1258 if (lType == DeviceType_DVD)
1259 {
1260 rc = CFGMR3InsertInteger(pCfg, "ReadOnly", 1); RC_CHECK();
1261 }
1262 /* Start without exclusive write access to the images. */
1263 /** @todo Live Migration: I don't quite like this, we risk screwing up when
1264 * we're resuming the VM if some 3rd dude have any of the VDIs open
1265 * with write sharing denied. However, if the two VMs are sharing a
1266 * image it really is necessary....
1267 *
1268 * So, on the "lock-media" command, the target teleporter should also
1269 * make DrvVD undo TempReadOnly. It gets interesting if we fail after
1270 * that. Grumble. */
1271 else if (pConsole->mMachineState == MachineState_TeleportingIn)
1272 {
1273 rc = CFGMR3InsertInteger(pCfg, "TempReadOnly", 1); RC_CHECK();
1274 }
1275
1276 /* Pass all custom parameters. */
1277 bool fHostIP = true;
1278 SafeArray<BSTR> names;
1279 SafeArray<BSTR> values;
1280 hrc = medium->GetProperties(NULL,
1281 ComSafeArrayAsOutParam(names),
1282 ComSafeArrayAsOutParam(values)); H();
1283
1284 if (names.size() != 0)
1285 {
1286 PCFGMNODE pVDC;
1287 rc = CFGMR3InsertNode(pCfg, "VDConfig", &pVDC); RC_CHECK();
1288 for (size_t ii = 0; ii < names.size(); ++ii)
1289 {
1290 if (values[ii] && *values[ii])
1291 {
1292 Utf8Str name = names[ii];
1293 Utf8Str value = values[ii];
1294 rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str()); RC_CHECK();
1295 if ( name.compare("HostIPStack") == 0
1296 && value.compare("0") == 0)
1297 fHostIP = false;
1298 }
1299 }
1300 }
1301
1302 /* Create an inversed tree of parents. */
1303 ComPtr<IMedium> parentMedium = medium;
1304 for (PCFGMNODE pParent = pCfg;;)
1305 {
1306 hrc = parentMedium->COMGETTER(Parent)(medium.asOutParam()); H();
1307 if (medium.isNull())
1308 break;
1309
1310 PCFGMNODE pCur;
1311 rc = CFGMR3InsertNode(pParent, "Parent", &pCur); RC_CHECK();
1312 hrc = medium->COMGETTER(Location)(&str); H();
1313 rc = CFGMR3InsertStringW(pCur, "Path", str); RC_CHECK();
1314 STR_FREE();
1315
1316 hrc = medium->COMGETTER(Format)(&str); H();
1317 rc = CFGMR3InsertStringW(pCur, "Format", str); RC_CHECK();
1318 STR_FREE();
1319
1320 /* Pass all custom parameters. */
1321 SafeArray<BSTR> aNames;
1322 SafeArray<BSTR> aValues;
1323 hrc = medium->GetProperties(NULL,
1324 ComSafeArrayAsOutParam(aNames),
1325 ComSafeArrayAsOutParam(aValues)); H();
1326
1327 if (aNames.size() != 0)
1328 {
1329 PCFGMNODE pVDC;
1330 rc = CFGMR3InsertNode(pCur, "VDConfig", &pVDC); RC_CHECK();
1331 for (size_t ii = 0; ii < aNames.size(); ++ii)
1332 {
1333 if (aValues[ii] && *aValues[ii])
1334 {
1335 Utf8Str name = aNames[ii];
1336 Utf8Str value = aValues[ii];
1337 rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str()); RC_CHECK();
1338 if ( name.compare("HostIPStack") == 0
1339 && value.compare("0") == 0)
1340 fHostIP = false;
1341 }
1342 }
1343 }
1344
1345 /* Custom code: put marker to not use host IP stack to driver
1346 * configuration node. Simplifies life of DrvVD a bit. */
1347 if (!fHostIP)
1348 {
1349 rc = CFGMR3InsertInteger(pCfg, "HostIPStack", 0); RC_CHECK();
1350 }
1351
1352 /* next */
1353 pParent = pCur;
1354 parentMedium = medium;
1355 }
1356 }
1357 }
1358
1359 if (paLedDevType)
1360 paLedDevType[uLUN] = lType;
1361 }
1362 H();
1363 }
1364 H();
1365
1366 /*
1367 * Network adapters
1368 */
1369#ifdef VMWARE_NET_IN_SLOT_11
1370 bool fSwapSlots3and11 = false;
1371#endif
1372 PCFGMNODE pDevPCNet = NULL; /* PCNet-type devices */
1373 rc = CFGMR3InsertNode(pDevices, "pcnet", &pDevPCNet); RC_CHECK();
1374#ifdef VBOX_WITH_E1000
1375 PCFGMNODE pDevE1000 = NULL; /* E1000-type devices */
1376 rc = CFGMR3InsertNode(pDevices, "e1000", &pDevE1000); RC_CHECK();
1377#endif
1378#ifdef VBOX_WITH_VIRTIO
1379 PCFGMNODE pDevVirtioNet = NULL; /* Virtio network devices */
1380 rc = CFGMR3InsertNode(pDevices, "virtio-net", &pDevVirtioNet); RC_CHECK();
1381#endif /* VBOX_WITH_VIRTIO */
1382 for (ULONG ulInstance = 0; ulInstance < SchemaDefs::NetworkAdapterCount; ++ulInstance)
1383 {
1384 ComPtr<INetworkAdapter> networkAdapter;
1385 hrc = pMachine->GetNetworkAdapter(ulInstance, networkAdapter.asOutParam()); H();
1386 BOOL fEnabled = FALSE;
1387 hrc = networkAdapter->COMGETTER(Enabled)(&fEnabled); H();
1388 if (!fEnabled)
1389 continue;
1390
1391 /*
1392 * The virtual hardware type. Create appropriate device first.
1393 */
1394 const char *pszAdapterName = "pcnet";
1395 NetworkAdapterType_T adapterType;
1396 hrc = networkAdapter->COMGETTER(AdapterType)(&adapterType); H();
1397 switch (adapterType)
1398 {
1399 case NetworkAdapterType_Am79C970A:
1400 case NetworkAdapterType_Am79C973:
1401 pDev = pDevPCNet;
1402 break;
1403#ifdef VBOX_WITH_E1000
1404 case NetworkAdapterType_I82540EM:
1405 case NetworkAdapterType_I82543GC:
1406 case NetworkAdapterType_I82545EM:
1407 pDev = pDevE1000;
1408 pszAdapterName = "e1000";
1409 break;
1410#endif
1411#ifdef VBOX_WITH_VIRTIO
1412 case NetworkAdapterType_Virtio:
1413 pDev = pDevVirtioNet;
1414 pszAdapterName = "virtio-net";
1415 break;
1416#endif /* VBOX_WITH_VIRTIO */
1417 default:
1418 AssertMsgFailed(("Invalid network adapter type '%d' for slot '%d'",
1419 adapterType, ulInstance));
1420 return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
1421 N_("Invalid network adapter type '%d' for slot '%d'"),
1422 adapterType, ulInstance);
1423 }
1424
1425 rc = CFGMR3InsertNodeF(pDev, &pInst, "%u", ulInstance); RC_CHECK();
1426 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
1427 /* the first network card gets the PCI ID 3, the next 3 gets 8..10,
1428 * next 4 get 16..19. */
1429 unsigned iPciDeviceNo = 3;
1430 if (ulInstance)
1431 {
1432 if (ulInstance < 4)
1433 iPciDeviceNo = ulInstance - 1 + 8;
1434 else
1435 iPciDeviceNo = ulInstance - 4 + 16;
1436 }
1437#ifdef VMWARE_NET_IN_SLOT_11
1438 /*
1439 * Dirty hack for PCI slot compatibility with VMWare,
1440 * it assigns slot 11 to the first network controller.
1441 */
1442 if (iPciDeviceNo == 3 && adapterType == NetworkAdapterType_I82545EM)
1443 {
1444 iPciDeviceNo = 0x11;
1445 fSwapSlots3and11 = true;
1446 }
1447 else if (iPciDeviceNo == 0x11 && fSwapSlots3and11)
1448 iPciDeviceNo = 3;
1449#endif
1450 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", iPciDeviceNo); RC_CHECK();
1451 Assert(!afPciDeviceNo[iPciDeviceNo]);
1452 afPciDeviceNo[iPciDeviceNo] = true;
1453 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1454 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1455#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE /* not safe here yet. */
1456 if (pDev == pDevPCNet)
1457 {
1458 rc = CFGMR3InsertInteger(pCfg, "R0Enabled", false); RC_CHECK();
1459 }
1460#endif
1461
1462 /*
1463 * The virtual hardware type. PCNet supports two types.
1464 */
1465 switch (adapterType)
1466 {
1467 case NetworkAdapterType_Am79C970A:
1468 rc = CFGMR3InsertInteger(pCfg, "Am79C973", 0); RC_CHECK();
1469 break;
1470 case NetworkAdapterType_Am79C973:
1471 rc = CFGMR3InsertInteger(pCfg, "Am79C973", 1); RC_CHECK();
1472 break;
1473 case NetworkAdapterType_I82540EM:
1474 rc = CFGMR3InsertInteger(pCfg, "AdapterType", 0); RC_CHECK();
1475 break;
1476 case NetworkAdapterType_I82543GC:
1477 rc = CFGMR3InsertInteger(pCfg, "AdapterType", 1); RC_CHECK();
1478 break;
1479 case NetworkAdapterType_I82545EM:
1480 rc = CFGMR3InsertInteger(pCfg, "AdapterType", 2); RC_CHECK();
1481 break;
1482 }
1483
1484 /*
1485 * Get the MAC address and convert it to binary representation
1486 */
1487 Bstr macAddr;
1488 hrc = networkAdapter->COMGETTER(MACAddress)(macAddr.asOutParam()); H();
1489 Assert(macAddr);
1490 Utf8Str macAddrUtf8 = macAddr;
1491 char *macStr = (char*)macAddrUtf8.raw();
1492 Assert(strlen(macStr) == 12);
1493 RTMAC Mac;
1494 memset(&Mac, 0, sizeof(Mac));
1495 char *pMac = (char*)&Mac;
1496 for (uint32_t i = 0; i < 6; ++i)
1497 {
1498 char c1 = *macStr++ - '0';
1499 if (c1 > 9)
1500 c1 -= 7;
1501 char c2 = *macStr++ - '0';
1502 if (c2 > 9)
1503 c2 -= 7;
1504 *pMac++ = ((c1 & 0x0f) << 4) | (c2 & 0x0f);
1505 }
1506 rc = CFGMR3InsertBytes(pCfg, "MAC", &Mac, sizeof(Mac)); RC_CHECK();
1507
1508 /*
1509 * Check if the cable is supposed to be unplugged
1510 */
1511 BOOL fCableConnected;
1512 hrc = networkAdapter->COMGETTER(CableConnected)(&fCableConnected); H();
1513 rc = CFGMR3InsertInteger(pCfg, "CableConnected", fCableConnected ? 1 : 0); RC_CHECK();
1514
1515 /*
1516 * Line speed to report from custom drivers
1517 */
1518 ULONG ulLineSpeed;
1519 hrc = networkAdapter->COMGETTER(LineSpeed)(&ulLineSpeed); H();
1520 rc = CFGMR3InsertInteger(pCfg, "LineSpeed", ulLineSpeed); RC_CHECK();
1521
1522 /*
1523 * Attach the status driver.
1524 */
1525 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
1526 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1527 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1528 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapNetworkLeds[ulInstance]); RC_CHECK();
1529
1530 /*
1531 * Configure the network card now
1532 */
1533 rc = configNetwork(pConsole, pszAdapterName, ulInstance, 0, networkAdapter,
1534 pCfg, pLunL0, pInst, false /*fAttachDetach*/); RC_CHECK();
1535 }
1536
1537 /*
1538 * Serial (UART) Ports
1539 */
1540 rc = CFGMR3InsertNode(pDevices, "serial", &pDev); RC_CHECK();
1541 for (ULONG ulInstance = 0; ulInstance < SchemaDefs::SerialPortCount; ++ulInstance)
1542 {
1543 ComPtr<ISerialPort> serialPort;
1544 hrc = pMachine->GetSerialPort (ulInstance, serialPort.asOutParam()); H();
1545 BOOL fEnabled = FALSE;
1546 if (serialPort)
1547 hrc = serialPort->COMGETTER(Enabled)(&fEnabled); H();
1548 if (!fEnabled)
1549 continue;
1550
1551 rc = CFGMR3InsertNodeF(pDev, &pInst, "%u", ulInstance); RC_CHECK();
1552 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1553
1554 ULONG ulIRQ;
1555 hrc = serialPort->COMGETTER(IRQ)(&ulIRQ); H();
1556 rc = CFGMR3InsertInteger(pCfg, "IRQ", ulIRQ); RC_CHECK();
1557 ULONG ulIOBase;
1558 hrc = serialPort->COMGETTER(IOBase)(&ulIOBase); H();
1559 rc = CFGMR3InsertInteger(pCfg, "IOBase", ulIOBase); RC_CHECK();
1560 BOOL fServer;
1561 hrc = serialPort->COMGETTER(Server)(&fServer); H();
1562 hrc = serialPort->COMGETTER(Path)(&str); H();
1563 PortMode_T eHostMode;
1564 hrc = serialPort->COMGETTER(HostMode)(&eHostMode); H();
1565 if (eHostMode != PortMode_Disconnected)
1566 {
1567 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1568 if (eHostMode == PortMode_HostPipe)
1569 {
1570 rc = CFGMR3InsertString(pLunL0, "Driver", "Char"); RC_CHECK();
1571 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
1572 rc = CFGMR3InsertString(pLunL1, "Driver", "NamedPipe"); RC_CHECK();
1573 rc = CFGMR3InsertNode(pLunL1, "Config", &pLunL2); RC_CHECK();
1574 rc = CFGMR3InsertStringW(pLunL2, "Location", str); RC_CHECK();
1575 rc = CFGMR3InsertInteger(pLunL2, "IsServer", fServer); RC_CHECK();
1576 }
1577 else if (eHostMode == PortMode_HostDevice)
1578 {
1579 rc = CFGMR3InsertString(pLunL0, "Driver", "Host Serial"); RC_CHECK();
1580 rc = CFGMR3InsertNode(pLunL0, "Config", &pLunL1); RC_CHECK();
1581 rc = CFGMR3InsertStringW(pLunL1, "DevicePath", str); RC_CHECK();
1582 }
1583 else if (eHostMode == PortMode_RawFile)
1584 {
1585 rc = CFGMR3InsertString(pLunL0, "Driver", "Char"); RC_CHECK();
1586 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
1587 rc = CFGMR3InsertString(pLunL1, "Driver", "RawFile"); RC_CHECK();
1588 rc = CFGMR3InsertNode(pLunL1, "Config", &pLunL2); RC_CHECK();
1589 rc = CFGMR3InsertStringW(pLunL2, "Location", str); RC_CHECK();
1590 }
1591 }
1592 STR_FREE();
1593 }
1594
1595 /*
1596 * Parallel (LPT) Ports
1597 */
1598 rc = CFGMR3InsertNode(pDevices, "parallel", &pDev); RC_CHECK();
1599 for (ULONG ulInstance = 0; ulInstance < SchemaDefs::ParallelPortCount; ++ulInstance)
1600 {
1601 ComPtr<IParallelPort> parallelPort;
1602 hrc = pMachine->GetParallelPort(ulInstance, parallelPort.asOutParam()); H();
1603 BOOL fEnabled = FALSE;
1604 if (parallelPort)
1605 {
1606 hrc = parallelPort->COMGETTER(Enabled)(&fEnabled); H();
1607 }
1608 if (!fEnabled)
1609 continue;
1610
1611 rc = CFGMR3InsertNodeF(pDev, &pInst, "%u", ulInstance); RC_CHECK();
1612 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1613
1614 ULONG ulIRQ;
1615 hrc = parallelPort->COMGETTER(IRQ)(&ulIRQ); H();
1616 rc = CFGMR3InsertInteger(pCfg, "IRQ", ulIRQ); RC_CHECK();
1617 ULONG ulIOBase;
1618 hrc = parallelPort->COMGETTER(IOBase)(&ulIOBase); H();
1619 rc = CFGMR3InsertInteger(pCfg, "IOBase", ulIOBase); RC_CHECK();
1620 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1621 rc = CFGMR3InsertString(pLunL0, "Driver", "HostParallel"); RC_CHECK();
1622 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
1623 hrc = parallelPort->COMGETTER(Path)(&str); H();
1624 rc = CFGMR3InsertStringW(pLunL1, "DevicePath", str); RC_CHECK();
1625 STR_FREE();
1626 }
1627
1628 /*
1629 * VMM Device
1630 */
1631 rc = CFGMR3InsertNode(pDevices, "VMMDev", &pDev); RC_CHECK();
1632 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1633 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1634 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
1635 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 4); RC_CHECK();
1636 Assert(!afPciDeviceNo[4]);
1637 afPciDeviceNo[4] = true;
1638 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1639 Bstr hwVersion;
1640 hrc = pMachine->COMGETTER(HardwareVersion)(hwVersion.asOutParam()); H();
1641 if (hwVersion.compare(Bstr("1")) == 0) /* <= 2.0.x */
1642 {
1643 CFGMR3InsertInteger(pCfg, "HeapEnabled", 0); RC_CHECK();
1644 }
1645
1646 /* the VMM device's Main driver */
1647 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1648 rc = CFGMR3InsertString(pLunL0, "Driver", "HGCM"); RC_CHECK();
1649 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1650 VMMDev *pVMMDev = pConsole->mVMMDev;
1651 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pVMMDev); RC_CHECK();
1652
1653 /*
1654 * Attach the status driver.
1655 */
1656 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
1657 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1658 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1659 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapSharedFolderLed); RC_CHECK();
1660 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1661 rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
1662
1663 /*
1664 * Audio Sniffer Device
1665 */
1666 rc = CFGMR3InsertNode(pDevices, "AudioSniffer", &pDev); RC_CHECK();
1667 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1668 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1669
1670 /* the Audio Sniffer device's Main driver */
1671 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1672 rc = CFGMR3InsertString(pLunL0, "Driver", "MainAudioSniffer"); RC_CHECK();
1673 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1674 AudioSniffer *pAudioSniffer = pConsole->mAudioSniffer;
1675 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pAudioSniffer); RC_CHECK();
1676
1677 /*
1678 * AC'97 ICH / SoundBlaster16 audio
1679 */
1680 BOOL enabled;
1681 ComPtr<IAudioAdapter> audioAdapter;
1682 hrc = pMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam()); H();
1683 if (audioAdapter)
1684 hrc = audioAdapter->COMGETTER(Enabled)(&enabled); H();
1685
1686 if (enabled)
1687 {
1688 AudioControllerType_T audioController;
1689 hrc = audioAdapter->COMGETTER(AudioController)(&audioController); H();
1690 switch (audioController)
1691 {
1692 case AudioControllerType_AC97:
1693 {
1694 /* default: ICH AC97 */
1695 rc = CFGMR3InsertNode(pDevices, "ichac97", &pDev); RC_CHECK();
1696 rc = CFGMR3InsertNode(pDev, "0", &pInst);
1697 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* bool */ RC_CHECK();
1698 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 5); RC_CHECK();
1699 Assert(!afPciDeviceNo[5]);
1700 afPciDeviceNo[5] = true;
1701 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1702 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1703 break;
1704 }
1705 case AudioControllerType_SB16:
1706 {
1707 /* legacy SoundBlaster16 */
1708 rc = CFGMR3InsertNode(pDevices, "sb16", &pDev); RC_CHECK();
1709 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1710 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* bool */ RC_CHECK();
1711 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1712 rc = CFGMR3InsertInteger(pCfg, "IRQ", 5); RC_CHECK();
1713 rc = CFGMR3InsertInteger(pCfg, "DMA", 1); RC_CHECK();
1714 rc = CFGMR3InsertInteger(pCfg, "DMA16", 5); RC_CHECK();
1715 rc = CFGMR3InsertInteger(pCfg, "Port", 0x220); RC_CHECK();
1716 rc = CFGMR3InsertInteger(pCfg, "Version", 0x0405); RC_CHECK();
1717 break;
1718 }
1719 }
1720
1721 /* the Audio driver */
1722 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1723 rc = CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); RC_CHECK();
1724 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1725
1726 AudioDriverType_T audioDriver;
1727 hrc = audioAdapter->COMGETTER(AudioDriver)(&audioDriver); H();
1728 switch (audioDriver)
1729 {
1730 case AudioDriverType_Null:
1731 {
1732 rc = CFGMR3InsertString(pCfg, "AudioDriver", "null"); RC_CHECK();
1733 break;
1734 }
1735#ifdef RT_OS_WINDOWS
1736#ifdef VBOX_WITH_WINMM
1737 case AudioDriverType_WinMM:
1738 {
1739 rc = CFGMR3InsertString(pCfg, "AudioDriver", "winmm"); RC_CHECK();
1740 break;
1741 }
1742#endif
1743 case AudioDriverType_DirectSound:
1744 {
1745 rc = CFGMR3InsertString(pCfg, "AudioDriver", "dsound"); RC_CHECK();
1746 break;
1747 }
1748#endif /* RT_OS_WINDOWS */
1749#ifdef RT_OS_SOLARIS
1750 case AudioDriverType_SolAudio:
1751 {
1752 rc = CFGMR3InsertString(pCfg, "AudioDriver", "solaudio"); RC_CHECK();
1753 break;
1754 }
1755#endif
1756#ifdef RT_OS_LINUX
1757# ifdef VBOX_WITH_ALSA
1758 case AudioDriverType_ALSA:
1759 {
1760 rc = CFGMR3InsertString(pCfg, "AudioDriver", "alsa"); RC_CHECK();
1761 break;
1762 }
1763# endif
1764# ifdef VBOX_WITH_PULSE
1765 case AudioDriverType_Pulse:
1766 {
1767 rc = CFGMR3InsertString(pCfg, "AudioDriver", "pulse"); RC_CHECK();
1768 break;
1769 }
1770# endif
1771#endif /* RT_OS_LINUX */
1772#if defined (RT_OS_LINUX) || defined (RT_OS_FREEBSD) || defined(VBOX_WITH_SOLARIS_OSS)
1773 case AudioDriverType_OSS:
1774 {
1775 rc = CFGMR3InsertString(pCfg, "AudioDriver", "oss"); RC_CHECK();
1776 break;
1777 }
1778#endif
1779#ifdef RT_OS_FREEBSD
1780# ifdef VBOX_WITH_PULSE
1781 case AudioDriverType_Pulse:
1782 {
1783 rc = CFGMR3InsertString(pCfg, "AudioDriver", "pulse"); RC_CHECK();
1784 break;
1785 }
1786# endif
1787#endif
1788#ifdef RT_OS_DARWIN
1789 case AudioDriverType_CoreAudio:
1790 {
1791 rc = CFGMR3InsertString(pCfg, "AudioDriver", "coreaudio"); RC_CHECK();
1792 break;
1793 }
1794#endif
1795 }
1796 hrc = pMachine->COMGETTER(Name)(&str); H();
1797 rc = CFGMR3InsertStringW(pCfg, "StreamName", str); RC_CHECK();
1798 STR_FREE();
1799 }
1800
1801 /*
1802 * The USB Controller.
1803 */
1804 ComPtr<IUSBController> USBCtlPtr;
1805 hrc = pMachine->COMGETTER(USBController)(USBCtlPtr.asOutParam());
1806 if (USBCtlPtr)
1807 {
1808 BOOL fEnabled;
1809 hrc = USBCtlPtr->COMGETTER(Enabled)(&fEnabled); H();
1810 if (fEnabled)
1811 {
1812 rc = CFGMR3InsertNode(pDevices, "usb-ohci", &pDev); RC_CHECK();
1813 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1814 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1815 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
1816 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 6); RC_CHECK();
1817 Assert(!afPciDeviceNo[6]);
1818 afPciDeviceNo[6] = true;
1819 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1820
1821 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1822 rc = CFGMR3InsertString(pLunL0, "Driver", "VUSBRootHub"); RC_CHECK();
1823 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1824
1825 /*
1826 * Attach the status driver.
1827 */
1828 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
1829 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1830 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1831 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapUSBLed[0]);RC_CHECK();
1832 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1833 rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
1834
1835 PCFGMNODE pUsbDevices = NULL;
1836#ifdef VBOX_WITH_EHCI
1837 hrc = USBCtlPtr->COMGETTER(EnabledEhci)(&fEnabled); H();
1838 if (fEnabled)
1839 {
1840 rc = CFGMR3InsertNode(pDevices, "usb-ehci", &pDev); RC_CHECK();
1841 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1842 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1843 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* bool */ RC_CHECK();
1844 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 11); RC_CHECK();
1845 Assert(!afPciDeviceNo[11]);
1846 afPciDeviceNo[11] = true;
1847 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1848
1849 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1850 rc = CFGMR3InsertString(pLunL0, "Driver", "VUSBRootHub"); RC_CHECK();
1851 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1852
1853 /*
1854 * Attach the status driver.
1855 */
1856 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
1857 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1858 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1859 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapUSBLed[1]);RC_CHECK();
1860 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1861 rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
1862 }
1863 else
1864#endif
1865 {
1866 /*
1867 * Global USB options, currently unused as we'll apply the 2.0 -> 1.1 morphing
1868 * on a per device level now.
1869 */
1870 rc = CFGMR3InsertNode(pRoot, "USB", &pUsbDevices); RC_CHECK();
1871 rc = CFGMR3InsertNode(pUsbDevices, "USBProxy", &pCfg); RC_CHECK();
1872 rc = CFGMR3InsertNode(pCfg, "GlobalConfig", &pCfg); RC_CHECK();
1873 // This globally enables the 2.0 -> 1.1 device morphing of proxied devies to keep windows quiet.
1874 //rc = CFGMR3InsertInteger(pCfg, "Force11Device", true); RC_CHECK();
1875 // The following breaks stuff, but it makes MSDs work in vista. (I include it here so
1876 // that it's documented somewhere.) Users needing it can use:
1877 // VBoxManage setextradata "myvm" "VBoxInternal/USB/USBProxy/GlobalConfig/Force11PacketSize" 1
1878 //rc = CFGMR3InsertInteger(pCfg, "Force11PacketSize", true); RC_CHECK();
1879 }
1880
1881#if 1 /* Enable+edit this to play with the virtual USB devices). */
1882 if (!pUsbDevices)
1883 {
1884 rc = CFGMR3InsertNode(pRoot, "USB", &pUsbDevices); RC_CHECK();
1885 }
1886
1887# if 0 /* Virtual MSD*/
1888
1889 rc = CFGMR3InsertNode(pUsbDevices, "Msd", &pDev); RC_CHECK();
1890 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1891 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1892 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1893
1894 rc = CFGMR3InsertString(pLunL0, "Driver", "SCSI"); RC_CHECK();
1895 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1896
1897 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
1898 rc = CFGMR3InsertString(pLunL1, "Driver", "Block"); RC_CHECK();
1899 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
1900 rc = CFGMR3InsertString(pCfg, "Type", "HardDisk"); RC_CHECK();
1901 rc = CFGMR3InsertInteger(pCfg, "Mountable", 0); RC_CHECK();
1902
1903 rc = CFGMR3InsertNode(pLunL1, "AttachedDriver", &pLunL2); RC_CHECK();
1904 rc = CFGMR3InsertString(pLunL2, "Driver", "VD"); RC_CHECK();
1905 rc = CFGMR3InsertNode(pLunL2, "Config", &pCfg); RC_CHECK();
1906 rc = CFGMR3InsertString(pCfg, "Path", "/Volumes/DataHFS/bird/VDIs/linux.vdi"); RC_CHECK();
1907 rc = CFGMR3InsertString(pCfg, "Format", "VDI"); RC_CHECK();
1908# endif
1909
1910 /* Virtual USB Mouse*/
1911 PointingHidType_T aPointingHid;
1912 hrc = pMachine->COMGETTER(PointingHidType)(&aPointingHid); H();
1913 if (aPointingHid == PointingHidType_USBMouse)
1914 {
1915 rc = CFGMR3InsertNode(pUsbDevices, "HidMouse", &pDev); RC_CHECK();
1916 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1917 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1918
1919 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1920 rc = CFGMR3InsertString(pLunL0, "Driver", "MouseQueue"); RC_CHECK();
1921 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1922 rc = CFGMR3InsertInteger(pCfg, "QueueSize", 128); RC_CHECK();
1923
1924 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
1925 rc = CFGMR3InsertString(pLunL1, "Driver", "MainMouse"); RC_CHECK();
1926 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
1927 pMouse = pConsole->mMouse;
1928 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pMouse); RC_CHECK();
1929 }
1930
1931 /* Virtual USB Keyboard */
1932 KeyboardHidType_T aKbdHid;
1933 hrc = pMachine->COMGETTER(KeyboardHidType)(&aKbdHid); H();
1934 if (aKbdHid == KeyboardHidType_USBKeyboard)
1935 {
1936 rc = CFGMR3InsertNode(pUsbDevices, "HidKeyboard", &pDev); RC_CHECK();
1937 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1938 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1939
1940 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1941 rc = CFGMR3InsertString(pLunL0, "Driver", "KeyboardQueue"); RC_CHECK();
1942 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1943 rc = CFGMR3InsertInteger(pCfg, "QueueSize", 64); RC_CHECK();
1944
1945 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
1946 rc = CFGMR3InsertString(pLunL1, "Driver", "MainKeyboard"); RC_CHECK();
1947 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
1948 pKeyboard = pConsole->mKeyboard;
1949 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pKeyboard); RC_CHECK();
1950 }
1951#endif
1952 }
1953 }
1954
1955 /*
1956 * Clipboard
1957 */
1958 {
1959 ClipboardMode_T mode = ClipboardMode_Disabled;
1960 hrc = pMachine->COMGETTER(ClipboardMode)(&mode); H();
1961
1962 if (mode != ClipboardMode_Disabled)
1963 {
1964 /* Load the service */
1965 rc = pConsole->mVMMDev->hgcmLoadService ("VBoxSharedClipboard", "VBoxSharedClipboard");
1966
1967 if (RT_FAILURE(rc))
1968 {
1969 LogRel(("VBoxSharedClipboard is not available. rc = %Rrc\n", rc));
1970 /* That is not a fatal failure. */
1971 rc = VINF_SUCCESS;
1972 }
1973 else
1974 {
1975 /* Setup the service. */
1976 VBOXHGCMSVCPARM parm;
1977
1978 parm.type = VBOX_HGCM_SVC_PARM_32BIT;
1979
1980 switch (mode)
1981 {
1982 default:
1983 case ClipboardMode_Disabled:
1984 {
1985 LogRel(("VBoxSharedClipboard mode: Off\n"));
1986 parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_OFF;
1987 break;
1988 }
1989 case ClipboardMode_GuestToHost:
1990 {
1991 LogRel(("VBoxSharedClipboard mode: Guest to Host\n"));
1992 parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST;
1993 break;
1994 }
1995 case ClipboardMode_HostToGuest:
1996 {
1997 LogRel(("VBoxSharedClipboard mode: Host to Guest\n"));
1998 parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_HOST_TO_GUEST;
1999 break;
2000 }
2001 case ClipboardMode_Bidirectional:
2002 {
2003 LogRel(("VBoxSharedClipboard mode: Bidirectional\n"));
2004 parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL;
2005 break;
2006 }
2007 }
2008
2009 pConsole->mVMMDev->hgcmHostCall ("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm);
2010
2011 Log(("Set VBoxSharedClipboard mode\n"));
2012 }
2013 }
2014 }
2015
2016#ifdef VBOX_WITH_CROGL
2017 /*
2018 * crOpenGL
2019 */
2020 {
2021 BOOL fEnabled = false;
2022 hrc = pMachine->COMGETTER(Accelerate3DEnabled)(&fEnabled); H();
2023
2024 if (fEnabled)
2025 {
2026 /* Load the service */
2027 rc = pConsole->mVMMDev->hgcmLoadService ("VBoxSharedCrOpenGL", "VBoxSharedCrOpenGL");
2028 if (RT_FAILURE(rc))
2029 {
2030 LogRel(("Failed to load Shared OpenGL service %Rrc\n", rc));
2031 /* That is not a fatal failure. */
2032 rc = VINF_SUCCESS;
2033 }
2034 else
2035 {
2036 LogRel(("Shared crOpenGL service loaded.\n"));
2037
2038 /* Setup the service. */
2039 VBOXHGCMSVCPARM parm;
2040 parm.type = VBOX_HGCM_SVC_PARM_PTR;
2041
2042 parm.u.pointer.addr = pConsole->getDisplay()->getFramebuffer();
2043 parm.u.pointer.size = sizeof(IFramebuffer *);
2044
2045 rc = pConsole->mVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_FRAMEBUFFER, 1, &parm);
2046 if (!RT_SUCCESS(rc))
2047 AssertMsgFailed(("SHCRGL_HOST_FN_SET_FRAMEBUFFER failed with %Rrc\n", rc));
2048
2049 parm.u.pointer.addr = pVM;
2050 parm.u.pointer.size = sizeof(pVM);
2051 rc = pConsole->mVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_VM, 1, &parm);
2052 if (!RT_SUCCESS(rc))
2053 AssertMsgFailed(("SHCRGL_HOST_FN_SET_VM failed with %Rrc\n", rc));
2054 }
2055
2056 }
2057 }
2058#endif
2059
2060#ifdef VBOX_WITH_GUEST_PROPS
2061 /*
2062 * Guest property service
2063 */
2064
2065 rc = configGuestProperties(pConsole);
2066#endif /* VBOX_WITH_GUEST_PROPS defined */
2067
2068 /*
2069 * ACPI
2070 */
2071 BOOL fACPI;
2072 hrc = biosSettings->COMGETTER(ACPIEnabled)(&fACPI); H();
2073 if (fACPI)
2074 {
2075 BOOL fCpuHotPlug = false;
2076 BOOL fShowCpu = fExtProfile;
2077 /* Always show the CPU leafs when we have multiple VCPUs or when the IO-APIC is enabled.
2078 * The Windows SMP kernel needs a CPU leaf or else its idle loop will burn cpu cycles; the
2079 * intelppm driver refuses to register an idle state handler.
2080 */
2081 if ((cCpus > 1) || fIOAPIC)
2082 fShowCpu = true;
2083
2084 hrc = pMachine->COMGETTER(CPUHotPlugEnabled)(&fCpuHotPlug); H();
2085
2086 rc = CFGMR3InsertNode(pDevices, "acpi", &pDev); RC_CHECK();
2087 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
2088 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
2089 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
2090 rc = CFGMR3InsertInteger(pCfg, "RamSize", cbRam); RC_CHECK();
2091 rc = CFGMR3InsertInteger(pCfg, "RamHoleSize", cbRamHole); RC_CHECK();
2092 rc = CFGMR3InsertInteger(pCfg, "NumCPUs", cCpus); RC_CHECK();
2093
2094 rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
2095 rc = CFGMR3InsertInteger(pCfg, "FdcEnabled", fFdcEnabled); RC_CHECK();
2096 rc = CFGMR3InsertInteger(pCfg, "HpetEnabled", fHpetEnabled); RC_CHECK();
2097#ifdef VBOX_WITH_SMC
2098 rc = CFGMR3InsertInteger(pCfg, "SmcEnabled", fSmcEnabled); RC_CHECK();
2099#endif
2100 rc = CFGMR3InsertInteger(pCfg, "ShowRtc", fExtProfile); RC_CHECK();
2101
2102 rc = CFGMR3InsertInteger(pCfg, "ShowCpu", fShowCpu); RC_CHECK();
2103 rc = CFGMR3InsertInteger(pCfg, "CpuHotPlug", fCpuHotPlug); RC_CHECK();
2104 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 7); RC_CHECK();
2105 Assert(!afPciDeviceNo[7]);
2106 afPciDeviceNo[7] = true;
2107 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
2108
2109 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
2110 rc = CFGMR3InsertString(pLunL0, "Driver", "ACPIHost"); RC_CHECK();
2111 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
2112
2113 /* Attach the dummy CPU drivers */
2114 for (ULONG iCpuCurr = 1; iCpuCurr < cCpus; iCpuCurr++)
2115 {
2116 BOOL fCpuAttached = true;
2117
2118 if (fCpuHotPlug)
2119 {
2120 hrc = pMachine->GetCPUStatus(iCpuCurr, &fCpuAttached); H();
2121 }
2122
2123 if (fCpuAttached)
2124 {
2125 rc = CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%u", iCpuCurr); RC_CHECK();
2126 rc = CFGMR3InsertString(pLunL0, "Driver", "ACPICpu"); RC_CHECK();
2127 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
2128 }
2129 }
2130 }
2131
2132
2133 /*
2134 * CFGM overlay handling.
2135 *
2136 * Here we check the extra data entries for CFGM values
2137 * and create the nodes and insert the values on the fly. Existing
2138 * values will be removed and reinserted. CFGM is typed, so by default
2139 * we will guess whether it's a string or an integer (byte arrays are
2140 * not currently supported). It's possible to override this autodetection
2141 * by adding "string:", "integer:" or "bytes:" (future).
2142 *
2143 * We first perform a run on global extra data, then on the machine
2144 * extra data to support global settings with local overrides.
2145 *
2146 */
2147 /** @todo add support for removing nodes and byte blobs. */
2148 SafeArray<BSTR> aGlobalExtraDataKeys;
2149 SafeArray<BSTR> aMachineExtraDataKeys;
2150 /*
2151 * Get the next key
2152 */
2153 if (FAILED(hrc = virtualBox->GetExtraDataKeys(ComSafeArrayAsOutParam(aGlobalExtraDataKeys))))
2154 AssertMsgFailed(("VirtualBox::GetExtraDataKeys failed with %Rrc\n", hrc));
2155
2156 // remember the no. of global values so we can call the correct method below
2157 size_t cGlobalValues = aGlobalExtraDataKeys.size();
2158
2159 if (FAILED(hrc = pMachine->GetExtraDataKeys(ComSafeArrayAsOutParam(aMachineExtraDataKeys))))
2160 AssertMsgFailed(("IMachine::GetExtraDataKeys failed with %Rrc\n", hrc));
2161
2162 // build a combined list from global keys...
2163 std::list<Utf8Str> llExtraDataKeys;
2164 size_t i = 0;
2165
2166 for (i = 0; i < aGlobalExtraDataKeys.size(); ++i)
2167 llExtraDataKeys.push_back(Utf8Str(aGlobalExtraDataKeys[i]));
2168 // ... and machine keys
2169 for (i = 0; i < aMachineExtraDataKeys.size(); ++i)
2170 llExtraDataKeys.push_back(Utf8Str(aMachineExtraDataKeys[i]));
2171
2172 i = 0;
2173 for (std::list<Utf8Str>::const_iterator it = llExtraDataKeys.begin();
2174 it != llExtraDataKeys.end();
2175 ++it, ++i)
2176 {
2177 const Utf8Str &strKey = *it;
2178
2179 /*
2180 * We only care about keys starting with "VBoxInternal/" (skip "G:" or "M:")
2181 */
2182 if (!strKey.startsWith("VBoxInternal/"))
2183 continue;
2184
2185 const char *pszExtraDataKey = strKey.raw() + sizeof("VBoxInternal/") - 1;
2186
2187 // get the value
2188 Bstr strExtraDataValue;
2189 if (i < cGlobalValues)
2190 // this is still one of the global values:
2191 hrc = virtualBox->GetExtraData(Bstr(strKey), strExtraDataValue.asOutParam());
2192 else
2193 hrc = pMachine->GetExtraData(Bstr(strKey), strExtraDataValue.asOutParam());
2194 if (FAILED(hrc))
2195 LogRel(("Warning: Cannot get extra data key %s, rc = %Rrc\n", strKey.raw(), hrc));
2196
2197 /*
2198 * The key will be in the format "Node1/Node2/Value" or simply "Value".
2199 * Split the two and get the node, delete the value and create the node
2200 * if necessary.
2201 */
2202 PCFGMNODE pNode;
2203 const char *pszCFGMValueName = strrchr(pszExtraDataKey, '/');
2204 if (pszCFGMValueName)
2205 {
2206 /* terminate the node and advance to the value (Utf8Str might not
2207 offically like this but wtf) */
2208 *(char*)pszCFGMValueName = '\0';
2209 ++pszCFGMValueName;
2210
2211 /* does the node already exist? */
2212 pNode = CFGMR3GetChild(pRoot, pszExtraDataKey);
2213 if (pNode)
2214 CFGMR3RemoveValue(pNode, pszCFGMValueName);
2215 else
2216 {
2217 /* create the node */
2218 rc = CFGMR3InsertNode(pRoot, pszExtraDataKey, &pNode);
2219 if (RT_FAILURE(rc))
2220 {
2221 AssertLogRelMsgRC(rc, ("failed to insert node '%s'\n", pszExtraDataKey));
2222 continue;
2223 }
2224 Assert(pNode);
2225 }
2226 }
2227 else
2228 {
2229 /* root value (no node path). */
2230 pNode = pRoot;
2231 pszCFGMValueName = pszExtraDataKey;
2232 pszExtraDataKey--;
2233 CFGMR3RemoveValue(pNode, pszCFGMValueName);
2234 }
2235
2236 /*
2237 * Now let's have a look at the value.
2238 * Empty strings means that we should remove the value, which we've
2239 * already done above.
2240 */
2241 Utf8Str strCFGMValueUtf8(strExtraDataValue);
2242 const char *pszCFGMValue = strCFGMValueUtf8.raw();
2243 if ( pszCFGMValue
2244 && *pszCFGMValue)
2245 {
2246 uint64_t u64Value;
2247
2248 /* check for type prefix first. */
2249 if (!strncmp(pszCFGMValue, "string:", sizeof("string:") - 1))
2250 rc = CFGMR3InsertString(pNode, pszCFGMValueName, pszCFGMValue + sizeof("string:") - 1);
2251 else if (!strncmp(pszCFGMValue, "integer:", sizeof("integer:") - 1))
2252 {
2253 rc = RTStrToUInt64Full(pszCFGMValue + sizeof("integer:") - 1, 0, &u64Value);
2254 if (RT_SUCCESS(rc))
2255 rc = CFGMR3InsertInteger(pNode, pszCFGMValueName, u64Value);
2256 }
2257 else if (!strncmp(pszCFGMValue, "bytes:", sizeof("bytes:") - 1))
2258 rc = VERR_NOT_IMPLEMENTED;
2259 /* auto detect type. */
2260 else if (RT_SUCCESS(RTStrToUInt64Full(pszCFGMValue, 0, &u64Value)))
2261 rc = CFGMR3InsertInteger(pNode, pszCFGMValueName, u64Value);
2262 else
2263 rc = CFGMR3InsertString(pNode, pszCFGMValueName, pszCFGMValue);
2264 AssertLogRelMsgRC(rc, ("failed to insert CFGM value '%s' to key '%s'\n", pszCFGMValue, pszExtraDataKey));
2265 }
2266 }
2267
2268#undef STR_FREE
2269#undef H
2270#undef RC_CHECK
2271
2272 /* Register VM state change handler */
2273 int rc2 = VMR3AtStateRegister (pVM, Console::vmstateChangeCallback, pConsole);
2274 AssertRC(rc2);
2275 if (RT_SUCCESS(rc))
2276 rc = rc2;
2277
2278 /* Register VM runtime error handler */
2279 rc2 = VMR3AtRuntimeErrorRegister (pVM, Console::setVMRuntimeErrorCallback, pConsole);
2280 AssertRC(rc2);
2281 if (RT_SUCCESS(rc))
2282 rc = rc2;
2283
2284 LogFlowFunc (("vrc = %Rrc\n", rc));
2285 LogFlowFuncLeave();
2286
2287 return rc;
2288}
2289
2290/**
2291 * Ellipsis to va_list wrapper for calling setVMRuntimeErrorCallback.
2292 */
2293/*static*/ void Console::setVMRuntimeErrorCallbackF(PVM pVM, void *pvConsole, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
2294{
2295 va_list va;
2296 va_start(va, pszFormat);
2297 setVMRuntimeErrorCallback(pVM, pvConsole, fFlags, pszErrorId, pszFormat, va);
2298 va_end(va);
2299}
2300
2301/**
2302 * Construct the Network configuration tree
2303 *
2304 * @returns VBox status code.
2305 *
2306 * @param pThis Pointer to the Console object.
2307 * @param pszDevice The PDM device name.
2308 * @param uInstance The PDM device instance.
2309 * @param uLun The PDM LUN number of the drive.
2310 * @param aNetworkAdapter The network adapter whose attachment needs to be changed
2311 * @param pCfg Configuration node for the device
2312 * @param pLunL0 To store the pointer to the LUN#0.
2313 * @param pInst The instance CFGM node
2314 * @param fAttachDetach To determine if the network attachment should
2315 * be attached/detached after/before
2316 * configuration.
2317 *
2318 * @note Locks the Console object for writing.
2319 */
2320/*static*/ int Console::configNetwork(Console *pThis, const char *pszDevice,
2321 unsigned uInstance, unsigned uLun,
2322 INetworkAdapter *aNetworkAdapter,
2323 PCFGMNODE pCfg, PCFGMNODE pLunL0,
2324 PCFGMNODE pInst, bool fAttachDetach)
2325{
2326 int rc = VINF_SUCCESS;
2327
2328 AutoCaller autoCaller(pThis);
2329 AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED);
2330
2331 /*
2332 * Locking the object before doing VMR3* calls is quite safe here, since
2333 * we're on EMT. Write lock is necessary because we indirectly modify the
2334 * meAttachmentType member.
2335 */
2336 AutoWriteLock alock(pThis COMMA_LOCKVAL_SRC_POS);
2337
2338 PVM pVM = pThis->mpVM;
2339 BSTR str = NULL;
2340
2341#define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } } while (0)
2342#define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0)
2343#define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%#x\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0)
2344
2345 HRESULT hrc;
2346 ComPtr<IMachine> pMachine = pThis->machine();
2347
2348 ComPtr<IVirtualBox> virtualBox;
2349 hrc = pMachine->COMGETTER(Parent)(virtualBox.asOutParam());
2350 H();
2351
2352 ComPtr<IHost> host;
2353 hrc = virtualBox->COMGETTER(Host)(host.asOutParam());
2354 H();
2355
2356 BOOL fSniffer;
2357 hrc = aNetworkAdapter->COMGETTER(TraceEnabled)(&fSniffer);
2358 H();
2359
2360 if (fAttachDetach && fSniffer)
2361 {
2362 const char *pszNetDriver = "IntNet";
2363 if (pThis->meAttachmentType[uInstance] == NetworkAttachmentType_NAT)
2364 pszNetDriver = "NAT";
2365#if !defined(VBOX_WITH_NETFLT) && defined(RT_OS_LINUX)
2366 if (pThis->meAttachmentType[uInstance] == NetworkAttachmentType_Bridged)
2367 pszNetDriver = "HostInterface";
2368#endif
2369
2370 rc = PDMR3DriverDetach(pVM, pszDevice, uInstance, uLun, pszNetDriver, 0, 0 /*fFlags*/);
2371 if (rc == VINF_PDM_NO_DRIVER_ATTACHED_TO_LUN)
2372 rc = VINF_SUCCESS;
2373 AssertLogRelRCReturn(rc, rc);
2374
2375 pLunL0 = CFGMR3GetChildF(pInst, "LUN#%u", uLun);
2376 PCFGMNODE pLunAD = CFGMR3GetChildF(pLunL0, "AttachedDriver");
2377 if (pLunAD)
2378 {
2379 CFGMR3RemoveNode(pLunAD);
2380 }
2381 else
2382 {
2383 CFGMR3RemoveNode(pLunL0);
2384 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
2385 rc = CFGMR3InsertString(pLunL0, "Driver", "NetSniffer"); RC_CHECK();
2386 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
2387 hrc = aNetworkAdapter->COMGETTER(TraceFile)(&str); H();
2388 if (str) /* check convention for indicating default file. */
2389 {
2390 rc = CFGMR3InsertStringW(pCfg, "File", str); RC_CHECK();
2391 }
2392 STR_FREE();
2393 }
2394 }
2395 else if (fAttachDetach && !fSniffer)
2396 {
2397 rc = PDMR3DeviceDetach(pVM, pszDevice, uInstance, uLun, 0 /*fFlags*/);
2398 if (rc == VINF_PDM_NO_DRIVER_ATTACHED_TO_LUN)
2399 rc = VINF_SUCCESS;
2400 AssertLogRelRCReturn(rc, rc);
2401
2402 /* nuke anything which might have been left behind. */
2403 CFGMR3RemoveNode(CFGMR3GetChildF(pInst, "LUN#%u", uLun));
2404 }
2405 else if (!fAttachDetach && fSniffer)
2406 {
2407 /* insert the sniffer filter driver. */
2408 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
2409 rc = CFGMR3InsertString(pLunL0, "Driver", "NetSniffer"); RC_CHECK();
2410 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
2411 hrc = aNetworkAdapter->COMGETTER(TraceFile)(&str); H();
2412 if (str) /* check convention for indicating default file. */
2413 {
2414 rc = CFGMR3InsertStringW(pCfg, "File", str); RC_CHECK();
2415 }
2416 STR_FREE();
2417 }
2418
2419 Bstr networkName, trunkName, trunkType;
2420 NetworkAttachmentType_T eAttachmentType;
2421 hrc = aNetworkAdapter->COMGETTER(AttachmentType)(&eAttachmentType); H();
2422 switch (eAttachmentType)
2423 {
2424 case NetworkAttachmentType_Null:
2425 break;
2426
2427 case NetworkAttachmentType_NAT:
2428 {
2429 if (fSniffer)
2430 {
2431 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
2432 }
2433 else
2434 {
2435 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
2436 }
2437 rc = CFGMR3InsertString(pLunL0, "Driver", "NAT"); RC_CHECK();
2438 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
2439
2440 /* Configure TFTP prefix and boot filename. */
2441 hrc = virtualBox->COMGETTER(HomeFolder)(&str); H();
2442 if (str && *str)
2443 {
2444 rc = CFGMR3InsertStringF(pCfg, "TFTPPrefix", "%ls%c%s", str, RTPATH_DELIMITER, "TFTP"); RC_CHECK();
2445 }
2446 STR_FREE();
2447 hrc = pMachine->COMGETTER(Name)(&str); H();
2448 rc = CFGMR3InsertStringF(pCfg, "BootFile", "%ls.pxe", str); RC_CHECK();
2449 STR_FREE();
2450
2451 hrc = aNetworkAdapter->COMGETTER(NATNetwork)(&str); H();
2452 if (str && *str)
2453 {
2454 rc = CFGMR3InsertStringW(pCfg, "Network", str); RC_CHECK();
2455 /* NAT uses its own DHCP implementation */
2456 //networkName = Bstr(psz);
2457 }
2458 STR_FREE();
2459 break;
2460 }
2461
2462 case NetworkAttachmentType_Bridged:
2463 {
2464#if (defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)) && !defined(VBOX_WITH_NETFLT)
2465 hrc = pThis->attachToTapInterface(aNetworkAdapter);
2466 if (FAILED(hrc))
2467 {
2468 switch (hrc)
2469 {
2470 case VERR_ACCESS_DENIED:
2471 return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
2472 "Failed to open '/dev/net/tun' for read/write access. Please check the "
2473 "permissions of that node. Either run 'chmod 0666 /dev/net/tun' or "
2474 "change the group of that node and make yourself a member of that group. Make "
2475 "sure that these changes are permanent, especially if you are "
2476 "using udev"));
2477 default:
2478 AssertMsgFailed(("Could not attach to host interface! Bad!\n"));
2479 return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
2480 "Failed to initialize Host Interface Networking"));
2481 }
2482 }
2483
2484 Assert((int)pThis->maTapFD[uInstance] >= 0);
2485 if ((int)pThis->maTapFD[uInstance] >= 0)
2486 {
2487 if (fSniffer)
2488 {
2489 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
2490 }
2491 else
2492 {
2493 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
2494 }
2495 rc = CFGMR3InsertString(pLunL0, "Driver", "HostInterface"); RC_CHECK();
2496 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
2497 rc = CFGMR3InsertInteger(pCfg, "FileHandle", pThis->maTapFD[uInstance]); RC_CHECK();
2498 }
2499
2500#elif defined(VBOX_WITH_NETFLT)
2501 /*
2502 * This is the new VBoxNetFlt+IntNet stuff.
2503 */
2504 if (fSniffer)
2505 {
2506 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
2507 }
2508 else
2509 {
2510 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
2511 }
2512
2513 Bstr HifName;
2514 hrc = aNetworkAdapter->COMGETTER(HostInterface)(HifName.asOutParam());
2515 if (FAILED(hrc))
2516 {
2517 LogRel(("NetworkAttachmentType_Bridged: COMGETTER(HostInterface) failed, hrc (0x%x)", hrc));
2518 H();
2519 }
2520
2521 Utf8Str HifNameUtf8(HifName);
2522 const char *pszHifName = HifNameUtf8.raw();
2523
2524# if defined(RT_OS_DARWIN)
2525 /* The name is on the form 'ifX: long name', chop it off at the colon. */
2526 char szTrunk[8];
2527 strncpy(szTrunk, pszHifName, sizeof(szTrunk));
2528 char *pszColon = (char *)memchr(szTrunk, ':', sizeof(szTrunk));
2529 if (!pszColon)
2530 {
2531 hrc = aNetworkAdapter->Detach(); H();
2532 return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
2533 N_("Malformed host interface networking name '%ls'"),
2534 HifName.raw());
2535 }
2536 *pszColon = '\0';
2537 const char *pszTrunk = szTrunk;
2538
2539# elif defined(RT_OS_SOLARIS)
2540 /* The name is on the form format 'ifX[:1] - long name, chop it off at space. */
2541 char szTrunk[256];
2542 strlcpy(szTrunk, pszHifName, sizeof(szTrunk));
2543 char *pszSpace = (char *)memchr(szTrunk, ' ', sizeof(szTrunk));
2544
2545 /*
2546 * Currently don't bother about malformed names here for the sake of people using
2547 * VBoxManage and setting only the NIC name from there. If there is a space we
2548 * chop it off and proceed, otherwise just use whatever we've got.
2549 */
2550 if (pszSpace)
2551 *pszSpace = '\0';
2552
2553 /* Chop it off at the colon (zone naming eg: e1000g:1 we need only the e1000g) */
2554 char *pszColon = (char *)memchr(szTrunk, ':', sizeof(szTrunk));
2555 if (pszColon)
2556 *pszColon = '\0';
2557
2558 const char *pszTrunk = szTrunk;
2559
2560# elif defined(RT_OS_WINDOWS)
2561 ComPtr<IHostNetworkInterface> hostInterface;
2562 hrc = host->FindHostNetworkInterfaceByName(HifName, hostInterface.asOutParam());
2563 if (!SUCCEEDED(hrc))
2564 {
2565 AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: FindByName failed, rc=%Rhrc (0x%x)", hrc, hrc));
2566 return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
2567 N_("Inexistent host networking interface, name '%ls'"),
2568 HifName.raw());
2569 }
2570
2571 HostNetworkInterfaceType_T eIfType;
2572 hrc = hostInterface->COMGETTER(InterfaceType)(&eIfType);
2573 if (FAILED(hrc))
2574 {
2575 LogRel(("NetworkAttachmentType_Bridged: COMGETTER(InterfaceType) failed, hrc (0x%x)", hrc));
2576 H();
2577 }
2578
2579 if (eIfType != HostNetworkInterfaceType_Bridged)
2580 {
2581 return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
2582 N_("Interface ('%ls') is not a Bridged Adapter interface"),
2583 HifName.raw());
2584 }
2585
2586 hrc = hostInterface->COMGETTER(Id)(&str);
2587 if (FAILED(hrc))
2588 {
2589 LogRel(("NetworkAttachmentType_Bridged: COMGETTER(Id) failed, hrc (0x%x)", hrc));
2590 H();
2591 }
2592 Guid hostIFGuid(str);
2593 STR_FREE();
2594
2595 INetCfg *pNc;
2596 ComPtr<INetCfgComponent> pAdaptorComponent;
2597 LPWSTR pszApp;
2598 int rc = VERR_INTNET_FLT_IF_NOT_FOUND;
2599
2600 hrc = VBoxNetCfgWinQueryINetCfg(FALSE /*fGetWriteLock*/,
2601 L"VirtualBox",
2602 &pNc,
2603 &pszApp);
2604 Assert(hrc == S_OK);
2605 if (hrc == S_OK)
2606 {
2607 /* get the adapter's INetCfgComponent*/
2608 hrc = VBoxNetCfgWinGetComponentByGuid(pNc, &GUID_DEVCLASS_NET, (GUID*)hostIFGuid.ptr(), pAdaptorComponent.asOutParam());
2609 if (hrc != S_OK)
2610 {
2611 VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
2612 LogRel(("NetworkAttachmentType_Bridged: VBoxNetCfgWinGetComponentByGuid failed, hrc (0x%x)", hrc));
2613 H();
2614 }
2615 }
2616#define VBOX_WIN_BINDNAME_PREFIX "\\DEVICE\\"
2617 char szTrunkName[INTNET_MAX_TRUNK_NAME];
2618 char *pszTrunkName = szTrunkName;
2619 wchar_t * pswzBindName;
2620 hrc = pAdaptorComponent->GetBindName(&pswzBindName);
2621 Assert(hrc == S_OK);
2622 if (hrc == S_OK)
2623 {
2624 int cwBindName = (int)wcslen(pswzBindName) + 1;
2625 int cbFullBindNamePrefix = sizeof(VBOX_WIN_BINDNAME_PREFIX);
2626 if (sizeof(szTrunkName) > cbFullBindNamePrefix + cwBindName)
2627 {
2628 strcpy(szTrunkName, VBOX_WIN_BINDNAME_PREFIX);
2629 pszTrunkName += cbFullBindNamePrefix-1;
2630 if (!WideCharToMultiByte(CP_ACP, 0, pswzBindName, cwBindName, pszTrunkName,
2631 sizeof(szTrunkName) - cbFullBindNamePrefix + 1, NULL, NULL))
2632 {
2633 DWORD err = GetLastError();
2634 hrc = HRESULT_FROM_WIN32(err);
2635 AssertMsgFailed(("%hrc=%Rhrc %#x\n", hrc, hrc));
2636 AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: WideCharToMultiByte failed, hr=%Rhrc (0x%x) err=%u\n", hrc, hrc, err));
2637 }
2638 }
2639 else
2640 {
2641 AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: insufficient szTrunkName buffer space\n"));
2642 /** @todo set appropriate error code */
2643 hrc = E_FAIL;
2644 }
2645
2646 if (hrc != S_OK)
2647 {
2648 AssertFailed();
2649 CoTaskMemFree(pswzBindName);
2650 VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
2651 H();
2652 }
2653
2654 /* we're not freeing the bind name since we'll use it later for detecting wireless*/
2655 }
2656 else
2657 {
2658 VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
2659 AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: VBoxNetCfgWinGetComponentByGuid failed, hrc (0x%x)", hrc));
2660 H();
2661 }
2662 const char *pszTrunk = szTrunkName;
2663 /* we're not releasing the INetCfg stuff here since we use it later to figure out whether it is wireless */
2664
2665# elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
2666# if defined(RT_OS_FREEBSD)
2667 /*
2668 * If we bridge to a tap interface open it the `old' direct way.
2669 * This works and performs better than bridging a physical
2670 * interface via the current FreeBSD vboxnetflt implementation.
2671 */
2672 if (!strncmp(pszHifName, "tap", sizeof "tap" - 1)) {
2673 hrc = pThis->attachToTapInterface(aNetworkAdapter);
2674 if (FAILED(hrc))
2675 {
2676 switch (hrc)
2677 {
2678 case VERR_ACCESS_DENIED:
2679 return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
2680 "Failed to open '/dev/%s' for read/write access. Please check the "
2681 "permissions of that node, and that the net.link.tap.user_open "
2682 "sysctl is set. Either run 'chmod 0666 /dev/%s' or "
2683 "change the group of that node to vboxusers and make yourself "
2684 "a member of that group. Make sure that these changes are permanent."), pszHifName, pszHifName);
2685 default:
2686 AssertMsgFailed(("Could not attach to tap interface! Bad!\n"));
2687 return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
2688 "Failed to initialize Host Interface Networking"));
2689 }
2690 }
2691
2692 Assert((int)pThis->maTapFD[uInstance] >= 0);
2693 if ((int)pThis->maTapFD[uInstance] >= 0)
2694 {
2695 rc = CFGMR3InsertString(pLunL0, "Driver", "HostInterface"); RC_CHECK();
2696 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
2697 rc = CFGMR3InsertInteger(pCfg, "FileHandle", pThis->maTapFD[uInstance]); RC_CHECK();
2698 }
2699 break;
2700 }
2701# endif
2702 /** @todo Check for malformed names. */
2703 const char *pszTrunk = pszHifName;
2704
2705 /* Issue a warning if the interface is down */
2706 {
2707 int iSock = socket(AF_INET, SOCK_DGRAM, 0);
2708 if (iSock >= 0)
2709 {
2710 struct ifreq Req;
2711
2712 memset(&Req, 0, sizeof(Req));
2713 strncpy(Req.ifr_name, pszHifName, sizeof(Req.ifr_name) - 1);
2714 if (ioctl(iSock, SIOCGIFFLAGS, &Req) >= 0)
2715 if ((Req.ifr_flags & IFF_UP) == 0)
2716 {
2717 setVMRuntimeErrorCallbackF(pVM, pThis, 0, "BridgedInterfaceDown", "Bridged interface %s is down. Guest will not be able to use this interface", pszHifName);
2718 }
2719
2720 close(iSock);
2721 }
2722 }
2723
2724# else
2725# error "PORTME (VBOX_WITH_NETFLT)"
2726# endif
2727
2728 rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK();
2729 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
2730 rc = CFGMR3InsertString(pCfg, "Trunk", pszTrunk); RC_CHECK();
2731 rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_NetFlt);
2732 RC_CHECK();
2733 char szNetwork[INTNET_MAX_NETWORK_NAME];
2734 RTStrPrintf(szNetwork, sizeof(szNetwork), "HostInterfaceNetworking-%s", pszHifName);
2735 rc = CFGMR3InsertString(pCfg, "Network", szNetwork); RC_CHECK();
2736 networkName = Bstr(szNetwork);
2737 trunkName = Bstr(pszTrunk);
2738 trunkType = Bstr(TRUNKTYPE_NETFLT);
2739
2740# if defined(RT_OS_DARWIN)
2741 /** @todo Come up with a better deal here. Problem is that IHostNetworkInterface is completely useless here. */
2742 if ( strstr(pszHifName, "Wireless")
2743 || strstr(pszHifName, "AirPort" ))
2744 {
2745 rc = CFGMR3InsertInteger(pCfg, "SharedMacOnWire", true); RC_CHECK();
2746 }
2747# elif defined(RT_OS_LINUX)
2748 int iSock = socket(AF_INET, SOCK_DGRAM, 0);
2749 if (iSock >= 0)
2750 {
2751 struct iwreq WRq;
2752
2753 memset(&WRq, 0, sizeof(WRq));
2754 strncpy(WRq.ifr_name, pszHifName, IFNAMSIZ);
2755 bool fSharedMacOnWire = ioctl(iSock, SIOCGIWNAME, &WRq) >= 0;
2756 close(iSock);
2757 if (fSharedMacOnWire)
2758 {
2759 rc = CFGMR3InsertInteger(pCfg, "SharedMacOnWire", true);
2760 RC_CHECK();
2761 Log(("Set SharedMacOnWire\n"));
2762 }
2763 else
2764 Log(("Failed to get wireless name\n"));
2765 }
2766 else
2767 Log(("Failed to open wireless socket\n"));
2768# elif defined(RT_OS_FREEBSD)
2769 int iSock = socket(AF_INET, SOCK_DGRAM, 0);
2770 if (iSock >= 0)
2771 {
2772 struct ieee80211req WReq;
2773 uint8_t abData[32];
2774
2775 memset(&WReq, 0, sizeof(WReq));
2776 strncpy(WReq.i_name, pszHifName, sizeof(WReq.i_name));
2777 WReq.i_type = IEEE80211_IOC_SSID;
2778 WReq.i_val = -1;
2779 WReq.i_data = abData;
2780 WReq.i_len = sizeof(abData);
2781
2782 bool fSharedMacOnWire = ioctl(iSock, SIOCG80211, &WReq) >= 0;
2783 close(iSock);
2784 if (fSharedMacOnWire)
2785 {
2786 rc = CFGMR3InsertInteger(pCfg, "SharedMacOnWire", true);
2787 RC_CHECK();
2788 Log(("Set SharedMacOnWire\n"));
2789 }
2790 else
2791 Log(("Failed to get wireless name\n"));
2792 }
2793 else
2794 Log(("Failed to open wireless socket\n"));
2795# elif defined(RT_OS_WINDOWS)
2796# define DEVNAME_PREFIX L"\\\\.\\"
2797 /* we are getting the medium type via IOCTL_NDIS_QUERY_GLOBAL_STATS Io Control
2798 * there is a pretty long way till there though since we need to obtain the symbolic link name
2799 * for the adapter device we are going to query given the device Guid */
2800
2801
2802 /* prepend the "\\\\.\\" to the bind name to obtain the link name */
2803
2804 wchar_t FileName[MAX_PATH];
2805 wcscpy(FileName, DEVNAME_PREFIX);
2806 wcscpy((wchar_t*)(((char*)FileName) + sizeof(DEVNAME_PREFIX) - sizeof(FileName[0])), pswzBindName);
2807
2808 /* open the device */
2809 HANDLE hDevice = CreateFile(FileName,
2810 GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
2811 NULL,
2812 OPEN_EXISTING,
2813 FILE_ATTRIBUTE_NORMAL,
2814 NULL);
2815
2816 if (hDevice != INVALID_HANDLE_VALUE)
2817 {
2818 bool fSharedMacOnWire = false;
2819
2820 /* now issue the OID_GEN_PHYSICAL_MEDIUM query */
2821 DWORD Oid = OID_GEN_PHYSICAL_MEDIUM;
2822 NDIS_PHYSICAL_MEDIUM PhMedium;
2823 DWORD cbResult;
2824 if (DeviceIoControl(hDevice,
2825 IOCTL_NDIS_QUERY_GLOBAL_STATS,
2826 &Oid,
2827 sizeof(Oid),
2828 &PhMedium,
2829 sizeof(PhMedium),
2830 &cbResult,
2831 NULL))
2832 {
2833 /* that was simple, now examine PhMedium */
2834 if ( PhMedium == NdisPhysicalMediumWirelessWan
2835 || PhMedium == NdisPhysicalMediumWirelessLan
2836 || PhMedium == NdisPhysicalMediumNative802_11
2837 || PhMedium == NdisPhysicalMediumBluetooth)
2838 fSharedMacOnWire = true;
2839 }
2840 else
2841 {
2842 int winEr = GetLastError();
2843 LogRel(("Console::configConstructor: DeviceIoControl failed, err (0x%x), ignoring\n", winEr));
2844 Assert(winEr == ERROR_INVALID_PARAMETER || winEr == ERROR_NOT_SUPPORTED || winEr == ERROR_BAD_COMMAND);
2845 }
2846 CloseHandle(hDevice);
2847
2848 if (fSharedMacOnWire)
2849 {
2850 Log(("this is a wireless adapter"));
2851 rc = CFGMR3InsertInteger(pCfg, "SharedMacOnWire", true); RC_CHECK();
2852 Log(("Set SharedMacOnWire\n"));
2853 }
2854 else
2855 Log(("this is NOT a wireless adapter"));
2856 }
2857 else
2858 {
2859 int winEr = GetLastError();
2860 AssertLogRelMsgFailed(("Console::configConstructor: CreateFile failed, err (0x%x), ignoring\n", winEr));
2861 }
2862
2863 CoTaskMemFree(pswzBindName);
2864
2865 pAdaptorComponent.setNull();
2866 /* release the pNc finally */
2867 VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
2868# else
2869 /** @todo PORTME: wireless detection */
2870# endif
2871
2872# if defined(RT_OS_SOLARIS)
2873# if 0 /* bird: this is a bit questionable and might cause more trouble than its worth. */
2874 /* Zone access restriction, don't allow snopping the global zone. */
2875 zoneid_t ZoneId = getzoneid();
2876 if (ZoneId != GLOBAL_ZONEID)
2877 {
2878 rc = CFGMR3InsertInteger(pCfg, "IgnoreAllPromisc", true); RC_CHECK();
2879 }
2880# endif
2881# endif
2882
2883#elif defined(RT_OS_WINDOWS) /* not defined NetFlt */
2884 /* NOTHING TO DO HERE */
2885#elif defined(RT_OS_LINUX)
2886/// @todo aleksey: is there anything to be done here?
2887#elif defined(RT_OS_FREEBSD)
2888/** @todo FreeBSD: Check out this later (HIF networking). */
2889#else
2890# error "Port me"
2891#endif
2892 break;
2893 }
2894
2895 case NetworkAttachmentType_Internal:
2896 {
2897 hrc = aNetworkAdapter->COMGETTER(InternalNetwork)(&str); H();
2898 if (str && *str)
2899 {
2900 if (fSniffer)
2901 {
2902 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0);
2903 RC_CHECK();
2904 }
2905 else
2906 {
2907 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0);
2908 RC_CHECK();
2909 }
2910 rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK();
2911 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
2912 rc = CFGMR3InsertStringW(pCfg, "Network", str); RC_CHECK();
2913 rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_WhateverNone); RC_CHECK();
2914 networkName = str;
2915 trunkType = Bstr(TRUNKTYPE_WHATEVER);
2916 }
2917 STR_FREE();
2918 break;
2919 }
2920
2921 case NetworkAttachmentType_HostOnly:
2922 {
2923 if (fSniffer)
2924 {
2925 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0);
2926 RC_CHECK();
2927 }
2928 else
2929 {
2930 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0);
2931 RC_CHECK();
2932 }
2933
2934 rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK();
2935 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
2936
2937 Bstr HifName;
2938 hrc = aNetworkAdapter->COMGETTER(HostInterface)(HifName.asOutParam());
2939 if (FAILED(hrc))
2940 {
2941 LogRel(("NetworkAttachmentType_HostOnly: COMGETTER(HostInterface) failed, hrc (0x%x)\n", hrc));
2942 H();
2943 }
2944
2945 Utf8Str HifNameUtf8(HifName);
2946 const char *pszHifName = HifNameUtf8.raw();
2947 LogRel(("NetworkAttachmentType_HostOnly: COMGETTER(HostInterface): %s\n", pszHifName));
2948 ComPtr<IHostNetworkInterface> hostInterface;
2949 rc = host->FindHostNetworkInterfaceByName(HifName, hostInterface.asOutParam());
2950 if (!SUCCEEDED(rc))
2951 {
2952 LogRel(("NetworkAttachmentType_HostOnly: FindByName failed, rc (0x%x)\n", rc));
2953 return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
2954 N_("Inexistent host networking interface, name '%ls'"),
2955 HifName.raw());
2956 }
2957
2958 char szNetwork[INTNET_MAX_NETWORK_NAME];
2959 RTStrPrintf(szNetwork, sizeof(szNetwork), "HostInterfaceNetworking-%s", pszHifName);
2960
2961#if defined(RT_OS_WINDOWS)
2962# ifndef VBOX_WITH_NETFLT
2963 hrc = E_NOTIMPL;
2964 LogRel(("NetworkAttachmentType_HostOnly: Not Implemented\n"));
2965 H();
2966# else /* defined VBOX_WITH_NETFLT*/
2967 /** @todo r=bird: Put this in a function. */
2968
2969 HostNetworkInterfaceType_T eIfType;
2970 hrc = hostInterface->COMGETTER(InterfaceType)(&eIfType);
2971 if (FAILED(hrc))
2972 {
2973 LogRel(("NetworkAttachmentType_HostOnly: COMGETTER(InterfaceType) failed, hrc (0x%x)\n", hrc));
2974 H();
2975 }
2976
2977 if (eIfType != HostNetworkInterfaceType_HostOnly)
2978 return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
2979 N_("Interface ('%ls') is not a Host-Only Adapter interface"),
2980 HifName.raw());
2981
2982 hrc = hostInterface->COMGETTER(Id)(&str);
2983 if (FAILED(hrc))
2984 {
2985 LogRel(("NetworkAttachmentType_HostOnly: COMGETTER(Id) failed, hrc (0x%x)\n", hrc));
2986 H();
2987 }
2988 Guid hostIFGuid(str);
2989 STR_FREE();
2990
2991 INetCfg *pNc;
2992 ComPtr<INetCfgComponent> pAdaptorComponent;
2993 LPWSTR pszApp;
2994 rc = VERR_INTNET_FLT_IF_NOT_FOUND;
2995
2996 hrc = VBoxNetCfgWinQueryINetCfg(FALSE,
2997 L"VirtualBox",
2998 &pNc,
2999 &pszApp);
3000 Assert(hrc == S_OK);
3001 if (hrc == S_OK)
3002 {
3003 /* get the adapter's INetCfgComponent*/
3004 hrc = VBoxNetCfgWinGetComponentByGuid(pNc, &GUID_DEVCLASS_NET, (GUID*)hostIFGuid.ptr(), pAdaptorComponent.asOutParam());
3005 if (hrc != S_OK)
3006 {
3007 VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
3008 LogRel(("NetworkAttachmentType_HostOnly: VBoxNetCfgWinGetComponentByGuid failed, hrc=%Rhrc (0x%x)\n", hrc, hrc));
3009 H();
3010 }
3011 }
3012#define VBOX_WIN_BINDNAME_PREFIX "\\DEVICE\\"
3013 char szTrunkName[INTNET_MAX_TRUNK_NAME];
3014 char *pszTrunkName = szTrunkName;
3015 wchar_t * pswzBindName;
3016 hrc = pAdaptorComponent->GetBindName(&pswzBindName);
3017 Assert(hrc == S_OK);
3018 if (hrc == S_OK)
3019 {
3020 int cwBindName = (int)wcslen(pswzBindName) + 1;
3021 int cbFullBindNamePrefix = sizeof(VBOX_WIN_BINDNAME_PREFIX);
3022 if (sizeof(szTrunkName) > cbFullBindNamePrefix + cwBindName)
3023 {
3024 strcpy(szTrunkName, VBOX_WIN_BINDNAME_PREFIX);
3025 pszTrunkName += cbFullBindNamePrefix-1;
3026 if (!WideCharToMultiByte(CP_ACP, 0, pswzBindName, cwBindName, pszTrunkName,
3027 sizeof(szTrunkName) - cbFullBindNamePrefix + 1, NULL, NULL))
3028 {
3029 DWORD err = GetLastError();
3030 hrc = HRESULT_FROM_WIN32(err);
3031 AssertLogRelMsgFailed(("NetworkAttachmentType_HostOnly: WideCharToMultiByte failed, hr=%Rhrc (0x%x) err=%u\n", hrc, hrc, err));
3032 }
3033 }
3034 else
3035 {
3036 AssertLogRelMsgFailed(("NetworkAttachmentType_HostOnly: insufficient szTrunkName buffer space\n"));
3037 /** @todo set appropriate error code */
3038 hrc = E_FAIL;
3039 }
3040
3041 if (hrc != S_OK)
3042 {
3043 AssertFailed();
3044 CoTaskMemFree(pswzBindName);
3045 VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
3046 H();
3047 }
3048 }
3049 else
3050 {
3051 VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
3052 AssertLogRelMsgFailed(("NetworkAttachmentType_HostOnly: VBoxNetCfgWinGetComponentByGuid failed, hrc=%Rhrc (0x%x)\n", hrc, hrc));
3053 H();
3054 }
3055
3056
3057 CoTaskMemFree(pswzBindName);
3058
3059 pAdaptorComponent.setNull();
3060 /* release the pNc finally */
3061 VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/);
3062
3063 const char *pszTrunk = szTrunkName;
3064
3065 rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_NetAdp); RC_CHECK();
3066 rc = CFGMR3InsertString(pCfg, "Trunk", pszTrunk); RC_CHECK();
3067 rc = CFGMR3InsertString(pCfg, "Network", szNetwork); RC_CHECK();
3068 networkName = Bstr(szNetwork);
3069 trunkName = Bstr(pszTrunk);
3070 trunkType = TRUNKTYPE_NETADP;
3071# endif /* defined VBOX_WITH_NETFLT*/
3072#elif defined(RT_OS_DARWIN)
3073 rc = CFGMR3InsertString(pCfg, "Trunk", pszHifName); RC_CHECK();
3074 rc = CFGMR3InsertString(pCfg, "Network", szNetwork); RC_CHECK();
3075 rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_NetAdp); RC_CHECK();
3076 networkName = Bstr(szNetwork);
3077 trunkName = Bstr(pszHifName);
3078 trunkType = TRUNKTYPE_NETADP;
3079#else
3080 rc = CFGMR3InsertString(pCfg, "Trunk", pszHifName); RC_CHECK();
3081 rc = CFGMR3InsertString(pCfg, "Network", szNetwork); RC_CHECK();
3082 rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_NetFlt); RC_CHECK();
3083 networkName = Bstr(szNetwork);
3084 trunkName = Bstr(pszHifName);
3085 trunkType = TRUNKTYPE_NETFLT;
3086#endif
3087#if !defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
3088
3089 Bstr tmpAddr, tmpMask;
3090
3091 hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPAddress", pszHifName), tmpAddr.asOutParam());
3092 if (SUCCEEDED(hrc) && !tmpAddr.isEmpty())
3093 {
3094 hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPNetMask", pszHifName), tmpMask.asOutParam());
3095 if (SUCCEEDED(hrc) && !tmpMask.isEmpty())
3096 hrc = hostInterface->EnableStaticIpConfig(tmpAddr, tmpMask);
3097 else
3098 hrc = hostInterface->EnableStaticIpConfig(tmpAddr,
3099 Bstr(VBOXNET_IPV4MASK_DEFAULT));
3100 }
3101 else
3102 {
3103 /* Grab the IP number from the 'vboxnetX' instance number (see netif.h) */
3104 hrc = hostInterface->EnableStaticIpConfig(getDefaultIPv4Address(Bstr(pszHifName)),
3105 Bstr(VBOXNET_IPV4MASK_DEFAULT));
3106 }
3107
3108 ComAssertComRC(hrc); /** @todo r=bird: Why this isn't fatal? (H()) */
3109
3110 hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6Address", pszHifName), tmpAddr.asOutParam());
3111 if (SUCCEEDED(hrc))
3112 hrc = virtualBox->GetExtraData(BstrFmt("HostOnly/%s/IPV6NetMask", pszHifName), tmpMask.asOutParam());
3113 if (SUCCEEDED(hrc) && !tmpAddr.isEmpty() && !tmpMask.isEmpty())
3114 {
3115 hrc = hostInterface->EnableStaticIpConfigV6(tmpAddr, Utf8Str(tmpMask).toUInt32());
3116 ComAssertComRC(hrc); /** @todo r=bird: Why this isn't fatal? (H()) */
3117 }
3118#endif
3119 break;
3120 }
3121
3122 default:
3123 AssertMsgFailed(("should not get here!\n"));
3124 break;
3125 }
3126
3127 /*
3128 * Attempt to attach the driver.
3129 */
3130 switch (eAttachmentType)
3131 {
3132 case NetworkAttachmentType_Null:
3133 break;
3134
3135 case NetworkAttachmentType_Bridged:
3136 case NetworkAttachmentType_Internal:
3137 case NetworkAttachmentType_HostOnly:
3138 case NetworkAttachmentType_NAT:
3139 {
3140 if (SUCCEEDED(hrc) && SUCCEEDED(rc))
3141 {
3142 if (fAttachDetach)
3143 {
3144 rc = PDMR3DriverAttach(pVM, pszDevice, uInstance, uLun, 0 /*fFlags*/, NULL /* ppBase */);
3145 AssertRC(rc);
3146 }
3147
3148 {
3149 /** @todo pritesh: get the dhcp server name from the
3150 * previous network configuration and then stop the server
3151 * else it may conflict with the dhcp server running with
3152 * the current attachment type
3153 */
3154 /* Stop the hostonly DHCP Server */
3155 }
3156
3157 if (!networkName.isNull())
3158 {
3159 /*
3160 * Until we implement service reference counters DHCP Server will be stopped
3161 * by DHCPServerRunner destructor.
3162 */
3163 ComPtr<IDHCPServer> dhcpServer;
3164 hrc = virtualBox->FindDHCPServerByNetworkName(networkName.mutableRaw(), dhcpServer.asOutParam());
3165 if (SUCCEEDED(hrc))
3166 {
3167 /* there is a DHCP server available for this network */
3168 BOOL fEnabled;
3169 hrc = dhcpServer->COMGETTER(Enabled)(&fEnabled);
3170 if (FAILED(hrc))
3171 {
3172 LogRel(("DHCP svr: COMGETTER(Enabled) failed, hrc (%Rhrc)", hrc));
3173 H();
3174 }
3175
3176 if (fEnabled)
3177 hrc = dhcpServer->Start(networkName, trunkName, trunkType);
3178 }
3179 else
3180 hrc = S_OK;
3181 }
3182 }
3183
3184 break;
3185 }
3186
3187 default:
3188 AssertMsgFailed(("should not get here!\n"));
3189 break;
3190 }
3191
3192 pThis->meAttachmentType[uInstance] = eAttachmentType;
3193
3194#undef STR_FREE
3195#undef H
3196#undef RC_CHECK
3197
3198 return VINF_SUCCESS;
3199}
3200
3201#ifdef VBOX_WITH_GUEST_PROPS
3202/**
3203 * Set an array of guest properties
3204 */
3205static void configSetProperties(VMMDev * const pVMMDev, void *names,
3206 void *values, void *timestamps, void *flags)
3207{
3208 VBOXHGCMSVCPARM parms[4];
3209
3210 parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
3211 parms[0].u.pointer.addr = names;
3212 parms[0].u.pointer.size = 0; /* We don't actually care. */
3213 parms[1].type = VBOX_HGCM_SVC_PARM_PTR;
3214 parms[1].u.pointer.addr = values;
3215 parms[1].u.pointer.size = 0; /* We don't actually care. */
3216 parms[2].type = VBOX_HGCM_SVC_PARM_PTR;
3217 parms[2].u.pointer.addr = timestamps;
3218 parms[2].u.pointer.size = 0; /* We don't actually care. */
3219 parms[3].type = VBOX_HGCM_SVC_PARM_PTR;
3220 parms[3].u.pointer.addr = flags;
3221 parms[3].u.pointer.size = 0; /* We don't actually care. */
3222
3223 pVMMDev->hgcmHostCall ("VBoxGuestPropSvc", guestProp::SET_PROPS_HOST, 4,
3224 &parms[0]);
3225}
3226
3227/**
3228 * Set a single guest property
3229 */
3230static void configSetProperty(VMMDev * const pVMMDev, const char *pszName,
3231 const char *pszValue, const char *pszFlags)
3232{
3233 VBOXHGCMSVCPARM parms[4];
3234
3235 AssertPtrReturnVoid(pszName);
3236 AssertPtrReturnVoid(pszValue);
3237 AssertPtrReturnVoid(pszFlags);
3238 parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
3239 parms[0].u.pointer.addr = (void *)pszName;
3240 parms[0].u.pointer.size = strlen(pszName) + 1;
3241 parms[1].type = VBOX_HGCM_SVC_PARM_PTR;
3242 parms[1].u.pointer.addr = (void *)pszValue;
3243 parms[1].u.pointer.size = strlen(pszValue) + 1;
3244 parms[2].type = VBOX_HGCM_SVC_PARM_PTR;
3245 parms[2].u.pointer.addr = (void *)pszFlags;
3246 parms[2].u.pointer.size = strlen(pszFlags) + 1;
3247 pVMMDev->hgcmHostCall ("VBoxGuestPropSvc", guestProp::SET_PROP_HOST, 3,
3248 &parms[0]);
3249}
3250
3251/**
3252 * Set the global flags value by calling the service
3253 * @returns the status returned by the call to the service
3254 *
3255 * @param pTable the service instance handle
3256 * @param eFlags the flags to set
3257 */
3258int configSetGlobalPropertyFlags(VMMDev * const pVMMDev,
3259 guestProp::ePropFlags eFlags)
3260{
3261 VBOXHGCMSVCPARM paParm;
3262 paParm.setUInt32(eFlags);
3263 int rc = pVMMDev->hgcmHostCall ("VBoxGuestPropSvc",
3264 guestProp::SET_GLOBAL_FLAGS_HOST, 1,
3265 &paParm);
3266 if (RT_FAILURE(rc))
3267 {
3268 char szFlags[guestProp::MAX_FLAGS_LEN];
3269 if (RT_FAILURE(writeFlags(eFlags, szFlags)))
3270 Log(("Failed to set the global flags.\n"));
3271 else
3272 Log(("Failed to set the global flags \"%s\".\n", szFlags));
3273 }
3274 return rc;
3275}
3276#endif /* VBOX_WITH_GUEST_PROPS */
3277
3278/**
3279 * Set up the Guest Property service, populate it with properties read from
3280 * the machine XML and set a couple of initial properties.
3281 */
3282/* static */ int Console::configGuestProperties(void *pvConsole)
3283{
3284#ifdef VBOX_WITH_GUEST_PROPS
3285 AssertReturn(pvConsole, VERR_GENERAL_FAILURE);
3286 ComObjPtr<Console> pConsole = static_cast <Console *> (pvConsole);
3287
3288 /* Load the service */
3289 int rc = pConsole->mVMMDev->hgcmLoadService ("VBoxGuestPropSvc", "VBoxGuestPropSvc");
3290
3291 if (RT_FAILURE(rc))
3292 {
3293 LogRel(("VBoxGuestPropSvc is not available. rc = %Rrc\n", rc));
3294 /* That is not a fatal failure. */
3295 rc = VINF_SUCCESS;
3296 }
3297 else
3298 {
3299 /*
3300 * Initialize built-in properties that can be changed and saved.
3301 *
3302 * These are typically transient properties that the guest cannot
3303 * change.
3304 */
3305
3306 /* Sysprep execution by VBoxService. */
3307 configSetProperty(pConsole->mVMMDev,
3308 "/VirtualBox/HostGuest/SysprepExec", "",
3309 "TRANSIENT, RDONLYGUEST");
3310 configSetProperty(pConsole->mVMMDev,
3311 "/VirtualBox/HostGuest/SysprepArgs", "",
3312 "TRANSIENT, RDONLYGUEST");
3313
3314 /*
3315 * Pull over the properties from the server.
3316 */
3317 SafeArray<BSTR> namesOut;
3318 SafeArray<BSTR> valuesOut;
3319 SafeArray<ULONG64> timestampsOut;
3320 SafeArray<BSTR> flagsOut;
3321 HRESULT hrc;
3322 hrc = pConsole->mControl->PullGuestProperties(ComSafeArrayAsOutParam(namesOut),
3323 ComSafeArrayAsOutParam(valuesOut),
3324 ComSafeArrayAsOutParam(timestampsOut),
3325 ComSafeArrayAsOutParam(flagsOut));
3326 AssertMsgReturn(SUCCEEDED(hrc), ("hrc=%Rrc\n", hrc), VERR_GENERAL_FAILURE);
3327 size_t cProps = namesOut.size();
3328 size_t cAlloc = cProps + 1;
3329 if ( valuesOut.size() != cProps
3330 || timestampsOut.size() != cProps
3331 || flagsOut.size() != cProps
3332 )
3333 AssertFailedReturn(VERR_INVALID_PARAMETER);
3334
3335 char **papszNames, **papszValues, **papszFlags;
3336 char szEmpty[] = "";
3337 ULONG64 *pau64Timestamps;
3338 papszNames = (char **)RTMemTmpAllocZ(sizeof(void *) * cAlloc);
3339 papszValues = (char **)RTMemTmpAllocZ(sizeof(void *) * cAlloc);
3340 pau64Timestamps = (ULONG64 *)RTMemTmpAllocZ(sizeof(ULONG64) * cAlloc);
3341 papszFlags = (char **)RTMemTmpAllocZ(sizeof(void *) * cAlloc);
3342 if (papszNames && papszValues && pau64Timestamps && papszFlags)
3343 {
3344 for (unsigned i = 0; RT_SUCCESS(rc) && i < cProps; ++i)
3345 {
3346 AssertPtrReturn(namesOut[i], VERR_INVALID_PARAMETER);
3347 rc = RTUtf16ToUtf8(namesOut[i], &papszNames[i]);
3348 if (RT_FAILURE(rc))
3349 break;
3350 if (valuesOut[i])
3351 rc = RTUtf16ToUtf8(valuesOut[i], &papszValues[i]);
3352 else
3353 papszValues[i] = szEmpty;
3354 if (RT_FAILURE(rc))
3355 break;
3356 pau64Timestamps[i] = timestampsOut[i];
3357 if (flagsOut[i])
3358 rc = RTUtf16ToUtf8(flagsOut[i], &papszFlags[i]);
3359 else
3360 papszFlags[i] = szEmpty;
3361 }
3362 if (RT_SUCCESS(rc))
3363 configSetProperties(pConsole->mVMMDev,
3364 (void *)papszNames,
3365 (void *)papszValues,
3366 (void *)pau64Timestamps,
3367 (void *)papszFlags);
3368 for (unsigned i = 0; i < cProps; ++i)
3369 {
3370 RTStrFree(papszNames[i]);
3371 if (valuesOut[i])
3372 RTStrFree(papszValues[i]);
3373 if (flagsOut[i])
3374 RTStrFree(papszFlags[i]);
3375 }
3376 }
3377 else
3378 rc = VERR_NO_MEMORY;
3379 RTMemTmpFree(papszNames);
3380 RTMemTmpFree(papszValues);
3381 RTMemTmpFree(pau64Timestamps);
3382 RTMemTmpFree(papszFlags);
3383 AssertRCReturn(rc, rc);
3384
3385 /*
3386 * These properties have to be set before pulling over the properties
3387 * from the machine XML, to ensure that properties saved in the XML
3388 * will override them.
3389 */
3390 /* Set the VBox version string as a guest property */
3391 configSetProperty(pConsole->mVMMDev, "/VirtualBox/HostInfo/VBoxVer",
3392 VBOX_VERSION_STRING, "TRANSIENT, RDONLYGUEST");
3393 /* Set the VBox SVN revision as a guest property */
3394 configSetProperty(pConsole->mVMMDev, "/VirtualBox/HostInfo/VBoxRev",
3395 RTBldCfgRevisionStr(), "TRANSIENT, RDONLYGUEST");
3396
3397 /*
3398 * Register the host notification callback
3399 */
3400 HGCMSVCEXTHANDLE hDummy;
3401 HGCMHostRegisterServiceExtension(&hDummy, "VBoxGuestPropSvc",
3402 Console::doGuestPropNotification,
3403 pvConsole);
3404
3405#ifdef VBOX_WITH_GUEST_PROPS_RDONLY_GUEST
3406 rc = configSetGlobalPropertyFlags(pConsole->mVMMDev,
3407 guestProp::RDONLYGUEST);
3408 AssertRCReturn(rc, rc);
3409#endif
3410
3411 Log(("Set VBoxGuestPropSvc property store\n"));
3412 }
3413 return VINF_SUCCESS;
3414#else /* !VBOX_WITH_GUEST_PROPS */
3415 return VERR_NOT_SUPPORTED;
3416#endif /* !VBOX_WITH_GUEST_PROPS */
3417}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette