VirtualBox

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

Last change on this file since 5101 was 5101, checked in by vboxsync, 17 years ago

Introduce a new harddisk object which supports virtual harddisk through plugins

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 66.5 KB
Line 
1/** $Id: ConsoleImpl2.cpp 5101 2007-09-28 16:13:06Z 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 innotek GmbH
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 as published by the Free Software Foundation,
17 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
18 * distribution. VirtualBox OSE is distributed in the hope that it will
19 * be useful, but WITHOUT ANY WARRANTY of any kind.
20 */
21
22/*******************************************************************************
23* Header Files *
24*******************************************************************************/
25#include "ConsoleImpl.h"
26#include "DisplayImpl.h"
27#include "VMMDev.h"
28
29// generated header
30#include "SchemaDefs.h"
31
32#include "Logging.h"
33
34#include <iprt/string.h>
35#include <iprt/path.h>
36#include <iprt/dir.h>
37#include <iprt/param.h>
38
39#include <VBox/vmapi.h>
40#include <VBox/err.h>
41#include <VBox/version.h>
42#include <VBox/HostServices/VBoxClipboardSvc.h>
43
44
45/*
46 * VC++ 8 / amd64 has some serious trouble with this function.
47 * As a temporary measure, we'll drop global optimizations.
48 */
49#if defined(_MSC_VER) && defined(RT_ARCH_AMD64)
50# pragma optimize("g", off)
51#endif
52
53/**
54 * Construct the VM configuration tree (CFGM).
55 *
56 * This is a callback for VMR3Create() call. It is called from CFGMR3Init()
57 * in the emulation thread (EMT). Any per thread COM/XPCOM initialization
58 * is done here.
59 *
60 * @param pVM VM handle.
61 * @param pvConsole Pointer to the VMPowerUpTask object.
62 * @return VBox status code.
63 *
64 * @note Locks the Console object for writing.
65 */
66DECLCALLBACK(int) Console::configConstructor(PVM pVM, void *pvConsole)
67{
68 LogFlowFuncEnter();
69
70#if defined(RT_OS_WINDOWS)
71 {
72 /* initialize COM */
73 HRESULT hrc = CoInitializeEx(NULL,
74 COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE |
75 COINIT_SPEED_OVER_MEMORY);
76 LogFlow (("Console::configConstructor(): CoInitializeEx()=%08X\n", hrc));
77 AssertComRCReturn (hrc, VERR_GENERAL_FAILURE);
78 }
79#endif
80
81 AssertReturn (pvConsole, VERR_GENERAL_FAILURE);
82 ComObjPtr <Console> pConsole = static_cast <Console *> (pvConsole);
83
84 AutoCaller autoCaller (pConsole);
85 AssertComRCReturn (autoCaller.rc(), VERR_ACCESS_DENIED);
86
87 /* lock the console because we widely use internal fields and methods */
88 AutoLock alock (pConsole);
89
90 ComPtr <IMachine> pMachine = pConsole->machine();
91
92 int rc;
93 HRESULT hrc;
94 char *psz = NULL;
95 BSTR str = NULL;
96 unsigned i;
97
98#define STR_CONV() do { rc = RTStrUcs2ToUtf8(&psz, str); RC_CHECK(); } while (0)
99#define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } if (psz) { RTStrFree(psz); psz = NULL; } } while (0)
100#define RC_CHECK() do { if (VBOX_FAILURE(rc)) { AssertMsgFailed(("rc=%Vrc\n", rc)); STR_FREE(); return rc; } } while (0)
101#define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%#x\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0)
102
103 /*
104 * Get necessary objects and frequently used parameters.
105 */
106 ComPtr<IVirtualBox> virtualBox;
107 hrc = pMachine->COMGETTER(Parent)(virtualBox.asOutParam()); H();
108
109 ComPtr<IHost> host;
110 hrc = virtualBox->COMGETTER(Host)(host.asOutParam()); H();
111
112 ComPtr <ISystemProperties> systemProperties;
113 hrc = virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam()); H();
114
115 ComPtr<IBIOSSettings> biosSettings;
116 hrc = pMachine->COMGETTER(BIOSSettings)(biosSettings.asOutParam()); H();
117
118 Guid uuid;
119 hrc = pMachine->COMGETTER(Id)(uuid.asOutParam()); H();
120 PCRTUUID pUuid = uuid.raw();
121
122 ULONG cRamMBs;
123 hrc = pMachine->COMGETTER(MemorySize)(&cRamMBs); H();
124
125
126 /*
127 * Get root node first.
128 * This is the only node in the tree.
129 */
130 PCFGMNODE pRoot = CFGMR3GetRoot(pVM);
131 Assert(pRoot);
132
133 /*
134 * Set the root level values.
135 */
136 hrc = pMachine->COMGETTER(Name)(&str); H();
137 STR_CONV();
138 rc = CFGMR3InsertString(pRoot, "Name", psz); RC_CHECK();
139 STR_FREE();
140 rc = CFGMR3InsertBytes(pRoot, "UUID", pUuid, sizeof(*pUuid)); RC_CHECK();
141 rc = CFGMR3InsertInteger(pRoot, "RamSize", cRamMBs * _1M); RC_CHECK();
142 rc = CFGMR3InsertInteger(pRoot, "TimerMillies", 10); RC_CHECK();
143 rc = CFGMR3InsertInteger(pRoot, "RawR3Enabled", 1); /* boolean */ RC_CHECK();
144 rc = CFGMR3InsertInteger(pRoot, "RawR0Enabled", 1); /* boolean */ RC_CHECK();
145 /** @todo Config: RawR0, PATMEnabled and CASMEnabled needs attention later. */
146 rc = CFGMR3InsertInteger(pRoot, "PATMEnabled", 1); /* boolean */ RC_CHECK();
147 rc = CFGMR3InsertInteger(pRoot, "CSAMEnabled", 1); /* boolean */ RC_CHECK();
148
149 /* hardware virtualization extensions */
150 TriStateBool_T hwVirtExEnabled;
151 BOOL fHWVirtExEnabled;
152 hrc = pMachine->COMGETTER(HWVirtExEnabled)(&hwVirtExEnabled); H();
153 if (hwVirtExEnabled == TriStateBool_Default)
154 {
155 /* check the default value */
156 hrc = systemProperties->COMGETTER(HWVirtExEnabled)(&fHWVirtExEnabled); H();
157 }
158 else
159 fHWVirtExEnabled = (hwVirtExEnabled == TriStateBool_True);
160#ifndef RT_OS_DARWIN /** @todo Implement HWVirtExt on darwin. See #1865. */
161 if (fHWVirtExEnabled)
162 {
163 PCFGMNODE pHWVirtExt;
164 rc = CFGMR3InsertNode(pRoot, "HWVirtExt", &pHWVirtExt); RC_CHECK();
165 rc = CFGMR3InsertInteger(pHWVirtExt, "Enabled", 1); RC_CHECK();
166 }
167#endif
168
169 BOOL fIOAPIC;
170 hrc = biosSettings->COMGETTER(IOAPICEnabled)(&fIOAPIC); H();
171
172 /*
173 * PDM config.
174 * Load drivers in VBoxC.[so|dll]
175 */
176 PCFGMNODE pPDM;
177 PCFGMNODE pDrivers;
178 PCFGMNODE pMod;
179 rc = CFGMR3InsertNode(pRoot, "PDM", &pPDM); RC_CHECK();
180 rc = CFGMR3InsertNode(pPDM, "Drivers", &pDrivers); RC_CHECK();
181 rc = CFGMR3InsertNode(pDrivers, "VBoxC", &pMod); RC_CHECK();
182#ifdef VBOX_WITH_XPCOM
183 // VBoxC is located in the components subdirectory
184 char szPathVBoxC[RTPATH_MAX];
185 rc = RTPathAppPrivateArch(szPathVBoxC, RTPATH_MAX - sizeof("/components/VBoxC")); AssertRC(rc);
186 strcat(szPathVBoxC, "/components/VBoxC");
187 rc = CFGMR3InsertString(pMod, "Path", szPathVBoxC); RC_CHECK();
188#else
189 rc = CFGMR3InsertString(pMod, "Path", "VBoxC"); RC_CHECK();
190#endif
191
192 /*
193 * Devices
194 */
195 PCFGMNODE pDevices = NULL; /* /Devices */
196 PCFGMNODE pDev = NULL; /* /Devices/Dev/ */
197 PCFGMNODE pInst = NULL; /* /Devices/Dev/0/ */
198 PCFGMNODE pCfg = NULL; /* /Devices/Dev/.../Config/ */
199 PCFGMNODE pLunL0 = NULL; /* /Devices/Dev/0/LUN#0/ */
200 PCFGMNODE pLunL1 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/ */
201 PCFGMNODE pLunL2 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/Config/ */
202
203 rc = CFGMR3InsertNode(pRoot, "Devices", &pDevices); RC_CHECK();
204
205 /*
206 * PC Arch.
207 */
208 rc = CFGMR3InsertNode(pDevices, "pcarch", &pDev); RC_CHECK();
209 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
210 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
211 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
212
213 /*
214 * PC Bios.
215 */
216 rc = CFGMR3InsertNode(pDevices, "pcbios", &pDev); RC_CHECK();
217 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
218 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
219 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
220 rc = CFGMR3InsertInteger(pCfg, "RamSize", cRamMBs * _1M); RC_CHECK();
221 rc = CFGMR3InsertString(pCfg, "HardDiskDevice", "piix3ide"); RC_CHECK();
222 rc = CFGMR3InsertString(pCfg, "FloppyDevice", "i82078"); RC_CHECK();
223 rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
224 rc = CFGMR3InsertBytes(pCfg, "UUID", pUuid, sizeof(*pUuid)); RC_CHECK();
225
226 DeviceType_T bootDevice;
227 if (SchemaDefs::MaxBootPosition > 9)
228 {
229 AssertMsgFailed (("Too many boot devices %d\n",
230 SchemaDefs::MaxBootPosition));
231 return VERR_INVALID_PARAMETER;
232 }
233
234 for (ULONG pos = 1; pos <= SchemaDefs::MaxBootPosition; pos ++)
235 {
236 hrc = pMachine->GetBootOrder(pos, &bootDevice); H();
237
238 char szParamName[] = "BootDeviceX";
239 szParamName[sizeof (szParamName) - 2] = ((char (pos - 1)) + '0');
240
241 const char *pszBootDevice;
242 switch (bootDevice)
243 {
244 case DeviceType_NoDevice:
245 pszBootDevice = "NONE";
246 break;
247 case DeviceType_HardDiskDevice:
248 pszBootDevice = "IDE";
249 break;
250 case DeviceType_DVDDevice:
251 pszBootDevice = "DVD";
252 break;
253 case DeviceType_FloppyDevice:
254 pszBootDevice = "FLOPPY";
255 break;
256 case DeviceType_NetworkDevice:
257 pszBootDevice = "LAN";
258 break;
259 default:
260 AssertMsgFailed(("Invalid bootDevice=%d\n", bootDevice));
261 return VERR_INVALID_PARAMETER;
262 }
263 rc = CFGMR3InsertString(pCfg, szParamName, pszBootDevice); RC_CHECK();
264 }
265
266 /*
267 * BIOS logo
268 */
269 BOOL fFadeIn;
270 hrc = biosSettings->COMGETTER(LogoFadeIn)(&fFadeIn); H();
271 rc = CFGMR3InsertInteger(pCfg, "FadeIn", fFadeIn ? 1 : 0); RC_CHECK();
272 BOOL fFadeOut;
273 hrc = biosSettings->COMGETTER(LogoFadeOut)(&fFadeOut); H();
274 rc = CFGMR3InsertInteger(pCfg, "FadeOut", fFadeOut ? 1: 0); RC_CHECK();
275 ULONG logoDisplayTime;
276 hrc = biosSettings->COMGETTER(LogoDisplayTime)(&logoDisplayTime); H();
277 rc = CFGMR3InsertInteger(pCfg, "LogoTime", logoDisplayTime); RC_CHECK();
278 Bstr logoImagePath;
279 hrc = biosSettings->COMGETTER(LogoImagePath)(logoImagePath.asOutParam()); H();
280 rc = CFGMR3InsertString(pCfg, "LogoFile", logoImagePath ? Utf8Str(logoImagePath) : ""); RC_CHECK();
281
282 /*
283 * Boot menu
284 */
285 BIOSBootMenuMode_T bootMenuMode;
286 int value;
287 biosSettings->COMGETTER(BootMenuMode)(&bootMenuMode);
288 switch (bootMenuMode)
289 {
290 case BIOSBootMenuMode_Disabled:
291 value = 0;
292 break;
293 case BIOSBootMenuMode_MenuOnly:
294 value = 1;
295 break;
296 default:
297 value = 2;
298 }
299 rc = CFGMR3InsertInteger(pCfg, "ShowBootMenu", value); RC_CHECK();
300
301 /*
302 * The time offset
303 */
304 LONG64 timeOffset;
305 hrc = biosSettings->COMGETTER(TimeOffset)(&timeOffset); H();
306 PCFGMNODE pTMNode;
307 rc = CFGMR3InsertNode(pRoot, "TM", &pTMNode); RC_CHECK();
308 rc = CFGMR3InsertInteger(pTMNode, "UTCOffset", timeOffset * 1000000); RC_CHECK();
309
310 /*
311 * ACPI
312 */
313 BOOL fACPI;
314 hrc = biosSettings->COMGETTER(ACPIEnabled)(&fACPI); H();
315 if (fACPI)
316 {
317 rc = CFGMR3InsertNode(pDevices, "acpi", &pDev); RC_CHECK();
318 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
319 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
320 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
321 rc = CFGMR3InsertInteger(pCfg, "RamSize", cRamMBs * _1M); RC_CHECK();
322 rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
323 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 7); RC_CHECK();
324 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
325
326 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
327 rc = CFGMR3InsertString(pLunL0, "Driver", "ACPIHost"); RC_CHECK();
328 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
329 }
330
331 /*
332 * DMA
333 */
334 rc = CFGMR3InsertNode(pDevices, "8237A", &pDev); RC_CHECK();
335 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
336 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
337
338 /*
339 * PCI bus.
340 */
341 rc = CFGMR3InsertNode(pDevices, "pci", &pDev); /* piix3 */ RC_CHECK();
342 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
343 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
344 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
345 rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
346
347 /*
348 * PS/2 keyboard & mouse.
349 */
350 rc = CFGMR3InsertNode(pDevices, "pckbd", &pDev); RC_CHECK();
351 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
352 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
353 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
354
355 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
356 rc = CFGMR3InsertString(pLunL0, "Driver", "KeyboardQueue"); RC_CHECK();
357 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
358 rc = CFGMR3InsertInteger(pCfg, "QueueSize", 64); RC_CHECK();
359
360 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
361 rc = CFGMR3InsertString(pLunL1, "Driver", "MainKeyboard"); RC_CHECK();
362 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
363 Keyboard *pKeyboard = pConsole->mKeyboard;
364 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pKeyboard); RC_CHECK();
365
366 rc = CFGMR3InsertNode(pInst, "LUN#1", &pLunL0); RC_CHECK();
367 rc = CFGMR3InsertString(pLunL0, "Driver", "MouseQueue"); RC_CHECK();
368 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
369 rc = CFGMR3InsertInteger(pCfg, "QueueSize", 128); RC_CHECK();
370
371 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
372 rc = CFGMR3InsertString(pLunL1, "Driver", "MainMouse"); RC_CHECK();
373 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
374 Mouse *pMouse = pConsole->mMouse;
375 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pMouse); RC_CHECK();
376
377 /*
378 * i82078 Floppy drive controller
379 */
380 ComPtr<IFloppyDrive> floppyDrive;
381 hrc = pMachine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam()); H();
382 BOOL fFloppyEnabled;
383 hrc = floppyDrive->COMGETTER(Enabled)(&fFloppyEnabled); H();
384 if (fFloppyEnabled)
385 {
386 rc = CFGMR3InsertNode(pDevices, "i82078", &pDev); RC_CHECK();
387 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
388 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); RC_CHECK();
389 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
390 rc = CFGMR3InsertInteger(pCfg, "IRQ", 6); RC_CHECK();
391 rc = CFGMR3InsertInteger(pCfg, "DMA", 2); RC_CHECK();
392 rc = CFGMR3InsertInteger(pCfg, "MemMapped", 0 ); RC_CHECK();
393 rc = CFGMR3InsertInteger(pCfg, "IOBase", 0x3f0); RC_CHECK();
394
395 /* Attach the status driver */
396 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
397 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
398 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
399 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapFDLeds[0]); RC_CHECK();
400 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
401 rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
402
403 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
404
405 ComPtr<IFloppyImage> floppyImage;
406 hrc = floppyDrive->GetImage(floppyImage.asOutParam()); H();
407 if (floppyImage)
408 {
409 pConsole->meFloppyState = DriveState_ImageMounted;
410 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
411 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
412 rc = CFGMR3InsertString(pCfg, "Type", "Floppy 1.44"); RC_CHECK();
413 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK();
414
415 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
416 rc = CFGMR3InsertString(pLunL1, "Driver", "RawImage"); RC_CHECK();
417 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
418 hrc = floppyImage->COMGETTER(FilePath)(&str); H();
419 STR_CONV();
420 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
421 STR_FREE();
422 }
423 else
424 {
425 ComPtr<IHostFloppyDrive> hostFloppyDrive;
426 hrc = floppyDrive->GetHostDrive(hostFloppyDrive.asOutParam()); H();
427 if (hostFloppyDrive)
428 {
429 pConsole->meFloppyState = DriveState_HostDriveCaptured;
430 rc = CFGMR3InsertString(pLunL0, "Driver", "HostFloppy"); RC_CHECK();
431 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
432 hrc = hostFloppyDrive->COMGETTER(Name)(&str); H();
433 STR_CONV();
434 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
435 STR_FREE();
436 }
437 else
438 {
439 pConsole->meFloppyState = DriveState_NotMounted;
440 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
441 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
442 rc = CFGMR3InsertString(pCfg, "Type", "Floppy 1.44"); RC_CHECK();
443 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK();
444 }
445 }
446 }
447
448 /*
449 * i8254 Programmable Interval Timer And Dummy Speaker
450 */
451 rc = CFGMR3InsertNode(pDevices, "i8254", &pDev); RC_CHECK();
452 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
453 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
454#ifdef DEBUG
455 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
456#endif
457
458 /*
459 * i8259 Programmable Interrupt Controller.
460 */
461 rc = CFGMR3InsertNode(pDevices, "i8259", &pDev); RC_CHECK();
462 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
463 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
464 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
465
466 /*
467 * Advanced Programmable Interrupt Controller.
468 */
469 rc = CFGMR3InsertNode(pDevices, "apic", &pDev); RC_CHECK();
470 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
471 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
472 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
473 rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
474
475 if (fIOAPIC)
476 {
477 /*
478 * I/O Advanced Programmable Interrupt Controller.
479 */
480 rc = CFGMR3InsertNode(pDevices, "ioapic", &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 /*
487 * RTC MC146818.
488 */
489 rc = CFGMR3InsertNode(pDevices, "mc146818", &pDev); RC_CHECK();
490 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
491 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
492
493 /*
494 * VGA.
495 */
496 rc = CFGMR3InsertNode(pDevices, "vga", &pDev); RC_CHECK();
497 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
498 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
499 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 2); RC_CHECK();
500 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
501 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
502 hrc = pMachine->COMGETTER(VRAMSize)(&cRamMBs); H();
503 rc = CFGMR3InsertInteger(pCfg, "VRamSize", cRamMBs * _1M); RC_CHECK();
504
505 /* Custom VESA mode list */
506 unsigned cModes = 0;
507 for (unsigned iMode = 1; iMode <= 16; iMode++)
508 {
509 char szExtraDataKey[sizeof("CustomVideoModeXX")];
510 RTStrPrintf(szExtraDataKey, sizeof(szExtraDataKey), "CustomVideoMode%d", iMode);
511 hrc = pMachine->GetExtraData(Bstr(szExtraDataKey), &str); H();
512 if (!str || !*str)
513 break;
514 STR_CONV();
515 rc = CFGMR3InsertString(pCfg, szExtraDataKey, psz);
516 STR_FREE();
517 cModes++;
518 }
519 rc = CFGMR3InsertInteger(pCfg, "CustomVideoModes", cModes);
520
521 /* VESA height reduction */
522 ULONG ulHeightReduction;
523 IFramebuffer *pFramebuffer = pConsole->getDisplay()->getFramebuffer();
524 if (pFramebuffer)
525 {
526 hrc = pFramebuffer->COMGETTER(HeightReduction)(&ulHeightReduction); H();
527 }
528 else
529 {
530 /* If framebuffer is not available, there is no height reduction. */
531 ulHeightReduction = 0;
532 }
533 rc = CFGMR3InsertInteger(pCfg, "HeightReduction", ulHeightReduction); RC_CHECK();
534
535 /* Attach the display. */
536 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
537 rc = CFGMR3InsertString(pLunL0, "Driver", "MainDisplay"); RC_CHECK();
538 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
539 Display *pDisplay = pConsole->mDisplay;
540 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pDisplay); RC_CHECK();
541
542 /*
543 * IDE (update this when the main interface changes)
544 */
545 rc = CFGMR3InsertNode(pDevices, "piix3ide", &pDev); /* piix3 */ RC_CHECK();
546 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
547 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
548 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 1); RC_CHECK();
549 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 1); RC_CHECK();
550 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
551
552 /* Attach the status driver */
553 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
554 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
555 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
556 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapIDELeds[0]);RC_CHECK();
557 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
558 rc = CFGMR3InsertInteger(pCfg, "Last", 3); RC_CHECK();
559
560 /* Attach the harddisks */
561 ComPtr<IHardDiskAttachmentCollection> hdaColl;
562 hrc = pMachine->COMGETTER(HardDiskAttachments)(hdaColl.asOutParam()); H();
563 ComPtr<IHardDiskAttachmentEnumerator> hdaEnum;
564 hrc = hdaColl->Enumerate(hdaEnum.asOutParam()); H();
565
566 BOOL fMore = FALSE;
567 while ( SUCCEEDED(hrc = hdaEnum->HasMore(&fMore))
568 && fMore)
569 {
570 ComPtr<IHardDiskAttachment> hda;
571 hrc = hdaEnum->GetNext(hda.asOutParam()); H();
572 ComPtr<IHardDisk> hardDisk;
573 hrc = hda->COMGETTER(HardDisk)(hardDisk.asOutParam()); H();
574 DiskControllerType_T enmCtl;
575 hrc = hda->COMGETTER(Controller)(&enmCtl); H();
576 LONG lDev;
577 hrc = hda->COMGETTER(DeviceNumber)(&lDev); H();
578
579 switch (enmCtl)
580 {
581 case DiskControllerType_IDE0Controller:
582 i = 0;
583 break;
584 case DiskControllerType_IDE1Controller:
585 i = 2;
586 break;
587 default:
588 AssertMsgFailed(("invalid disk controller type: %d\n", enmCtl));
589 return VERR_GENERAL_FAILURE;
590 }
591
592 if (lDev < 0 || lDev >= 2)
593 {
594 AssertMsgFailed(("invalid controller device number: %d\n", lDev));
595 return VERR_GENERAL_FAILURE;
596 }
597
598 i = i + lDev;
599
600 char szLUN[16];
601 RTStrPrintf(szLUN, sizeof(szLUN), "LUN#%d", i);
602 rc = CFGMR3InsertNode(pInst, szLUN, &pLunL0); RC_CHECK();
603 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
604 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
605 rc = CFGMR3InsertString(pCfg, "Type", "HardDisk"); RC_CHECK();
606 rc = CFGMR3InsertInteger(pCfg, "Mountable", 0); RC_CHECK();
607
608 HardDiskStorageType_T hddType;
609 hardDisk->COMGETTER(StorageType)(&hddType);
610 if (hddType == HardDiskStorageType_VirtualDiskImage)
611 {
612 ComPtr<IVirtualDiskImage> vdiDisk = hardDisk;
613 AssertBreak (!vdiDisk.isNull(), hrc = E_FAIL);
614
615 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
616 rc = CFGMR3InsertString(pLunL1, "Driver", "VBoxHDD"); RC_CHECK();
617 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
618 hrc = vdiDisk->COMGETTER(FilePath)(&str); H();
619 STR_CONV();
620 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
621 STR_FREE();
622
623 /* Create an inversed tree of parents. */
624 ComPtr<IHardDisk> parentHardDisk = hardDisk;
625 for (PCFGMNODE pParent = pCfg;;)
626 {
627 ComPtr<IHardDisk> curHardDisk;
628 hrc = parentHardDisk->COMGETTER(Parent)(curHardDisk.asOutParam()); H();
629 if (!curHardDisk)
630 break;
631
632 vdiDisk = curHardDisk;
633 AssertBreak (!vdiDisk.isNull(), hrc = E_FAIL);
634
635 PCFGMNODE pCur;
636 rc = CFGMR3InsertNode(pParent, "Parent", &pCur); RC_CHECK();
637 hrc = vdiDisk->COMGETTER(FilePath)(&str); H();
638 STR_CONV();
639 rc = CFGMR3InsertString(pCur, "Path", psz); RC_CHECK();
640 STR_FREE();
641 rc = CFGMR3InsertInteger(pCur, "ReadOnly", 1); RC_CHECK();
642
643 /* next */
644 pParent = pCur;
645 parentHardDisk = curHardDisk;
646 }
647 }
648 else if (hddType == HardDiskStorageType_ISCSIHardDisk)
649 {
650 ComPtr<IISCSIHardDisk> iSCSIDisk = hardDisk;
651 AssertBreak (!iSCSIDisk.isNull(), hrc = E_FAIL);
652
653 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
654 rc = CFGMR3InsertString(pLunL1, "Driver", "iSCSI"); RC_CHECK();
655 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
656
657 /* Set up the iSCSI initiator driver configuration. */
658 hrc = iSCSIDisk->COMGETTER(Target)(&str); H();
659 STR_CONV();
660 rc = CFGMR3InsertString(pCfg, "TargetName", psz); RC_CHECK();
661 STR_FREE();
662
663 // @todo currently there is no Initiator name config.
664 rc = CFGMR3InsertString(pCfg, "InitiatorName", "iqn.2006-02.de.innotek.initiator"); RC_CHECK();
665
666 ULONG64 lun;
667 hrc = iSCSIDisk->COMGETTER(Lun)(&lun); H();
668 rc = CFGMR3InsertInteger(pCfg, "LUN", lun); RC_CHECK();
669
670 hrc = iSCSIDisk->COMGETTER(Server)(&str); H();
671 STR_CONV();
672 USHORT port;
673 hrc = iSCSIDisk->COMGETTER(Port)(&port); H();
674 if (port != 0)
675 {
676 char *pszTN;
677 RTStrAPrintf(&pszTN, "%s:%u", psz, port);
678 rc = CFGMR3InsertString(pCfg, "TargetAddress", pszTN); RC_CHECK();
679 RTStrFree(pszTN);
680 }
681 else
682 {
683 rc = CFGMR3InsertString(pCfg, "TargetAddress", psz); RC_CHECK();
684 }
685 STR_FREE();
686
687 hrc = iSCSIDisk->COMGETTER(UserName)(&str); H();
688 if (str)
689 {
690 STR_CONV();
691 rc = CFGMR3InsertString(pCfg, "InitiatorUsername", psz); RC_CHECK();
692 STR_FREE();
693 }
694
695 hrc = iSCSIDisk->COMGETTER(Password)(&str); H();
696 if (str)
697 {
698 STR_CONV();
699 rc = CFGMR3InsertString(pCfg, "InitiatorSecret", psz); RC_CHECK();
700 STR_FREE();
701 }
702
703 // @todo currently there is no target username config.
704 //rc = CFGMR3InsertString(pCfg, "TargetUsername", ""); RC_CHECK();
705
706 // @todo currently there is no target password config.
707 //rc = CFGMR3InsertString(pCfg, "TargetSecret", ""); RC_CHECK();
708
709 /* The iSCSI initiator needs an attached iSCSI transport driver. */
710 rc = CFGMR3InsertNode(pLunL1, "AttachedDriver", &pLunL2); RC_CHECK();
711 rc = CFGMR3InsertString(pLunL2, "Driver", "iSCSITCP"); RC_CHECK();
712 /* Currently the transport driver has no config options. */
713 }
714 else if (hddType == HardDiskStorageType_VMDKImage)
715 {
716 ComPtr<IVMDKImage> vmdkDisk = hardDisk;
717 AssertBreak (!vmdkDisk.isNull(), hrc = E_FAIL);
718
719 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
720#if 1 /* Enable new VD container code (and new VMDK), as the bugs are fixed. */
721 rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK();
722#else
723 rc = CFGMR3InsertString(pLunL1, "Driver", "VmdkHDD"); RC_CHECK();
724#endif
725 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
726 hrc = vmdkDisk->COMGETTER(FilePath)(&str); H();
727 STR_CONV();
728 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
729 STR_FREE();
730 }
731 else if (hddType == HardDiskStorageType_CustomHardDisk)
732 {
733 ComPtr<ICustomHardDisk> customHardDisk = hardDisk;
734 AssertBreak (!customHardDisk.isNull(), hrc = E_FAIL);
735
736 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
737 rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK();
738 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
739 hrc = customHardDisk->COMGETTER(Location)(&str); H();
740 STR_CONV();
741 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
742 STR_FREE();
743 hrc = customHardDisk->COMGETTER(Format)(&str); H();
744 STR_CONV();
745 rc = CFGMR3InsertString(pCfg, "Format", psz); RC_CHECK();
746 STR_FREE();
747 }
748 else
749 AssertFailed();
750 }
751 H();
752
753 ComPtr<IDVDDrive> dvdDrive;
754 hrc = pMachine->COMGETTER(DVDDrive)(dvdDrive.asOutParam()); H();
755 if (dvdDrive)
756 {
757 // ASSUME: DVD drive is always attached to LUN#2 (i.e. secondary IDE master)
758 rc = CFGMR3InsertNode(pInst, "LUN#2", &pLunL0); RC_CHECK();
759 ComPtr<IHostDVDDrive> hostDvdDrive;
760 hrc = dvdDrive->GetHostDrive(hostDvdDrive.asOutParam()); H();
761 if (hostDvdDrive)
762 {
763 pConsole->meDVDState = DriveState_HostDriveCaptured;
764 rc = CFGMR3InsertString(pLunL0, "Driver", "HostDVD"); RC_CHECK();
765 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
766 hrc = hostDvdDrive->COMGETTER(Name)(&str); H();
767 STR_CONV();
768 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
769 STR_FREE();
770 BOOL fPassthrough;
771 hrc = dvdDrive->COMGETTER(Passthrough)(&fPassthrough); H();
772 rc = CFGMR3InsertInteger(pCfg, "Passthrough", !!fPassthrough); RC_CHECK();
773 }
774 else
775 {
776 pConsole->meDVDState = DriveState_NotMounted;
777 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
778 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
779 rc = CFGMR3InsertString(pCfg, "Type", "DVD"); RC_CHECK();
780 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK();
781
782 ComPtr<IDVDImage> dvdImage;
783 hrc = dvdDrive->GetImage(dvdImage.asOutParam()); H();
784 if (dvdImage)
785 {
786 pConsole->meDVDState = DriveState_ImageMounted;
787 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
788 rc = CFGMR3InsertString(pLunL1, "Driver", "MediaISO"); RC_CHECK();
789 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
790 hrc = dvdImage->COMGETTER(FilePath)(&str); H();
791 STR_CONV();
792 rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
793 STR_FREE();
794 }
795 }
796 }
797
798 /*
799 * Network adapters
800 */
801 rc = CFGMR3InsertNode(pDevices, "pcnet", &pDev); RC_CHECK();
802 //rc = CFGMR3InsertNode(pDevices, "ne2000", &pDev); RC_CHECK();
803 for (ULONG ulInstance = 0; ulInstance < SchemaDefs::NetworkAdapterCount; ulInstance++)
804 {
805 ComPtr<INetworkAdapter> networkAdapter;
806 hrc = pMachine->GetNetworkAdapter(ulInstance, networkAdapter.asOutParam()); H();
807 BOOL fEnabled = FALSE;
808 hrc = networkAdapter->COMGETTER(Enabled)(&fEnabled); H();
809 if (!fEnabled)
810 continue;
811
812 char szInstance[4]; Assert(ulInstance <= 999);
813 RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance);
814 rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK();
815 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
816 /* the first network card gets the PCI ID 3, the followings starting from 8 */
817 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", !ulInstance ? 3 : ulInstance - 1 + 8); RC_CHECK();
818 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
819 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
820
821 /*
822 * The virtual hardware type.
823 */
824 NetworkAdapterType_T adapterType;
825 hrc = networkAdapter->COMGETTER(AdapterType)(&adapterType); H();
826 switch (adapterType)
827 {
828 case NetworkAdapterType_NetworkAdapterAm79C970A:
829 rc = CFGMR3InsertInteger(pCfg, "Am79C973", 0); RC_CHECK();
830 break;
831 case NetworkAdapterType_NetworkAdapterAm79C973:
832 rc = CFGMR3InsertInteger(pCfg, "Am79C973", 1); RC_CHECK();
833 break;
834 default:
835 AssertMsgFailed(("Invalid network adapter type '%d' for slot '%d'",
836 adapterType, ulInstance));
837 return VERR_GENERAL_FAILURE;
838 }
839
840 /*
841 * Get the MAC address and convert it to binary representation
842 */
843 Bstr macAddr;
844 hrc = networkAdapter->COMGETTER(MACAddress)(macAddr.asOutParam()); H();
845 Assert(macAddr);
846 Utf8Str macAddrUtf8 = macAddr;
847 char *macStr = (char*)macAddrUtf8.raw();
848 Assert(strlen(macStr) == 12);
849 PDMMAC Mac;
850 memset(&Mac, 0, sizeof(Mac));
851 char *pMac = (char*)&Mac;
852 for (uint32_t i = 0; i < 6; i++)
853 {
854 char c1 = *macStr++ - '0';
855 if (c1 > 9)
856 c1 -= 7;
857 char c2 = *macStr++ - '0';
858 if (c2 > 9)
859 c2 -= 7;
860 *pMac++ = ((c1 & 0x0f) << 4) | (c2 & 0x0f);
861 }
862 rc = CFGMR3InsertBytes(pCfg, "MAC", &Mac, sizeof(Mac)); RC_CHECK();
863
864 /*
865 * Check if the cable is supposed to be unplugged
866 */
867 BOOL fCableConnected;
868 hrc = networkAdapter->COMGETTER(CableConnected)(&fCableConnected); H();
869 rc = CFGMR3InsertInteger(pCfg, "CableConnected", fCableConnected ? 1 : 0); RC_CHECK();
870
871 /*
872 * Line speed to report from custom drivers
873 */
874 ULONG ulLineSpeed;
875 hrc = networkAdapter->COMGETTER(LineSpeed)(&ulLineSpeed); H();
876 rc = CFGMR3InsertInteger(pCfg, "LineSpeed", ulLineSpeed); RC_CHECK();
877
878 /*
879 * Attach the status driver.
880 */
881 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
882 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
883 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
884 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapNetworkLeds[ulInstance]); RC_CHECK();
885
886 /*
887 * Enable the packet sniffer if requested.
888 */
889 BOOL fSniffer;
890 hrc = networkAdapter->COMGETTER(TraceEnabled)(&fSniffer); H();
891 if (fSniffer)
892 {
893 /* insert the sniffer filter driver. */
894 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
895 rc = CFGMR3InsertString(pLunL0, "Driver", "NetSniffer"); RC_CHECK();
896 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
897 hrc = networkAdapter->COMGETTER(TraceFile)(&str); H();
898 if (str) /* check convention for indicating default file. */
899 {
900 STR_CONV();
901 rc = CFGMR3InsertString(pCfg, "File", psz); RC_CHECK();
902 STR_FREE();
903 }
904 }
905
906 NetworkAttachmentType_T networkAttachment;
907 hrc = networkAdapter->COMGETTER(AttachmentType)(&networkAttachment); H();
908 switch (networkAttachment)
909 {
910 case NetworkAttachmentType_NoNetworkAttachment:
911 break;
912
913 case NetworkAttachmentType_NATNetworkAttachment:
914 {
915 if (fSniffer)
916 {
917 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
918 }
919 else
920 {
921 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
922 }
923 rc = CFGMR3InsertString(pLunL0, "Driver", "NAT"); RC_CHECK();
924 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
925 /* (Port forwarding goes here.) */
926 break;
927 }
928
929 case NetworkAttachmentType_HostInterfaceNetworkAttachment:
930 {
931 /*
932 * Perform the attachment if required (don't return on error!)
933 */
934 hrc = pConsole->attachToHostInterface(networkAdapter);
935 if (SUCCEEDED(hrc))
936 {
937#ifdef VBOX_WITH_UNIXY_TAP_NETWORKING
938 Assert (pConsole->maTapFD[ulInstance] >= 0);
939 if (pConsole->maTapFD[ulInstance] >= 0)
940 {
941 if (fSniffer)
942 {
943 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
944 }
945 else
946 {
947 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
948 }
949 rc = CFGMR3InsertString(pLunL0, "Driver", "HostInterface"); RC_CHECK();
950 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
951 rc = CFGMR3InsertInteger(pCfg, "FileHandle", pConsole->maTapFD[ulInstance]); RC_CHECK();
952 }
953#elif defined(RT_OS_WINDOWS)
954 if (fSniffer)
955 {
956 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
957 }
958 else
959 {
960 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
961 }
962 Bstr hostInterfaceName;
963 hrc = networkAdapter->COMGETTER(HostInterface)(hostInterfaceName.asOutParam()); H();
964 ComPtr<IHostNetworkInterfaceCollection> coll;
965 hrc = host->COMGETTER(NetworkInterfaces)(coll.asOutParam()); H();
966 ComPtr<IHostNetworkInterface> hostInterface;
967 rc = coll->FindByName(hostInterfaceName, hostInterface.asOutParam());
968 if (!SUCCEEDED(rc))
969 {
970 AssertMsgFailed(("Cannot get GUID for host interface '%ls'\n", hostInterfaceName));
971 hrc = networkAdapter->Detach(); H();
972 }
973 else
974 {
975 rc = CFGMR3InsertString(pLunL0, "Driver", "HostInterface"); RC_CHECK();
976 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
977 rc = CFGMR3InsertString(pCfg, "HostInterfaceName", Utf8Str(hostInterfaceName)); RC_CHECK();
978 Guid hostIFGuid;
979 hrc = hostInterface->COMGETTER(Id)(hostIFGuid.asOutParam()); H();
980 char szDriverGUID[256] = {0};
981 /* add curly brackets */
982 szDriverGUID[0] = '{';
983 strcpy(szDriverGUID + 1, hostIFGuid.toString().raw());
984 strcat(szDriverGUID, "}");
985 rc = CFGMR3InsertBytes(pCfg, "GUID", szDriverGUID, sizeof(szDriverGUID)); RC_CHECK();
986 }
987#else
988# error "Port me"
989#endif
990 }
991 else
992 {
993 switch (hrc)
994 {
995#ifdef RT_OS_LINUX
996 case VERR_ACCESS_DENIED:
997 return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
998 "Failed to open '/dev/net/tun' for read/write access. Please check the "
999 "permissions of that node. Either do 'chmod 0666 /dev/net/tun' or "
1000 "change the group of that node and get member of that group. Make "
1001 "sure that these changes are permanently in particular if you are "
1002 "using udev"));
1003#endif /* RT_OS_LINUX */
1004 default:
1005 AssertMsgFailed(("Could not attach to host interface! Bad!\n"));
1006 return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
1007 "Failed to initialize Host Interface Networking"));
1008 }
1009 }
1010 break;
1011 }
1012
1013 case NetworkAttachmentType_InternalNetworkAttachment:
1014 {
1015 hrc = networkAdapter->COMGETTER(InternalNetwork)(&str); H();
1016 STR_CONV();
1017 if (psz && *psz)
1018 {
1019 if (fSniffer)
1020 {
1021 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
1022 }
1023 else
1024 {
1025 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1026 }
1027 rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK();
1028 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1029 rc = CFGMR3InsertString(pCfg, "Network", psz); RC_CHECK();
1030 }
1031 STR_FREE();
1032 break;
1033 }
1034
1035 default:
1036 AssertMsgFailed(("should not get here!\n"));
1037 break;
1038 }
1039 }
1040
1041 /*
1042 * Serial (UART) Ports
1043 */
1044 rc = CFGMR3InsertNode(pDevices, "serial", &pDev); RC_CHECK();
1045 for (ULONG ulInstance = 0; ulInstance < SchemaDefs::SerialPortCount; ulInstance++)
1046 {
1047 ComPtr<ISerialPort> serialPort;
1048 hrc = pMachine->GetSerialPort (ulInstance, serialPort.asOutParam()); H();
1049 BOOL fEnabled = FALSE;
1050 if (serialPort)
1051 hrc = serialPort->COMGETTER(Enabled)(&fEnabled); H();
1052 if (!fEnabled)
1053 continue;
1054
1055 char szInstance[4]; Assert(ulInstance <= 999);
1056 RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance);
1057
1058 rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK();
1059 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1060
1061 ULONG ulIRQ, ulIOBase;
1062 PortMode_T HostMode;
1063 Bstr path;
1064 BOOL fServer;
1065 hrc = serialPort->COMGETTER(HostMode)(&HostMode); H();
1066 hrc = serialPort->COMGETTER(IRQ)(&ulIRQ); H();
1067 hrc = serialPort->COMGETTER(IOBase)(&ulIOBase); H();
1068 hrc = serialPort->COMGETTER(Path)(path.asOutParam()); H();
1069 hrc = serialPort->COMGETTER(Server)(&fServer); H();
1070 rc = CFGMR3InsertInteger(pCfg, "IRQ", ulIRQ); RC_CHECK();
1071 rc = CFGMR3InsertInteger(pCfg, "IOBase", ulIOBase); RC_CHECK();
1072 if (HostMode != PortMode_DisconnectedPort)
1073 {
1074 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1075 if (HostMode == PortMode_HostPipePort)
1076 {
1077 rc = CFGMR3InsertString(pLunL0, "Driver", "Char"); RC_CHECK();
1078 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
1079 rc = CFGMR3InsertString(pLunL1, "Driver", "NamedPipe"); RC_CHECK();
1080 rc = CFGMR3InsertNode(pLunL1, "Config", &pLunL2); RC_CHECK();
1081 rc = CFGMR3InsertString(pLunL2, "Location", Utf8Str(path)); RC_CHECK();
1082 rc = CFGMR3InsertInteger(pLunL2, "IsServer", fServer); RC_CHECK();
1083 }
1084 else if (HostMode == PortMode_HostDevicePort)
1085 {
1086 rc = CFGMR3InsertString(pLunL0, "Driver", "Host Serial"); RC_CHECK();
1087 rc = CFGMR3InsertNode(pLunL0, "Config", &pLunL1); RC_CHECK();
1088 rc = CFGMR3InsertString(pLunL1, "DevicePath", Utf8Str(path)); RC_CHECK();
1089 }
1090 }
1091 }
1092
1093 /*
1094 * Parallel (LPT) Ports
1095 */
1096 rc = CFGMR3InsertNode(pDevices, "parallel", &pDev); RC_CHECK();
1097 for (ULONG ulInstance = 0; ulInstance < SchemaDefs::ParallelPortCount; ulInstance++)
1098 {
1099 ComPtr<IParallelPort> parallelPort;
1100 hrc = pMachine->GetParallelPort (ulInstance, parallelPort.asOutParam()); H();
1101 BOOL fEnabled = FALSE;
1102 if (parallelPort)
1103 hrc = parallelPort->COMGETTER(Enabled)(&fEnabled); H();
1104 if (!fEnabled)
1105 continue;
1106
1107 char szInstance[4]; Assert(ulInstance <= 999);
1108 RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance);
1109
1110 rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK();
1111 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1112
1113 ULONG ulIRQ, ulIOBase;
1114 Bstr DevicePath;
1115 hrc = parallelPort->COMGETTER(IRQ)(&ulIRQ); H();
1116 hrc = parallelPort->COMGETTER(IOBase)(&ulIOBase); H();
1117 hrc = parallelPort->COMGETTER(Path)(DevicePath.asOutParam()); H();
1118 rc = CFGMR3InsertInteger(pCfg, "IRQ", ulIRQ); RC_CHECK();
1119 rc = CFGMR3InsertInteger(pCfg, "IOBase", ulIOBase); RC_CHECK();
1120 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1121 rc = CFGMR3InsertString(pLunL0, "Driver", "HostParallel"); RC_CHECK();
1122 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
1123 rc = CFGMR3InsertString(pLunL1, "DevicePath", Utf8Str(DevicePath)); RC_CHECK();
1124 }
1125
1126 /*
1127 * VMM Device
1128 */
1129 rc = CFGMR3InsertNode(pDevices, "VMMDev", &pDev); RC_CHECK();
1130 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1131 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1132 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
1133 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 4); RC_CHECK();
1134 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1135
1136 /* the VMM device's Main driver */
1137 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1138 rc = CFGMR3InsertString(pLunL0, "Driver", "MainVMMDev"); RC_CHECK();
1139 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1140 VMMDev *pVMMDev = pConsole->mVMMDev;
1141 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pVMMDev); RC_CHECK();
1142
1143 /*
1144 * Attach the status driver.
1145 */
1146 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
1147 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1148 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1149 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapSharedFolderLed); RC_CHECK();
1150 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1151 rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
1152
1153 /*
1154 * Audio Sniffer Device
1155 */
1156 rc = CFGMR3InsertNode(pDevices, "AudioSniffer", &pDev); RC_CHECK();
1157 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1158 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1159
1160 /* the Audio Sniffer device's Main driver */
1161 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1162 rc = CFGMR3InsertString(pLunL0, "Driver", "MainAudioSniffer"); RC_CHECK();
1163 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1164 AudioSniffer *pAudioSniffer = pConsole->mAudioSniffer;
1165 rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pAudioSniffer); RC_CHECK();
1166
1167 /*
1168 * AC'97 ICH audio
1169 */
1170 ComPtr<IAudioAdapter> audioAdapter;
1171 hrc = pMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam()); H();
1172 BOOL enabled = FALSE;
1173 if (audioAdapter)
1174 {
1175 hrc = audioAdapter->COMGETTER(Enabled)(&enabled); H();
1176 }
1177 if (enabled)
1178 {
1179 rc = CFGMR3InsertNode(pDevices, "ichac97", &pDev); /* ichac97 */
1180 rc = CFGMR3InsertNode(pDev, "0", &pInst);
1181 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
1182 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 5); RC_CHECK();
1183 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1184 rc = CFGMR3InsertNode(pInst, "Config", &pCfg);
1185
1186 /* the Audio driver */
1187 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1188 rc = CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); RC_CHECK();
1189 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1190 AudioDriverType_T audioDriver;
1191 hrc = audioAdapter->COMGETTER(AudioDriver)(&audioDriver); H();
1192 switch (audioDriver)
1193 {
1194 case AudioDriverType_NullAudioDriver:
1195 {
1196 rc = CFGMR3InsertString(pCfg, "AudioDriver", "null"); RC_CHECK();
1197 break;
1198 }
1199#ifdef RT_OS_WINDOWS
1200#ifdef VBOX_WITH_WINMM
1201 case AudioDriverType_WINMMAudioDriver:
1202 {
1203 rc = CFGMR3InsertString(pCfg, "AudioDriver", "winmm"); RC_CHECK();
1204 break;
1205 }
1206#endif
1207 case AudioDriverType_DSOUNDAudioDriver:
1208 {
1209 rc = CFGMR3InsertString(pCfg, "AudioDriver", "dsound"); RC_CHECK();
1210 break;
1211 }
1212#endif /* RT_OS_WINDOWS */
1213#ifdef RT_OS_LINUX
1214 case AudioDriverType_OSSAudioDriver:
1215 {
1216 rc = CFGMR3InsertString(pCfg, "AudioDriver", "oss"); RC_CHECK();
1217 break;
1218 }
1219# ifdef VBOX_WITH_ALSA
1220 case AudioDriverType_ALSAAudioDriver:
1221 {
1222 rc = CFGMR3InsertString(pCfg, "AudioDriver", "alsa"); RC_CHECK();
1223 break;
1224 }
1225# endif
1226#endif /* RT_OS_LINUX */
1227#ifdef RT_OS_DARWIN
1228 case AudioDriverType_CoreAudioDriver:
1229 {
1230 rc = CFGMR3InsertString(pCfg, "AudioDriver", "coreaudio"); RC_CHECK();
1231 break;
1232 }
1233#endif
1234 }
1235 }
1236
1237 /*
1238 * The USB Controller.
1239 */
1240 ComPtr<IUSBController> USBCtlPtr;
1241 hrc = pMachine->COMGETTER(USBController)(USBCtlPtr.asOutParam());
1242 if (USBCtlPtr)
1243 {
1244 BOOL fEnabled;
1245 hrc = USBCtlPtr->COMGETTER(Enabled)(&fEnabled); H();
1246 if (fEnabled)
1247 {
1248 rc = CFGMR3InsertNode(pDevices, "usb-ohci", &pDev); RC_CHECK();
1249 rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
1250 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
1251 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
1252 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 6); RC_CHECK();
1253 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
1254
1255 rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
1256 rc = CFGMR3InsertString(pLunL0, "Driver", "VUSBRootHub"); RC_CHECK();
1257 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1258
1259 /*
1260 * Attach the status driver.
1261 */
1262 rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
1263 rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
1264 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
1265 rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapUSBLed);RC_CHECK();
1266 rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
1267 rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
1268 }
1269 }
1270
1271 /*
1272 * Clipboard
1273 */
1274 {
1275 ClipboardMode_T mode = ClipboardMode_ClipDisabled;
1276 hrc = pMachine->COMGETTER(ClipboardMode) (&mode); H();
1277
1278 if (mode != ClipboardMode_ClipDisabled)
1279 {
1280 /* Load the service */
1281 rc = pConsole->mVMMDev->hgcmLoadService ("VBoxSharedClipboard", "VBoxSharedClipboard");
1282
1283 if (VBOX_FAILURE (rc))
1284 {
1285 LogRel(("VBoxSharedClipboard is not available. rc = %Vrc\n", rc));
1286 /* That is not a fatal failure. */
1287 rc = VINF_SUCCESS;
1288 }
1289 else
1290 {
1291 /* Setup the service. */
1292 VBOXHGCMSVCPARM parm;
1293
1294 parm.type = VBOX_HGCM_SVC_PARM_32BIT;
1295
1296 switch (mode)
1297 {
1298 default:
1299 case ClipboardMode_ClipDisabled:
1300 {
1301 LogRel(("VBoxSharedClipboard mode: Off\n"));
1302 parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_OFF;
1303 break;
1304 }
1305 case ClipboardMode_ClipGuestToHost:
1306 {
1307 LogRel(("VBoxSharedClipboard mode: Guest to Host\n"));
1308 parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST;
1309 break;
1310 }
1311 case ClipboardMode_ClipHostToGuest:
1312 {
1313 LogRel(("VBoxSharedClipboard mode: Host to Guest\n"));
1314 parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_HOST_TO_GUEST;
1315 break;
1316 }
1317 case ClipboardMode_ClipBidirectional:
1318 {
1319 LogRel(("VBoxSharedClipboard mode: Bidirectional\n"));
1320 parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL;
1321 break;
1322 }
1323 }
1324
1325 pConsole->mVMMDev->hgcmHostCall ("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm);
1326
1327 Log(("Set VBoxSharedClipboard mode\n"));
1328 }
1329 }
1330 }
1331
1332 /*
1333 * CFGM overlay handling.
1334 *
1335 * Here we check the extra data entries for CFGM values
1336 * and create the nodes and insert the values on the fly. Existing
1337 * values will be removed and reinserted. If a value is a valid number,
1338 * it will be inserted as a number, otherwise as a string.
1339 *
1340 * We first perform a run on global extra data, then on the machine
1341 * extra data to support global settings with local overrides.
1342 *
1343 */
1344 Bstr strExtraDataKey;
1345 bool fGlobalExtraData = true;
1346 for (;;)
1347 {
1348 Bstr strNextExtraDataKey;
1349 Bstr strExtraDataValue;
1350
1351 /* get the next key */
1352 if (fGlobalExtraData)
1353 hrc = virtualBox->GetNextExtraDataKey(strExtraDataKey, strNextExtraDataKey.asOutParam(),
1354 strExtraDataValue.asOutParam());
1355 else
1356 hrc = pMachine->GetNextExtraDataKey(strExtraDataKey, strNextExtraDataKey.asOutParam(),
1357 strExtraDataValue.asOutParam());
1358
1359 /* stop if for some reason there's nothing more to request */
1360 if (FAILED(hrc) || !strNextExtraDataKey)
1361 {
1362 /* if we're out of global keys, continue with machine, otherwise we're done */
1363 if (fGlobalExtraData)
1364 {
1365 fGlobalExtraData = false;
1366 strExtraDataKey.setNull();
1367 continue;
1368 }
1369 break;
1370 }
1371
1372 strExtraDataKey = strNextExtraDataKey;
1373 Utf8Str strExtraDataKeyUtf8 = Utf8Str(strExtraDataKey);
1374
1375 /* we only care about keys starting with "VBoxInternal/" */
1376 if (strncmp(strExtraDataKeyUtf8.raw(), "VBoxInternal/", 13) != 0)
1377 continue;
1378 char *pszExtraDataKey = (char*)strExtraDataKeyUtf8.raw() + 13;
1379
1380 /* the key will be in the format "Node1/Node2/Value" or simply "Value". */
1381 PCFGMNODE pNode;
1382 char *pszCFGMValueName = strrchr(pszExtraDataKey, '/');
1383 if (pszCFGMValueName)
1384 {
1385 /* terminate the node and advance to the value */
1386 *pszCFGMValueName = '\0';
1387 pszCFGMValueName++;
1388
1389 /* does the node already exist? */
1390 pNode = CFGMR3GetChild(pRoot, pszExtraDataKey);
1391 if (pNode)
1392 {
1393 /* the value might already exist, remove it to be safe */
1394 CFGMR3RemoveValue(pNode, pszCFGMValueName);
1395 }
1396 else
1397 {
1398 /* create the node */
1399 rc = CFGMR3InsertNode(pRoot, pszExtraDataKey, &pNode);
1400 AssertMsgRC(rc, ("failed to insert node '%s'\n", pszExtraDataKey));
1401 if (VBOX_FAILURE(rc) || !pNode)
1402 continue;
1403 }
1404 }
1405 else
1406 {
1407 pNode = pRoot;
1408 pszCFGMValueName = pszExtraDataKey;
1409 pszExtraDataKey--;
1410
1411 /* the value might already exist, remove it to be safe */
1412 CFGMR3RemoveValue(pNode, pszCFGMValueName);
1413 }
1414
1415 /* now let's have a look at the value */
1416 Utf8Str strCFGMValueUtf8 = Utf8Str(strExtraDataValue);
1417 const char *pszCFGMValue = strCFGMValueUtf8.raw();
1418 /* empty value means remove value which we've already done */
1419 if (pszCFGMValue && *pszCFGMValue)
1420 {
1421 /* if it's a valid number, we'll insert it as such, otherwise string */
1422 uint64_t u64Value;
1423 if (RTStrToUInt64Ex(pszCFGMValue, NULL, 0, &u64Value) == VINF_SUCCESS)
1424 {
1425 rc = CFGMR3InsertInteger(pNode, pszCFGMValueName, u64Value);
1426 }
1427 else
1428 {
1429 rc = CFGMR3InsertString(pNode, pszCFGMValueName, pszCFGMValue);
1430 }
1431 AssertMsgRC(rc, ("failed to insert CFGM value '%s' to key '%s'\n", pszCFGMValue, pszExtraDataKey));
1432 }
1433 }
1434
1435#undef H
1436#undef RC_CHECK
1437#undef STR_FREE
1438#undef STR_CONV
1439
1440 /* Register VM state change handler */
1441 int rc2 = VMR3AtStateRegister (pVM, Console::vmstateChangeCallback, pConsole);
1442 AssertRC (rc2);
1443 if (VBOX_SUCCESS (rc))
1444 rc = rc2;
1445
1446 /* Register VM runtime error handler */
1447 rc2 = VMR3AtRuntimeErrorRegister (pVM, Console::setVMRuntimeErrorCallback, pConsole);
1448 AssertRC (rc2);
1449 if (VBOX_SUCCESS (rc))
1450 rc = rc2;
1451
1452 /* Save the VM pointer in the machine object */
1453 pConsole->mpVM = pVM;
1454
1455 LogFlowFunc (("vrc = %Vrc\n", rc));
1456 LogFlowFuncLeave();
1457
1458 return rc;
1459}
1460
1461
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