VirtualBox

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

Last change on this file since 11814 was 11814, checked in by vboxsync, 16 years ago

Initial commit of the NetFlt driver for Windows

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 89.4 KB
Line 
1/** $Id: ConsoleImpl2.cpp 11814 2008-08-29 12:47:44Z 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
6 * finds problematic to optimize so we can disable optimizations
7 * and later, perhaps, find a real solution for it.
8 */
9
10/*
11 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
12 *
13 * This file is part of VirtualBox Open Source Edition (OSE), as
14 * available from http://www.virtualbox.org. This file is free software;
15 * you can redistribute it and/or modify it under the terms of the GNU
16 * General Public License (GPL) as published by the Free Software
17 * Foundation, in version 2 as it comes in the "COPYING" file of the
18 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
19 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
22 * Clara, CA 95054 USA or visit http://www.sun.com if you need
23 * additional information or have any questions.
24 */
25
26/*******************************************************************************
27* Header Files *
28*******************************************************************************/
29#include "ConsoleImpl.h"
30#include "DisplayImpl.h"
31#include "VMMDev.h"
32
33// generated header
34#include "SchemaDefs.h"
35
36#include "Logging.h"
37
38#include <iprt/string.h>
39#include <iprt/path.h>
40#include <iprt/dir.h>
41#include <iprt/param.h>
42
43#include <VBox/vmapi.h>
44#include <VBox/err.h>
45#include <VBox/version.h>
46#include <VBox/HostServices/VBoxClipboardSvc.h>
47#ifdef VBOX_WITH_GUEST_PROPS
48# include <VBox/HostServices/GuestPropertySvc.h>
49# include <VBox/com/defs.h>
50# include <VBox/com/array.h>
51#endif /* VBOX_WITH_GUEST_PROPS */
52#include <VBox/intnet.h>
53
54
55/*
56 * VC++ 8 / amd64 has some serious trouble with this function.
57 * As a temporary measure, we'll drop global optimizations.
58 */
59#if defined(_MSC_VER) && defined(RT_ARCH_AMD64)
60# pragma optimize("g", off)
61#endif
62
63/**
64 * Construct the VM configuration tree (CFGM).
65 *
66 * This is a callback for VMR3Create() call. It is called from CFGMR3Init()
67 * in the emulation thread (EMT). Any per thread COM/XPCOM initialization
68 * is done here.
69 *
70 * @param pVM VM handle.
71 * @param pvConsole Pointer to the VMPowerUpTask object.
72 * @return VBox status code.
73 *
74 * @note Locks the Console object for writing.
75 */
76DECLCALLBACK(int) Console::configConstructor(PVM pVM, void *pvConsole)
77{
78 LogFlowFuncEnter();
79 /* Note: hardcoded assumption about number of slots; see rom bios */
80 bool afPciDeviceNo[15] = {false};
81
82#if !defined (VBOX_WITH_XPCOM)
83 {
84 /* initialize COM */
85 HRESULT hrc = CoInitializeEx(NULL,
86 COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE |
87 COINIT_SPEED_OVER_MEMORY);
88 LogFlow (("Console::configConstructor(): CoInitializeEx()=%08X\n", hrc));
89 AssertComRCReturn (hrc, VERR_GENERAL_FAILURE);
90 }
91#endif
92
93 AssertReturn (pvConsole, VERR_GENERAL_FAILURE);
94 ComObjPtr <Console> pConsole = static_cast <Console *> (pvConsole);
95
96 AutoCaller autoCaller (pConsole);
97 AssertComRCReturn (autoCaller.rc(), VERR_ACCESS_DENIED);
98
99 /* lock the console because we widely use internal fields and methods */
100 AutoWriteLock alock (pConsole);
101
102 ComPtr <IMachine> pMachine = pConsole->machine();
103
104 int rc;
105 HRESULT hrc;
106 char *psz = NULL;
107 BSTR str = NULL;
108
109#define STR_CONV() do { rc = RTUtf16ToUtf8(str, &psz); RC_CHECK(); } while (0)
110#define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } if (psz) { RTStrFree(psz); psz = NULL; } } while (0)
111#define RC_CHECK() do { if (VBOX_FAILURE(rc)) { AssertMsgFailed(("rc=%Vrc\n", rc)); STR_FREE(); return rc; } } while (0)
112#define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%#x\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0)
113
114 /*
115 * Get necessary objects and frequently used parameters.
116 */
117 ComPtr<IVirtualBox> virtualBox;
118 hrc = pMachine->COMGETTER(Parent)(virtualBox.asOutParam()); H();
119
120 ComPtr<IHost> host;
121 hrc = virtualBox->COMGETTER(Host)(host.asOutParam()); H();
122
123 ComPtr <ISystemProperties> systemProperties;
124 hrc = virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam()); H();
125
126 ComPtr<IBIOSSettings> biosSettings;
127 hrc = pMachine->COMGETTER(BIOSSettings)(biosSettings.asOutParam()); H();
128
129 Guid uuid;
130 hrc = pMachine->COMGETTER(Id)(uuid.asOutParam()); H();
131 PCRTUUID pUuid = uuid.raw();
132
133 ULONG cRamMBs;
134 hrc = pMachine->COMGETTER(MemorySize)(&cRamMBs); H();
135
136
137 /*
138 * Get root node first.
139 * This is the only node in the tree.
140 */
141 PCFGMNODE pRoot = CFGMR3GetRoot(pVM);
142 Assert(pRoot);
143
144 /*
145 * Set the root level values.
146 */
147 hrc = pMachine->COMGETTER(Name)(&str); H();
148 STR_CONV();
149 rc = CFGMR3InsertString(pRoot, "Name", psz); RC_CHECK();
150 STR_FREE();
151 rc = CFGMR3InsertBytes(pRoot, "UUID", pUuid, sizeof(*pUuid)); RC_CHECK();
152 rc = CFGMR3InsertInteger(pRoot, "RamSize", cRamMBs * _1M); RC_CHECK();
153 rc = CFGMR3InsertInteger(pRoot, "TimerMillies", 10); RC_CHECK();
154 rc = CFGMR3InsertInteger(pRoot, "RawR3Enabled", 1); /* boolean */ RC_CHECK();
155 rc = CFGMR3InsertInteger(pRoot, "RawR0Enabled", 1); /* boolean */ RC_CHECK();
156 /** @todo Config: RawR0, PATMEnabled and CASMEnabled needs attention later. */
157 rc = CFGMR3InsertInteger(pRoot, "PATMEnabled", 1); /* boolean */ RC_CHECK();
158 rc = CFGMR3InsertInteger(pRoot, "CSAMEnabled", 1); /* boolean */ RC_CHECK();
159
160 /* hardware virtualization extensions */
161 TSBool_T hwVirtExEnabled;
162 BOOL fHWVirtExEnabled;
163 hrc = pMachine->COMGETTER(HWVirtExEnabled)(&hwVirtExEnabled); H();
164 if (hwVirtExEnabled == TSBool_Default)
165 {
166 /* check the default value */
167 hrc = systemProperties->COMGETTER(HWVirtExEnabled)(&fHWVirtExEnabled); H();
168 }
169 else
170 fHWVirtExEnabled = (hwVirtExEnabled == TSBool_True);
171#ifndef RT_OS_DARWIN /** @todo Implement HWVirtExt on darwin. See #1865. */
172 if (fHWVirtExEnabled)
173 {
174 PCFGMNODE pHWVirtExt;
175 rc = CFGMR3InsertNode(pRoot, "HWVirtExt", &pHWVirtExt); RC_CHECK();
176 rc = CFGMR3InsertInteger(pHWVirtExt, "Enabled", 1); RC_CHECK();
177 }
178#endif
179
180 /* Nested paging (VT-x/AMD-V) */
181 BOOL fEnableNestedPaging = false;
182 hrc = pMachine->COMGETTER(HWVirtExNestedPagingEnabled)(&fEnableNestedPaging); H();
183 rc = CFGMR3InsertInteger(pRoot, "EnableNestedPaging", fEnableNestedPaging); RC_CHECK();
184
185 /* Physical Address Extension (PAE) */
186 BOOL fEnablePAE = false;
187 hrc = pMachine->COMGETTER(PAEEnabled)(&fEnablePAE); H();
188 rc = CFGMR3InsertInteger(pRoot, "EnablePAE", fEnablePAE); RC_CHECK();
189
190 BOOL fIOAPIC;
191 hrc = biosSettings->COMGETTER(IOAPICEnabled)(&fIOAPIC); H();
192
193 BOOL fPXEDebug;
194 hrc = biosSettings->COMGETTER(PXEDebugEnabled)(&fPXEDebug); H();
195
196 /*
197 * Virtual IDE controller type.
198 */
199 IDEControllerType_T controllerType;
200 BOOL fPIIX4;
201 hrc = biosSettings->COMGETTER(IDEControllerType)(&controllerType); H();
202 switch (controllerType)
203 {
204 case IDEControllerType_PIIX3:
205 fPIIX4 = FALSE;
206 break;
207 case IDEControllerType_PIIX4:
208 fPIIX4 = TRUE;
209 break;
210 default:
211 AssertMsgFailed(("Invalid IDE controller type '%d'", controllerType));
212 return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
213 N_("Invalid IDE controller type '%d'"), controllerType);
214 }
215
216 /*
217 * PDM config.
218 * Load drivers in VBoxC.[so|dll]
219 */
220 PCFGMNODE pPDM;
221 PCFGMNODE pDrivers;
222 PCFGMNODE pMod;
223 rc = CFGMR3InsertNode(pRoot, "PDM", &pPDM); RC_CHECK();
224 rc = CFGMR3InsertNode(pPDM, "Drivers", &pDrivers); RC_CHECK();
225 rc = CFGMR3InsertNode(pDrivers, "VBoxC", &pMod); RC_CHECK();
226#ifdef VBOX_WITH_XPCOM
227 // VBoxC is located in the components subdirectory
228 char szPathVBoxC[RTPATH_MAX];
229 rc = RTPathAppPrivateArch(szPathVBoxC, RTPATH_MAX - sizeof("/components/VBoxC")); AssertRC(rc);
230 strcat(szPathVBoxC, "/components/VBoxC");
231 rc = CFGMR3InsertString(pMod, "Path", szPathVBoxC); RC_CHECK();
232#else
233 rc = CFGMR3InsertString(pMod, "Path", "VBoxC"); RC_CHECK();
234#endif
235
236 /*
237 * Devices
238 */
239 PCFGMNODE pDevices = NULL; /* /Devices */
240 PCFGMNODE pDev = NULL; /* /Devices/Dev/ */
241 PCFGMNODE pInst = NULL; /* /Devices/Dev/0/ */
242 PCFGMNODE pCfg = NULL; /* /Devices/Dev/.../Config/ */
243 PCFGMNODE pLunL0 = NULL; /* /Devices/Dev/0/LUN#0/ */
244 PCFGMNODE pLunL1 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/ */
245 PCFGMNODE pLunL2 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/Config/ */
246 PCFGMNODE pIdeInst = NULL; /* /Devices/piix3ide/0/ */
247 PCFGMNODE pSataInst = NULL; /* /Devices/ahci/0/ */
248 PCFGMNODE pBiosCfg = NULL; /* /Devices/pcbios/0/Config/ */
249#ifdef VBOX_WITH_GUEST_PROPS
250 PCFGMNODE pGuestProps = NULL; /* /GuestProps */
251 PCFGMNODE pValues = NULL; /* /GuestProps/Values */
252 PCFGMNODE pTimestamps = NULL; /* /GuestProps/Timestamps */
253 PCFGMNODE pFlags = NULL; /* /GuestProps/Flags */
254#endif /* VBOX_WITH_GUEST_PROPS defined */
255
256 rc = CFGMR3InsertNode(pRoot, "Devices", &pDevices); RC_CHECK();
257
258 /*
259 * PC Arch.
260 */
261 rc = CFGMR3InsertNode(pDevices, "pcarch", &pDev); RC_CHECK();
262 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
263 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
264 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
265
266 /*
267 * PC Bios.
268 */
269 rc = CFGMR3InsertNode(pDevices, "pcbios", &pDev); RC_CHECK();
270 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
271 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
272 rc = CFGMR3InsertNode(pInst, "Config", &pBiosCfg); RC_CHECK();
273 rc = CFGMR3InsertInteger(pBiosCfg, "RamSize", cRamMBs * _1M); RC_CHECK();
274 rc = CFGMR3InsertString(pBiosCfg, "HardDiskDevice", "piix3ide"); RC_CHECK();
275 rc = CFGMR3InsertString(pBiosCfg, "FloppyDevice", "i82078"); RC_CHECK();
276 rc = CFGMR3InsertInteger(pBiosCfg, "IOAPIC", fIOAPIC); RC_CHECK();
277 rc = CFGMR3InsertInteger(pBiosCfg, "PXEDebug", fPXEDebug); RC_CHECK();
278 rc = CFGMR3InsertBytes(pBiosCfg, "UUID", pUuid, sizeof(*pUuid)); RC_CHECK();
279
280 DeviceType_T bootDevice;
281 if (SchemaDefs::MaxBootPosition > 9)
282 {
283 AssertMsgFailed (("Too many boot devices %d\n",
284 SchemaDefs::MaxBootPosition));
285 return VERR_INVALID_PARAMETER;
286 }
287
288 for (ULONG pos = 1; pos <= SchemaDefs::MaxBootPosition; pos ++)
289 {
290 hrc = pMachine->GetBootOrder(pos, &bootDevice); H();
291
292 char szParamName[] = "BootDeviceX";
293 szParamName[sizeof (szParamName) - 2] = ((char (pos - 1)) + '0');
294
295 const char *pszBootDevice;
296 switch (bootDevice)
297 {
298 case DeviceType_Null:
299 pszBootDevice = "NONE";
300 break;
301 case DeviceType_HardDisk:
302 pszBootDevice = "IDE";
303 break;
304 case DeviceType_DVD:
305 pszBootDevice = "DVD";
306 break;
307 case DeviceType_Floppy:
308 pszBootDevice = "FLOPPY";
309 break;
310 case DeviceType_Network:
311 pszBootDevice = "LAN";
312 break;
313 default:
314 AssertMsgFailed(("Invalid bootDevice=%d\n", bootDevice));
315 return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
316 N_("Invalid boot device '%d'"), bootDevice);
317 }
318 rc = CFGMR3InsertString(pBiosCfg, szParamName, pszBootDevice); RC_CHECK();
319 }
320
321 /*
322 * The time offset
323 */
324 LONG64 timeOffset;
325 hrc = biosSettings->COMGETTER(TimeOffset)(&timeOffset); H();
326 PCFGMNODE pTMNode;
327 rc = CFGMR3InsertNode(pRoot, "TM", &pTMNode); RC_CHECK();
328 rc = CFGMR3InsertInteger(pTMNode, "UTCOffset", timeOffset * 1000000); RC_CHECK();
329
330 /*
331 * DMA
332 */
333 rc = CFGMR3InsertNode(pDevices, "8237A", &pDev); RC_CHECK();
334 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
335 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
336
337 /*
338 * PCI bus.
339 */
340 rc = CFGMR3InsertNode(pDevices, "pci", &pDev); /* piix3 */ RC_CHECK();
341 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
342 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
343 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
344 rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
345
346 /*
347 * PS/2 keyboard & mouse.
348 */
349 rc = CFGMR3InsertNode(pDevices, "pckbd", &pDev); RC_CHECK();
350 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
351 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
352 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
353
354 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
355 rc = CFGMR3InsertString(pLunL0, "Driver", "KeyboardQueue"); RC_CHECK();
356 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
357 rc = CFGMR3InsertInteger(pCfg, "QueueSize", 64); RC_CHECK();
358
359 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
360 rc = CFGMR3InsertString(pLunL1, "Driver", "MainKeyboard"); RC_CHECK();
361 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
362 Keyboard *pKeyboard = pConsole->mKeyboard;
363 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pKeyboard); RC_CHECK();
364
365 rc = CFGMR3InsertNode(pInst, "LUN#1", &pLunL0); RC_CHECK();
366 rc = CFGMR3InsertString(pLunL0, "Driver", "MouseQueue"); RC_CHECK();
367 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
368 rc = CFGMR3InsertInteger(pCfg, "QueueSize", 128); RC_CHECK();
369
370 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
371 rc = CFGMR3InsertString(pLunL1, "Driver", "MainMouse"); RC_CHECK();
372 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
373 Mouse *pMouse = pConsole->mMouse;
374 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pMouse); RC_CHECK();
375
376 /*
377 * i82078 Floppy drive controller
378 */
379 ComPtr<IFloppyDrive> floppyDrive;
380 hrc = pMachine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam()); H();
381 BOOL fFdcEnabled;
382 hrc = floppyDrive->COMGETTER(Enabled)(&fFdcEnabled); H();
383 if (fFdcEnabled)
384 {
385 rc = CFGMR3InsertNode(pDevices, "i82078", &pDev); RC_CHECK();
386 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
387 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); RC_CHECK();
388 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
389 rc = CFGMR3InsertInteger(pCfg, "IRQ", 6); RC_CHECK();
390 rc = CFGMR3InsertInteger(pCfg, "DMA", 2); RC_CHECK();
391 rc = CFGMR3InsertInteger(pCfg, "MemMapped", 0 ); RC_CHECK();
392 rc = CFGMR3InsertInteger(pCfg, "IOBase", 0x3f0); RC_CHECK();
393
394 /* Attach the status driver */
395 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
396 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
397 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
398 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapFDLeds[0]); RC_CHECK();
399 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
400 rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
401
402 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
403
404 ComPtr<IFloppyImage> floppyImage;
405 hrc = floppyDrive->GetImage(floppyImage.asOutParam()); H();
406 if (floppyImage)
407 {
408 pConsole->meFloppyState = DriveState_ImageMounted;
409 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
410 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
411 rc = CFGMR3InsertString(pCfg, "Type", "Floppy 1.44"); RC_CHECK();
412 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK();
413
414 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
415 rc = CFGMR3InsertString(pLunL1, "Driver", "RawImage"); RC_CHECK();
416 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
417 hrc = floppyImage->COMGETTER(FilePath)(&str); H();
418 STR_CONV();
419 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
420 STR_FREE();
421 }
422 else
423 {
424 ComPtr<IHostFloppyDrive> hostFloppyDrive;
425 hrc = floppyDrive->GetHostDrive(hostFloppyDrive.asOutParam()); H();
426 if (hostFloppyDrive)
427 {
428 pConsole->meFloppyState = DriveState_HostDriveCaptured;
429 rc = CFGMR3InsertString(pLunL0, "Driver", "HostFloppy"); RC_CHECK();
430 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
431 hrc = hostFloppyDrive->COMGETTER(Name)(&str); H();
432 STR_CONV();
433 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
434 STR_FREE();
435 }
436 else
437 {
438 pConsole->meFloppyState = DriveState_NotMounted;
439 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
440 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
441 rc = CFGMR3InsertString(pCfg, "Type", "Floppy 1.44"); RC_CHECK();
442 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK();
443 }
444 }
445 }
446
447 /*
448 * ACPI
449 */
450 BOOL fACPI;
451 hrc = biosSettings->COMGETTER(ACPIEnabled)(&fACPI); H();
452 if (fACPI)
453 {
454 rc = CFGMR3InsertNode(pDevices, "acpi", &pDev); RC_CHECK();
455 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
456 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
457 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
458 rc = CFGMR3InsertInteger(pCfg, "RamSize", cRamMBs * _1M); RC_CHECK();
459 rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
460 rc = CFGMR3InsertInteger(pCfg, "FdcEnabled", fFdcEnabled); RC_CHECK();
461 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 7); RC_CHECK();
462 Assert(!afPciDeviceNo[7]);
463 afPciDeviceNo[7] = true;
464 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
465
466 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
467 rc = CFGMR3InsertString(pLunL0, "Driver", "ACPIHost"); RC_CHECK();
468 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
469 }
470
471 /*
472 * i8254 Programmable Interval Timer And Dummy Speaker
473 */
474 rc = CFGMR3InsertNode(pDevices, "i8254", &pDev); RC_CHECK();
475 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
476 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
477#ifdef DEBUG
478 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
479#endif
480
481 /*
482 * i8259 Programmable Interrupt Controller.
483 */
484 rc = CFGMR3InsertNode(pDevices, "i8259", &pDev); RC_CHECK();
485 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
486 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
487 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
488
489 /*
490 * Advanced Programmable Interrupt Controller.
491 */
492 rc = CFGMR3InsertNode(pDevices, "apic", &pDev); RC_CHECK();
493 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
494 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
495 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
496 rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
497
498 if (fIOAPIC)
499 {
500 /*
501 * I/O Advanced Programmable Interrupt Controller.
502 */
503 rc = CFGMR3InsertNode(pDevices, "ioapic", &pDev); RC_CHECK();
504 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
505 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
506 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
507 }
508
509 /*
510 * RTC MC146818.
511 */
512 rc = CFGMR3InsertNode(pDevices, "mc146818", &pDev); RC_CHECK();
513 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
514 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
515
516 /*
517 * VGA.
518 */
519 rc = CFGMR3InsertNode(pDevices, "vga", &pDev); RC_CHECK();
520 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
521 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
522 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 2); RC_CHECK();
523 Assert(!afPciDeviceNo[2]);
524 afPciDeviceNo[2] = true;
525 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
526 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
527 hrc = pMachine->COMGETTER(VRAMSize)(&cRamMBs); H();
528 rc = CFGMR3InsertInteger(pCfg, "VRamSize", cRamMBs * _1M); RC_CHECK();
529
530 /*
531 * BIOS logo
532 */
533 BOOL fFadeIn;
534 hrc = biosSettings->COMGETTER(LogoFadeIn)(&fFadeIn); H();
535 rc = CFGMR3InsertInteger(pCfg, "FadeIn", fFadeIn ? 1 : 0); RC_CHECK();
536 BOOL fFadeOut;
537 hrc = biosSettings->COMGETTER(LogoFadeOut)(&fFadeOut); H();
538 rc = CFGMR3InsertInteger(pCfg, "FadeOut", fFadeOut ? 1: 0); RC_CHECK();
539 ULONG logoDisplayTime;
540 hrc = biosSettings->COMGETTER(LogoDisplayTime)(&logoDisplayTime); H();
541 rc = CFGMR3InsertInteger(pCfg, "LogoTime", logoDisplayTime); RC_CHECK();
542 Bstr logoImagePath;
543 hrc = biosSettings->COMGETTER(LogoImagePath)(logoImagePath.asOutParam()); H();
544 rc = CFGMR3InsertString(pCfg, "LogoFile", logoImagePath ? Utf8Str(logoImagePath) : ""); RC_CHECK();
545
546 /*
547 * Boot menu
548 */
549 BIOSBootMenuMode_T bootMenuMode;
550 int value;
551 biosSettings->COMGETTER(BootMenuMode)(&bootMenuMode);
552 switch (bootMenuMode)
553 {
554 case BIOSBootMenuMode_Disabled:
555 value = 0;
556 break;
557 case BIOSBootMenuMode_MenuOnly:
558 value = 1;
559 break;
560 default:
561 value = 2;
562 }
563 rc = CFGMR3InsertInteger(pCfg, "ShowBootMenu", value); RC_CHECK();
564
565 /* Custom VESA mode list */
566 unsigned cModes = 0;
567 for (unsigned iMode = 1; iMode <= 16; iMode++)
568 {
569 char szExtraDataKey[sizeof("CustomVideoModeXX")];
570 RTStrPrintf(szExtraDataKey, sizeof(szExtraDataKey), "CustomVideoMode%d", iMode);
571 hrc = pMachine->GetExtraData(Bstr(szExtraDataKey), &str); H();
572 if (!str || !*str)
573 break;
574 STR_CONV();
575 rc = CFGMR3InsertString(pCfg, szExtraDataKey, psz);
576 STR_FREE();
577 cModes++;
578 }
579 rc = CFGMR3InsertInteger(pCfg, "CustomVideoModes", cModes);
580
581 /* VESA height reduction */
582 ULONG ulHeightReduction;
583 IFramebuffer *pFramebuffer = pConsole->getDisplay()->getFramebuffer();
584 if (pFramebuffer)
585 {
586 hrc = pFramebuffer->COMGETTER(HeightReduction)(&ulHeightReduction); H();
587 }
588 else
589 {
590 /* If framebuffer is not available, there is no height reduction. */
591 ulHeightReduction = 0;
592 }
593 rc = CFGMR3InsertInteger(pCfg, "HeightReduction", ulHeightReduction); RC_CHECK();
594
595 /* Attach the display. */
596 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
597 rc = CFGMR3InsertString(pLunL0, "Driver", "MainDisplay"); RC_CHECK();
598 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
599 Display *pDisplay = pConsole->mDisplay;
600 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pDisplay); RC_CHECK();
601
602 /*
603 * IDE (update this when the main interface changes)
604 */
605 rc = CFGMR3InsertNode(pDevices, "piix3ide", &pDev); /* piix3 */ RC_CHECK();
606 rc = CFGMR3InsertNode(pDev, "0", &pIdeInst); RC_CHECK();
607 rc = CFGMR3InsertInteger(pIdeInst, "Trusted", 1); /* boolean */ RC_CHECK();
608 rc = CFGMR3InsertInteger(pIdeInst, "PCIDeviceNo", 1); RC_CHECK();
609 Assert(!afPciDeviceNo[1]);
610 afPciDeviceNo[1] = true;
611 rc = CFGMR3InsertInteger(pIdeInst, "PCIFunctionNo", 1); RC_CHECK();
612 rc = CFGMR3InsertNode(pIdeInst, "Config", &pCfg); RC_CHECK();
613 rc = CFGMR3InsertInteger(pCfg, "PIIX4", fPIIX4); /* boolean */ RC_CHECK();
614
615 /* Attach the status driver */
616 rc = CFGMR3InsertNode(pIdeInst, "LUN#999", &pLunL0); RC_CHECK();
617 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
618 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
619 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapIDELeds[0]);RC_CHECK();
620 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
621 rc = CFGMR3InsertInteger(pCfg, "Last", 3); RC_CHECK();
622
623 /*
624 * SATA controller
625 */
626 ComPtr<ISATAController> sataController;
627 hrc = pMachine->COMGETTER(SATAController)(sataController.asOutParam());
628 BOOL enabled = FALSE;
629
630 if (sataController)
631 {
632 hrc = sataController->COMGETTER(Enabled)(&enabled); H();
633
634 if (enabled)
635 {
636 rc = CFGMR3InsertNode(pDevices, "ahci", &pDev); RC_CHECK();
637 rc = CFGMR3InsertNode(pDev, "0", &pSataInst); RC_CHECK();
638 rc = CFGMR3InsertInteger(pSataInst, "Trusted", 1); RC_CHECK();
639 rc = CFGMR3InsertInteger(pSataInst, "PCIDeviceNo", 13); RC_CHECK();
640 Assert(!afPciDeviceNo[13]);
641 afPciDeviceNo[13] = true;
642 rc = CFGMR3InsertInteger(pSataInst, "PCIFunctionNo", 0); RC_CHECK();
643 rc = CFGMR3InsertNode(pSataInst, "Config", &pCfg); RC_CHECK();
644
645 ULONG cPorts = 0;
646 hrc = sataController->COMGETTER(PortCount)(&cPorts); H();
647 rc = CFGMR3InsertInteger(pCfg, "PortCount", cPorts); RC_CHECK();
648
649 /* Needed configuration values for the bios. */
650 rc = CFGMR3InsertString(pBiosCfg, "SataHardDiskDevice", "ahci"); RC_CHECK();
651
652 for (uint32_t i = 0; i < 4; i++)
653 {
654 static const char *s_apszConfig[4] =
655 { "PrimaryMaster", "PrimarySlave", "SecondaryMaster", "SecondarySlave" };
656 static const char *s_apszBiosConfig[4] =
657 { "SataPrimaryMasterLUN", "SataPrimarySlaveLUN", "SataSecondaryMasterLUN", "SataSecondarySlaveLUN" };
658
659 LONG lPortNumber = -1;
660 hrc = sataController->GetIDEEmulationPort(i, &lPortNumber); H();
661 rc = CFGMR3InsertInteger(pCfg, s_apszConfig[i], lPortNumber); RC_CHECK();
662 rc = CFGMR3InsertInteger(pBiosCfg, s_apszBiosConfig[i], lPortNumber); RC_CHECK();
663 }
664
665 /* Attach the status driver */
666 rc = CFGMR3InsertNode(pSataInst,"LUN#999", &pLunL0); RC_CHECK();
667 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
668 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
669 AssertRelease(cPorts <= RT_ELEMENTS(pConsole->mapSATALeds));
670 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapSATALeds[0]); RC_CHECK();
671 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
672 rc = CFGMR3InsertInteger(pCfg, "Last", cPorts - 1); RC_CHECK();
673 }
674 }
675
676 /* Attach the harddisks */
677 ComPtr<IHardDiskAttachmentCollection> hdaColl;
678 hrc = pMachine->COMGETTER(HardDiskAttachments)(hdaColl.asOutParam()); H();
679 ComPtr<IHardDiskAttachmentEnumerator> hdaEnum;
680 hrc = hdaColl->Enumerate(hdaEnum.asOutParam()); H();
681
682 BOOL fMore = FALSE;
683 while ( SUCCEEDED(hrc = hdaEnum->HasMore(&fMore))
684 && fMore)
685 {
686 PCFGMNODE pHardDiskCtl;
687 ComPtr<IHardDiskAttachment> hda;
688 hrc = hdaEnum->GetNext(hda.asOutParam()); H();
689 ComPtr<IHardDisk> hardDisk;
690 hrc = hda->COMGETTER(HardDisk)(hardDisk.asOutParam()); H();
691 StorageBus_T enmBus;
692 hrc = hda->COMGETTER(Bus)(&enmBus); H();
693 LONG lDev;
694 hrc = hda->COMGETTER(Device)(&lDev); H();
695 LONG lChannel;
696 hrc = hda->COMGETTER(Channel)(&lChannel); H();
697
698 int iLUN;
699 switch (enmBus)
700 {
701 case StorageBus_IDE:
702 {
703 if (lChannel >= 2 || lChannel < 0)
704 {
705 AssertMsgFailed(("invalid controller channel number: %d\n", lChannel));
706 return VERR_GENERAL_FAILURE;
707 }
708
709 if (lDev >= 2 || lDev < 0)
710 {
711 AssertMsgFailed(("invalid controller device number: %d\n", lDev));
712 return VERR_GENERAL_FAILURE;
713 }
714 iLUN = 2*lChannel + lDev;
715 pHardDiskCtl = pIdeInst;
716 }
717 break;
718 case StorageBus_SATA:
719 iLUN = lChannel;
720 pHardDiskCtl = enabled ? pSataInst : NULL;
721 break;
722 default:
723 AssertMsgFailed(("invalid disk controller type: %d\n", enmBus));
724 return VERR_GENERAL_FAILURE;
725 }
726
727 /* Can be NULL if SATA controller is not enabled and current hard disk is attached to SATA controller. */
728 if (pHardDiskCtl)
729 {
730 char szLUN[16];
731 RTStrPrintf(szLUN, sizeof(szLUN), "LUN#%d", iLUN);
732 rc = CFGMR3InsertNode(pHardDiskCtl, szLUN, &pLunL0); RC_CHECK();
733 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
734 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
735 rc = CFGMR3InsertString(pCfg, "Type", "HardDisk"); RC_CHECK();
736 rc = CFGMR3InsertInteger(pCfg, "Mountable", 0); RC_CHECK();
737
738 HardDiskStorageType_T hddType;
739 hardDisk->COMGETTER(StorageType)(&hddType);
740 if (hddType == HardDiskStorageType_VirtualDiskImage)
741 {
742 ComPtr<IVirtualDiskImage> vdiDisk = hardDisk;
743 AssertBreakStmt (!vdiDisk.isNull(), hrc = E_FAIL);
744
745 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
746 rc = CFGMR3InsertString(pLunL1, "Driver", "VBoxHDD"); RC_CHECK();
747 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
748 hrc = vdiDisk->COMGETTER(FilePath)(&str); H();
749 STR_CONV();
750 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
751 STR_FREE();
752
753 /* Create an inversed tree of parents. */
754 ComPtr<IHardDisk> parentHardDisk = hardDisk;
755 for (PCFGMNODE pParent = pCfg;;)
756 {
757 ComPtr<IHardDisk> curHardDisk;
758 hrc = parentHardDisk->COMGETTER(Parent)(curHardDisk.asOutParam()); H();
759 if (!curHardDisk)
760 break;
761
762 vdiDisk = curHardDisk;
763 AssertBreakStmt (!vdiDisk.isNull(), hrc = E_FAIL);
764
765 PCFGMNODE pCur;
766 rc = CFGMR3InsertNode(pParent, "Parent", &pCur); RC_CHECK();
767 hrc = vdiDisk->COMGETTER(FilePath)(&str); H();
768 STR_CONV();
769 rc = CFGMR3InsertString(pCur, "Path", psz); RC_CHECK();
770 STR_FREE();
771 rc = CFGMR3InsertInteger(pCur, "ReadOnly", 1); RC_CHECK();
772
773 /* next */
774 pParent = pCur;
775 parentHardDisk = curHardDisk;
776 }
777 }
778 else if (hddType == HardDiskStorageType_ISCSIHardDisk)
779 {
780 ComPtr<IISCSIHardDisk> iSCSIDisk = hardDisk;
781 AssertBreakStmt (!iSCSIDisk.isNull(), hrc = E_FAIL);
782
783 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
784 rc = CFGMR3InsertString(pLunL1, "Driver", "iSCSI"); RC_CHECK();
785 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
786
787 /* Set up the iSCSI initiator driver configuration. */
788 hrc = iSCSIDisk->COMGETTER(Target)(&str); H();
789 STR_CONV();
790 rc = CFGMR3InsertString(pCfg, "TargetName", psz); RC_CHECK();
791 STR_FREE();
792
793 ULONG64 lun;
794 hrc = iSCSIDisk->COMGETTER(Lun)(&lun); H();
795 rc = CFGMR3InsertInteger(pCfg, "LUN", lun); RC_CHECK();
796
797 hrc = iSCSIDisk->COMGETTER(Server)(&str); H();
798 STR_CONV();
799 USHORT port;
800 hrc = iSCSIDisk->COMGETTER(Port)(&port); H();
801 if (port != 0)
802 {
803 char *pszTN;
804 RTStrAPrintf(&pszTN, "%s:%u", psz, port);
805 rc = CFGMR3InsertString(pCfg, "TargetAddress", pszTN); RC_CHECK();
806 RTStrFree(pszTN);
807 }
808 else
809 {
810 rc = CFGMR3InsertString(pCfg, "TargetAddress", psz); RC_CHECK();
811 }
812 STR_FREE();
813
814 hrc = iSCSIDisk->COMGETTER(UserName)(&str); H();
815 if (str)
816 {
817 STR_CONV();
818 rc = CFGMR3InsertString(pCfg, "InitiatorUsername", psz); RC_CHECK();
819 STR_FREE();
820 }
821
822 hrc = iSCSIDisk->COMGETTER(Password)(&str); H();
823 if (str)
824 {
825 STR_CONV();
826 rc = CFGMR3InsertString(pCfg, "InitiatorSecret", psz); RC_CHECK();
827 STR_FREE();
828 }
829
830 // @todo currently there is no target username config.
831 //rc = CFGMR3InsertString(pCfg, "TargetUsername", ""); RC_CHECK();
832
833 // @todo currently there is no target password config.
834 //rc = CFGMR3InsertString(pCfg, "TargetSecret", ""); RC_CHECK();
835
836 /* The iSCSI initiator needs an attached iSCSI transport driver. */
837 rc = CFGMR3InsertNode(pLunL1, "AttachedDriver", &pLunL2); RC_CHECK();
838 rc = CFGMR3InsertString(pLunL2, "Driver", "iSCSITCP"); RC_CHECK();
839 /* Currently the transport driver has no config options. */
840 }
841 else if (hddType == HardDiskStorageType_VMDKImage)
842 {
843 ComPtr<IVMDKImage> vmdkDisk = hardDisk;
844 AssertBreakStmt (!vmdkDisk.isNull(), hrc = E_FAIL);
845
846 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
847#if 1 /* Enable new VD container code (and new VMDK), as the bugs are fixed. */
848 rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK();
849#else
850 rc = CFGMR3InsertString(pLunL1, "Driver", "VmdkHDD"); RC_CHECK();
851#endif
852 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
853 hrc = vmdkDisk->COMGETTER(FilePath)(&str); H();
854 STR_CONV();
855 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
856 STR_FREE();
857 rc = CFGMR3InsertString(pCfg, "Format", "VMDK"); RC_CHECK();
858
859 /*
860 * Create cfgm nodes for async transport driver because VMDK is currently the only
861 * one which may support async I/O. This has to be made generic based on the capabiliy flags
862 * when the new HardDisk interface is merged.
863 */
864 rc = CFGMR3InsertNode(pLunL1, "AttachedDriver", &pLunL2); RC_CHECK();
865 rc = CFGMR3InsertString(pLunL2, "Driver", "TransportAsync"); RC_CHECK();
866 /* The async transport driver has no config options yet. */
867 }
868 else if (hddType == HardDiskStorageType_CustomHardDisk)
869 {
870 ComPtr<ICustomHardDisk> customHardDisk = hardDisk;
871 AssertBreakStmt (!customHardDisk.isNull(), hrc = E_FAIL);
872
873 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
874 rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK();
875 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
876 hrc = customHardDisk->COMGETTER(Location)(&str); H();
877 STR_CONV();
878 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
879 STR_FREE();
880 hrc = customHardDisk->COMGETTER(Format)(&str); H();
881 STR_CONV();
882 rc = CFGMR3InsertString(pCfg, "Format", psz); RC_CHECK();
883 STR_FREE();
884 }
885 else if (hddType == HardDiskStorageType_VHDImage)
886 {
887 ComPtr<IVHDImage> vhdDisk = hardDisk;
888 AssertBreakStmt (!vhdDisk.isNull(), hrc = E_FAIL);
889
890 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
891 rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK();
892 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
893 hrc = vhdDisk->COMGETTER(FilePath)(&str); H();
894 STR_CONV();
895 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
896 rc = CFGMR3InsertString(pCfg, "Format", "VHD"); RC_CHECK();
897 STR_FREE();
898 }
899 else
900 AssertFailed();
901 }
902 }
903 H();
904
905 ComPtr<IDVDDrive> dvdDrive;
906 hrc = pMachine->COMGETTER(DVDDrive)(dvdDrive.asOutParam()); H();
907 if (dvdDrive)
908 {
909 // ASSUME: DVD drive is always attached to LUN#2 (i.e. secondary IDE master)
910 rc = CFGMR3InsertNode(pIdeInst, "LUN#2", &pLunL0); RC_CHECK();
911 ComPtr<IHostDVDDrive> hostDvdDrive;
912 hrc = dvdDrive->GetHostDrive(hostDvdDrive.asOutParam()); H();
913 if (hostDvdDrive)
914 {
915 pConsole->meDVDState = DriveState_HostDriveCaptured;
916 rc = CFGMR3InsertString(pLunL0, "Driver", "HostDVD"); RC_CHECK();
917 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
918 hrc = hostDvdDrive->COMGETTER(Name)(&str); H();
919 STR_CONV();
920 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
921 STR_FREE();
922 BOOL fPassthrough;
923 hrc = dvdDrive->COMGETTER(Passthrough)(&fPassthrough); H();
924 rc = CFGMR3InsertInteger(pCfg, "Passthrough", !!fPassthrough); RC_CHECK();
925 }
926 else
927 {
928 pConsole->meDVDState = DriveState_NotMounted;
929 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
930 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
931 rc = CFGMR3InsertString(pCfg, "Type", "DVD"); RC_CHECK();
932 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK();
933
934 ComPtr<IDVDImage> dvdImage;
935 hrc = dvdDrive->GetImage(dvdImage.asOutParam()); H();
936 if (dvdImage)
937 {
938 pConsole->meDVDState = DriveState_ImageMounted;
939 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
940 rc = CFGMR3InsertString(pLunL1, "Driver", "MediaISO"); RC_CHECK();
941 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
942 hrc = dvdImage->COMGETTER(FilePath)(&str); H();
943 STR_CONV();
944 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
945 STR_FREE();
946 }
947 }
948 }
949
950 /*
951 * Network adapters
952 */
953 PCFGMNODE pDevPCNet = NULL; /* PCNet-type devices */
954 rc = CFGMR3InsertNode(pDevices, "pcnet", &pDevPCNet); RC_CHECK();
955#ifdef VBOX_WITH_E1000
956 PCFGMNODE pDevE1000 = NULL; /* E1000-type devices */
957 rc = CFGMR3InsertNode(pDevices, "e1000", &pDevE1000); RC_CHECK();
958#endif
959 for (ULONG ulInstance = 0; ulInstance < SchemaDefs::NetworkAdapterCount; ulInstance++)
960 {
961 ComPtr<INetworkAdapter> networkAdapter;
962 hrc = pMachine->GetNetworkAdapter(ulInstance, networkAdapter.asOutParam()); H();
963 BOOL fEnabled = FALSE;
964 hrc = networkAdapter->COMGETTER(Enabled)(&fEnabled); H();
965 if (!fEnabled)
966 continue;
967
968 /*
969 * The virtual hardware type. Create appropriate device first.
970 */
971 NetworkAdapterType_T adapterType;
972 hrc = networkAdapter->COMGETTER(AdapterType)(&adapterType); H();
973 switch (adapterType)
974 {
975 case NetworkAdapterType_Am79C970A:
976 case NetworkAdapterType_Am79C973:
977 pDev = pDevPCNet;
978 break;
979#ifdef VBOX_WITH_E1000
980 case NetworkAdapterType_I82540EM:
981 case NetworkAdapterType_I82543GC:
982 pDev = pDevE1000;
983 break;
984#endif
985 default:
986 AssertMsgFailed(("Invalid network adapter type '%d' for slot '%d'",
987 adapterType, ulInstance));
988 return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
989 N_("Invalid network adapter type '%d' for slot '%d'"),
990 adapterType, ulInstance);
991 }
992
993 char szInstance[4]; Assert(ulInstance <= 999);
994 RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance);
995 rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK();
996 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
997 /* the first network card gets the PCI ID 3, the next 3 gets 8..10. */
998 const unsigned iPciDeviceNo = !ulInstance ? 3 : ulInstance - 1 + 8;
999 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", iPciDeviceNo); RC_CHECK();
1000 Assert(!afPciDeviceNo[iPciDeviceNo]);
1001 afPciDeviceNo[iPciDeviceNo] = true;
1002 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1003 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1004
1005 /*
1006 * The virtual hardware type. PCNet supports two types.
1007 */
1008 switch (adapterType)
1009 {
1010 case NetworkAdapterType_Am79C970A:
1011 rc = CFGMR3InsertInteger(pCfg, "Am79C973", 0); RC_CHECK();
1012 break;
1013 case NetworkAdapterType_Am79C973:
1014 rc = CFGMR3InsertInteger(pCfg, "Am79C973", 1); RC_CHECK();
1015 break;
1016 case NetworkAdapterType_I82540EM:
1017 rc = CFGMR3InsertInteger(pCfg, "AdapterType", 0); RC_CHECK();
1018 break;
1019 case NetworkAdapterType_I82543GC:
1020 rc = CFGMR3InsertInteger(pCfg, "AdapterType", 1); RC_CHECK();
1021 break;
1022 }
1023
1024 /*
1025 * Get the MAC address and convert it to binary representation
1026 */
1027 Bstr macAddr;
1028 hrc = networkAdapter->COMGETTER(MACAddress)(macAddr.asOutParam()); H();
1029 Assert(macAddr);
1030 Utf8Str macAddrUtf8 = macAddr;
1031 char *macStr = (char*)macAddrUtf8.raw();
1032 Assert(strlen(macStr) == 12);
1033 RTMAC Mac;
1034 memset(&Mac, 0, sizeof(Mac));
1035 char *pMac = (char*)&Mac;
1036 for (uint32_t i = 0; i < 6; i++)
1037 {
1038 char c1 = *macStr++ - '0';
1039 if (c1 > 9)
1040 c1 -= 7;
1041 char c2 = *macStr++ - '0';
1042 if (c2 > 9)
1043 c2 -= 7;
1044 *pMac++ = ((c1 & 0x0f) << 4) | (c2 & 0x0f);
1045 }
1046 rc = CFGMR3InsertBytes(pCfg, "MAC", &Mac, sizeof(Mac)); RC_CHECK();
1047
1048 /*
1049 * Check if the cable is supposed to be unplugged
1050 */
1051 BOOL fCableConnected;
1052 hrc = networkAdapter->COMGETTER(CableConnected)(&fCableConnected); H();
1053 rc = CFGMR3InsertInteger(pCfg, "CableConnected", fCableConnected ? 1 : 0); RC_CHECK();
1054
1055 /*
1056 * Line speed to report from custom drivers
1057 */
1058 ULONG ulLineSpeed;
1059 hrc = networkAdapter->COMGETTER(LineSpeed)(&ulLineSpeed); H();
1060 rc = CFGMR3InsertInteger(pCfg, "LineSpeed", ulLineSpeed); RC_CHECK();
1061
1062 /*
1063 * Attach the status driver.
1064 */
1065 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
1066 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1067 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1068 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapNetworkLeds[ulInstance]); RC_CHECK();
1069
1070 /*
1071 * Enable the packet sniffer if requested.
1072 */
1073 BOOL fSniffer;
1074 hrc = networkAdapter->COMGETTER(TraceEnabled)(&fSniffer); H();
1075 if (fSniffer)
1076 {
1077 /* insert the sniffer filter driver. */
1078 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1079 rc = CFGMR3InsertString(pLunL0, "Driver", "NetSniffer"); RC_CHECK();
1080 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1081 hrc = networkAdapter->COMGETTER(TraceFile)(&str); H();
1082 if (str) /* check convention for indicating default file. */
1083 {
1084 STR_CONV();
1085 rc = CFGMR3InsertString(pCfg, "File", psz); RC_CHECK();
1086 STR_FREE();
1087 }
1088 }
1089
1090 NetworkAttachmentType_T networkAttachment;
1091 hrc = networkAdapter->COMGETTER(AttachmentType)(&networkAttachment); H();
1092 switch (networkAttachment)
1093 {
1094 case NetworkAttachmentType_Null:
1095 break;
1096
1097 case NetworkAttachmentType_NAT:
1098 {
1099 if (fSniffer)
1100 {
1101 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
1102 }
1103 else
1104 {
1105 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1106 }
1107 rc = CFGMR3InsertString(pLunL0, "Driver", "NAT"); RC_CHECK();
1108 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1109 /* (Port forwarding goes here.) */
1110
1111 /* Configure TFTP prefix and boot filename. */
1112 hrc = virtualBox->COMGETTER(HomeFolder)(&str); H();
1113 STR_CONV();
1114 if (psz && *psz)
1115 {
1116 char *pszTFTPPrefix = NULL;
1117 RTStrAPrintf(&pszTFTPPrefix, "%s%c%s", psz, RTPATH_DELIMITER, "TFTP");
1118 rc = CFGMR3InsertString(pCfg, "TFTPPrefix", pszTFTPPrefix); RC_CHECK();
1119 RTStrFree(pszTFTPPrefix);
1120 }
1121 STR_FREE();
1122 hrc = pMachine->COMGETTER(Name)(&str); H();
1123 STR_CONV();
1124 char *pszBootFile = NULL;
1125 RTStrAPrintf(&pszBootFile, "%s.pxe", psz);
1126 STR_FREE();
1127 rc = CFGMR3InsertString(pCfg, "BootFile", pszBootFile); RC_CHECK();
1128 RTStrFree(pszBootFile);
1129
1130 hrc = networkAdapter->COMGETTER(NATNetwork)(&str); H();
1131 if (str)
1132 {
1133 STR_CONV();
1134 if (psz && *psz)
1135 rc = CFGMR3InsertString(pCfg, "Network", psz); RC_CHECK();
1136 STR_FREE();
1137 }
1138 break;
1139 }
1140
1141 case NetworkAttachmentType_HostInterface:
1142 {
1143 /*
1144 * Perform the attachment if required (don't return on error!)
1145 */
1146 hrc = pConsole->attachToHostInterface(networkAdapter);
1147 if (SUCCEEDED(hrc))
1148 {
1149#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
1150 Assert (pConsole->maTapFD[ulInstance] >= 0);
1151 if (pConsole->maTapFD[ulInstance] >= 0)
1152 {
1153 if (fSniffer)
1154 {
1155 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
1156 }
1157 else
1158 {
1159 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1160 }
1161 rc = CFGMR3InsertString(pLunL0, "Driver", "HostInterface"); RC_CHECK();
1162 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1163# if defined(RT_OS_SOLARIS)
1164 /* Device name/number is required for Solaris as we need it for TAP PPA. */
1165 Bstr tapDeviceName;
1166 networkAdapter->COMGETTER(HostInterface)(tapDeviceName.asOutParam());
1167 if (!tapDeviceName.isEmpty())
1168 rc = CFGMR3InsertString(pCfg, "Device", Utf8Str(tapDeviceName)); RC_CHECK();
1169
1170 /* TAP setup application/script */
1171 Bstr tapSetupApp;
1172 networkAdapter->COMGETTER(TAPSetupApplication)(tapSetupApp.asOutParam());
1173 if (!tapSetupApp.isEmpty())
1174 rc = CFGMR3InsertString(pCfg, "TAPSetupApplication", Utf8Str(tapSetupApp)); RC_CHECK();
1175
1176 /* TAP terminate application/script */
1177 Bstr tapTerminateApp;
1178 networkAdapter->COMGETTER(TAPTerminateApplication)(tapTerminateApp.asOutParam());
1179 if (!tapTerminateApp.isEmpty())
1180 rc = CFGMR3InsertString(pCfg, "TAPTerminateApplication", Utf8Str(tapTerminateApp)); RC_CHECK();
1181
1182 /* "FileHandle" must NOT be inserted here, it is done in DrvTAP.cpp */
1183
1184# ifdef VBOX_WITH_CROSSBOW
1185 /* Crossbow: needs the MAC address for setting up TAP. */
1186 rc = CFGMR3InsertBytes(pCfg, "MAC", &Mac, sizeof(Mac)); RC_CHECK();
1187# endif
1188# else
1189 rc = CFGMR3InsertInteger(pCfg, "FileHandle", pConsole->maTapFD[ulInstance]); RC_CHECK();
1190# endif
1191 }
1192
1193#elif defined(RT_OS_DARWIN)
1194 if (fSniffer)
1195 {
1196 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
1197 }
1198 else
1199 {
1200 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1201 }
1202 /* The name is on the form 'ifX: long name', chop it off at the colon. */
1203 Bstr HifName;
1204 hrc = networkAdapter->COMGETTER(HostInterface)(HifName.asOutParam()); H();
1205 Utf8Str HifNameUtf8(HifName);
1206 const char *pszHifName = HifNameUtf8.raw();
1207 char szTrunk[8];
1208 strncpy(szTrunk, pszHifName, sizeof(szTrunk));
1209 char *pszColon = (char *)memchr(szTrunk, ':', sizeof(szTrunk));
1210 if (!pszColon)
1211 {
1212 hrc = networkAdapter->Detach(); H();
1213 return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
1214 N_("Malformed host interface networking name '%ls'"),
1215 HifName.raw());
1216 }
1217 *pszColon = '\0';
1218
1219 rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK();
1220 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1221 rc = CFGMR3InsertString(pCfg, "Trunk", szTrunk); RC_CHECK();
1222 rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_NetFlt); RC_CHECK();
1223 char szNetwork[80];
1224 RTStrPrintf(szNetwork, sizeof(szNetwork), "HostInterfaceNetworking-%s\n", szTrunk);
1225 rc = CFGMR3InsertString(pCfg, "Network", szNetwork); RC_CHECK();
1226 /** @todo Come up with a better deal here. Problem is that IHostNetworkInterface is completely useless here. */
1227 if ( strstr(pszHifName, "Wireless")
1228 || strstr(pszHifName, "AirPort" ))
1229 {
1230 rc = CFGMR3InsertInteger(pCfg, "SharedMacOnWire", true); RC_CHECK();
1231 }
1232
1233#elif defined(RT_OS_WINDOWS)
1234 if (fSniffer)
1235 {
1236 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
1237 }
1238 else
1239 {
1240 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1241 }
1242 Bstr hostInterfaceName;
1243 hrc = networkAdapter->COMGETTER(HostInterface)(hostInterfaceName.asOutParam()); H();
1244 ComPtr<IHostNetworkInterfaceCollection> coll;
1245 hrc = host->COMGETTER(NetworkInterfaces)(coll.asOutParam()); H();
1246 ComPtr<IHostNetworkInterface> hostInterface;
1247 rc = coll->FindByName(hostInterfaceName, hostInterface.asOutParam());
1248 if (!SUCCEEDED(rc))
1249 {
1250 AssertMsgFailed(("Cannot get GUID for host interface '%ls'\n", hostInterfaceName));
1251 hrc = networkAdapter->Detach(); H();
1252 }
1253 else
1254 {
1255#ifndef VBOX_WITH_NETFLT_WINDOWS
1256 rc = CFGMR3InsertString(pLunL0, "Driver", "HostInterface"); RC_CHECK();
1257 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1258 rc = CFGMR3InsertString(pCfg, "HostInterfaceName", Utf8Str(hostInterfaceName)); RC_CHECK();
1259#else
1260 rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK();
1261 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1262 rc = CFGMR3InsertString(pCfg, "Trunk", Utf8Str(hostInterfaceName)); RC_CHECK();
1263 rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_NetFlt); RC_CHECK();
1264#endif
1265 Guid hostIFGuid;
1266 hrc = hostInterface->COMGETTER(Id)(hostIFGuid.asOutParam()); H();
1267 char szDriverGUID[256] = {0};
1268 /* add curly brackets */
1269 szDriverGUID[0] = '{';
1270 strcpy(szDriverGUID + 1, hostIFGuid.toString().raw());
1271 strcat(szDriverGUID, "}");
1272 rc = CFGMR3InsertBytes(pCfg, "GUID", szDriverGUID, sizeof(szDriverGUID)); RC_CHECK();
1273 }
1274#else
1275# error "Port me"
1276#endif
1277 }
1278 else
1279 {
1280 switch (hrc)
1281 {
1282#ifdef RT_OS_LINUX
1283 case VERR_ACCESS_DENIED:
1284 return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
1285 "Failed to open '/dev/net/tun' for read/write access. Please check the "
1286 "permissions of that node. Either run 'chmod 0666 /dev/net/tun' or "
1287 "change the group of that node and make yourself a member of that group. Make "
1288 "sure that these changes are permanent, especially if you are "
1289 "using udev"));
1290#endif /* RT_OS_LINUX */
1291 default:
1292 AssertMsgFailed(("Could not attach to host interface! Bad!\n"));
1293 return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
1294 "Failed to initialize Host Interface Networking"));
1295 }
1296 }
1297 break;
1298 }
1299
1300 case NetworkAttachmentType_Internal:
1301 {
1302 hrc = networkAdapter->COMGETTER(InternalNetwork)(&str); H();
1303 if (str)
1304 {
1305 STR_CONV();
1306 if (psz && *psz)
1307 {
1308 if (fSniffer)
1309 {
1310 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
1311 }
1312 else
1313 {
1314 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1315 }
1316 rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK();
1317 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1318 rc = CFGMR3InsertString(pCfg, "Network", psz); RC_CHECK();
1319 }
1320 STR_FREE();
1321 }
1322 break;
1323 }
1324
1325 default:
1326 AssertMsgFailed(("should not get here!\n"));
1327 break;
1328 }
1329 }
1330
1331 /*
1332 * Serial (UART) Ports
1333 */
1334 rc = CFGMR3InsertNode(pDevices, "serial", &pDev); RC_CHECK();
1335 for (ULONG ulInstance = 0; ulInstance < SchemaDefs::SerialPortCount; ulInstance++)
1336 {
1337 ComPtr<ISerialPort> serialPort;
1338 hrc = pMachine->GetSerialPort (ulInstance, serialPort.asOutParam()); H();
1339 BOOL fEnabled = FALSE;
1340 if (serialPort)
1341 hrc = serialPort->COMGETTER(Enabled)(&fEnabled); H();
1342 if (!fEnabled)
1343 continue;
1344
1345 char szInstance[4]; Assert(ulInstance <= 999);
1346 RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance);
1347
1348 rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK();
1349 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1350
1351 ULONG ulIRQ, ulIOBase;
1352 PortMode_T HostMode;
1353 Bstr path;
1354 BOOL fServer;
1355 hrc = serialPort->COMGETTER(HostMode)(&HostMode); H();
1356 hrc = serialPort->COMGETTER(IRQ)(&ulIRQ); H();
1357 hrc = serialPort->COMGETTER(IOBase)(&ulIOBase); H();
1358 hrc = serialPort->COMGETTER(Path)(path.asOutParam()); H();
1359 hrc = serialPort->COMGETTER(Server)(&fServer); H();
1360 rc = CFGMR3InsertInteger(pCfg, "IRQ", ulIRQ); RC_CHECK();
1361 rc = CFGMR3InsertInteger(pCfg, "IOBase", ulIOBase); RC_CHECK();
1362 if (HostMode != PortMode_Disconnected)
1363 {
1364 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1365 if (HostMode == PortMode_HostPipe)
1366 {
1367 rc = CFGMR3InsertString(pLunL0, "Driver", "Char"); RC_CHECK();
1368 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
1369 rc = CFGMR3InsertString(pLunL1, "Driver", "NamedPipe"); RC_CHECK();
1370 rc = CFGMR3InsertNode(pLunL1, "Config", &pLunL2); RC_CHECK();
1371 rc = CFGMR3InsertString(pLunL2, "Location", Utf8Str(path)); RC_CHECK();
1372 rc = CFGMR3InsertInteger(pLunL2, "IsServer", fServer); RC_CHECK();
1373 }
1374 else if (HostMode == PortMode_HostDevice)
1375 {
1376 rc = CFGMR3InsertString(pLunL0, "Driver", "Host Serial"); RC_CHECK();
1377 rc = CFGMR3InsertNode(pLunL0, "Config", &pLunL1); RC_CHECK();
1378 rc = CFGMR3InsertString(pLunL1, "DevicePath", Utf8Str(path)); RC_CHECK();
1379 }
1380 }
1381 }
1382
1383 /*
1384 * Parallel (LPT) Ports
1385 */
1386 rc = CFGMR3InsertNode(pDevices, "parallel", &pDev); RC_CHECK();
1387 for (ULONG ulInstance = 0; ulInstance < SchemaDefs::ParallelPortCount; ulInstance++)
1388 {
1389 ComPtr<IParallelPort> parallelPort;
1390 hrc = pMachine->GetParallelPort (ulInstance, parallelPort.asOutParam()); H();
1391 BOOL fEnabled = FALSE;
1392 if (parallelPort)
1393 hrc = parallelPort->COMGETTER(Enabled)(&fEnabled); H();
1394 if (!fEnabled)
1395 continue;
1396
1397 char szInstance[4]; Assert(ulInstance <= 999);
1398 RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance);
1399
1400 rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK();
1401 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1402
1403 ULONG ulIRQ, ulIOBase;
1404 Bstr DevicePath;
1405 hrc = parallelPort->COMGETTER(IRQ)(&ulIRQ); H();
1406 hrc = parallelPort->COMGETTER(IOBase)(&ulIOBase); H();
1407 hrc = parallelPort->COMGETTER(Path)(DevicePath.asOutParam()); H();
1408 rc = CFGMR3InsertInteger(pCfg, "IRQ", ulIRQ); RC_CHECK();
1409 rc = CFGMR3InsertInteger(pCfg, "IOBase", ulIOBase); RC_CHECK();
1410 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1411 rc = CFGMR3InsertString(pLunL0, "Driver", "HostParallel"); RC_CHECK();
1412 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
1413 rc = CFGMR3InsertString(pLunL1, "DevicePath", Utf8Str(DevicePath)); RC_CHECK();
1414 }
1415
1416 /*
1417 * VMM Device
1418 */
1419 rc = CFGMR3InsertNode(pDevices, "VMMDev", &pDev); RC_CHECK();
1420 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1421 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1422 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
1423 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 4); RC_CHECK();
1424 Assert(!afPciDeviceNo[4]);
1425 afPciDeviceNo[4] = true;
1426 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1427
1428 /* the VMM device's Main driver */
1429 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1430 rc = CFGMR3InsertString(pLunL0, "Driver", "MainVMMDev"); RC_CHECK();
1431 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1432 VMMDev *pVMMDev = pConsole->mVMMDev;
1433 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pVMMDev); RC_CHECK();
1434
1435 /*
1436 * Attach the status driver.
1437 */
1438 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
1439 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1440 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1441 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapSharedFolderLed); RC_CHECK();
1442 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1443 rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
1444
1445 /*
1446 * Audio Sniffer Device
1447 */
1448 rc = CFGMR3InsertNode(pDevices, "AudioSniffer", &pDev); RC_CHECK();
1449 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1450 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1451
1452 /* the Audio Sniffer device's Main driver */
1453 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1454 rc = CFGMR3InsertString(pLunL0, "Driver", "MainAudioSniffer"); RC_CHECK();
1455 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1456 AudioSniffer *pAudioSniffer = pConsole->mAudioSniffer;
1457 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pAudioSniffer); RC_CHECK();
1458
1459 /*
1460 * AC'97 ICH / SoundBlaster16 audio
1461 */
1462 ComPtr<IAudioAdapter> audioAdapter;
1463 hrc = pMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam()); H();
1464 if (audioAdapter)
1465 hrc = audioAdapter->COMGETTER(Enabled)(&enabled); H();
1466
1467 if (enabled)
1468 {
1469 AudioControllerType_T audioController;
1470 hrc = audioAdapter->COMGETTER(AudioController)(&audioController); H();
1471 switch (audioController)
1472 {
1473 case AudioControllerType_AC97:
1474 {
1475 /* default: ICH AC97 */
1476 rc = CFGMR3InsertNode(pDevices, "ichac97", &pDev); RC_CHECK();
1477 rc = CFGMR3InsertNode(pDev, "0", &pInst);
1478 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
1479 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 5); RC_CHECK();
1480 Assert(!afPciDeviceNo[5]);
1481 afPciDeviceNo[5] = true;
1482 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1483 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1484 break;
1485 }
1486 case AudioControllerType_SB16:
1487 {
1488 /* legacy SoundBlaster16 */
1489 rc = CFGMR3InsertNode(pDevices, "sb16", &pDev); RC_CHECK();
1490 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1491 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
1492 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1493 rc = CFGMR3InsertInteger(pCfg, "IRQ", 5); RC_CHECK();
1494 rc = CFGMR3InsertInteger(pCfg, "DMA", 1); RC_CHECK();
1495 rc = CFGMR3InsertInteger(pCfg, "DMA16", 5); RC_CHECK();
1496 rc = CFGMR3InsertInteger(pCfg, "Port", 0x220); RC_CHECK();
1497 rc = CFGMR3InsertInteger(pCfg, "Version", 0x0405); RC_CHECK();
1498 break;
1499 }
1500 }
1501
1502 /* the Audio driver */
1503 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1504 rc = CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); RC_CHECK();
1505 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1506
1507 AudioDriverType_T audioDriver;
1508 hrc = audioAdapter->COMGETTER(AudioDriver)(&audioDriver); H();
1509 switch (audioDriver)
1510 {
1511 case AudioDriverType_Null:
1512 {
1513 rc = CFGMR3InsertString(pCfg, "AudioDriver", "null"); RC_CHECK();
1514 break;
1515 }
1516#ifdef RT_OS_WINDOWS
1517#ifdef VBOX_WITH_WINMM
1518 case AudioDriverType_WinMM:
1519 {
1520 rc = CFGMR3InsertString(pCfg, "AudioDriver", "winmm"); RC_CHECK();
1521 break;
1522 }
1523#endif
1524 case AudioDriverType_DirectSound:
1525 {
1526 rc = CFGMR3InsertString(pCfg, "AudioDriver", "dsound"); RC_CHECK();
1527 break;
1528 }
1529#endif /* RT_OS_WINDOWS */
1530#ifdef RT_OS_SOLARIS
1531 case AudioDriverType_SolAudio:
1532 {
1533 rc = CFGMR3InsertString(pCfg, "AudioDriver", "solaudio"); RC_CHECK();
1534 break;
1535 }
1536#endif
1537#ifdef RT_OS_LINUX
1538 case AudioDriverType_OSS:
1539 {
1540 rc = CFGMR3InsertString(pCfg, "AudioDriver", "oss"); RC_CHECK();
1541 break;
1542 }
1543# ifdef VBOX_WITH_ALSA
1544 case AudioDriverType_ALSA:
1545 {
1546 rc = CFGMR3InsertString(pCfg, "AudioDriver", "alsa"); RC_CHECK();
1547 break;
1548 }
1549# endif
1550# ifdef VBOX_WITH_PULSE
1551 case AudioDriverType_Pulse:
1552 {
1553 rc = CFGMR3InsertString(pCfg, "AudioDriver", "pulse"); RC_CHECK();
1554 break;
1555 }
1556# endif
1557#endif /* RT_OS_LINUX */
1558#ifdef RT_OS_DARWIN
1559 case AudioDriverType_CoreAudio:
1560 {
1561 rc = CFGMR3InsertString(pCfg, "AudioDriver", "coreaudio"); RC_CHECK();
1562 break;
1563 }
1564#endif
1565 }
1566 hrc = pMachine->COMGETTER(Name)(&str); H();
1567 STR_CONV();
1568 rc = CFGMR3InsertString(pCfg, "StreamName", psz); RC_CHECK();
1569 STR_FREE();
1570 }
1571
1572 /*
1573 * The USB Controller.
1574 */
1575 ComPtr<IUSBController> USBCtlPtr;
1576 hrc = pMachine->COMGETTER(USBController)(USBCtlPtr.asOutParam());
1577 if (USBCtlPtr)
1578 {
1579 BOOL fEnabled;
1580 hrc = USBCtlPtr->COMGETTER(Enabled)(&fEnabled); H();
1581 if (fEnabled)
1582 {
1583 rc = CFGMR3InsertNode(pDevices, "usb-ohci", &pDev); RC_CHECK();
1584 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1585 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1586 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
1587 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 6); RC_CHECK();
1588 Assert(!afPciDeviceNo[6]);
1589 afPciDeviceNo[6] = true;
1590 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1591
1592 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1593 rc = CFGMR3InsertString(pLunL0, "Driver", "VUSBRootHub"); RC_CHECK();
1594 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1595
1596 /*
1597 * Attach the status driver.
1598 */
1599 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
1600 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1601 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1602 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapUSBLed[0]);RC_CHECK();
1603 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1604 rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
1605
1606#ifdef VBOX_WITH_EHCI
1607 hrc = USBCtlPtr->COMGETTER(EnabledEhci)(&fEnabled); H();
1608 if (fEnabled)
1609 {
1610 rc = CFGMR3InsertNode(pDevices, "usb-ehci", &pDev); RC_CHECK();
1611 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1612 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1613 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
1614 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 11); RC_CHECK();
1615 Assert(!afPciDeviceNo[11]);
1616 afPciDeviceNo[11] = true;
1617 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1618
1619 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1620 rc = CFGMR3InsertString(pLunL0, "Driver", "VUSBRootHub"); RC_CHECK();
1621 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1622
1623 /*
1624 * Attach the status driver.
1625 */
1626 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
1627 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1628 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1629 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapUSBLed[1]);RC_CHECK();
1630 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1631 rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
1632 }
1633 else
1634#endif
1635 {
1636 /*
1637 * Global USB options, currently unused as we'll apply the 2.0 -> 1.1 morphing
1638 * on a per device level now.
1639 */
1640 rc = CFGMR3InsertNode(pRoot, "USB", &pCfg); RC_CHECK();
1641 rc = CFGMR3InsertNode(pCfg, "USBProxy", &pCfg); RC_CHECK();
1642 rc = CFGMR3InsertNode(pCfg, "GlobalConfig", &pCfg); RC_CHECK();
1643 // This globally enables the 2.0 -> 1.1 device morphing of proxied devies to keep windows quiet.
1644 //rc = CFGMR3InsertInteger(pCfg, "Force11Device", true); RC_CHECK();
1645 // The following breaks stuff, but it makes MSDs work in vista. (I include it here so
1646 // that it's documented somewhere.) Users needing it can use:
1647 // VBoxManage setextradata "myvm" "VBoxInternal/USB/USBProxy/GlobalConfig/Force11PacketSize" 1
1648 //rc = CFGMR3InsertInteger(pCfg, "Force11PacketSize", true); RC_CHECK();
1649 }
1650 }
1651 }
1652
1653 /*
1654 * Clipboard
1655 */
1656 {
1657 ClipboardMode_T mode = ClipboardMode_Disabled;
1658 hrc = pMachine->COMGETTER(ClipboardMode) (&mode); H();
1659
1660 if (mode != ClipboardMode_Disabled)
1661 {
1662 /* Load the service */
1663 rc = pConsole->mVMMDev->hgcmLoadService ("VBoxSharedClipboard", "VBoxSharedClipboard");
1664
1665 if (VBOX_FAILURE (rc))
1666 {
1667 LogRel(("VBoxSharedClipboard is not available. rc = %Vrc\n", rc));
1668 /* That is not a fatal failure. */
1669 rc = VINF_SUCCESS;
1670 }
1671 else
1672 {
1673 /* Setup the service. */
1674 VBOXHGCMSVCPARM parm;
1675
1676 parm.type = VBOX_HGCM_SVC_PARM_32BIT;
1677
1678 switch (mode)
1679 {
1680 default:
1681 case ClipboardMode_Disabled:
1682 {
1683 LogRel(("VBoxSharedClipboard mode: Off\n"));
1684 parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_OFF;
1685 break;
1686 }
1687 case ClipboardMode_GuestToHost:
1688 {
1689 LogRel(("VBoxSharedClipboard mode: Guest to Host\n"));
1690 parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST;
1691 break;
1692 }
1693 case ClipboardMode_HostToGuest:
1694 {
1695 LogRel(("VBoxSharedClipboard mode: Host to Guest\n"));
1696 parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_HOST_TO_GUEST;
1697 break;
1698 }
1699 case ClipboardMode_Bidirectional:
1700 {
1701 LogRel(("VBoxSharedClipboard mode: Bidirectional\n"));
1702 parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL;
1703 break;
1704 }
1705 }
1706
1707 pConsole->mVMMDev->hgcmHostCall ("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm);
1708
1709 Log(("Set VBoxSharedClipboard mode\n"));
1710 }
1711 }
1712 }
1713#ifdef VBOX_WITH_GUEST_PROPS
1714 /*
1715 * Shared information services
1716 */
1717 {
1718 /* Load the service */
1719 rc = pConsole->mVMMDev->hgcmLoadService ("VBoxGuestPropSvc", "VBoxGuestPropSvc");
1720
1721 if (VBOX_FAILURE (rc))
1722 {
1723 LogRel(("VBoxGuestPropSvc is not available. rc = %Vrc\n", rc));
1724 /* That is not a fatal failure. */
1725 rc = VINF_SUCCESS;
1726 }
1727 else
1728 {
1729 rc = CFGMR3InsertNode(pRoot, "GuestProps", &pGuestProps); RC_CHECK();
1730 rc = CFGMR3InsertNode(pGuestProps, "Values", &pValues); RC_CHECK();
1731 rc = CFGMR3InsertNode(pGuestProps, "Timestamps", &pTimestamps); RC_CHECK();
1732 rc = CFGMR3InsertNode(pGuestProps, "Flags", &pFlags); RC_CHECK();
1733
1734 /* Pull over the properties from the server. */
1735 SafeArray <BSTR> names;
1736 SafeArray <BSTR> values;
1737 SafeArray <ULONG64> timestamps;
1738 SafeArray <BSTR> flags;
1739 hrc = pConsole->mControl->PullGuestProperties(ComSafeArrayAsOutParam(names),
1740 ComSafeArrayAsOutParam(values),
1741 ComSafeArrayAsOutParam(timestamps),
1742 ComSafeArrayAsOutParam(flags)); H();
1743 size_t cProps = names.size();
1744 for (size_t i = 0; i < cProps; ++i)
1745 {
1746 rc = CFGMR3InsertString(pValues, Utf8Str(names[i]).raw(), Utf8Str(values[i]).raw()); RC_CHECK();
1747 rc = CFGMR3InsertInteger(pTimestamps, Utf8Str(names[i]).raw(), timestamps[i]); RC_CHECK();
1748 rc = CFGMR3InsertString(pFlags, Utf8Str(names[i]).raw(), Utf8Str(flags[i]).raw()); RC_CHECK();
1749 }
1750
1751 /* Setup the service. */
1752 VBOXHGCMSVCPARM parms[3];
1753
1754 parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
1755 parms[0].u.pointer.addr = pValues;
1756 parms[0].u.pointer.size = sizeof(pValues); /* We don't actually care. */
1757 parms[1].type = VBOX_HGCM_SVC_PARM_PTR;
1758 parms[1].u.pointer.addr = pTimestamps;
1759 parms[1].u.pointer.size = sizeof(pTimestamps);
1760 parms[2].type = VBOX_HGCM_SVC_PARM_PTR;
1761 parms[2].u.pointer.addr = pFlags;
1762 parms[2].u.pointer.size = sizeof(pFlags);
1763
1764 pConsole->mVMMDev->hgcmHostCall ("VBoxGuestPropSvc", guestProp::SET_CFGM_NODE, 3, &parms[0]);
1765
1766 Log(("Set VBoxGuestPropSvc property store\n"));
1767 }
1768 }
1769#endif /* VBOX_WITH_GUEST_PROPS defined */
1770
1771 /*
1772 * CFGM overlay handling.
1773 *
1774 * Here we check the extra data entries for CFGM values
1775 * and create the nodes and insert the values on the fly. Existing
1776 * values will be removed and reinserted. If a value is a valid number,
1777 * it will be inserted as a number, otherwise as a string.
1778 *
1779 * We first perform a run on global extra data, then on the machine
1780 * extra data to support global settings with local overrides.
1781 *
1782 */
1783 Bstr strExtraDataKey;
1784 bool fGlobalExtraData = true;
1785 for (;;)
1786 {
1787 Bstr strNextExtraDataKey;
1788 Bstr strExtraDataValue;
1789
1790 /* get the next key */
1791 if (fGlobalExtraData)
1792 hrc = virtualBox->GetNextExtraDataKey(strExtraDataKey, strNextExtraDataKey.asOutParam(),
1793 strExtraDataValue.asOutParam());
1794 else
1795 hrc = pMachine->GetNextExtraDataKey(strExtraDataKey, strNextExtraDataKey.asOutParam(),
1796 strExtraDataValue.asOutParam());
1797
1798 /* stop if for some reason there's nothing more to request */
1799 if (FAILED(hrc) || !strNextExtraDataKey)
1800 {
1801 /* if we're out of global keys, continue with machine, otherwise we're done */
1802 if (fGlobalExtraData)
1803 {
1804 fGlobalExtraData = false;
1805 strExtraDataKey.setNull();
1806 continue;
1807 }
1808 break;
1809 }
1810
1811 strExtraDataKey = strNextExtraDataKey;
1812 Utf8Str strExtraDataKeyUtf8 = Utf8Str(strExtraDataKey);
1813
1814 /* we only care about keys starting with "VBoxInternal/" */
1815 if (strncmp(strExtraDataKeyUtf8.raw(), "VBoxInternal/", 13) != 0)
1816 continue;
1817 char *pszExtraDataKey = (char*)strExtraDataKeyUtf8.raw() + 13;
1818
1819 /* the key will be in the format "Node1/Node2/Value" or simply "Value". */
1820 PCFGMNODE pNode;
1821 char *pszCFGMValueName = strrchr(pszExtraDataKey, '/');
1822 if (pszCFGMValueName)
1823 {
1824 /* terminate the node and advance to the value */
1825 *pszCFGMValueName = '\0';
1826 pszCFGMValueName++;
1827
1828 /* does the node already exist? */
1829 pNode = CFGMR3GetChild(pRoot, pszExtraDataKey);
1830 if (pNode)
1831 {
1832 /* the value might already exist, remove it to be safe */
1833 CFGMR3RemoveValue(pNode, pszCFGMValueName);
1834 }
1835 else
1836 {
1837 /* create the node */
1838 rc = CFGMR3InsertNode(pRoot, pszExtraDataKey, &pNode);
1839 AssertMsgRC(rc, ("failed to insert node '%s'\n", pszExtraDataKey));
1840 if (VBOX_FAILURE(rc) || !pNode)
1841 continue;
1842 }
1843 }
1844 else
1845 {
1846 pNode = pRoot;
1847 pszCFGMValueName = pszExtraDataKey;
1848 pszExtraDataKey--;
1849
1850 /* the value might already exist, remove it to be safe */
1851 CFGMR3RemoveValue(pNode, pszCFGMValueName);
1852 }
1853
1854 /* now let's have a look at the value */
1855 Utf8Str strCFGMValueUtf8 = Utf8Str(strExtraDataValue);
1856 const char *pszCFGMValue = strCFGMValueUtf8.raw();
1857 /* empty value means remove value which we've already done */
1858 if (pszCFGMValue && *pszCFGMValue)
1859 {
1860 /* if it's a valid number, we'll insert it as such, otherwise string */
1861 uint64_t u64Value;
1862 char *pszNext = NULL;
1863 if ( RTStrToUInt64Ex(pszCFGMValue, &pszNext, 0, &u64Value) == VINF_SUCCESS
1864 && (!pszNext || *pszNext == '\0') /* check if the _whole_ string is a valid number */
1865 )
1866 {
1867 rc = CFGMR3InsertInteger(pNode, pszCFGMValueName, u64Value);
1868 }
1869 else
1870 {
1871 rc = CFGMR3InsertString(pNode, pszCFGMValueName, pszCFGMValue);
1872 }
1873 AssertMsgRC(rc, ("failed to insert CFGM value '%s' to key '%s'\n", pszCFGMValue, pszExtraDataKey));
1874 }
1875 }
1876
1877#undef H
1878#undef RC_CHECK
1879#undef STR_FREE
1880#undef STR_CONV
1881
1882 /* Register VM state change handler */
1883 int rc2 = VMR3AtStateRegister (pVM, Console::vmstateChangeCallback, pConsole);
1884 AssertRC (rc2);
1885 if (VBOX_SUCCESS (rc))
1886 rc = rc2;
1887
1888 /* Register VM runtime error handler */
1889 rc2 = VMR3AtRuntimeErrorRegister (pVM, Console::setVMRuntimeErrorCallback, pConsole);
1890 AssertRC (rc2);
1891 if (VBOX_SUCCESS (rc))
1892 rc = rc2;
1893
1894 /* Save the VM pointer in the machine object */
1895 pConsole->mpVM = pVM;
1896
1897 LogFlowFunc (("vrc = %Vrc\n", rc));
1898 LogFlowFuncLeave();
1899
1900 return rc;
1901}
1902
1903
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