VirtualBox

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

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

Storage/VBoxHDD-new: Add information about configuration settings supported by a backend.
Storage/iSCSI: Move initiator name default to backend.
Main: Move iSCSI initiator name default to backend.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 88.9 KB
Line 
1/** $Id: ConsoleImpl2.cpp 11484 2008-08-19 12:41:38Z 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 rc = CFGMR3InsertString(pLunL0, "Driver", "HostInterface"); RC_CHECK();
1256 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1257 rc = CFGMR3InsertString(pCfg, "HostInterfaceName", Utf8Str(hostInterfaceName)); RC_CHECK();
1258 Guid hostIFGuid;
1259 hrc = hostInterface->COMGETTER(Id)(hostIFGuid.asOutParam()); H();
1260 char szDriverGUID[256] = {0};
1261 /* add curly brackets */
1262 szDriverGUID[0] = '{';
1263 strcpy(szDriverGUID + 1, hostIFGuid.toString().raw());
1264 strcat(szDriverGUID, "}");
1265 rc = CFGMR3InsertBytes(pCfg, "GUID", szDriverGUID, sizeof(szDriverGUID)); RC_CHECK();
1266 }
1267#else
1268# error "Port me"
1269#endif
1270 }
1271 else
1272 {
1273 switch (hrc)
1274 {
1275#ifdef RT_OS_LINUX
1276 case VERR_ACCESS_DENIED:
1277 return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
1278 "Failed to open '/dev/net/tun' for read/write access. Please check the "
1279 "permissions of that node. Either run 'chmod 0666 /dev/net/tun' or "
1280 "change the group of that node and make yourself a member of that group. Make "
1281 "sure that these changes are permanent, especially if you are "
1282 "using udev"));
1283#endif /* RT_OS_LINUX */
1284 default:
1285 AssertMsgFailed(("Could not attach to host interface! Bad!\n"));
1286 return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
1287 "Failed to initialize Host Interface Networking"));
1288 }
1289 }
1290 break;
1291 }
1292
1293 case NetworkAttachmentType_Internal:
1294 {
1295 hrc = networkAdapter->COMGETTER(InternalNetwork)(&str); H();
1296 if (str)
1297 {
1298 STR_CONV();
1299 if (psz && *psz)
1300 {
1301 if (fSniffer)
1302 {
1303 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
1304 }
1305 else
1306 {
1307 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1308 }
1309 rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK();
1310 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1311 rc = CFGMR3InsertString(pCfg, "Network", psz); RC_CHECK();
1312 }
1313 STR_FREE();
1314 }
1315 break;
1316 }
1317
1318 default:
1319 AssertMsgFailed(("should not get here!\n"));
1320 break;
1321 }
1322 }
1323
1324 /*
1325 * Serial (UART) Ports
1326 */
1327 rc = CFGMR3InsertNode(pDevices, "serial", &pDev); RC_CHECK();
1328 for (ULONG ulInstance = 0; ulInstance < SchemaDefs::SerialPortCount; ulInstance++)
1329 {
1330 ComPtr<ISerialPort> serialPort;
1331 hrc = pMachine->GetSerialPort (ulInstance, serialPort.asOutParam()); H();
1332 BOOL fEnabled = FALSE;
1333 if (serialPort)
1334 hrc = serialPort->COMGETTER(Enabled)(&fEnabled); H();
1335 if (!fEnabled)
1336 continue;
1337
1338 char szInstance[4]; Assert(ulInstance <= 999);
1339 RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance);
1340
1341 rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK();
1342 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1343
1344 ULONG ulIRQ, ulIOBase;
1345 PortMode_T HostMode;
1346 Bstr path;
1347 BOOL fServer;
1348 hrc = serialPort->COMGETTER(HostMode)(&HostMode); H();
1349 hrc = serialPort->COMGETTER(IRQ)(&ulIRQ); H();
1350 hrc = serialPort->COMGETTER(IOBase)(&ulIOBase); H();
1351 hrc = serialPort->COMGETTER(Path)(path.asOutParam()); H();
1352 hrc = serialPort->COMGETTER(Server)(&fServer); H();
1353 rc = CFGMR3InsertInteger(pCfg, "IRQ", ulIRQ); RC_CHECK();
1354 rc = CFGMR3InsertInteger(pCfg, "IOBase", ulIOBase); RC_CHECK();
1355 if (HostMode != PortMode_Disconnected)
1356 {
1357 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1358 if (HostMode == PortMode_HostPipe)
1359 {
1360 rc = CFGMR3InsertString(pLunL0, "Driver", "Char"); RC_CHECK();
1361 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
1362 rc = CFGMR3InsertString(pLunL1, "Driver", "NamedPipe"); RC_CHECK();
1363 rc = CFGMR3InsertNode(pLunL1, "Config", &pLunL2); RC_CHECK();
1364 rc = CFGMR3InsertString(pLunL2, "Location", Utf8Str(path)); RC_CHECK();
1365 rc = CFGMR3InsertInteger(pLunL2, "IsServer", fServer); RC_CHECK();
1366 }
1367 else if (HostMode == PortMode_HostDevice)
1368 {
1369 rc = CFGMR3InsertString(pLunL0, "Driver", "Host Serial"); RC_CHECK();
1370 rc = CFGMR3InsertNode(pLunL0, "Config", &pLunL1); RC_CHECK();
1371 rc = CFGMR3InsertString(pLunL1, "DevicePath", Utf8Str(path)); RC_CHECK();
1372 }
1373 }
1374 }
1375
1376 /*
1377 * Parallel (LPT) Ports
1378 */
1379 rc = CFGMR3InsertNode(pDevices, "parallel", &pDev); RC_CHECK();
1380 for (ULONG ulInstance = 0; ulInstance < SchemaDefs::ParallelPortCount; ulInstance++)
1381 {
1382 ComPtr<IParallelPort> parallelPort;
1383 hrc = pMachine->GetParallelPort (ulInstance, parallelPort.asOutParam()); H();
1384 BOOL fEnabled = FALSE;
1385 if (parallelPort)
1386 hrc = parallelPort->COMGETTER(Enabled)(&fEnabled); H();
1387 if (!fEnabled)
1388 continue;
1389
1390 char szInstance[4]; Assert(ulInstance <= 999);
1391 RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance);
1392
1393 rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK();
1394 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1395
1396 ULONG ulIRQ, ulIOBase;
1397 Bstr DevicePath;
1398 hrc = parallelPort->COMGETTER(IRQ)(&ulIRQ); H();
1399 hrc = parallelPort->COMGETTER(IOBase)(&ulIOBase); H();
1400 hrc = parallelPort->COMGETTER(Path)(DevicePath.asOutParam()); H();
1401 rc = CFGMR3InsertInteger(pCfg, "IRQ", ulIRQ); RC_CHECK();
1402 rc = CFGMR3InsertInteger(pCfg, "IOBase", ulIOBase); RC_CHECK();
1403 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1404 rc = CFGMR3InsertString(pLunL0, "Driver", "HostParallel"); RC_CHECK();
1405 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
1406 rc = CFGMR3InsertString(pLunL1, "DevicePath", Utf8Str(DevicePath)); RC_CHECK();
1407 }
1408
1409 /*
1410 * VMM Device
1411 */
1412 rc = CFGMR3InsertNode(pDevices, "VMMDev", &pDev); RC_CHECK();
1413 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1414 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1415 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
1416 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 4); RC_CHECK();
1417 Assert(!afPciDeviceNo[4]);
1418 afPciDeviceNo[4] = true;
1419 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1420
1421 /* the VMM device's Main driver */
1422 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1423 rc = CFGMR3InsertString(pLunL0, "Driver", "MainVMMDev"); RC_CHECK();
1424 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1425 VMMDev *pVMMDev = pConsole->mVMMDev;
1426 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pVMMDev); RC_CHECK();
1427
1428 /*
1429 * Attach the status driver.
1430 */
1431 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
1432 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1433 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1434 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapSharedFolderLed); RC_CHECK();
1435 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1436 rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
1437
1438 /*
1439 * Audio Sniffer Device
1440 */
1441 rc = CFGMR3InsertNode(pDevices, "AudioSniffer", &pDev); RC_CHECK();
1442 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1443 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1444
1445 /* the Audio Sniffer device's Main driver */
1446 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1447 rc = CFGMR3InsertString(pLunL0, "Driver", "MainAudioSniffer"); RC_CHECK();
1448 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1449 AudioSniffer *pAudioSniffer = pConsole->mAudioSniffer;
1450 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pAudioSniffer); RC_CHECK();
1451
1452 /*
1453 * AC'97 ICH / SoundBlaster16 audio
1454 */
1455 ComPtr<IAudioAdapter> audioAdapter;
1456 hrc = pMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam()); H();
1457 if (audioAdapter)
1458 hrc = audioAdapter->COMGETTER(Enabled)(&enabled); H();
1459
1460 if (enabled)
1461 {
1462 AudioControllerType_T audioController;
1463 hrc = audioAdapter->COMGETTER(AudioController)(&audioController); H();
1464 switch (audioController)
1465 {
1466 case AudioControllerType_AC97:
1467 {
1468 /* default: ICH AC97 */
1469 rc = CFGMR3InsertNode(pDevices, "ichac97", &pDev); RC_CHECK();
1470 rc = CFGMR3InsertNode(pDev, "0", &pInst);
1471 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
1472 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 5); RC_CHECK();
1473 Assert(!afPciDeviceNo[5]);
1474 afPciDeviceNo[5] = true;
1475 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1476 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1477 break;
1478 }
1479 case AudioControllerType_SB16:
1480 {
1481 /* legacy SoundBlaster16 */
1482 rc = CFGMR3InsertNode(pDevices, "sb16", &pDev); RC_CHECK();
1483 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1484 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
1485 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1486 rc = CFGMR3InsertInteger(pCfg, "IRQ", 5); RC_CHECK();
1487 rc = CFGMR3InsertInteger(pCfg, "DMA", 1); RC_CHECK();
1488 rc = CFGMR3InsertInteger(pCfg, "DMA16", 5); RC_CHECK();
1489 rc = CFGMR3InsertInteger(pCfg, "Port", 0x220); RC_CHECK();
1490 rc = CFGMR3InsertInteger(pCfg, "Version", 0x0405); RC_CHECK();
1491 break;
1492 }
1493 }
1494
1495 /* the Audio driver */
1496 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1497 rc = CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); RC_CHECK();
1498 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1499
1500 AudioDriverType_T audioDriver;
1501 hrc = audioAdapter->COMGETTER(AudioDriver)(&audioDriver); H();
1502 switch (audioDriver)
1503 {
1504 case AudioDriverType_Null:
1505 {
1506 rc = CFGMR3InsertString(pCfg, "AudioDriver", "null"); RC_CHECK();
1507 break;
1508 }
1509#ifdef RT_OS_WINDOWS
1510#ifdef VBOX_WITH_WINMM
1511 case AudioDriverType_WinMM:
1512 {
1513 rc = CFGMR3InsertString(pCfg, "AudioDriver", "winmm"); RC_CHECK();
1514 break;
1515 }
1516#endif
1517 case AudioDriverType_DirectSound:
1518 {
1519 rc = CFGMR3InsertString(pCfg, "AudioDriver", "dsound"); RC_CHECK();
1520 break;
1521 }
1522#endif /* RT_OS_WINDOWS */
1523#ifdef RT_OS_SOLARIS
1524 case AudioDriverType_SolAudio:
1525 {
1526 rc = CFGMR3InsertString(pCfg, "AudioDriver", "solaudio"); RC_CHECK();
1527 break;
1528 }
1529#endif
1530#ifdef RT_OS_LINUX
1531 case AudioDriverType_OSS:
1532 {
1533 rc = CFGMR3InsertString(pCfg, "AudioDriver", "oss"); RC_CHECK();
1534 break;
1535 }
1536# ifdef VBOX_WITH_ALSA
1537 case AudioDriverType_ALSA:
1538 {
1539 rc = CFGMR3InsertString(pCfg, "AudioDriver", "alsa"); RC_CHECK();
1540 break;
1541 }
1542# endif
1543# ifdef VBOX_WITH_PULSE
1544 case AudioDriverType_Pulse:
1545 {
1546 rc = CFGMR3InsertString(pCfg, "AudioDriver", "pulse"); RC_CHECK();
1547 break;
1548 }
1549# endif
1550#endif /* RT_OS_LINUX */
1551#ifdef RT_OS_DARWIN
1552 case AudioDriverType_CoreAudio:
1553 {
1554 rc = CFGMR3InsertString(pCfg, "AudioDriver", "coreaudio"); RC_CHECK();
1555 break;
1556 }
1557#endif
1558 }
1559 hrc = pMachine->COMGETTER(Name)(&str); H();
1560 STR_CONV();
1561 rc = CFGMR3InsertString(pCfg, "StreamName", psz); RC_CHECK();
1562 STR_FREE();
1563 }
1564
1565 /*
1566 * The USB Controller.
1567 */
1568 ComPtr<IUSBController> USBCtlPtr;
1569 hrc = pMachine->COMGETTER(USBController)(USBCtlPtr.asOutParam());
1570 if (USBCtlPtr)
1571 {
1572 BOOL fEnabled;
1573 hrc = USBCtlPtr->COMGETTER(Enabled)(&fEnabled); H();
1574 if (fEnabled)
1575 {
1576 rc = CFGMR3InsertNode(pDevices, "usb-ohci", &pDev); RC_CHECK();
1577 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1578 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1579 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
1580 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 6); RC_CHECK();
1581 Assert(!afPciDeviceNo[6]);
1582 afPciDeviceNo[6] = true;
1583 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1584
1585 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1586 rc = CFGMR3InsertString(pLunL0, "Driver", "VUSBRootHub"); RC_CHECK();
1587 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1588
1589 /*
1590 * Attach the status driver.
1591 */
1592 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
1593 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1594 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1595 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapUSBLed[0]);RC_CHECK();
1596 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1597 rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
1598
1599#ifdef VBOX_WITH_EHCI
1600 hrc = USBCtlPtr->COMGETTER(EnabledEhci)(&fEnabled); H();
1601 if (fEnabled)
1602 {
1603 rc = CFGMR3InsertNode(pDevices, "usb-ehci", &pDev); RC_CHECK();
1604 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1605 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1606 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
1607 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 11); RC_CHECK();
1608 Assert(!afPciDeviceNo[11]);
1609 afPciDeviceNo[11] = true;
1610 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1611
1612 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1613 rc = CFGMR3InsertString(pLunL0, "Driver", "VUSBRootHub"); RC_CHECK();
1614 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1615
1616 /*
1617 * Attach the status driver.
1618 */
1619 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
1620 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1621 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1622 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapUSBLed[1]);RC_CHECK();
1623 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1624 rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
1625 }
1626 else
1627#endif
1628 {
1629 /*
1630 * Global USB options, currently unused as we'll apply the 2.0 -> 1.1 morphing
1631 * on a per device level now.
1632 */
1633 rc = CFGMR3InsertNode(pRoot, "USB", &pCfg); RC_CHECK();
1634 rc = CFGMR3InsertNode(pCfg, "USBProxy", &pCfg); RC_CHECK();
1635 rc = CFGMR3InsertNode(pCfg, "GlobalConfig", &pCfg); RC_CHECK();
1636 // This globally enables the 2.0 -> 1.1 device morphing of proxied devies to keep windows quiet.
1637 //rc = CFGMR3InsertInteger(pCfg, "Force11Device", true); RC_CHECK();
1638 // The following breaks stuff, but it makes MSDs work in vista. (I include it here so
1639 // that it's documented somewhere.) Users needing it can use:
1640 // VBoxManage setextradata "myvm" "VBoxInternal/USB/USBProxy/GlobalConfig/Force11PacketSize" 1
1641 //rc = CFGMR3InsertInteger(pCfg, "Force11PacketSize", true); RC_CHECK();
1642 }
1643 }
1644 }
1645
1646 /*
1647 * Clipboard
1648 */
1649 {
1650 ClipboardMode_T mode = ClipboardMode_Disabled;
1651 hrc = pMachine->COMGETTER(ClipboardMode) (&mode); H();
1652
1653 if (mode != ClipboardMode_Disabled)
1654 {
1655 /* Load the service */
1656 rc = pConsole->mVMMDev->hgcmLoadService ("VBoxSharedClipboard", "VBoxSharedClipboard");
1657
1658 if (VBOX_FAILURE (rc))
1659 {
1660 LogRel(("VBoxSharedClipboard is not available. rc = %Vrc\n", rc));
1661 /* That is not a fatal failure. */
1662 rc = VINF_SUCCESS;
1663 }
1664 else
1665 {
1666 /* Setup the service. */
1667 VBOXHGCMSVCPARM parm;
1668
1669 parm.type = VBOX_HGCM_SVC_PARM_32BIT;
1670
1671 switch (mode)
1672 {
1673 default:
1674 case ClipboardMode_Disabled:
1675 {
1676 LogRel(("VBoxSharedClipboard mode: Off\n"));
1677 parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_OFF;
1678 break;
1679 }
1680 case ClipboardMode_GuestToHost:
1681 {
1682 LogRel(("VBoxSharedClipboard mode: Guest to Host\n"));
1683 parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST;
1684 break;
1685 }
1686 case ClipboardMode_HostToGuest:
1687 {
1688 LogRel(("VBoxSharedClipboard mode: Host to Guest\n"));
1689 parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_HOST_TO_GUEST;
1690 break;
1691 }
1692 case ClipboardMode_Bidirectional:
1693 {
1694 LogRel(("VBoxSharedClipboard mode: Bidirectional\n"));
1695 parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL;
1696 break;
1697 }
1698 }
1699
1700 pConsole->mVMMDev->hgcmHostCall ("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm);
1701
1702 Log(("Set VBoxSharedClipboard mode\n"));
1703 }
1704 }
1705 }
1706#ifdef VBOX_WITH_GUEST_PROPS
1707 /*
1708 * Shared information services
1709 */
1710 {
1711 /* Load the service */
1712 rc = pConsole->mVMMDev->hgcmLoadService ("VBoxGuestPropSvc", "VBoxGuestPropSvc");
1713
1714 if (VBOX_FAILURE (rc))
1715 {
1716 LogRel(("VBoxGuestPropSvc is not available. rc = %Vrc\n", rc));
1717 /* That is not a fatal failure. */
1718 rc = VINF_SUCCESS;
1719 }
1720 else
1721 {
1722 rc = CFGMR3InsertNode(pRoot, "GuestProps", &pGuestProps); RC_CHECK();
1723 rc = CFGMR3InsertNode(pGuestProps, "Values", &pValues); RC_CHECK();
1724 rc = CFGMR3InsertNode(pGuestProps, "Timestamps", &pTimestamps); RC_CHECK();
1725 rc = CFGMR3InsertNode(pGuestProps, "Flags", &pFlags); RC_CHECK();
1726
1727 /* Pull over the properties from the server. */
1728 SafeArray <BSTR> names;
1729 SafeArray <BSTR> values;
1730 SafeArray <ULONG64> timestamps;
1731 SafeArray <BSTR> flags;
1732 hrc = pConsole->mControl->PullGuestProperties(ComSafeArrayAsOutParam(names),
1733 ComSafeArrayAsOutParam(values),
1734 ComSafeArrayAsOutParam(timestamps),
1735 ComSafeArrayAsOutParam(flags)); H();
1736 size_t cProps = names.size();
1737 for (size_t i = 0; i < cProps; ++i)
1738 {
1739 rc = CFGMR3InsertString(pValues, Utf8Str(names[i]).raw(), Utf8Str(values[i]).raw()); RC_CHECK();
1740 rc = CFGMR3InsertInteger(pTimestamps, Utf8Str(names[i]).raw(), timestamps[i]); RC_CHECK();
1741 rc = CFGMR3InsertString(pFlags, Utf8Str(names[i]).raw(), Utf8Str(flags[i]).raw()); RC_CHECK();
1742 }
1743
1744 /* Setup the service. */
1745 VBOXHGCMSVCPARM parms[3];
1746
1747 parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
1748 parms[0].u.pointer.addr = pValues;
1749 parms[0].u.pointer.size = sizeof(pValues); /* We don't actually care. */
1750 parms[1].type = VBOX_HGCM_SVC_PARM_PTR;
1751 parms[1].u.pointer.addr = pTimestamps;
1752 parms[1].u.pointer.size = sizeof(pTimestamps);
1753 parms[2].type = VBOX_HGCM_SVC_PARM_PTR;
1754 parms[2].u.pointer.addr = pFlags;
1755 parms[2].u.pointer.size = sizeof(pFlags);
1756
1757 pConsole->mVMMDev->hgcmHostCall ("VBoxGuestPropSvc", guestProp::SET_CFGM_NODE, 3, &parms[0]);
1758
1759 Log(("Set VBoxGuestPropSvc property store\n"));
1760 }
1761 }
1762#endif /* VBOX_WITH_GUEST_PROPS defined */
1763
1764 /*
1765 * CFGM overlay handling.
1766 *
1767 * Here we check the extra data entries for CFGM values
1768 * and create the nodes and insert the values on the fly. Existing
1769 * values will be removed and reinserted. If a value is a valid number,
1770 * it will be inserted as a number, otherwise as a string.
1771 *
1772 * We first perform a run on global extra data, then on the machine
1773 * extra data to support global settings with local overrides.
1774 *
1775 */
1776 Bstr strExtraDataKey;
1777 bool fGlobalExtraData = true;
1778 for (;;)
1779 {
1780 Bstr strNextExtraDataKey;
1781 Bstr strExtraDataValue;
1782
1783 /* get the next key */
1784 if (fGlobalExtraData)
1785 hrc = virtualBox->GetNextExtraDataKey(strExtraDataKey, strNextExtraDataKey.asOutParam(),
1786 strExtraDataValue.asOutParam());
1787 else
1788 hrc = pMachine->GetNextExtraDataKey(strExtraDataKey, strNextExtraDataKey.asOutParam(),
1789 strExtraDataValue.asOutParam());
1790
1791 /* stop if for some reason there's nothing more to request */
1792 if (FAILED(hrc) || !strNextExtraDataKey)
1793 {
1794 /* if we're out of global keys, continue with machine, otherwise we're done */
1795 if (fGlobalExtraData)
1796 {
1797 fGlobalExtraData = false;
1798 strExtraDataKey.setNull();
1799 continue;
1800 }
1801 break;
1802 }
1803
1804 strExtraDataKey = strNextExtraDataKey;
1805 Utf8Str strExtraDataKeyUtf8 = Utf8Str(strExtraDataKey);
1806
1807 /* we only care about keys starting with "VBoxInternal/" */
1808 if (strncmp(strExtraDataKeyUtf8.raw(), "VBoxInternal/", 13) != 0)
1809 continue;
1810 char *pszExtraDataKey = (char*)strExtraDataKeyUtf8.raw() + 13;
1811
1812 /* the key will be in the format "Node1/Node2/Value" or simply "Value". */
1813 PCFGMNODE pNode;
1814 char *pszCFGMValueName = strrchr(pszExtraDataKey, '/');
1815 if (pszCFGMValueName)
1816 {
1817 /* terminate the node and advance to the value */
1818 *pszCFGMValueName = '\0';
1819 pszCFGMValueName++;
1820
1821 /* does the node already exist? */
1822 pNode = CFGMR3GetChild(pRoot, pszExtraDataKey);
1823 if (pNode)
1824 {
1825 /* the value might already exist, remove it to be safe */
1826 CFGMR3RemoveValue(pNode, pszCFGMValueName);
1827 }
1828 else
1829 {
1830 /* create the node */
1831 rc = CFGMR3InsertNode(pRoot, pszExtraDataKey, &pNode);
1832 AssertMsgRC(rc, ("failed to insert node '%s'\n", pszExtraDataKey));
1833 if (VBOX_FAILURE(rc) || !pNode)
1834 continue;
1835 }
1836 }
1837 else
1838 {
1839 pNode = pRoot;
1840 pszCFGMValueName = pszExtraDataKey;
1841 pszExtraDataKey--;
1842
1843 /* the value might already exist, remove it to be safe */
1844 CFGMR3RemoveValue(pNode, pszCFGMValueName);
1845 }
1846
1847 /* now let's have a look at the value */
1848 Utf8Str strCFGMValueUtf8 = Utf8Str(strExtraDataValue);
1849 const char *pszCFGMValue = strCFGMValueUtf8.raw();
1850 /* empty value means remove value which we've already done */
1851 if (pszCFGMValue && *pszCFGMValue)
1852 {
1853 /* if it's a valid number, we'll insert it as such, otherwise string */
1854 uint64_t u64Value;
1855 char *pszNext = NULL;
1856 if ( RTStrToUInt64Ex(pszCFGMValue, &pszNext, 0, &u64Value) == VINF_SUCCESS
1857 && (!pszNext || *pszNext == '\0') /* check if the _whole_ string is a valid number */
1858 )
1859 {
1860 rc = CFGMR3InsertInteger(pNode, pszCFGMValueName, u64Value);
1861 }
1862 else
1863 {
1864 rc = CFGMR3InsertString(pNode, pszCFGMValueName, pszCFGMValue);
1865 }
1866 AssertMsgRC(rc, ("failed to insert CFGM value '%s' to key '%s'\n", pszCFGMValue, pszExtraDataKey));
1867 }
1868 }
1869
1870#undef H
1871#undef RC_CHECK
1872#undef STR_FREE
1873#undef STR_CONV
1874
1875 /* Register VM state change handler */
1876 int rc2 = VMR3AtStateRegister (pVM, Console::vmstateChangeCallback, pConsole);
1877 AssertRC (rc2);
1878 if (VBOX_SUCCESS (rc))
1879 rc = rc2;
1880
1881 /* Register VM runtime error handler */
1882 rc2 = VMR3AtRuntimeErrorRegister (pVM, Console::setVMRuntimeErrorCallback, pConsole);
1883 AssertRC (rc2);
1884 if (VBOX_SUCCESS (rc))
1885 rc = rc2;
1886
1887 /* Save the VM pointer in the machine object */
1888 pConsole->mpVM = pVM;
1889
1890 LogFlowFunc (("vrc = %Vrc\n", rc));
1891 LogFlowFuncLeave();
1892
1893 return rc;
1894}
1895
1896
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