VirtualBox

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

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

BridgedInterfaceDown warning added.

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