VirtualBox

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

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

Main: Fixed the darwin hif setup.

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