1 | /* $Id: ConsoleImpl2.cpp 16509 2009-02-04 11:26:01Z 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_CROGL
|
---|
48 | #include <VBox/HostServices/VBoxCrOpenGLSvc.h>
|
---|
49 | #endif
|
---|
50 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
51 | # include <VBox/HostServices/GuestPropertySvc.h>
|
---|
52 | # include <VBox/com/defs.h>
|
---|
53 | # include <VBox/com/array.h>
|
---|
54 | # include <hgcm/HGCM.h> /** @todo it should be possible to register a service
|
---|
55 | * extension using a VMMDev callback. */
|
---|
56 | # include <vector>
|
---|
57 | #endif /* VBOX_WITH_GUEST_PROPS */
|
---|
58 | #include <VBox/intnet.h>
|
---|
59 |
|
---|
60 | #include <VBox/com/string.h>
|
---|
61 | #include <VBox/com/array.h>
|
---|
62 |
|
---|
63 | #if defined(RT_OS_SOLARIS) && defined(VBOX_WITH_NETFLT)
|
---|
64 | # include <zone.h>
|
---|
65 | #endif
|
---|
66 |
|
---|
67 | #if defined(RT_OS_LINUX) && defined(VBOX_WITH_NETFLT)
|
---|
68 | # include <unistd.h>
|
---|
69 | # include <sys/ioctl.h>
|
---|
70 | # include <sys/socket.h>
|
---|
71 | # include <linux/types.h>
|
---|
72 | # include <linux/if.h>
|
---|
73 | # include <linux/wireless.h>
|
---|
74 | #endif
|
---|
75 |
|
---|
76 | #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
|
---|
77 | # include <VBox/WinNetConfig.h>
|
---|
78 | # include <Ntddndis.h>
|
---|
79 | # include <devguid.h>
|
---|
80 | #endif
|
---|
81 |
|
---|
82 |
|
---|
83 | /*
|
---|
84 | * VC++ 8 / amd64 has some serious trouble with this function.
|
---|
85 | * As a temporary measure, we'll drop global optimizations.
|
---|
86 | */
|
---|
87 | #if defined(_MSC_VER) && defined(RT_ARCH_AMD64)
|
---|
88 | # pragma optimize("g", off)
|
---|
89 | #endif
|
---|
90 |
|
---|
91 | /**
|
---|
92 | * Construct the VM configuration tree (CFGM).
|
---|
93 | *
|
---|
94 | * This is a callback for VMR3Create() call. It is called from CFGMR3Init()
|
---|
95 | * in the emulation thread (EMT). Any per thread COM/XPCOM initialization
|
---|
96 | * is done here.
|
---|
97 | *
|
---|
98 | * @param pVM VM handle.
|
---|
99 | * @param pvConsole Pointer to the VMPowerUpTask object.
|
---|
100 | * @return VBox status code.
|
---|
101 | *
|
---|
102 | * @note Locks the Console object for writing.
|
---|
103 | */
|
---|
104 | DECLCALLBACK(int) Console::configConstructor(PVM pVM, void *pvConsole)
|
---|
105 | {
|
---|
106 | LogFlowFuncEnter();
|
---|
107 | /* Note: hardcoded assumption about number of slots; see rom bios */
|
---|
108 | bool afPciDeviceNo[32] = {false};
|
---|
109 |
|
---|
110 | #if !defined (VBOX_WITH_XPCOM)
|
---|
111 | {
|
---|
112 | /* initialize COM */
|
---|
113 | HRESULT hrc = CoInitializeEx(NULL,
|
---|
114 | COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE |
|
---|
115 | COINIT_SPEED_OVER_MEMORY);
|
---|
116 | LogFlow (("Console::configConstructor(): CoInitializeEx()=%08X\n", hrc));
|
---|
117 | AssertComRCReturn (hrc, VERR_GENERAL_FAILURE);
|
---|
118 | }
|
---|
119 | #endif
|
---|
120 |
|
---|
121 | AssertReturn (pvConsole, VERR_GENERAL_FAILURE);
|
---|
122 | ComObjPtr <Console> pConsole = static_cast <Console *> (pvConsole);
|
---|
123 |
|
---|
124 | AutoCaller autoCaller (pConsole);
|
---|
125 | AssertComRCReturn (autoCaller.rc(), VERR_ACCESS_DENIED);
|
---|
126 |
|
---|
127 | /* lock the console because we widely use internal fields and methods */
|
---|
128 | AutoWriteLock alock (pConsole);
|
---|
129 |
|
---|
130 | ComPtr <IMachine> pMachine = pConsole->machine();
|
---|
131 |
|
---|
132 | int rc;
|
---|
133 | HRESULT hrc;
|
---|
134 | char *psz = NULL;
|
---|
135 | BSTR str = NULL;
|
---|
136 |
|
---|
137 | Bstr bstr; /* use this bstr when calling COM methods instead
|
---|
138 | of str as it manages memory! */
|
---|
139 |
|
---|
140 | #define STR_CONV() do { rc = RTUtf16ToUtf8(str, &psz); RC_CHECK(); } while (0)
|
---|
141 | #define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } if (psz) { RTStrFree(psz); psz = NULL; } } while (0)
|
---|
142 | #define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0)
|
---|
143 | #define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%#x\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0)
|
---|
144 |
|
---|
145 | /*
|
---|
146 | * Get necessary objects and frequently used parameters.
|
---|
147 | */
|
---|
148 | ComPtr<IVirtualBox> virtualBox;
|
---|
149 | hrc = pMachine->COMGETTER(Parent)(virtualBox.asOutParam()); H();
|
---|
150 |
|
---|
151 | ComPtr<IHost> host;
|
---|
152 | hrc = virtualBox->COMGETTER(Host)(host.asOutParam()); H();
|
---|
153 |
|
---|
154 | ComPtr <ISystemProperties> systemProperties;
|
---|
155 | hrc = virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam()); H();
|
---|
156 |
|
---|
157 | ComPtr<IBIOSSettings> biosSettings;
|
---|
158 | hrc = pMachine->COMGETTER(BIOSSettings)(biosSettings.asOutParam()); H();
|
---|
159 |
|
---|
160 | Guid uuid;
|
---|
161 | hrc = pMachine->COMGETTER(Id)(uuid.asOutParam()); H();
|
---|
162 | PCRTUUID pUuid = uuid.raw();
|
---|
163 |
|
---|
164 | ULONG cRamMBs;
|
---|
165 | hrc = pMachine->COMGETTER(MemorySize)(&cRamMBs); H();
|
---|
166 |
|
---|
167 | ULONG cCpus = 1;
|
---|
168 | #ifdef VBOX_WITH_SMP_GUESTS
|
---|
169 | hrc = pMachine->COMGETTER(CPUCount)(&cCpus); H();
|
---|
170 | #endif
|
---|
171 |
|
---|
172 | /*
|
---|
173 | * Get root node first.
|
---|
174 | * This is the only node in the tree.
|
---|
175 | */
|
---|
176 | PCFGMNODE pRoot = CFGMR3GetRoot(pVM);
|
---|
177 | Assert(pRoot);
|
---|
178 |
|
---|
179 | /*
|
---|
180 | * Set the root (and VMM) level values.
|
---|
181 | */
|
---|
182 | hrc = pMachine->COMGETTER(Name)(&str); H();
|
---|
183 | STR_CONV();
|
---|
184 | rc = CFGMR3InsertString(pRoot, "Name", psz); RC_CHECK();
|
---|
185 | STR_FREE();
|
---|
186 | rc = CFGMR3InsertBytes(pRoot, "UUID", pUuid, sizeof(*pUuid)); RC_CHECK();
|
---|
187 | rc = CFGMR3InsertInteger(pRoot, "RamSize", cRamMBs * _1M); RC_CHECK();
|
---|
188 | rc = CFGMR3InsertInteger(pRoot, "NumCPUs", cCpus); RC_CHECK();
|
---|
189 | rc = CFGMR3InsertInteger(pRoot, "TimerMillies", 10); RC_CHECK();
|
---|
190 | rc = CFGMR3InsertInteger(pRoot, "RawR3Enabled", 1); /* boolean */ RC_CHECK();
|
---|
191 | rc = CFGMR3InsertInteger(pRoot, "RawR0Enabled", 1); /* boolean */ RC_CHECK();
|
---|
192 | /** @todo Config: RawR0, PATMEnabled and CASMEnabled needs attention later. */
|
---|
193 | rc = CFGMR3InsertInteger(pRoot, "PATMEnabled", 1); /* boolean */ RC_CHECK();
|
---|
194 | rc = CFGMR3InsertInteger(pRoot, "CSAMEnabled", 1); /* boolean */ RC_CHECK();
|
---|
195 |
|
---|
196 | /* hardware virtualization extensions */
|
---|
197 | TSBool_T hwVirtExEnabled;
|
---|
198 | BOOL fHWVirtExEnabled;
|
---|
199 | hrc = pMachine->COMGETTER(HWVirtExEnabled)(&hwVirtExEnabled); H();
|
---|
200 | if (hwVirtExEnabled == TSBool_Default)
|
---|
201 | {
|
---|
202 | /* check the default value */
|
---|
203 | hrc = systemProperties->COMGETTER(HWVirtExEnabled)(&fHWVirtExEnabled); H();
|
---|
204 | }
|
---|
205 | else
|
---|
206 | fHWVirtExEnabled = (hwVirtExEnabled == TSBool_True);
|
---|
207 | #ifdef RT_OS_DARWIN
|
---|
208 | rc = CFGMR3InsertInteger(pRoot, "HwVirtExtForced", fHWVirtExEnabled); RC_CHECK();
|
---|
209 | #else
|
---|
210 | rc = CFGMR3InsertInteger(pRoot, "HwVirtExtForced", 0); RC_CHECK();
|
---|
211 | #endif
|
---|
212 |
|
---|
213 | PCFGMNODE pHWVirtExt;
|
---|
214 | rc = CFGMR3InsertNode(pRoot, "HWVirtExt", &pHWVirtExt); RC_CHECK();
|
---|
215 | if (fHWVirtExEnabled)
|
---|
216 | {
|
---|
217 | rc = CFGMR3InsertInteger(pHWVirtExt, "Enabled", 1); RC_CHECK();
|
---|
218 |
|
---|
219 | /* Indicate whether 64-bit guests are supported or not. */
|
---|
220 | /** @todo This is currently only forced off on 32-bit hosts only because it
|
---|
221 | * makes a lof of difference there (REM and Solaris performance).
|
---|
222 | */
|
---|
223 |
|
---|
224 | Bstr osTypeId;
|
---|
225 | hrc = pMachine->COMGETTER(OSTypeId)(osTypeId.asOutParam()); H();
|
---|
226 |
|
---|
227 | ComPtr <IGuestOSType> guestOSType;
|
---|
228 | hrc = virtualBox->GetGuestOSType(osTypeId, guestOSType.asOutParam()); H();
|
---|
229 |
|
---|
230 | BOOL fSupportsLongMode = false;
|
---|
231 | hrc = host->GetProcessorFeature(ProcessorFeature_LongMode,
|
---|
232 | &fSupportsLongMode); H();
|
---|
233 | BOOL fIs64BitGuest = false;
|
---|
234 | hrc = guestOSType->COMGETTER(Is64Bit)(&fIs64BitGuest); H();
|
---|
235 |
|
---|
236 | if (fSupportsLongMode && fIs64BitGuest)
|
---|
237 | {
|
---|
238 | rc = CFGMR3InsertInteger(pHWVirtExt, "64bitEnabled", 1); RC_CHECK();
|
---|
239 | #if ARCH_BITS == 32 /* The recompiler must use load VBoxREM64 (32-bit host only). */
|
---|
240 | PCFGMNODE pREM;
|
---|
241 | rc = CFGMR3InsertNode(pRoot, "REM", &pREM); RC_CHECK();
|
---|
242 | rc = CFGMR3InsertInteger(pREM, "64bitEnabled", 1); RC_CHECK();
|
---|
243 | #endif
|
---|
244 | }
|
---|
245 | #if ARCH_BITS == 32 /* 32-bit guests only. */
|
---|
246 | else
|
---|
247 | {
|
---|
248 | rc = CFGMR3InsertInteger(pHWVirtExt, "64bitEnabled", 0); RC_CHECK();
|
---|
249 | }
|
---|
250 | #endif
|
---|
251 | }
|
---|
252 |
|
---|
253 | /* Nested paging (VT-x/AMD-V) */
|
---|
254 | BOOL fEnableNestedPaging = false;
|
---|
255 | hrc = pMachine->COMGETTER(HWVirtExNestedPagingEnabled)(&fEnableNestedPaging); H();
|
---|
256 | rc = CFGMR3InsertInteger(pRoot, "EnableNestedPaging", fEnableNestedPaging); RC_CHECK();
|
---|
257 |
|
---|
258 | /* VPID (VT-x) */
|
---|
259 | BOOL fEnableVPID = false;
|
---|
260 | hrc = pMachine->COMGETTER(HWVirtExVPIDEnabled)(&fEnableVPID); H();
|
---|
261 | rc = CFGMR3InsertInteger(pRoot, "EnableVPID", fEnableVPID); RC_CHECK();
|
---|
262 |
|
---|
263 | /* Physical Address Extension (PAE) */
|
---|
264 | BOOL fEnablePAE = false;
|
---|
265 | hrc = pMachine->COMGETTER(PAEEnabled)(&fEnablePAE); H();
|
---|
266 | rc = CFGMR3InsertInteger(pRoot, "EnablePAE", fEnablePAE); RC_CHECK();
|
---|
267 |
|
---|
268 | BOOL fIOAPIC;
|
---|
269 | hrc = biosSettings->COMGETTER(IOAPICEnabled)(&fIOAPIC); H();
|
---|
270 |
|
---|
271 | BOOL fPXEDebug;
|
---|
272 | hrc = biosSettings->COMGETTER(PXEDebugEnabled)(&fPXEDebug); H();
|
---|
273 |
|
---|
274 | /*
|
---|
275 | * Virtual IDE controller type.
|
---|
276 | */
|
---|
277 | IDEControllerType_T controllerType;
|
---|
278 | BOOL fPIIX4;
|
---|
279 | hrc = biosSettings->COMGETTER(IDEControllerType)(&controllerType); H();
|
---|
280 | switch (controllerType)
|
---|
281 | {
|
---|
282 | case IDEControllerType_PIIX3:
|
---|
283 | fPIIX4 = FALSE;
|
---|
284 | break;
|
---|
285 | case IDEControllerType_PIIX4:
|
---|
286 | fPIIX4 = TRUE;
|
---|
287 | break;
|
---|
288 | default:
|
---|
289 | AssertMsgFailed(("Invalid IDE controller type '%d'", controllerType));
|
---|
290 | return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
|
---|
291 | N_("Invalid IDE controller type '%d'"), controllerType);
|
---|
292 | }
|
---|
293 |
|
---|
294 | /*
|
---|
295 | * PDM config.
|
---|
296 | * Load drivers in VBoxC.[so|dll]
|
---|
297 | */
|
---|
298 | PCFGMNODE pPDM;
|
---|
299 | PCFGMNODE pDrivers;
|
---|
300 | PCFGMNODE pMod;
|
---|
301 | rc = CFGMR3InsertNode(pRoot, "PDM", &pPDM); RC_CHECK();
|
---|
302 | rc = CFGMR3InsertNode(pPDM, "Drivers", &pDrivers); RC_CHECK();
|
---|
303 | rc = CFGMR3InsertNode(pDrivers, "VBoxC", &pMod); RC_CHECK();
|
---|
304 | #ifdef VBOX_WITH_XPCOM
|
---|
305 | // VBoxC is located in the components subdirectory
|
---|
306 | char szPathVBoxC[RTPATH_MAX];
|
---|
307 | rc = RTPathAppPrivateArch(szPathVBoxC, RTPATH_MAX - sizeof("/components/VBoxC")); AssertRC(rc);
|
---|
308 | strcat(szPathVBoxC, "/components/VBoxC");
|
---|
309 | rc = CFGMR3InsertString(pMod, "Path", szPathVBoxC); RC_CHECK();
|
---|
310 | #else
|
---|
311 | rc = CFGMR3InsertString(pMod, "Path", "VBoxC"); RC_CHECK();
|
---|
312 | #endif
|
---|
313 |
|
---|
314 | /*
|
---|
315 | * Devices
|
---|
316 | */
|
---|
317 | PCFGMNODE pDevices = NULL; /* /Devices */
|
---|
318 | PCFGMNODE pDev = NULL; /* /Devices/Dev/ */
|
---|
319 | PCFGMNODE pInst = NULL; /* /Devices/Dev/0/ */
|
---|
320 | PCFGMNODE pCfg = NULL; /* /Devices/Dev/.../Config/ */
|
---|
321 | PCFGMNODE pLunL0 = NULL; /* /Devices/Dev/0/LUN#0/ */
|
---|
322 | PCFGMNODE pLunL1 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/ */
|
---|
323 | PCFGMNODE pLunL2 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/Config/ */
|
---|
324 | PCFGMNODE pIdeInst = NULL; /* /Devices/piix3ide/0/ */
|
---|
325 | PCFGMNODE pSataInst = NULL; /* /Devices/ahci/0/ */
|
---|
326 | PCFGMNODE pBiosCfg = NULL; /* /Devices/pcbios/0/Config/ */
|
---|
327 |
|
---|
328 | rc = CFGMR3InsertNode(pRoot, "Devices", &pDevices); RC_CHECK();
|
---|
329 |
|
---|
330 | /*
|
---|
331 | * PC Arch.
|
---|
332 | */
|
---|
333 | rc = CFGMR3InsertNode(pDevices, "pcarch", &pDev); RC_CHECK();
|
---|
334 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
335 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
336 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
337 |
|
---|
338 | /*
|
---|
339 | * PC Bios.
|
---|
340 | */
|
---|
341 | rc = CFGMR3InsertNode(pDevices, "pcbios", &pDev); RC_CHECK();
|
---|
342 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
343 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
344 | rc = CFGMR3InsertNode(pInst, "Config", &pBiosCfg); RC_CHECK();
|
---|
345 | rc = CFGMR3InsertInteger(pBiosCfg, "RamSize", cRamMBs * _1M); RC_CHECK();
|
---|
346 | rc = CFGMR3InsertInteger(pBiosCfg, "NumCPUs", cCpus); RC_CHECK();
|
---|
347 | rc = CFGMR3InsertString(pBiosCfg, "HardDiskDevice", "piix3ide"); RC_CHECK();
|
---|
348 | rc = CFGMR3InsertString(pBiosCfg, "FloppyDevice", "i82078"); RC_CHECK();
|
---|
349 | rc = CFGMR3InsertInteger(pBiosCfg, "IOAPIC", fIOAPIC); RC_CHECK();
|
---|
350 | rc = CFGMR3InsertInteger(pBiosCfg, "PXEDebug", fPXEDebug); RC_CHECK();
|
---|
351 | rc = CFGMR3InsertBytes(pBiosCfg, "UUID", pUuid, sizeof(*pUuid)); RC_CHECK();
|
---|
352 |
|
---|
353 | DeviceType_T bootDevice;
|
---|
354 | if (SchemaDefs::MaxBootPosition > 9)
|
---|
355 | {
|
---|
356 | AssertMsgFailed (("Too many boot devices %d\n",
|
---|
357 | SchemaDefs::MaxBootPosition));
|
---|
358 | return VERR_INVALID_PARAMETER;
|
---|
359 | }
|
---|
360 |
|
---|
361 | for (ULONG pos = 1; pos <= SchemaDefs::MaxBootPosition; pos ++)
|
---|
362 | {
|
---|
363 | hrc = pMachine->GetBootOrder(pos, &bootDevice); H();
|
---|
364 |
|
---|
365 | char szParamName[] = "BootDeviceX";
|
---|
366 | szParamName[sizeof (szParamName) - 2] = ((char (pos - 1)) + '0');
|
---|
367 |
|
---|
368 | const char *pszBootDevice;
|
---|
369 | switch (bootDevice)
|
---|
370 | {
|
---|
371 | case DeviceType_Null:
|
---|
372 | pszBootDevice = "NONE";
|
---|
373 | break;
|
---|
374 | case DeviceType_HardDisk:
|
---|
375 | pszBootDevice = "IDE";
|
---|
376 | break;
|
---|
377 | case DeviceType_DVD:
|
---|
378 | pszBootDevice = "DVD";
|
---|
379 | break;
|
---|
380 | case DeviceType_Floppy:
|
---|
381 | pszBootDevice = "FLOPPY";
|
---|
382 | break;
|
---|
383 | case DeviceType_Network:
|
---|
384 | pszBootDevice = "LAN";
|
---|
385 | break;
|
---|
386 | default:
|
---|
387 | AssertMsgFailed(("Invalid bootDevice=%d\n", bootDevice));
|
---|
388 | return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
|
---|
389 | N_("Invalid boot device '%d'"), bootDevice);
|
---|
390 | }
|
---|
391 | rc = CFGMR3InsertString(pBiosCfg, szParamName, pszBootDevice); RC_CHECK();
|
---|
392 | }
|
---|
393 |
|
---|
394 | /*
|
---|
395 | * The time offset
|
---|
396 | */
|
---|
397 | LONG64 timeOffset;
|
---|
398 | hrc = biosSettings->COMGETTER(TimeOffset)(&timeOffset); H();
|
---|
399 | PCFGMNODE pTMNode;
|
---|
400 | rc = CFGMR3InsertNode(pRoot, "TM", &pTMNode); RC_CHECK();
|
---|
401 | rc = CFGMR3InsertInteger(pTMNode, "UTCOffset", timeOffset * 1000000); RC_CHECK();
|
---|
402 |
|
---|
403 | /*
|
---|
404 | * DMA
|
---|
405 | */
|
---|
406 | rc = CFGMR3InsertNode(pDevices, "8237A", &pDev); RC_CHECK();
|
---|
407 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
408 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
409 |
|
---|
410 | /*
|
---|
411 | * PCI buses.
|
---|
412 | */
|
---|
413 | rc = CFGMR3InsertNode(pDevices, "pci", &pDev); /* piix3 */ RC_CHECK();
|
---|
414 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
415 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
416 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
417 | rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
|
---|
418 |
|
---|
419 | #if 0 /* enable this to test PCI bridging */
|
---|
420 | rc = CFGMR3InsertNode(pDevices, "pcibridge", &pDev); RC_CHECK();
|
---|
421 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
422 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
423 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
424 | rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 14); RC_CHECK();
|
---|
425 | rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
|
---|
426 | rc = CFGMR3InsertInteger(pInst, "PCIBusNo", 0);/* -> pci[0] */ RC_CHECK();
|
---|
427 |
|
---|
428 | rc = CFGMR3InsertNode(pDev, "1", &pInst); RC_CHECK();
|
---|
429 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
430 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
431 | rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 1); RC_CHECK();
|
---|
432 | rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
|
---|
433 | rc = CFGMR3InsertInteger(pInst, "PCIBusNo", 1);/* ->pcibridge[0] */ RC_CHECK();
|
---|
434 |
|
---|
435 | rc = CFGMR3InsertNode(pDev, "2", &pInst); RC_CHECK();
|
---|
436 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
437 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
438 | rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 3); RC_CHECK();
|
---|
439 | rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
|
---|
440 | rc = CFGMR3InsertInteger(pInst, "PCIBusNo", 1);/* ->pcibridge[0] */ RC_CHECK();
|
---|
441 | #endif
|
---|
442 |
|
---|
443 | /*
|
---|
444 | * High Precision Event Timer (HPET)
|
---|
445 | */
|
---|
446 | BOOL fHpetEnabled;
|
---|
447 | /** @todo: implement appropriate getter */
|
---|
448 | #ifdef VBOX_WITH_HPET
|
---|
449 | fHpetEnabled = true;
|
---|
450 | #else
|
---|
451 | fHpetEnabled = false;
|
---|
452 | #endif
|
---|
453 |
|
---|
454 | if (fHpetEnabled)
|
---|
455 | {
|
---|
456 | rc = CFGMR3InsertNode(pDevices, "hpet", &pDev); RC_CHECK();
|
---|
457 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
458 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
459 | }
|
---|
460 |
|
---|
461 | /*
|
---|
462 | * System Management Controller (SMC)
|
---|
463 | */
|
---|
464 | BOOL fSmcEnabled;
|
---|
465 | /** @todo: implement appropriate getter */
|
---|
466 | #ifdef VBOX_WITH_SMC
|
---|
467 | fSmcEnabled = true;
|
---|
468 | #else
|
---|
469 | fSmcEnabled = false;
|
---|
470 | #endif
|
---|
471 | if (fSmcEnabled)
|
---|
472 | {
|
---|
473 | rc = CFGMR3InsertNode(pDevices, "smc", &pDev); RC_CHECK();
|
---|
474 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
475 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
476 | }
|
---|
477 |
|
---|
478 | /*
|
---|
479 | * Low Pin Count (LPC) bus
|
---|
480 | */
|
---|
481 | BOOL fLpcEnabled;
|
---|
482 | /** @todo: implement appropriate getter */
|
---|
483 | #ifdef VBOX_WITH_LPC
|
---|
484 | fLpcEnabled = true;
|
---|
485 | #else
|
---|
486 | fLpcEnabled = false;
|
---|
487 | #endif
|
---|
488 |
|
---|
489 | if (fLpcEnabled)
|
---|
490 | {
|
---|
491 | rc = CFGMR3InsertNode(pDevices, "lpc", &pDev); RC_CHECK();
|
---|
492 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
493 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
494 | }
|
---|
495 |
|
---|
496 | /*
|
---|
497 | * PS/2 keyboard & mouse.
|
---|
498 | */
|
---|
499 | rc = CFGMR3InsertNode(pDevices, "pckbd", &pDev); RC_CHECK();
|
---|
500 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
501 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
502 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
503 |
|
---|
504 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
505 | rc = CFGMR3InsertString(pLunL0, "Driver", "KeyboardQueue"); RC_CHECK();
|
---|
506 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
507 | rc = CFGMR3InsertInteger(pCfg, "QueueSize", 64); RC_CHECK();
|
---|
508 |
|
---|
509 | rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
|
---|
510 | rc = CFGMR3InsertString(pLunL1, "Driver", "MainKeyboard"); RC_CHECK();
|
---|
511 | rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
|
---|
512 | Keyboard *pKeyboard = pConsole->mKeyboard;
|
---|
513 | rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pKeyboard); RC_CHECK();
|
---|
514 |
|
---|
515 | rc = CFGMR3InsertNode(pInst, "LUN#1", &pLunL0); RC_CHECK();
|
---|
516 | rc = CFGMR3InsertString(pLunL0, "Driver", "MouseQueue"); RC_CHECK();
|
---|
517 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
518 | rc = CFGMR3InsertInteger(pCfg, "QueueSize", 128); RC_CHECK();
|
---|
519 |
|
---|
520 | rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
|
---|
521 | rc = CFGMR3InsertString(pLunL1, "Driver", "MainMouse"); RC_CHECK();
|
---|
522 | rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
|
---|
523 | Mouse *pMouse = pConsole->mMouse;
|
---|
524 | rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pMouse); RC_CHECK();
|
---|
525 |
|
---|
526 | /*
|
---|
527 | * i82078 Floppy drive controller
|
---|
528 | */
|
---|
529 | ComPtr<IFloppyDrive> floppyDrive;
|
---|
530 | hrc = pMachine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam()); H();
|
---|
531 | BOOL fFdcEnabled;
|
---|
532 | hrc = floppyDrive->COMGETTER(Enabled)(&fFdcEnabled); H();
|
---|
533 | if (fFdcEnabled)
|
---|
534 | {
|
---|
535 | rc = CFGMR3InsertNode(pDevices, "i82078", &pDev); RC_CHECK();
|
---|
536 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
537 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); RC_CHECK();
|
---|
538 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
539 | rc = CFGMR3InsertInteger(pCfg, "IRQ", 6); RC_CHECK();
|
---|
540 | rc = CFGMR3InsertInteger(pCfg, "DMA", 2); RC_CHECK();
|
---|
541 | rc = CFGMR3InsertInteger(pCfg, "MemMapped", 0 ); RC_CHECK();
|
---|
542 | rc = CFGMR3InsertInteger(pCfg, "IOBase", 0x3f0); RC_CHECK();
|
---|
543 |
|
---|
544 | /* Attach the status driver */
|
---|
545 | rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
|
---|
546 | rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
|
---|
547 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
548 | rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapFDLeds[0]); RC_CHECK();
|
---|
549 | rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
|
---|
550 | rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
|
---|
551 |
|
---|
552 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
553 |
|
---|
554 | ComPtr<IFloppyImage2> floppyImage;
|
---|
555 | hrc = floppyDrive->GetImage(floppyImage.asOutParam()); H();
|
---|
556 | if (floppyImage)
|
---|
557 | {
|
---|
558 | pConsole->meFloppyState = DriveState_ImageMounted;
|
---|
559 | rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
|
---|
560 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
561 | rc = CFGMR3InsertString(pCfg, "Type", "Floppy 1.44"); RC_CHECK();
|
---|
562 | rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK();
|
---|
563 |
|
---|
564 | rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
|
---|
565 | rc = CFGMR3InsertString(pLunL1, "Driver", "RawImage"); RC_CHECK();
|
---|
566 | rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
|
---|
567 | hrc = floppyImage->COMGETTER(Location)(&str); H();
|
---|
568 | STR_CONV();
|
---|
569 | rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
|
---|
570 | STR_FREE();
|
---|
571 | }
|
---|
572 | else
|
---|
573 | {
|
---|
574 | ComPtr<IHostFloppyDrive> hostFloppyDrive;
|
---|
575 | hrc = floppyDrive->GetHostDrive(hostFloppyDrive.asOutParam()); H();
|
---|
576 | if (hostFloppyDrive)
|
---|
577 | {
|
---|
578 | pConsole->meFloppyState = DriveState_HostDriveCaptured;
|
---|
579 | rc = CFGMR3InsertString(pLunL0, "Driver", "HostFloppy"); RC_CHECK();
|
---|
580 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
581 | hrc = hostFloppyDrive->COMGETTER(Name)(&str); H();
|
---|
582 | STR_CONV();
|
---|
583 | rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
|
---|
584 | STR_FREE();
|
---|
585 | }
|
---|
586 | else
|
---|
587 | {
|
---|
588 | pConsole->meFloppyState = DriveState_NotMounted;
|
---|
589 | rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
|
---|
590 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
591 | rc = CFGMR3InsertString(pCfg, "Type", "Floppy 1.44"); RC_CHECK();
|
---|
592 | rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK();
|
---|
593 | }
|
---|
594 | }
|
---|
595 | }
|
---|
596 |
|
---|
597 | /*
|
---|
598 | * ACPI
|
---|
599 | */
|
---|
600 | BOOL fACPI;
|
---|
601 | hrc = biosSettings->COMGETTER(ACPIEnabled)(&fACPI); H();
|
---|
602 | if (fACPI)
|
---|
603 | {
|
---|
604 | rc = CFGMR3InsertNode(pDevices, "acpi", &pDev); RC_CHECK();
|
---|
605 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
606 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
607 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
608 | rc = CFGMR3InsertInteger(pCfg, "RamSize", cRamMBs * _1M); RC_CHECK();
|
---|
609 | rc = CFGMR3InsertInteger(pCfg, "NumCPUs", cCpus); RC_CHECK();
|
---|
610 |
|
---|
611 | rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
|
---|
612 | rc = CFGMR3InsertInteger(pCfg, "FdcEnabled", fFdcEnabled); RC_CHECK();
|
---|
613 | #ifdef VBOX_WITH_HPET
|
---|
614 | rc = CFGMR3InsertInteger(pCfg, "HpetEnabled", fHpetEnabled); RC_CHECK();
|
---|
615 | #endif
|
---|
616 | #ifdef VBOX_WITH_SMC
|
---|
617 | rc = CFGMR3InsertInteger(pCfg, "SmcEnabled", fSmcEnabled); RC_CHECK();
|
---|
618 | #endif
|
---|
619 | rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 7); RC_CHECK();
|
---|
620 | Assert(!afPciDeviceNo[7]);
|
---|
621 | afPciDeviceNo[7] = true;
|
---|
622 | rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
|
---|
623 |
|
---|
624 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
625 | rc = CFGMR3InsertString(pLunL0, "Driver", "ACPIHost"); RC_CHECK();
|
---|
626 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
627 | }
|
---|
628 |
|
---|
629 | /*
|
---|
630 | * i8254 Programmable Interval Timer And Dummy Speaker
|
---|
631 | */
|
---|
632 | rc = CFGMR3InsertNode(pDevices, "i8254", &pDev); RC_CHECK();
|
---|
633 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
634 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
635 | #ifdef DEBUG
|
---|
636 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
637 | #endif
|
---|
638 |
|
---|
639 | /*
|
---|
640 | * i8259 Programmable Interrupt Controller.
|
---|
641 | */
|
---|
642 | rc = CFGMR3InsertNode(pDevices, "i8259", &pDev); RC_CHECK();
|
---|
643 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
644 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
645 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
646 |
|
---|
647 | /*
|
---|
648 | * Advanced Programmable Interrupt Controller.
|
---|
649 | * SMP: Each CPU has a LAPIC, but we have a single device representing all LAPICs states,
|
---|
650 | * thus only single insert
|
---|
651 | */
|
---|
652 | rc = CFGMR3InsertNode(pDevices, "apic", &pDev); RC_CHECK();
|
---|
653 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
654 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
655 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
656 | rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); RC_CHECK();
|
---|
657 | rc = CFGMR3InsertInteger(pCfg, "NumCPUs", cCpus); RC_CHECK();
|
---|
658 |
|
---|
659 | /* SMP: @todo: IOAPIC may be required for SMP configs */
|
---|
660 | if (fIOAPIC)
|
---|
661 | {
|
---|
662 | /*
|
---|
663 | * I/O Advanced Programmable Interrupt Controller.
|
---|
664 | */
|
---|
665 | rc = CFGMR3InsertNode(pDevices, "ioapic", &pDev); RC_CHECK();
|
---|
666 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
667 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
668 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
669 | }
|
---|
670 |
|
---|
671 | /*
|
---|
672 | * RTC MC146818.
|
---|
673 | */
|
---|
674 | rc = CFGMR3InsertNode(pDevices, "mc146818", &pDev); RC_CHECK();
|
---|
675 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
676 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
677 |
|
---|
678 | /*
|
---|
679 | * VGA.
|
---|
680 | */
|
---|
681 | rc = CFGMR3InsertNode(pDevices, "vga", &pDev); RC_CHECK();
|
---|
682 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
683 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
684 | rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 2); RC_CHECK();
|
---|
685 | Assert(!afPciDeviceNo[2]);
|
---|
686 | afPciDeviceNo[2] = true;
|
---|
687 | rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
|
---|
688 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
689 | hrc = pMachine->COMGETTER(VRAMSize)(&cRamMBs); H();
|
---|
690 | rc = CFGMR3InsertInteger(pCfg, "VRamSize", cRamMBs * _1M); RC_CHECK();
|
---|
691 | #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE /* not safe here yet. */
|
---|
692 | rc = CFGMR3InsertInteger(pCfg, "R0Enabled", fHWVirtExEnabled); RC_CHECK();
|
---|
693 | #endif
|
---|
694 |
|
---|
695 | /*
|
---|
696 | * BIOS logo
|
---|
697 | */
|
---|
698 | BOOL fFadeIn;
|
---|
699 | hrc = biosSettings->COMGETTER(LogoFadeIn)(&fFadeIn); H();
|
---|
700 | rc = CFGMR3InsertInteger(pCfg, "FadeIn", fFadeIn ? 1 : 0); RC_CHECK();
|
---|
701 | BOOL fFadeOut;
|
---|
702 | hrc = biosSettings->COMGETTER(LogoFadeOut)(&fFadeOut); H();
|
---|
703 | rc = CFGMR3InsertInteger(pCfg, "FadeOut", fFadeOut ? 1: 0); RC_CHECK();
|
---|
704 | ULONG logoDisplayTime;
|
---|
705 | hrc = biosSettings->COMGETTER(LogoDisplayTime)(&logoDisplayTime); H();
|
---|
706 | rc = CFGMR3InsertInteger(pCfg, "LogoTime", logoDisplayTime); RC_CHECK();
|
---|
707 | Bstr logoImagePath;
|
---|
708 | hrc = biosSettings->COMGETTER(LogoImagePath)(logoImagePath.asOutParam()); H();
|
---|
709 | rc = CFGMR3InsertString(pCfg, "LogoFile", logoImagePath ? Utf8Str(logoImagePath) : ""); RC_CHECK();
|
---|
710 |
|
---|
711 | /*
|
---|
712 | * Boot menu
|
---|
713 | */
|
---|
714 | BIOSBootMenuMode_T bootMenuMode;
|
---|
715 | int value;
|
---|
716 | biosSettings->COMGETTER(BootMenuMode)(&bootMenuMode);
|
---|
717 | switch (bootMenuMode)
|
---|
718 | {
|
---|
719 | case BIOSBootMenuMode_Disabled:
|
---|
720 | value = 0;
|
---|
721 | break;
|
---|
722 | case BIOSBootMenuMode_MenuOnly:
|
---|
723 | value = 1;
|
---|
724 | break;
|
---|
725 | default:
|
---|
726 | value = 2;
|
---|
727 | }
|
---|
728 | rc = CFGMR3InsertInteger(pCfg, "ShowBootMenu", value); RC_CHECK();
|
---|
729 |
|
---|
730 | /* Custom VESA mode list */
|
---|
731 | unsigned cModes = 0;
|
---|
732 | for (unsigned iMode = 1; iMode <= 16; iMode++)
|
---|
733 | {
|
---|
734 | char szExtraDataKey[sizeof("CustomVideoModeXX")];
|
---|
735 | RTStrPrintf(szExtraDataKey, sizeof(szExtraDataKey), "CustomVideoMode%d", iMode);
|
---|
736 | hrc = pMachine->GetExtraData(Bstr(szExtraDataKey), &str); H();
|
---|
737 | if (!str || !*str)
|
---|
738 | break;
|
---|
739 | STR_CONV();
|
---|
740 | rc = CFGMR3InsertString(pCfg, szExtraDataKey, psz);
|
---|
741 | STR_FREE();
|
---|
742 | cModes++;
|
---|
743 | }
|
---|
744 | rc = CFGMR3InsertInteger(pCfg, "CustomVideoModes", cModes);
|
---|
745 |
|
---|
746 | /* VESA height reduction */
|
---|
747 | ULONG ulHeightReduction;
|
---|
748 | IFramebuffer *pFramebuffer = pConsole->getDisplay()->getFramebuffer();
|
---|
749 | if (pFramebuffer)
|
---|
750 | {
|
---|
751 | hrc = pFramebuffer->COMGETTER(HeightReduction)(&ulHeightReduction); H();
|
---|
752 | }
|
---|
753 | else
|
---|
754 | {
|
---|
755 | /* If framebuffer is not available, there is no height reduction. */
|
---|
756 | ulHeightReduction = 0;
|
---|
757 | }
|
---|
758 | rc = CFGMR3InsertInteger(pCfg, "HeightReduction", ulHeightReduction); RC_CHECK();
|
---|
759 |
|
---|
760 | /* Attach the display. */
|
---|
761 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
762 | rc = CFGMR3InsertString(pLunL0, "Driver", "MainDisplay"); RC_CHECK();
|
---|
763 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
764 | Display *pDisplay = pConsole->mDisplay;
|
---|
765 | rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pDisplay); RC_CHECK();
|
---|
766 |
|
---|
767 | /*
|
---|
768 | * IDE (update this when the main interface changes)
|
---|
769 | */
|
---|
770 | rc = CFGMR3InsertNode(pDevices, "piix3ide", &pDev); /* piix3 */ RC_CHECK();
|
---|
771 | rc = CFGMR3InsertNode(pDev, "0", &pIdeInst); RC_CHECK();
|
---|
772 | rc = CFGMR3InsertInteger(pIdeInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
773 | rc = CFGMR3InsertInteger(pIdeInst, "PCIDeviceNo", 1); RC_CHECK();
|
---|
774 | Assert(!afPciDeviceNo[1]);
|
---|
775 | afPciDeviceNo[1] = true;
|
---|
776 | rc = CFGMR3InsertInteger(pIdeInst, "PCIFunctionNo", 1); RC_CHECK();
|
---|
777 | rc = CFGMR3InsertNode(pIdeInst, "Config", &pCfg); RC_CHECK();
|
---|
778 | rc = CFGMR3InsertInteger(pCfg, "PIIX4", fPIIX4); /* boolean */ RC_CHECK();
|
---|
779 |
|
---|
780 | /* Attach the status driver */
|
---|
781 | rc = CFGMR3InsertNode(pIdeInst, "LUN#999", &pLunL0); RC_CHECK();
|
---|
782 | rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
|
---|
783 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
784 | rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapIDELeds[0]);RC_CHECK();
|
---|
785 | rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
|
---|
786 | rc = CFGMR3InsertInteger(pCfg, "Last", 3); RC_CHECK();
|
---|
787 |
|
---|
788 | /*
|
---|
789 | * SATA controller
|
---|
790 | */
|
---|
791 | ComPtr<ISATAController> sataController;
|
---|
792 | hrc = pMachine->COMGETTER(SATAController)(sataController.asOutParam());
|
---|
793 | BOOL enabled = FALSE;
|
---|
794 |
|
---|
795 | if (sataController)
|
---|
796 | {
|
---|
797 | hrc = sataController->COMGETTER(Enabled)(&enabled); H();
|
---|
798 |
|
---|
799 | if (enabled)
|
---|
800 | {
|
---|
801 | rc = CFGMR3InsertNode(pDevices, "ahci", &pDev); RC_CHECK();
|
---|
802 | rc = CFGMR3InsertNode(pDev, "0", &pSataInst); RC_CHECK();
|
---|
803 | rc = CFGMR3InsertInteger(pSataInst, "Trusted", 1); RC_CHECK();
|
---|
804 | rc = CFGMR3InsertInteger(pSataInst, "PCIDeviceNo", 13); RC_CHECK();
|
---|
805 | Assert(!afPciDeviceNo[13]);
|
---|
806 | afPciDeviceNo[13] = true;
|
---|
807 | rc = CFGMR3InsertInteger(pSataInst, "PCIFunctionNo", 0); RC_CHECK();
|
---|
808 | rc = CFGMR3InsertNode(pSataInst, "Config", &pCfg); RC_CHECK();
|
---|
809 |
|
---|
810 | ULONG cPorts = 0;
|
---|
811 | hrc = sataController->COMGETTER(PortCount)(&cPorts); H();
|
---|
812 | rc = CFGMR3InsertInteger(pCfg, "PortCount", cPorts); RC_CHECK();
|
---|
813 |
|
---|
814 | /* Needed configuration values for the bios. */
|
---|
815 | rc = CFGMR3InsertString(pBiosCfg, "SataHardDiskDevice", "ahci"); RC_CHECK();
|
---|
816 |
|
---|
817 | for (uint32_t i = 0; i < 4; i++)
|
---|
818 | {
|
---|
819 | static const char *s_apszConfig[4] =
|
---|
820 | { "PrimaryMaster", "PrimarySlave", "SecondaryMaster", "SecondarySlave" };
|
---|
821 | static const char *s_apszBiosConfig[4] =
|
---|
822 | { "SataPrimaryMasterLUN", "SataPrimarySlaveLUN", "SataSecondaryMasterLUN", "SataSecondarySlaveLUN" };
|
---|
823 |
|
---|
824 | LONG lPortNumber = -1;
|
---|
825 | hrc = sataController->GetIDEEmulationPort(i, &lPortNumber); H();
|
---|
826 | rc = CFGMR3InsertInteger(pCfg, s_apszConfig[i], lPortNumber); RC_CHECK();
|
---|
827 | rc = CFGMR3InsertInteger(pBiosCfg, s_apszBiosConfig[i], lPortNumber); RC_CHECK();
|
---|
828 | }
|
---|
829 |
|
---|
830 | /* Attach the status driver */
|
---|
831 | rc = CFGMR3InsertNode(pSataInst,"LUN#999", &pLunL0); RC_CHECK();
|
---|
832 | rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
|
---|
833 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
834 | AssertRelease(cPorts <= RT_ELEMENTS(pConsole->mapSATALeds));
|
---|
835 | rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapSATALeds[0]); RC_CHECK();
|
---|
836 | rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
|
---|
837 | rc = CFGMR3InsertInteger(pCfg, "Last", cPorts - 1); RC_CHECK();
|
---|
838 | }
|
---|
839 | }
|
---|
840 |
|
---|
841 | /* Attach the hard disks */
|
---|
842 | {
|
---|
843 | com::SafeIfaceArray <IHardDisk2Attachment> atts;
|
---|
844 | hrc = pMachine->
|
---|
845 | COMGETTER(HardDisk2Attachments) (ComSafeArrayAsOutParam (atts)); H();
|
---|
846 |
|
---|
847 | for (size_t i = 0; i < atts.size(); ++ i)
|
---|
848 | {
|
---|
849 | ComPtr <IHardDisk2> hardDisk;
|
---|
850 | hrc = atts [i]->COMGETTER(HardDisk) (hardDisk.asOutParam()); H();
|
---|
851 | StorageBus_T enmBus;
|
---|
852 | hrc = atts [i]->COMGETTER(Bus) (&enmBus); H();
|
---|
853 | LONG lDev;
|
---|
854 | hrc = atts [i]->COMGETTER(Device) (&lDev); H();
|
---|
855 | LONG lChannel;
|
---|
856 | hrc = atts [i]->COMGETTER(Channel) (&lChannel); H();
|
---|
857 |
|
---|
858 | PCFGMNODE pHardDiskCtl = NULL;
|
---|
859 | int iLUN = 0;
|
---|
860 |
|
---|
861 | switch (enmBus)
|
---|
862 | {
|
---|
863 | case StorageBus_IDE:
|
---|
864 | {
|
---|
865 | if (lChannel >= 2 || lChannel < 0)
|
---|
866 | {
|
---|
867 | AssertMsgFailed (("invalid controller channel number: "
|
---|
868 | "%d\n", lChannel));
|
---|
869 | return VERR_GENERAL_FAILURE;
|
---|
870 | }
|
---|
871 |
|
---|
872 | if (lDev >= 2 || lDev < 0)
|
---|
873 | {
|
---|
874 | AssertMsgFailed (("invalid controller device number: "
|
---|
875 | "%d\n", lDev));
|
---|
876 | return VERR_GENERAL_FAILURE;
|
---|
877 | }
|
---|
878 |
|
---|
879 | iLUN = 2 * lChannel + lDev;
|
---|
880 | pHardDiskCtl = pIdeInst;
|
---|
881 |
|
---|
882 | break;
|
---|
883 | }
|
---|
884 | case StorageBus_SATA:
|
---|
885 | {
|
---|
886 | iLUN = lChannel;
|
---|
887 | pHardDiskCtl = enabled ? pSataInst : NULL;
|
---|
888 | break;
|
---|
889 | }
|
---|
890 | default:
|
---|
891 | {
|
---|
892 | AssertMsgFailed (("invalid disk controller type: "
|
---|
893 | "%d\n", enmBus));
|
---|
894 | return VERR_GENERAL_FAILURE;
|
---|
895 | }
|
---|
896 | }
|
---|
897 |
|
---|
898 | /* Can be NULL if SATA controller is not enabled and current hard
|
---|
899 | * disk is attached to SATA controller. */
|
---|
900 | if (pHardDiskCtl == NULL)
|
---|
901 | continue;
|
---|
902 |
|
---|
903 | char szLUN[16];
|
---|
904 | RTStrPrintf (szLUN, sizeof(szLUN), "LUN#%d", iLUN);
|
---|
905 |
|
---|
906 | rc = CFGMR3InsertNode (pHardDiskCtl, szLUN, &pLunL0); RC_CHECK();
|
---|
907 | rc = CFGMR3InsertString (pLunL0, "Driver", "Block"); RC_CHECK();
|
---|
908 | rc = CFGMR3InsertNode (pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
909 | rc = CFGMR3InsertString (pCfg, "Type", "HardDisk"); RC_CHECK();
|
---|
910 | rc = CFGMR3InsertInteger (pCfg, "Mountable", 0); RC_CHECK();
|
---|
911 |
|
---|
912 | rc = CFGMR3InsertNode (pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
|
---|
913 | rc = CFGMR3InsertString (pLunL1, "Driver", "VD"); RC_CHECK();
|
---|
914 | rc = CFGMR3InsertNode (pLunL1, "Config", &pCfg); RC_CHECK();
|
---|
915 |
|
---|
916 | hrc = hardDisk->COMGETTER(Location) (bstr.asOutParam()); H();
|
---|
917 | rc = CFGMR3InsertString (pCfg, "Path", Utf8Str (bstr)); RC_CHECK();
|
---|
918 |
|
---|
919 | hrc = hardDisk->COMGETTER(Format) (bstr.asOutParam()); H();
|
---|
920 | rc = CFGMR3InsertString (pCfg, "Format", Utf8Str (bstr)); RC_CHECK();
|
---|
921 |
|
---|
922 | #if defined(VBOX_WITH_PDM_ASYNC_COMPLETION)
|
---|
923 | if (bstr == L"VMDK")
|
---|
924 | {
|
---|
925 | /* Create cfgm nodes for async transport driver because VMDK is
|
---|
926 | * currently the only one which may support async I/O. This has
|
---|
927 | * to be made generic based on the capabiliy flags when the new
|
---|
928 | * HardDisk interface is merged.
|
---|
929 | */
|
---|
930 | rc = CFGMR3InsertNode (pLunL1, "AttachedDriver", &pLunL2); RC_CHECK();
|
---|
931 | rc = CFGMR3InsertString (pLunL2, "Driver", "TransportAsync"); RC_CHECK();
|
---|
932 | /* The async transport driver has no config options yet. */
|
---|
933 | }
|
---|
934 | #endif
|
---|
935 | /* Pass all custom parameters. */
|
---|
936 | bool fHostIP = true;
|
---|
937 | SafeArray <BSTR> names;
|
---|
938 | SafeArray <BSTR> values;
|
---|
939 | hrc = hardDisk->GetProperties (NULL,
|
---|
940 | ComSafeArrayAsOutParam (names),
|
---|
941 | ComSafeArrayAsOutParam (values)); H();
|
---|
942 |
|
---|
943 | if (names.size() != 0)
|
---|
944 | {
|
---|
945 | PCFGMNODE pVDC;
|
---|
946 | rc = CFGMR3InsertNode (pCfg, "VDConfig", &pVDC); RC_CHECK();
|
---|
947 | for (size_t i = 0; i < names.size(); ++ i)
|
---|
948 | {
|
---|
949 | if (values [i])
|
---|
950 | {
|
---|
951 | Utf8Str name = names [i];
|
---|
952 | Utf8Str value = values [i];
|
---|
953 | rc = CFGMR3InsertString (pVDC, name, value);
|
---|
954 | if ( !(name.compare("HostIPStack"))
|
---|
955 | && !(value.compare("0")))
|
---|
956 | fHostIP = false;
|
---|
957 | }
|
---|
958 | }
|
---|
959 | }
|
---|
960 |
|
---|
961 | /* Create an inversed tree of parents. */
|
---|
962 | ComPtr <IHardDisk2> parentHardDisk = hardDisk;
|
---|
963 | for (PCFGMNODE pParent = pCfg;;)
|
---|
964 | {
|
---|
965 | hrc = parentHardDisk->
|
---|
966 | COMGETTER(Parent) (hardDisk.asOutParam()); H();
|
---|
967 | if (hardDisk.isNull())
|
---|
968 | break;
|
---|
969 |
|
---|
970 | PCFGMNODE pCur;
|
---|
971 | rc = CFGMR3InsertNode (pParent, "Parent", &pCur); RC_CHECK();
|
---|
972 | hrc = hardDisk->COMGETTER(Location) (bstr.asOutParam()); H();
|
---|
973 | rc = CFGMR3InsertString (pCur, "Path", Utf8Str (bstr)); RC_CHECK();
|
---|
974 |
|
---|
975 | hrc = hardDisk->COMGETTER(Format) (bstr.asOutParam()); H();
|
---|
976 | rc = CFGMR3InsertString (pCur, "Format", Utf8Str (bstr)); RC_CHECK();
|
---|
977 |
|
---|
978 | /* Pass all custom parameters. */
|
---|
979 | SafeArray <BSTR> names;
|
---|
980 | SafeArray <BSTR> values;
|
---|
981 | hrc = hardDisk->GetProperties (NULL,
|
---|
982 | ComSafeArrayAsOutParam (names),
|
---|
983 | ComSafeArrayAsOutParam (values));H();
|
---|
984 |
|
---|
985 | if (names.size() != 0)
|
---|
986 | {
|
---|
987 | PCFGMNODE pVDC;
|
---|
988 | rc = CFGMR3InsertNode (pCur, "VDConfig", &pVDC); RC_CHECK();
|
---|
989 | for (size_t i = 0; i < names.size(); ++ i)
|
---|
990 | {
|
---|
991 | if (values [i])
|
---|
992 | {
|
---|
993 | Utf8Str name = names [i];
|
---|
994 | Utf8Str value = values [i];
|
---|
995 | rc = CFGMR3InsertString (pVDC, name, value);
|
---|
996 | if ( !(name.compare("HostIPStack"))
|
---|
997 | && !(value.compare("0")))
|
---|
998 | fHostIP = false;
|
---|
999 | }
|
---|
1000 | }
|
---|
1001 | }
|
---|
1002 |
|
---|
1003 | /* Custom code: put marker to not use host IP stack to driver
|
---|
1004 | * configuration node. Simplifies life of DrvVD a bit. */
|
---|
1005 | if (!fHostIP)
|
---|
1006 | {
|
---|
1007 | rc = CFGMR3InsertInteger (pCfg, "HostIPStack", 0); RC_CHECK();
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 | /* next */
|
---|
1011 | pParent = pCur;
|
---|
1012 | parentHardDisk = hardDisk;
|
---|
1013 | }
|
---|
1014 | }
|
---|
1015 | }
|
---|
1016 | H();
|
---|
1017 |
|
---|
1018 | ComPtr<IDVDDrive> dvdDrive;
|
---|
1019 | hrc = pMachine->COMGETTER(DVDDrive)(dvdDrive.asOutParam()); H();
|
---|
1020 | if (dvdDrive)
|
---|
1021 | {
|
---|
1022 | // ASSUME: DVD drive is always attached to LUN#2 (i.e. secondary IDE master)
|
---|
1023 | rc = CFGMR3InsertNode(pIdeInst, "LUN#2", &pLunL0); RC_CHECK();
|
---|
1024 | ComPtr<IHostDVDDrive> hostDvdDrive;
|
---|
1025 | hrc = dvdDrive->GetHostDrive(hostDvdDrive.asOutParam()); H();
|
---|
1026 | if (hostDvdDrive)
|
---|
1027 | {
|
---|
1028 | pConsole->meDVDState = DriveState_HostDriveCaptured;
|
---|
1029 | rc = CFGMR3InsertString(pLunL0, "Driver", "HostDVD"); RC_CHECK();
|
---|
1030 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1031 | hrc = hostDvdDrive->COMGETTER(Name)(&str); H();
|
---|
1032 | STR_CONV();
|
---|
1033 | rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
|
---|
1034 | STR_FREE();
|
---|
1035 | BOOL fPassthrough;
|
---|
1036 | hrc = dvdDrive->COMGETTER(Passthrough)(&fPassthrough); H();
|
---|
1037 | rc = CFGMR3InsertInteger(pCfg, "Passthrough", !!fPassthrough); RC_CHECK();
|
---|
1038 | }
|
---|
1039 | else
|
---|
1040 | {
|
---|
1041 | pConsole->meDVDState = DriveState_NotMounted;
|
---|
1042 | rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK();
|
---|
1043 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1044 | rc = CFGMR3InsertString(pCfg, "Type", "DVD"); RC_CHECK();
|
---|
1045 | rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK();
|
---|
1046 |
|
---|
1047 | ComPtr<IDVDImage2> dvdImage;
|
---|
1048 | hrc = dvdDrive->GetImage(dvdImage.asOutParam()); H();
|
---|
1049 | if (dvdImage)
|
---|
1050 | {
|
---|
1051 | pConsole->meDVDState = DriveState_ImageMounted;
|
---|
1052 | rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
|
---|
1053 | rc = CFGMR3InsertString(pLunL1, "Driver", "MediaISO"); RC_CHECK();
|
---|
1054 | rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK();
|
---|
1055 | hrc = dvdImage->COMGETTER(Location)(&str); H();
|
---|
1056 | STR_CONV();
|
---|
1057 | rc = CFGMR3InsertString(pCfg, "Path", psz); RC_CHECK();
|
---|
1058 | STR_FREE();
|
---|
1059 | }
|
---|
1060 | }
|
---|
1061 | }
|
---|
1062 |
|
---|
1063 | /*
|
---|
1064 | * Network adapters
|
---|
1065 | */
|
---|
1066 | PCFGMNODE pDevPCNet = NULL; /* PCNet-type devices */
|
---|
1067 | rc = CFGMR3InsertNode(pDevices, "pcnet", &pDevPCNet); RC_CHECK();
|
---|
1068 | #ifdef VBOX_WITH_E1000
|
---|
1069 | PCFGMNODE pDevE1000 = NULL; /* E1000-type devices */
|
---|
1070 | rc = CFGMR3InsertNode(pDevices, "e1000", &pDevE1000); RC_CHECK();
|
---|
1071 | #endif
|
---|
1072 | for (ULONG ulInstance = 0; ulInstance < SchemaDefs::NetworkAdapterCount; ulInstance++)
|
---|
1073 | {
|
---|
1074 | ComPtr<INetworkAdapter> networkAdapter;
|
---|
1075 | hrc = pMachine->GetNetworkAdapter(ulInstance, networkAdapter.asOutParam()); H();
|
---|
1076 | BOOL fEnabled = FALSE;
|
---|
1077 | hrc = networkAdapter->COMGETTER(Enabled)(&fEnabled); H();
|
---|
1078 | if (!fEnabled)
|
---|
1079 | continue;
|
---|
1080 |
|
---|
1081 | /*
|
---|
1082 | * The virtual hardware type. Create appropriate device first.
|
---|
1083 | */
|
---|
1084 | NetworkAdapterType_T adapterType;
|
---|
1085 | hrc = networkAdapter->COMGETTER(AdapterType)(&adapterType); H();
|
---|
1086 | switch (adapterType)
|
---|
1087 | {
|
---|
1088 | case NetworkAdapterType_Am79C970A:
|
---|
1089 | case NetworkAdapterType_Am79C973:
|
---|
1090 | pDev = pDevPCNet;
|
---|
1091 | break;
|
---|
1092 | #ifdef VBOX_WITH_E1000
|
---|
1093 | case NetworkAdapterType_I82540EM:
|
---|
1094 | case NetworkAdapterType_I82543GC:
|
---|
1095 | pDev = pDevE1000;
|
---|
1096 | break;
|
---|
1097 | #endif
|
---|
1098 | default:
|
---|
1099 | AssertMsgFailed(("Invalid network adapter type '%d' for slot '%d'",
|
---|
1100 | adapterType, ulInstance));
|
---|
1101 | return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
|
---|
1102 | N_("Invalid network adapter type '%d' for slot '%d'"),
|
---|
1103 | adapterType, ulInstance);
|
---|
1104 | }
|
---|
1105 |
|
---|
1106 | char szInstance[4]; Assert(ulInstance <= 999);
|
---|
1107 | RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance);
|
---|
1108 | rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK();
|
---|
1109 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
1110 | /* the first network card gets the PCI ID 3, the next 3 gets 8..10,
|
---|
1111 | * next 4 get 16..19. */
|
---|
1112 | unsigned iPciDeviceNo = 3;
|
---|
1113 | if (ulInstance)
|
---|
1114 | {
|
---|
1115 | if (ulInstance < 4)
|
---|
1116 | iPciDeviceNo = ulInstance - 1 + 8;
|
---|
1117 | else
|
---|
1118 | iPciDeviceNo = ulInstance - 4 + 16;
|
---|
1119 | }
|
---|
1120 | rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", iPciDeviceNo); RC_CHECK();
|
---|
1121 | Assert(!afPciDeviceNo[iPciDeviceNo]);
|
---|
1122 | afPciDeviceNo[iPciDeviceNo] = true;
|
---|
1123 | rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
|
---|
1124 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
1125 | #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE /* not safe here yet. */
|
---|
1126 | if (pDev == pDevPCNet)
|
---|
1127 | {
|
---|
1128 | rc = CFGMR3InsertInteger(pCfg, "R0Enabled", false); RC_CHECK();
|
---|
1129 | }
|
---|
1130 | #endif
|
---|
1131 |
|
---|
1132 | /*
|
---|
1133 | * The virtual hardware type. PCNet supports two types.
|
---|
1134 | */
|
---|
1135 | switch (adapterType)
|
---|
1136 | {
|
---|
1137 | case NetworkAdapterType_Am79C970A:
|
---|
1138 | rc = CFGMR3InsertInteger(pCfg, "Am79C973", 0); RC_CHECK();
|
---|
1139 | break;
|
---|
1140 | case NetworkAdapterType_Am79C973:
|
---|
1141 | rc = CFGMR3InsertInteger(pCfg, "Am79C973", 1); RC_CHECK();
|
---|
1142 | break;
|
---|
1143 | case NetworkAdapterType_I82540EM:
|
---|
1144 | rc = CFGMR3InsertInteger(pCfg, "AdapterType", 0); RC_CHECK();
|
---|
1145 | break;
|
---|
1146 | case NetworkAdapterType_I82543GC:
|
---|
1147 | rc = CFGMR3InsertInteger(pCfg, "AdapterType", 1); RC_CHECK();
|
---|
1148 | break;
|
---|
1149 | }
|
---|
1150 |
|
---|
1151 | /*
|
---|
1152 | * Get the MAC address and convert it to binary representation
|
---|
1153 | */
|
---|
1154 | Bstr macAddr;
|
---|
1155 | hrc = networkAdapter->COMGETTER(MACAddress)(macAddr.asOutParam()); H();
|
---|
1156 | Assert(macAddr);
|
---|
1157 | Utf8Str macAddrUtf8 = macAddr;
|
---|
1158 | char *macStr = (char*)macAddrUtf8.raw();
|
---|
1159 | Assert(strlen(macStr) == 12);
|
---|
1160 | RTMAC Mac;
|
---|
1161 | memset(&Mac, 0, sizeof(Mac));
|
---|
1162 | char *pMac = (char*)&Mac;
|
---|
1163 | for (uint32_t i = 0; i < 6; i++)
|
---|
1164 | {
|
---|
1165 | char c1 = *macStr++ - '0';
|
---|
1166 | if (c1 > 9)
|
---|
1167 | c1 -= 7;
|
---|
1168 | char c2 = *macStr++ - '0';
|
---|
1169 | if (c2 > 9)
|
---|
1170 | c2 -= 7;
|
---|
1171 | *pMac++ = ((c1 & 0x0f) << 4) | (c2 & 0x0f);
|
---|
1172 | }
|
---|
1173 | rc = CFGMR3InsertBytes(pCfg, "MAC", &Mac, sizeof(Mac)); RC_CHECK();
|
---|
1174 |
|
---|
1175 | /*
|
---|
1176 | * Check if the cable is supposed to be unplugged
|
---|
1177 | */
|
---|
1178 | BOOL fCableConnected;
|
---|
1179 | hrc = networkAdapter->COMGETTER(CableConnected)(&fCableConnected); H();
|
---|
1180 | rc = CFGMR3InsertInteger(pCfg, "CableConnected", fCableConnected ? 1 : 0); RC_CHECK();
|
---|
1181 |
|
---|
1182 | /*
|
---|
1183 | * Line speed to report from custom drivers
|
---|
1184 | */
|
---|
1185 | ULONG ulLineSpeed;
|
---|
1186 | hrc = networkAdapter->COMGETTER(LineSpeed)(&ulLineSpeed); H();
|
---|
1187 | rc = CFGMR3InsertInteger(pCfg, "LineSpeed", ulLineSpeed); RC_CHECK();
|
---|
1188 |
|
---|
1189 | /*
|
---|
1190 | * Attach the status driver.
|
---|
1191 | */
|
---|
1192 | rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
|
---|
1193 | rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
|
---|
1194 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1195 | rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapNetworkLeds[ulInstance]); RC_CHECK();
|
---|
1196 |
|
---|
1197 | /*
|
---|
1198 | * Enable the packet sniffer if requested.
|
---|
1199 | */
|
---|
1200 | BOOL fSniffer;
|
---|
1201 | hrc = networkAdapter->COMGETTER(TraceEnabled)(&fSniffer); H();
|
---|
1202 | if (fSniffer)
|
---|
1203 | {
|
---|
1204 | /* insert the sniffer filter driver. */
|
---|
1205 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
1206 | rc = CFGMR3InsertString(pLunL0, "Driver", "NetSniffer"); RC_CHECK();
|
---|
1207 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1208 | hrc = networkAdapter->COMGETTER(TraceFile)(&str); H();
|
---|
1209 | if (str) /* check convention for indicating default file. */
|
---|
1210 | {
|
---|
1211 | STR_CONV();
|
---|
1212 | rc = CFGMR3InsertString(pCfg, "File", psz); RC_CHECK();
|
---|
1213 | STR_FREE();
|
---|
1214 | }
|
---|
1215 | }
|
---|
1216 |
|
---|
1217 | NetworkAttachmentType_T networkAttachment;
|
---|
1218 | hrc = networkAdapter->COMGETTER(AttachmentType)(&networkAttachment); H();
|
---|
1219 | switch (networkAttachment)
|
---|
1220 | {
|
---|
1221 | case NetworkAttachmentType_Null:
|
---|
1222 | break;
|
---|
1223 |
|
---|
1224 | case NetworkAttachmentType_NAT:
|
---|
1225 | {
|
---|
1226 | if (fSniffer)
|
---|
1227 | {
|
---|
1228 | rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
|
---|
1229 | }
|
---|
1230 | else
|
---|
1231 | {
|
---|
1232 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
1233 | }
|
---|
1234 | rc = CFGMR3InsertString(pLunL0, "Driver", "NAT"); RC_CHECK();
|
---|
1235 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1236 | /* (Port forwarding goes here.) */
|
---|
1237 |
|
---|
1238 | /* Configure TFTP prefix and boot filename. */
|
---|
1239 | hrc = virtualBox->COMGETTER(HomeFolder)(&str); H();
|
---|
1240 | STR_CONV();
|
---|
1241 | if (psz && *psz)
|
---|
1242 | {
|
---|
1243 | char *pszTFTPPrefix = NULL;
|
---|
1244 | RTStrAPrintf(&pszTFTPPrefix, "%s%c%s", psz, RTPATH_DELIMITER, "TFTP");
|
---|
1245 | rc = CFGMR3InsertString(pCfg, "TFTPPrefix", pszTFTPPrefix); RC_CHECK();
|
---|
1246 | RTStrFree(pszTFTPPrefix);
|
---|
1247 | }
|
---|
1248 | STR_FREE();
|
---|
1249 | hrc = pMachine->COMGETTER(Name)(&str); H();
|
---|
1250 | STR_CONV();
|
---|
1251 | char *pszBootFile = NULL;
|
---|
1252 | RTStrAPrintf(&pszBootFile, "%s.pxe", psz);
|
---|
1253 | STR_FREE();
|
---|
1254 | rc = CFGMR3InsertString(pCfg, "BootFile", pszBootFile); RC_CHECK();
|
---|
1255 | RTStrFree(pszBootFile);
|
---|
1256 |
|
---|
1257 | hrc = networkAdapter->COMGETTER(NATNetwork)(&str); H();
|
---|
1258 | if (str)
|
---|
1259 | {
|
---|
1260 | STR_CONV();
|
---|
1261 | if (psz && *psz)
|
---|
1262 | rc = CFGMR3InsertString(pCfg, "Network", psz); RC_CHECK();
|
---|
1263 | STR_FREE();
|
---|
1264 | }
|
---|
1265 | break;
|
---|
1266 | }
|
---|
1267 |
|
---|
1268 | case NetworkAttachmentType_HostInterface:
|
---|
1269 | {
|
---|
1270 | /*
|
---|
1271 | * Perform the attachment if required (don't return on error!)
|
---|
1272 | */
|
---|
1273 | hrc = pConsole->attachToHostInterface(networkAdapter);
|
---|
1274 | if (SUCCEEDED(hrc))
|
---|
1275 | {
|
---|
1276 | #if defined(VBOX_WITH_NETFLT)
|
---|
1277 | /*
|
---|
1278 | * This is the new VBoxNetFlt+IntNet stuff.
|
---|
1279 | */
|
---|
1280 | if (fSniffer)
|
---|
1281 | {
|
---|
1282 | rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
|
---|
1283 | }
|
---|
1284 | else
|
---|
1285 | {
|
---|
1286 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
1287 | }
|
---|
1288 |
|
---|
1289 | Bstr HifName;
|
---|
1290 | hrc = networkAdapter->COMGETTER(HostInterface)(HifName.asOutParam());
|
---|
1291 | if(FAILED(hrc))
|
---|
1292 | {
|
---|
1293 | LogRel(("NetworkAttachmentType_HostInterface: COMGETTER(HostInterface) failed, hrc (0x%x)", hrc));
|
---|
1294 | H();
|
---|
1295 | }
|
---|
1296 |
|
---|
1297 | Utf8Str HifNameUtf8(HifName);
|
---|
1298 | const char *pszHifName = HifNameUtf8.raw();
|
---|
1299 |
|
---|
1300 | # if defined(RT_OS_DARWIN)
|
---|
1301 | /* The name is on the form 'ifX: long name', chop it off at the colon. */
|
---|
1302 | char szTrunk[8];
|
---|
1303 | strncpy(szTrunk, pszHifName, sizeof(szTrunk));
|
---|
1304 | char *pszColon = (char *)memchr(szTrunk, ':', sizeof(szTrunk));
|
---|
1305 | if (!pszColon)
|
---|
1306 | {
|
---|
1307 | hrc = networkAdapter->Detach(); H();
|
---|
1308 | return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
|
---|
1309 | N_("Malformed host interface networking name '%ls'"),
|
---|
1310 | HifName.raw());
|
---|
1311 | }
|
---|
1312 | *pszColon = '\0';
|
---|
1313 | const char *pszTrunk = szTrunk;
|
---|
1314 |
|
---|
1315 | # elif defined(RT_OS_SOLARIS)
|
---|
1316 | /* The name is on the form format 'ifX[:1] - long name, chop it off at space. */
|
---|
1317 | char szTrunk[256];
|
---|
1318 | strlcpy(szTrunk, pszHifName, sizeof(szTrunk));
|
---|
1319 | char *pszSpace = (char *)memchr(szTrunk, ' ', sizeof(szTrunk));
|
---|
1320 |
|
---|
1321 | /*
|
---|
1322 | * Currently don't bother about malformed names here for the sake of people using
|
---|
1323 | * VBoxManage and setting only the NIC name from there. If there is a space we
|
---|
1324 | * chop it off and proceed, otherwise just use whatever we've got.
|
---|
1325 | */
|
---|
1326 | if (pszSpace)
|
---|
1327 | *pszSpace = '\0';
|
---|
1328 |
|
---|
1329 | /* Chop it off at the colon (zone naming eg: e1000g:1 we need only the e1000g) */
|
---|
1330 | char *pszColon = (char *)memchr(szTrunk, ':', sizeof(szTrunk));
|
---|
1331 | if (pszColon)
|
---|
1332 | *pszColon = '\0';
|
---|
1333 |
|
---|
1334 | const char *pszTrunk = szTrunk;
|
---|
1335 |
|
---|
1336 | # elif defined(RT_OS_WINDOWS)
|
---|
1337 | ComPtr<IHostNetworkInterface> hostInterface;
|
---|
1338 | rc = host->FindHostNetworkInterfaceByName(HifName, hostInterface.asOutParam());
|
---|
1339 | if (!SUCCEEDED(rc))
|
---|
1340 | {
|
---|
1341 | AssertBreakpoint();
|
---|
1342 | LogRel(("NetworkAttachmentType_HostInterface: FindByName failed, rc (0x%x)", rc));
|
---|
1343 | return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
|
---|
1344 | N_("Inexistent host networking interface, name '%ls'"),
|
---|
1345 | HifName.raw());
|
---|
1346 | }
|
---|
1347 |
|
---|
1348 | Guid hostIFGuid;
|
---|
1349 | hrc = hostInterface->COMGETTER(Id)(hostIFGuid.asOutParam());
|
---|
1350 | if(FAILED(hrc))
|
---|
1351 | {
|
---|
1352 | LogRel(("NetworkAttachmentType_HostInterface: COMGETTER(Id) failed, hrc (0x%x)", hrc));
|
---|
1353 | H();
|
---|
1354 | }
|
---|
1355 | char szDriverGUID[RTUUID_STR_LENGTH];
|
---|
1356 | strcpy(szDriverGUID , hostIFGuid.toString().raw());
|
---|
1357 | const char *pszTrunk = szDriverGUID;
|
---|
1358 | # elif defined(RT_OS_LINUX)
|
---|
1359 | /* @todo Check for malformed names. */
|
---|
1360 | const char *pszTrunk = pszHifName;
|
---|
1361 |
|
---|
1362 | # else
|
---|
1363 | # error "PORTME (VBOX_WITH_NETFLT)"
|
---|
1364 | # endif
|
---|
1365 |
|
---|
1366 | rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK();
|
---|
1367 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1368 | rc = CFGMR3InsertString(pCfg, "Trunk", pszTrunk); RC_CHECK();
|
---|
1369 | rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_NetFlt); RC_CHECK();
|
---|
1370 | char szNetwork[80];
|
---|
1371 | RTStrPrintf(szNetwork, sizeof(szNetwork), "HostInterfaceNetworking-%s", pszHifName);
|
---|
1372 | rc = CFGMR3InsertString(pCfg, "Network", szNetwork); RC_CHECK();
|
---|
1373 |
|
---|
1374 | # if defined(RT_OS_DARWIN)
|
---|
1375 | /** @todo Come up with a better deal here. Problem is that IHostNetworkInterface is completely useless here. */
|
---|
1376 | if ( strstr(pszHifName, "Wireless")
|
---|
1377 | || strstr(pszHifName, "AirPort" ))
|
---|
1378 | {
|
---|
1379 | rc = CFGMR3InsertInteger(pCfg, "SharedMacOnWire", true); RC_CHECK();
|
---|
1380 | }
|
---|
1381 | # elif defined(RT_OS_LINUX)
|
---|
1382 | int iSock = socket(AF_INET, SOCK_DGRAM, 0);
|
---|
1383 | if (iSock >= 0)
|
---|
1384 | {
|
---|
1385 | struct iwreq WRq;
|
---|
1386 |
|
---|
1387 | memset(&WRq, 0, sizeof(WRq));
|
---|
1388 | strncpy(WRq.ifr_name, pszHifName, IFNAMSIZ);
|
---|
1389 | if (ioctl(iSock, SIOCGIWNAME, &WRq) >= 0)
|
---|
1390 | {
|
---|
1391 | rc = CFGMR3InsertInteger(pCfg, "SharedMacOnWire", true); RC_CHECK();
|
---|
1392 | Log(("Set SharedMacOnWire\n"));
|
---|
1393 | }
|
---|
1394 | else
|
---|
1395 | {
|
---|
1396 | Log(("Failed to get wireless name\n"));
|
---|
1397 | }
|
---|
1398 | close(iSock);
|
---|
1399 | }
|
---|
1400 | else
|
---|
1401 | {
|
---|
1402 | Log(("Failed to open wireless socket\n"));
|
---|
1403 | }
|
---|
1404 | # elif defined(RT_OS_WINDOWS)
|
---|
1405 | # define DEVNAME_PREFIX L"\\\\.\\"
|
---|
1406 | INetCfg *pNc;
|
---|
1407 | LPWSTR lpszApp;
|
---|
1408 | HRESULT hr;
|
---|
1409 | int rc = VERR_INTNET_FLT_IF_NOT_FOUND;
|
---|
1410 |
|
---|
1411 | /* we are getting the medium type via IOCTL_NDIS_QUERY_GLOBAL_STATS Io Control
|
---|
1412 | * there is a pretty long way till there though since we need to obtain the symbolic link name
|
---|
1413 | * for the adapter device we are going to query given the device Guid */
|
---|
1414 | hr = VBoxNetCfgWinQueryINetCfg( FALSE,
|
---|
1415 | L"VirtualBox",
|
---|
1416 | &pNc,
|
---|
1417 | &lpszApp );
|
---|
1418 | Assert(hr == S_OK);
|
---|
1419 | if(hr == S_OK)
|
---|
1420 | {
|
---|
1421 | /* get the adapter's INetCfgComponent*/
|
---|
1422 | INetCfgComponent *pAdaptorComponent;
|
---|
1423 | hr = VBoxNetCfgWinGetComponentByGuid(pNc, &GUID_DEVCLASS_NET, (GUID*)hostIFGuid.ptr(), &pAdaptorComponent);
|
---|
1424 | Assert(hr == S_OK);
|
---|
1425 | if(hr == S_OK)
|
---|
1426 | {
|
---|
1427 | /* now get the bind name */
|
---|
1428 | LPWSTR pName;
|
---|
1429 | hr = pAdaptorComponent->GetBindName(&pName);
|
---|
1430 | Assert(hr == S_OK);
|
---|
1431 | if(hr == S_OK)
|
---|
1432 | {
|
---|
1433 | /* prepend the "\\\\.\\" to the bind name to obtain the link name */
|
---|
1434 | wchar_t FileName[MAX_PATH];
|
---|
1435 | wcscpy(FileName, DEVNAME_PREFIX);
|
---|
1436 | wcscpy((wchar_t*)(((char*)FileName) + sizeof(DEVNAME_PREFIX) - sizeof(FileName[0])), pName);
|
---|
1437 |
|
---|
1438 | /* open the device */
|
---|
1439 | HANDLE hDevice = CreateFile(FileName,
|
---|
1440 | GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
---|
1441 | NULL,
|
---|
1442 | OPEN_EXISTING,
|
---|
1443 | FILE_ATTRIBUTE_NORMAL,
|
---|
1444 | NULL);
|
---|
1445 | if (hDevice != INVALID_HANDLE_VALUE)
|
---|
1446 | {
|
---|
1447 | /* now issue the OID_GEN_PHYSICAL_MEDIUM query */
|
---|
1448 | DWORD Oid = OID_GEN_PHYSICAL_MEDIUM;
|
---|
1449 | NDIS_PHYSICAL_MEDIUM PhMedium;
|
---|
1450 | DWORD cbResult;
|
---|
1451 | if (DeviceIoControl(hDevice, IOCTL_NDIS_QUERY_GLOBAL_STATS, &Oid, sizeof(Oid), &PhMedium, sizeof(PhMedium), &cbResult, NULL))
|
---|
1452 | {
|
---|
1453 | /* that was simple, now examine PhMedium */
|
---|
1454 | if(PhMedium == NdisPhysicalMediumWirelessWan
|
---|
1455 | || PhMedium == NdisPhysicalMediumWirelessLan
|
---|
1456 | || PhMedium == NdisPhysicalMediumNative802_11
|
---|
1457 | || PhMedium == NdisPhysicalMediumBluetooth
|
---|
1458 | /*|| PhMedium == NdisPhysicalMediumWiMax*/
|
---|
1459 | )
|
---|
1460 | {
|
---|
1461 | Log(("this is a wireles adapter"));
|
---|
1462 | rc = CFGMR3InsertInteger(pCfg, "SharedMacOnWire", true); RC_CHECK();
|
---|
1463 | Log(("Set SharedMacOnWire\n"));
|
---|
1464 | }
|
---|
1465 | else
|
---|
1466 | {
|
---|
1467 | Log(("this is NOT a wireles adapter"));
|
---|
1468 | }
|
---|
1469 | }
|
---|
1470 | else
|
---|
1471 | {
|
---|
1472 | int winEr = GetLastError();
|
---|
1473 | LogRel(("Console::configConstructor: DeviceIoControl failed, err (0x%x), ignoring\n", winEr));
|
---|
1474 | Assert(winEr == ERROR_INVALID_PARAMETER || winEr == ERROR_NOT_SUPPORTED || winEr == ERROR_BAD_COMMAND);
|
---|
1475 | }
|
---|
1476 |
|
---|
1477 | CloseHandle(hDevice);
|
---|
1478 | }
|
---|
1479 | else
|
---|
1480 | {
|
---|
1481 | int winEr = GetLastError();
|
---|
1482 | LogRel(("Console::configConstructor: CreateFile failed, err (0x%x), ignoring\n", winEr));
|
---|
1483 | AssertBreakpoint();
|
---|
1484 | }
|
---|
1485 | CoTaskMemFree(pName);
|
---|
1486 | }
|
---|
1487 | VBoxNetCfgWinReleaseRef(pAdaptorComponent);
|
---|
1488 | }
|
---|
1489 | VBoxNetCfgWinReleaseINetCfg( pNc, FALSE );
|
---|
1490 | }
|
---|
1491 | # else
|
---|
1492 | /** @todo PORTME: wireless detection */
|
---|
1493 | # endif
|
---|
1494 |
|
---|
1495 | # if defined(RT_OS_SOLARIS)
|
---|
1496 | # if 0 /* bird: this is a bit questionable and might cause more trouble than its worth. */
|
---|
1497 | /* Zone access restriction, don't allow snopping the global zone. */
|
---|
1498 | zoneid_t ZoneId = getzoneid();
|
---|
1499 | if (ZoneId != GLOBAL_ZONEID)
|
---|
1500 | {
|
---|
1501 | rc = CFGMR3InsertInteger(pCfg, "IgnoreAllPromisc", true); RC_CHECK();
|
---|
1502 | }
|
---|
1503 | # endif
|
---|
1504 | # endif
|
---|
1505 |
|
---|
1506 | #elif defined(RT_OS_WINDOWS)
|
---|
1507 | if (fSniffer)
|
---|
1508 | {
|
---|
1509 | rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
|
---|
1510 | }
|
---|
1511 | else
|
---|
1512 | {
|
---|
1513 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
1514 | }
|
---|
1515 | Bstr hostInterfaceName;
|
---|
1516 | hrc = networkAdapter->COMGETTER(HostInterface)(hostInterfaceName.asOutParam()); H();
|
---|
1517 | ComPtr<IHostNetworkInterface> hostInterface;
|
---|
1518 | rc = host->FindHostNetworkInterfaceByName(hostInterfaceName, hostInterface.asOutParam());
|
---|
1519 | if (!SUCCEEDED(rc))
|
---|
1520 | {
|
---|
1521 | AssertMsgFailed(("Cannot get GUID for host interface '%ls'\n", hostInterfaceName));
|
---|
1522 | hrc = networkAdapter->Detach(); H();
|
---|
1523 | }
|
---|
1524 | else
|
---|
1525 | {
|
---|
1526 | # ifndef VBOX_WITH_NETFLT
|
---|
1527 | rc = CFGMR3InsertString(pLunL0, "Driver", "HostInterface"); RC_CHECK();
|
---|
1528 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1529 | rc = CFGMR3InsertString(pCfg, "HostInterfaceName", Utf8Str(hostInterfaceName)); RC_CHECK();
|
---|
1530 | # else
|
---|
1531 | rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK();
|
---|
1532 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1533 | rc = CFGMR3InsertString(pCfg, "Trunk", Utf8Str(hostInterfaceName)); RC_CHECK();
|
---|
1534 | rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_NetFlt); RC_CHECK();
|
---|
1535 | # endif
|
---|
1536 | Guid hostIFGuid;
|
---|
1537 | hrc = hostInterface->COMGETTER(Id)(hostIFGuid.asOutParam()); H();
|
---|
1538 | char szDriverGUID[256] = {0};
|
---|
1539 | /* add curly brackets */
|
---|
1540 | szDriverGUID[0] = '{';
|
---|
1541 | strcpy(szDriverGUID + 1, hostIFGuid.toString().raw());
|
---|
1542 | strcat(szDriverGUID, "}");
|
---|
1543 | rc = CFGMR3InsertBytes(pCfg, "GUID", szDriverGUID, sizeof(szDriverGUID)); RC_CHECK();
|
---|
1544 | }
|
---|
1545 | #elif defined(RT_OS_LINUX)
|
---|
1546 | /// @todo aleksey: is there anything to be done here?
|
---|
1547 | #elif defined(RT_OS_FREEBSD)
|
---|
1548 | /** @todo FreeBSD: Check out this later (HIF networking). */
|
---|
1549 | #else
|
---|
1550 | # error "Port me"
|
---|
1551 | #endif
|
---|
1552 | }
|
---|
1553 | else
|
---|
1554 | {
|
---|
1555 | switch (hrc)
|
---|
1556 | {
|
---|
1557 | #ifdef RT_OS_LINUX
|
---|
1558 | case VERR_ACCESS_DENIED:
|
---|
1559 | return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
|
---|
1560 | "Failed to open '/dev/net/tun' for read/write access. Please check the "
|
---|
1561 | "permissions of that node. Either run 'chmod 0666 /dev/net/tun' or "
|
---|
1562 | "change the group of that node and make yourself a member of that group. Make "
|
---|
1563 | "sure that these changes are permanent, especially if you are "
|
---|
1564 | "using udev"));
|
---|
1565 | #endif /* RT_OS_LINUX */
|
---|
1566 | default:
|
---|
1567 | AssertMsgFailed(("Could not attach to host interface! Bad!\n"));
|
---|
1568 | return VMSetError(pVM, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_(
|
---|
1569 | "Failed to initialize Host Interface Networking"));
|
---|
1570 | }
|
---|
1571 | }
|
---|
1572 | break;
|
---|
1573 | }
|
---|
1574 |
|
---|
1575 | case NetworkAttachmentType_Internal:
|
---|
1576 | {
|
---|
1577 | hrc = networkAdapter->COMGETTER(InternalNetwork)(&str); H();
|
---|
1578 | if (str)
|
---|
1579 | {
|
---|
1580 | STR_CONV();
|
---|
1581 | if (psz && *psz)
|
---|
1582 | {
|
---|
1583 | if (fSniffer)
|
---|
1584 | {
|
---|
1585 | rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
|
---|
1586 | }
|
---|
1587 | else
|
---|
1588 | {
|
---|
1589 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
1590 | }
|
---|
1591 | rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK();
|
---|
1592 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1593 | rc = CFGMR3InsertString(pCfg, "Network", psz); RC_CHECK();
|
---|
1594 | }
|
---|
1595 | STR_FREE();
|
---|
1596 | }
|
---|
1597 | break;
|
---|
1598 | }
|
---|
1599 |
|
---|
1600 | case NetworkAttachmentType_HostOnly:
|
---|
1601 | {
|
---|
1602 | if (fSniffer)
|
---|
1603 | {
|
---|
1604 | rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK();
|
---|
1605 | }
|
---|
1606 | else
|
---|
1607 | {
|
---|
1608 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
1609 | }
|
---|
1610 |
|
---|
1611 | rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet"); RC_CHECK();
|
---|
1612 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1613 | rc = CFGMR3InsertString(pCfg, "Trunk", "vboxnet0"); RC_CHECK();
|
---|
1614 | rc = CFGMR3InsertInteger(pCfg, "TrunkType", kIntNetTrunkType_NetFlt); RC_CHECK();
|
---|
1615 | rc = CFGMR3InsertString(pCfg, "Network", "HostInterfaceNetworking-vboxnet0"); RC_CHECK();
|
---|
1616 | break;
|
---|
1617 | }
|
---|
1618 |
|
---|
1619 | default:
|
---|
1620 | AssertMsgFailed(("should not get here!\n"));
|
---|
1621 | break;
|
---|
1622 | }
|
---|
1623 | }
|
---|
1624 |
|
---|
1625 | /*
|
---|
1626 | * Serial (UART) Ports
|
---|
1627 | */
|
---|
1628 | rc = CFGMR3InsertNode(pDevices, "serial", &pDev); RC_CHECK();
|
---|
1629 | for (ULONG ulInstance = 0; ulInstance < SchemaDefs::SerialPortCount; ulInstance++)
|
---|
1630 | {
|
---|
1631 | ComPtr<ISerialPort> serialPort;
|
---|
1632 | hrc = pMachine->GetSerialPort (ulInstance, serialPort.asOutParam()); H();
|
---|
1633 | BOOL fEnabled = FALSE;
|
---|
1634 | if (serialPort)
|
---|
1635 | hrc = serialPort->COMGETTER(Enabled)(&fEnabled); H();
|
---|
1636 | if (!fEnabled)
|
---|
1637 | continue;
|
---|
1638 |
|
---|
1639 | char szInstance[4]; Assert(ulInstance <= 999);
|
---|
1640 | RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance);
|
---|
1641 |
|
---|
1642 | rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK();
|
---|
1643 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
1644 |
|
---|
1645 | ULONG ulIRQ, ulIOBase;
|
---|
1646 | PortMode_T HostMode;
|
---|
1647 | Bstr path;
|
---|
1648 | BOOL fServer;
|
---|
1649 | hrc = serialPort->COMGETTER(HostMode)(&HostMode); H();
|
---|
1650 | hrc = serialPort->COMGETTER(IRQ)(&ulIRQ); H();
|
---|
1651 | hrc = serialPort->COMGETTER(IOBase)(&ulIOBase); H();
|
---|
1652 | hrc = serialPort->COMGETTER(Path)(path.asOutParam()); H();
|
---|
1653 | hrc = serialPort->COMGETTER(Server)(&fServer); H();
|
---|
1654 | rc = CFGMR3InsertInteger(pCfg, "IRQ", ulIRQ); RC_CHECK();
|
---|
1655 | rc = CFGMR3InsertInteger(pCfg, "IOBase", ulIOBase); RC_CHECK();
|
---|
1656 | if (HostMode != PortMode_Disconnected)
|
---|
1657 | {
|
---|
1658 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
1659 | if (HostMode == PortMode_HostPipe)
|
---|
1660 | {
|
---|
1661 | rc = CFGMR3InsertString(pLunL0, "Driver", "Char"); RC_CHECK();
|
---|
1662 | rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
|
---|
1663 | rc = CFGMR3InsertString(pLunL1, "Driver", "NamedPipe"); RC_CHECK();
|
---|
1664 | rc = CFGMR3InsertNode(pLunL1, "Config", &pLunL2); RC_CHECK();
|
---|
1665 | rc = CFGMR3InsertString(pLunL2, "Location", Utf8Str(path)); RC_CHECK();
|
---|
1666 | rc = CFGMR3InsertInteger(pLunL2, "IsServer", fServer); RC_CHECK();
|
---|
1667 | }
|
---|
1668 | else if (HostMode == PortMode_HostDevice)
|
---|
1669 | {
|
---|
1670 | rc = CFGMR3InsertString(pLunL0, "Driver", "Host Serial"); RC_CHECK();
|
---|
1671 | rc = CFGMR3InsertNode(pLunL0, "Config", &pLunL1); RC_CHECK();
|
---|
1672 | rc = CFGMR3InsertString(pLunL1, "DevicePath", Utf8Str(path)); RC_CHECK();
|
---|
1673 | }
|
---|
1674 | }
|
---|
1675 | }
|
---|
1676 |
|
---|
1677 | /*
|
---|
1678 | * Parallel (LPT) Ports
|
---|
1679 | */
|
---|
1680 | rc = CFGMR3InsertNode(pDevices, "parallel", &pDev); RC_CHECK();
|
---|
1681 | for (ULONG ulInstance = 0; ulInstance < SchemaDefs::ParallelPortCount; ulInstance++)
|
---|
1682 | {
|
---|
1683 | ComPtr<IParallelPort> parallelPort;
|
---|
1684 | hrc = pMachine->GetParallelPort (ulInstance, parallelPort.asOutParam()); H();
|
---|
1685 | BOOL fEnabled = FALSE;
|
---|
1686 | if (parallelPort)
|
---|
1687 | hrc = parallelPort->COMGETTER(Enabled)(&fEnabled); H();
|
---|
1688 | if (!fEnabled)
|
---|
1689 | continue;
|
---|
1690 |
|
---|
1691 | char szInstance[4]; Assert(ulInstance <= 999);
|
---|
1692 | RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance);
|
---|
1693 |
|
---|
1694 | rc = CFGMR3InsertNode(pDev, szInstance, &pInst); RC_CHECK();
|
---|
1695 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
1696 |
|
---|
1697 | ULONG ulIRQ, ulIOBase;
|
---|
1698 | Bstr DevicePath;
|
---|
1699 | hrc = parallelPort->COMGETTER(IRQ)(&ulIRQ); H();
|
---|
1700 | hrc = parallelPort->COMGETTER(IOBase)(&ulIOBase); H();
|
---|
1701 | hrc = parallelPort->COMGETTER(Path)(DevicePath.asOutParam()); H();
|
---|
1702 | rc = CFGMR3InsertInteger(pCfg, "IRQ", ulIRQ); RC_CHECK();
|
---|
1703 | rc = CFGMR3InsertInteger(pCfg, "IOBase", ulIOBase); RC_CHECK();
|
---|
1704 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
1705 | rc = CFGMR3InsertString(pLunL0, "Driver", "HostParallel"); RC_CHECK();
|
---|
1706 | rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK();
|
---|
1707 | rc = CFGMR3InsertString(pLunL1, "DevicePath", Utf8Str(DevicePath)); RC_CHECK();
|
---|
1708 | }
|
---|
1709 |
|
---|
1710 | /*
|
---|
1711 | * VMM Device
|
---|
1712 | */
|
---|
1713 | rc = CFGMR3InsertNode(pDevices, "VMMDev", &pDev); RC_CHECK();
|
---|
1714 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
1715 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
1716 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
1717 | rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 4); RC_CHECK();
|
---|
1718 | Assert(!afPciDeviceNo[4]);
|
---|
1719 | afPciDeviceNo[4] = true;
|
---|
1720 | rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
|
---|
1721 | Bstr hwVersion;
|
---|
1722 | hrc = pMachine->COMGETTER(HardwareVersion)(hwVersion.asOutParam()); H();
|
---|
1723 | if (hwVersion.compare(Bstr("1")) == 0) /* <= 2.0.x */
|
---|
1724 | {
|
---|
1725 | CFGMR3InsertInteger(pCfg, "HeapEnabled", 0); RC_CHECK();
|
---|
1726 | }
|
---|
1727 |
|
---|
1728 | /* the VMM device's Main driver */
|
---|
1729 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
1730 | rc = CFGMR3InsertString(pLunL0, "Driver", "MainVMMDev"); RC_CHECK();
|
---|
1731 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1732 | VMMDev *pVMMDev = pConsole->mVMMDev;
|
---|
1733 | rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pVMMDev); RC_CHECK();
|
---|
1734 |
|
---|
1735 | /*
|
---|
1736 | * Attach the status driver.
|
---|
1737 | */
|
---|
1738 | rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
|
---|
1739 | rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
|
---|
1740 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1741 | rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapSharedFolderLed); RC_CHECK();
|
---|
1742 | rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
|
---|
1743 | rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
|
---|
1744 |
|
---|
1745 | /*
|
---|
1746 | * Audio Sniffer Device
|
---|
1747 | */
|
---|
1748 | rc = CFGMR3InsertNode(pDevices, "AudioSniffer", &pDev); RC_CHECK();
|
---|
1749 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
1750 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
1751 |
|
---|
1752 | /* the Audio Sniffer device's Main driver */
|
---|
1753 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
1754 | rc = CFGMR3InsertString(pLunL0, "Driver", "MainAudioSniffer"); RC_CHECK();
|
---|
1755 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1756 | AudioSniffer *pAudioSniffer = pConsole->mAudioSniffer;
|
---|
1757 | rc = CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)pAudioSniffer); RC_CHECK();
|
---|
1758 |
|
---|
1759 | /*
|
---|
1760 | * AC'97 ICH / SoundBlaster16 audio
|
---|
1761 | */
|
---|
1762 | ComPtr<IAudioAdapter> audioAdapter;
|
---|
1763 | hrc = pMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam()); H();
|
---|
1764 | if (audioAdapter)
|
---|
1765 | hrc = audioAdapter->COMGETTER(Enabled)(&enabled); H();
|
---|
1766 |
|
---|
1767 | if (enabled)
|
---|
1768 | {
|
---|
1769 | AudioControllerType_T audioController;
|
---|
1770 | hrc = audioAdapter->COMGETTER(AudioController)(&audioController); H();
|
---|
1771 | switch (audioController)
|
---|
1772 | {
|
---|
1773 | case AudioControllerType_AC97:
|
---|
1774 | {
|
---|
1775 | /* default: ICH AC97 */
|
---|
1776 | rc = CFGMR3InsertNode(pDevices, "ichac97", &pDev); RC_CHECK();
|
---|
1777 | rc = CFGMR3InsertNode(pDev, "0", &pInst);
|
---|
1778 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* bool */ RC_CHECK();
|
---|
1779 | rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 5); RC_CHECK();
|
---|
1780 | Assert(!afPciDeviceNo[5]);
|
---|
1781 | afPciDeviceNo[5] = true;
|
---|
1782 | rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
|
---|
1783 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
1784 | break;
|
---|
1785 | }
|
---|
1786 | case AudioControllerType_SB16:
|
---|
1787 | {
|
---|
1788 | /* legacy SoundBlaster16 */
|
---|
1789 | rc = CFGMR3InsertNode(pDevices, "sb16", &pDev); RC_CHECK();
|
---|
1790 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
1791 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* bool */ RC_CHECK();
|
---|
1792 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
1793 | rc = CFGMR3InsertInteger(pCfg, "IRQ", 5); RC_CHECK();
|
---|
1794 | rc = CFGMR3InsertInteger(pCfg, "DMA", 1); RC_CHECK();
|
---|
1795 | rc = CFGMR3InsertInteger(pCfg, "DMA16", 5); RC_CHECK();
|
---|
1796 | rc = CFGMR3InsertInteger(pCfg, "Port", 0x220); RC_CHECK();
|
---|
1797 | rc = CFGMR3InsertInteger(pCfg, "Version", 0x0405); RC_CHECK();
|
---|
1798 | break;
|
---|
1799 | }
|
---|
1800 | }
|
---|
1801 |
|
---|
1802 | /* the Audio driver */
|
---|
1803 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
1804 | rc = CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); RC_CHECK();
|
---|
1805 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1806 |
|
---|
1807 | AudioDriverType_T audioDriver;
|
---|
1808 | hrc = audioAdapter->COMGETTER(AudioDriver)(&audioDriver); H();
|
---|
1809 | switch (audioDriver)
|
---|
1810 | {
|
---|
1811 | case AudioDriverType_Null:
|
---|
1812 | {
|
---|
1813 | rc = CFGMR3InsertString(pCfg, "AudioDriver", "null"); RC_CHECK();
|
---|
1814 | break;
|
---|
1815 | }
|
---|
1816 | #ifdef RT_OS_WINDOWS
|
---|
1817 | #ifdef VBOX_WITH_WINMM
|
---|
1818 | case AudioDriverType_WinMM:
|
---|
1819 | {
|
---|
1820 | rc = CFGMR3InsertString(pCfg, "AudioDriver", "winmm"); RC_CHECK();
|
---|
1821 | break;
|
---|
1822 | }
|
---|
1823 | #endif
|
---|
1824 | case AudioDriverType_DirectSound:
|
---|
1825 | {
|
---|
1826 | rc = CFGMR3InsertString(pCfg, "AudioDriver", "dsound"); RC_CHECK();
|
---|
1827 | break;
|
---|
1828 | }
|
---|
1829 | #endif /* RT_OS_WINDOWS */
|
---|
1830 | #ifdef RT_OS_SOLARIS
|
---|
1831 | case AudioDriverType_SolAudio:
|
---|
1832 | {
|
---|
1833 | rc = CFGMR3InsertString(pCfg, "AudioDriver", "solaudio"); RC_CHECK();
|
---|
1834 | break;
|
---|
1835 | }
|
---|
1836 | #endif
|
---|
1837 | #ifdef RT_OS_LINUX
|
---|
1838 | case AudioDriverType_OSS:
|
---|
1839 | {
|
---|
1840 | rc = CFGMR3InsertString(pCfg, "AudioDriver", "oss"); RC_CHECK();
|
---|
1841 | break;
|
---|
1842 | }
|
---|
1843 | # ifdef VBOX_WITH_ALSA
|
---|
1844 | case AudioDriverType_ALSA:
|
---|
1845 | {
|
---|
1846 | rc = CFGMR3InsertString(pCfg, "AudioDriver", "alsa"); RC_CHECK();
|
---|
1847 | break;
|
---|
1848 | }
|
---|
1849 | # endif
|
---|
1850 | # ifdef VBOX_WITH_PULSE
|
---|
1851 | case AudioDriverType_Pulse:
|
---|
1852 | {
|
---|
1853 | rc = CFGMR3InsertString(pCfg, "AudioDriver", "pulse"); RC_CHECK();
|
---|
1854 | break;
|
---|
1855 | }
|
---|
1856 | # endif
|
---|
1857 | #endif /* RT_OS_LINUX */
|
---|
1858 | #ifdef RT_OS_DARWIN
|
---|
1859 | case AudioDriverType_CoreAudio:
|
---|
1860 | {
|
---|
1861 | rc = CFGMR3InsertString(pCfg, "AudioDriver", "coreaudio"); RC_CHECK();
|
---|
1862 | break;
|
---|
1863 | }
|
---|
1864 | #endif
|
---|
1865 | }
|
---|
1866 | hrc = pMachine->COMGETTER(Name)(&str); H();
|
---|
1867 | STR_CONV();
|
---|
1868 | rc = CFGMR3InsertString(pCfg, "StreamName", psz); RC_CHECK();
|
---|
1869 | STR_FREE();
|
---|
1870 | }
|
---|
1871 |
|
---|
1872 | /*
|
---|
1873 | * The USB Controller.
|
---|
1874 | */
|
---|
1875 | ComPtr<IUSBController> USBCtlPtr;
|
---|
1876 | hrc = pMachine->COMGETTER(USBController)(USBCtlPtr.asOutParam());
|
---|
1877 | if (USBCtlPtr)
|
---|
1878 | {
|
---|
1879 | BOOL fEnabled;
|
---|
1880 | hrc = USBCtlPtr->COMGETTER(Enabled)(&fEnabled); H();
|
---|
1881 | if (fEnabled)
|
---|
1882 | {
|
---|
1883 | rc = CFGMR3InsertNode(pDevices, "usb-ohci", &pDev); RC_CHECK();
|
---|
1884 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
1885 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
1886 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK();
|
---|
1887 | rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 6); RC_CHECK();
|
---|
1888 | Assert(!afPciDeviceNo[6]);
|
---|
1889 | afPciDeviceNo[6] = true;
|
---|
1890 | rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
|
---|
1891 |
|
---|
1892 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
1893 | rc = CFGMR3InsertString(pLunL0, "Driver", "VUSBRootHub"); RC_CHECK();
|
---|
1894 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1895 |
|
---|
1896 | /*
|
---|
1897 | * Attach the status driver.
|
---|
1898 | */
|
---|
1899 | rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
|
---|
1900 | rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
|
---|
1901 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1902 | rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapUSBLed[0]);RC_CHECK();
|
---|
1903 | rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
|
---|
1904 | rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
|
---|
1905 |
|
---|
1906 | #ifdef VBOX_WITH_EHCI
|
---|
1907 | hrc = USBCtlPtr->COMGETTER(EnabledEhci)(&fEnabled); H();
|
---|
1908 | if (fEnabled)
|
---|
1909 | {
|
---|
1910 | rc = CFGMR3InsertNode(pDevices, "usb-ehci", &pDev); RC_CHECK();
|
---|
1911 | rc = CFGMR3InsertNode(pDev, "0", &pInst); RC_CHECK();
|
---|
1912 | rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK();
|
---|
1913 | rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* bool */ RC_CHECK();
|
---|
1914 | rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 11); RC_CHECK();
|
---|
1915 | Assert(!afPciDeviceNo[11]);
|
---|
1916 | afPciDeviceNo[11] = true;
|
---|
1917 | rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); RC_CHECK();
|
---|
1918 |
|
---|
1919 | rc = CFGMR3InsertNode(pInst, "LUN#0", &pLunL0); RC_CHECK();
|
---|
1920 | rc = CFGMR3InsertString(pLunL0, "Driver", "VUSBRootHub"); RC_CHECK();
|
---|
1921 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1922 |
|
---|
1923 | /*
|
---|
1924 | * Attach the status driver.
|
---|
1925 | */
|
---|
1926 | rc = CFGMR3InsertNode(pInst, "LUN#999", &pLunL0); RC_CHECK();
|
---|
1927 | rc = CFGMR3InsertString(pLunL0, "Driver", "MainStatus"); RC_CHECK();
|
---|
1928 | rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
|
---|
1929 | rc = CFGMR3InsertInteger(pCfg, "papLeds", (uintptr_t)&pConsole->mapUSBLed[1]);RC_CHECK();
|
---|
1930 | rc = CFGMR3InsertInteger(pCfg, "First", 0); RC_CHECK();
|
---|
1931 | rc = CFGMR3InsertInteger(pCfg, "Last", 0); RC_CHECK();
|
---|
1932 | }
|
---|
1933 | else
|
---|
1934 | #endif
|
---|
1935 | {
|
---|
1936 | /*
|
---|
1937 | * Global USB options, currently unused as we'll apply the 2.0 -> 1.1 morphing
|
---|
1938 | * on a per device level now.
|
---|
1939 | */
|
---|
1940 | rc = CFGMR3InsertNode(pRoot, "USB", &pCfg); RC_CHECK();
|
---|
1941 | rc = CFGMR3InsertNode(pCfg, "USBProxy", &pCfg); RC_CHECK();
|
---|
1942 | rc = CFGMR3InsertNode(pCfg, "GlobalConfig", &pCfg); RC_CHECK();
|
---|
1943 | // This globally enables the 2.0 -> 1.1 device morphing of proxied devies to keep windows quiet.
|
---|
1944 | //rc = CFGMR3InsertInteger(pCfg, "Force11Device", true); RC_CHECK();
|
---|
1945 | // The following breaks stuff, but it makes MSDs work in vista. (I include it here so
|
---|
1946 | // that it's documented somewhere.) Users needing it can use:
|
---|
1947 | // VBoxManage setextradata "myvm" "VBoxInternal/USB/USBProxy/GlobalConfig/Force11PacketSize" 1
|
---|
1948 | //rc = CFGMR3InsertInteger(pCfg, "Force11PacketSize", true); RC_CHECK();
|
---|
1949 | }
|
---|
1950 | }
|
---|
1951 | }
|
---|
1952 |
|
---|
1953 | /*
|
---|
1954 | * Clipboard
|
---|
1955 | */
|
---|
1956 | {
|
---|
1957 | ClipboardMode_T mode = ClipboardMode_Disabled;
|
---|
1958 | hrc = pMachine->COMGETTER(ClipboardMode) (&mode); H();
|
---|
1959 |
|
---|
1960 | if (mode != ClipboardMode_Disabled)
|
---|
1961 | {
|
---|
1962 | /* Load the service */
|
---|
1963 | rc = pConsole->mVMMDev->hgcmLoadService ("VBoxSharedClipboard", "VBoxSharedClipboard");
|
---|
1964 |
|
---|
1965 | if (RT_FAILURE (rc))
|
---|
1966 | {
|
---|
1967 | LogRel(("VBoxSharedClipboard is not available. rc = %Rrc\n", rc));
|
---|
1968 | /* That is not a fatal failure. */
|
---|
1969 | rc = VINF_SUCCESS;
|
---|
1970 | }
|
---|
1971 | else
|
---|
1972 | {
|
---|
1973 | /* Setup the service. */
|
---|
1974 | VBOXHGCMSVCPARM parm;
|
---|
1975 |
|
---|
1976 | parm.type = VBOX_HGCM_SVC_PARM_32BIT;
|
---|
1977 |
|
---|
1978 | switch (mode)
|
---|
1979 | {
|
---|
1980 | default:
|
---|
1981 | case ClipboardMode_Disabled:
|
---|
1982 | {
|
---|
1983 | LogRel(("VBoxSharedClipboard mode: Off\n"));
|
---|
1984 | parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_OFF;
|
---|
1985 | break;
|
---|
1986 | }
|
---|
1987 | case ClipboardMode_GuestToHost:
|
---|
1988 | {
|
---|
1989 | LogRel(("VBoxSharedClipboard mode: Guest to Host\n"));
|
---|
1990 | parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST;
|
---|
1991 | break;
|
---|
1992 | }
|
---|
1993 | case ClipboardMode_HostToGuest:
|
---|
1994 | {
|
---|
1995 | LogRel(("VBoxSharedClipboard mode: Host to Guest\n"));
|
---|
1996 | parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_HOST_TO_GUEST;
|
---|
1997 | break;
|
---|
1998 | }
|
---|
1999 | case ClipboardMode_Bidirectional:
|
---|
2000 | {
|
---|
2001 | LogRel(("VBoxSharedClipboard mode: Bidirectional\n"));
|
---|
2002 | parm.u.uint32 = VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL;
|
---|
2003 | break;
|
---|
2004 | }
|
---|
2005 | }
|
---|
2006 |
|
---|
2007 | pConsole->mVMMDev->hgcmHostCall ("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm);
|
---|
2008 |
|
---|
2009 | Log(("Set VBoxSharedClipboard mode\n"));
|
---|
2010 | }
|
---|
2011 | }
|
---|
2012 | }
|
---|
2013 |
|
---|
2014 | #ifdef VBOX_WITH_CROGL
|
---|
2015 | /*
|
---|
2016 | * crOpenGL
|
---|
2017 | */
|
---|
2018 | {
|
---|
2019 | BOOL fEnabled = false;
|
---|
2020 | hrc = pMachine->COMGETTER(Accelerate3DEnabled) (&fEnabled); H();
|
---|
2021 |
|
---|
2022 | if (fEnabled)
|
---|
2023 | {
|
---|
2024 | /* Load the service */
|
---|
2025 | rc = pConsole->mVMMDev->hgcmLoadService ("VBoxSharedCrOpenGL", "VBoxSharedCrOpenGL");
|
---|
2026 | if (RT_FAILURE(rc))
|
---|
2027 | {
|
---|
2028 | LogRel(("Failed to load Shared OpenGL service %Rrc\n", rc));
|
---|
2029 | /* That is not a fatal failure. */
|
---|
2030 | rc = VINF_SUCCESS;
|
---|
2031 | }
|
---|
2032 | else
|
---|
2033 | {
|
---|
2034 | LogRel(("Shared crOpenGL service loaded.\n"));
|
---|
2035 |
|
---|
2036 | /* Setup the service. */
|
---|
2037 | VBOXHGCMSVCPARM parm;
|
---|
2038 | parm.type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
2039 |
|
---|
2040 | //parm.u.pointer.addr = static_cast <IConsole *> (pData->pVMMDev->getParent());
|
---|
2041 | parm.u.pointer.addr = pConsole->mVMMDev->getParent()->getDisplay()->getFramebuffer();
|
---|
2042 | parm.u.pointer.size = sizeof(IFramebuffer *);
|
---|
2043 |
|
---|
2044 | rc = pConsole->mVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_FRAMEBUFFER, 1, &parm);
|
---|
2045 | if (!RT_SUCCESS(rc))
|
---|
2046 | AssertMsgFailed(("SHCRGL_HOST_FN_SET_FRAMEBUFFER failed with %Rrc\n", rc));
|
---|
2047 | }
|
---|
2048 | }
|
---|
2049 | }
|
---|
2050 | #endif
|
---|
2051 |
|
---|
2052 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
2053 | /*
|
---|
2054 | * Guest property service
|
---|
2055 | */
|
---|
2056 | {
|
---|
2057 | /* Load the service */
|
---|
2058 | rc = pConsole->mVMMDev->hgcmLoadService ("VBoxGuestPropSvc", "VBoxGuestPropSvc");
|
---|
2059 |
|
---|
2060 | if (RT_FAILURE (rc))
|
---|
2061 | {
|
---|
2062 | LogRel(("VBoxGuestPropSvc is not available. rc = %Rrc\n", rc));
|
---|
2063 | /* That is not a fatal failure. */
|
---|
2064 | rc = VINF_SUCCESS;
|
---|
2065 | }
|
---|
2066 | else
|
---|
2067 | {
|
---|
2068 | /* Pull over the properties from the server. */
|
---|
2069 | SafeArray <BSTR> namesOut;
|
---|
2070 | SafeArray <BSTR> valuesOut;
|
---|
2071 | SafeArray <ULONG64> timestampsOut;
|
---|
2072 | SafeArray <BSTR> flagsOut;
|
---|
2073 | hrc = pConsole->mControl->PullGuestProperties(ComSafeArrayAsOutParam(namesOut),
|
---|
2074 | ComSafeArrayAsOutParam(valuesOut),
|
---|
2075 | ComSafeArrayAsOutParam(timestampsOut),
|
---|
2076 | ComSafeArrayAsOutParam(flagsOut)); H();
|
---|
2077 | size_t cProps = namesOut.size();
|
---|
2078 | if ( valuesOut.size() != cProps
|
---|
2079 | || timestampsOut.size() != cProps
|
---|
2080 | || flagsOut.size() != cProps
|
---|
2081 | )
|
---|
2082 | rc = VERR_INVALID_PARAMETER;
|
---|
2083 |
|
---|
2084 | std::vector <Utf8Str> utf8Names, utf8Values, utf8Flags;
|
---|
2085 | std::vector <char *> names, values, flags;
|
---|
2086 | std::vector <ULONG64> timestamps;
|
---|
2087 | for (unsigned i = 0; i < cProps && RT_SUCCESS(rc); ++i)
|
---|
2088 | if ( !VALID_PTR(namesOut[i])
|
---|
2089 | || !VALID_PTR(valuesOut[i])
|
---|
2090 | || !VALID_PTR(flagsOut[i])
|
---|
2091 | )
|
---|
2092 | rc = VERR_INVALID_POINTER;
|
---|
2093 | for (unsigned i = 0; i < cProps && RT_SUCCESS(rc); ++i)
|
---|
2094 | {
|
---|
2095 | utf8Names.push_back(Bstr(namesOut[i]));
|
---|
2096 | utf8Values.push_back(Bstr(valuesOut[i]));
|
---|
2097 | timestamps.push_back(timestampsOut[i]);
|
---|
2098 | utf8Flags.push_back(Bstr(flagsOut[i]));
|
---|
2099 | if ( utf8Names.back().isNull()
|
---|
2100 | || utf8Values.back().isNull()
|
---|
2101 | || utf8Flags.back().isNull()
|
---|
2102 | )
|
---|
2103 | throw std::bad_alloc();
|
---|
2104 | }
|
---|
2105 | for (unsigned i = 0; i < cProps && RT_SUCCESS(rc); ++i)
|
---|
2106 | {
|
---|
2107 | names.push_back(utf8Names[i].mutableRaw());
|
---|
2108 | values.push_back(utf8Values[i].mutableRaw());
|
---|
2109 | flags.push_back(utf8Flags[i].mutableRaw());
|
---|
2110 | }
|
---|
2111 | names.push_back(NULL);
|
---|
2112 | values.push_back(NULL);
|
---|
2113 | timestamps.push_back(0);
|
---|
2114 | flags.push_back(NULL);
|
---|
2115 |
|
---|
2116 | /* Setup the service. */
|
---|
2117 | VBOXHGCMSVCPARM parms[4];
|
---|
2118 |
|
---|
2119 | parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
2120 | parms[0].u.pointer.addr = &names.front();
|
---|
2121 | parms[0].u.pointer.size = 0; /* We don't actually care. */
|
---|
2122 | parms[1].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
2123 | parms[1].u.pointer.addr = &values.front();
|
---|
2124 | parms[1].u.pointer.size = 0; /* We don't actually care. */
|
---|
2125 | parms[2].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
2126 | parms[2].u.pointer.addr = ×tamps.front();
|
---|
2127 | parms[2].u.pointer.size = 0; /* We don't actually care. */
|
---|
2128 | parms[3].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
2129 | parms[3].u.pointer.addr = &flags.front();
|
---|
2130 | parms[3].u.pointer.size = 0; /* We don't actually care. */
|
---|
2131 |
|
---|
2132 | pConsole->mVMMDev->hgcmHostCall ("VBoxGuestPropSvc", guestProp::SET_PROPS_HOST, 4, &parms[0]);
|
---|
2133 |
|
---|
2134 | /* Register the host notification callback */
|
---|
2135 | HGCMSVCEXTHANDLE hDummy;
|
---|
2136 | HGCMHostRegisterServiceExtension (&hDummy, "VBoxGuestPropSvc",
|
---|
2137 | Console::doGuestPropNotification,
|
---|
2138 | pvConsole);
|
---|
2139 |
|
---|
2140 | Log(("Set VBoxGuestPropSvc property store\n"));
|
---|
2141 | }
|
---|
2142 | }
|
---|
2143 | #endif /* VBOX_WITH_GUEST_PROPS defined */
|
---|
2144 |
|
---|
2145 | /*
|
---|
2146 | * CFGM overlay handling.
|
---|
2147 | *
|
---|
2148 | * Here we check the extra data entries for CFGM values
|
---|
2149 | * and create the nodes and insert the values on the fly. Existing
|
---|
2150 | * values will be removed and reinserted. CFGM is typed, so by default
|
---|
2151 | * we will guess whether it's a string or an integer (byte arrays are
|
---|
2152 | * not currently supported). It's possible to override this autodetection
|
---|
2153 | * by adding "string:", "integer:" or "bytes:" (future).
|
---|
2154 | *
|
---|
2155 | * We first perform a run on global extra data, then on the machine
|
---|
2156 | * extra data to support global settings with local overrides.
|
---|
2157 | *
|
---|
2158 | */
|
---|
2159 | /** @todo add support for removing nodes and byte blobs. */
|
---|
2160 | Bstr strExtraDataKey;
|
---|
2161 | bool fGlobalExtraData = true;
|
---|
2162 | for (;;)
|
---|
2163 | {
|
---|
2164 | /*
|
---|
2165 | * Get the next key
|
---|
2166 | */
|
---|
2167 | Bstr strNextExtraDataKey;
|
---|
2168 | Bstr strExtraDataValue;
|
---|
2169 | if (fGlobalExtraData)
|
---|
2170 | hrc = virtualBox->GetNextExtraDataKey(strExtraDataKey, strNextExtraDataKey.asOutParam(),
|
---|
2171 | strExtraDataValue.asOutParam());
|
---|
2172 | else
|
---|
2173 | hrc = pMachine->GetNextExtraDataKey(strExtraDataKey, strNextExtraDataKey.asOutParam(),
|
---|
2174 | strExtraDataValue.asOutParam());
|
---|
2175 |
|
---|
2176 | /* stop if for some reason there's nothing more to request */
|
---|
2177 | if (FAILED(hrc) || !strNextExtraDataKey)
|
---|
2178 | {
|
---|
2179 | /* if we're out of global keys, continue with machine, otherwise we're done */
|
---|
2180 | if (fGlobalExtraData)
|
---|
2181 | {
|
---|
2182 | fGlobalExtraData = false;
|
---|
2183 | strExtraDataKey.setNull();
|
---|
2184 | continue;
|
---|
2185 | }
|
---|
2186 | break;
|
---|
2187 | }
|
---|
2188 | strExtraDataKey = strNextExtraDataKey;
|
---|
2189 |
|
---|
2190 | /*
|
---|
2191 | * We only care about keys starting with "VBoxInternal/"
|
---|
2192 | */
|
---|
2193 | Utf8Str strExtraDataKeyUtf8(strExtraDataKey);
|
---|
2194 | char *pszExtraDataKey = (char *)strExtraDataKeyUtf8.raw();
|
---|
2195 | if (strncmp(pszExtraDataKey, "VBoxInternal/", sizeof("VBoxInternal/") - 1) != 0)
|
---|
2196 | continue;
|
---|
2197 | pszExtraDataKey += sizeof("VBoxInternal/") - 1;
|
---|
2198 |
|
---|
2199 | /*
|
---|
2200 | * The key will be in the format "Node1/Node2/Value" or simply "Value".
|
---|
2201 | * Split the two and get the node, delete the value and create the node
|
---|
2202 | * if necessary.
|
---|
2203 | */
|
---|
2204 | PCFGMNODE pNode;
|
---|
2205 | char *pszCFGMValueName = strrchr(pszExtraDataKey, '/');
|
---|
2206 | if (pszCFGMValueName)
|
---|
2207 | {
|
---|
2208 | /* terminate the node and advance to the value (Utf8Str might not
|
---|
2209 | offically like this but wtf) */
|
---|
2210 | *pszCFGMValueName = '\0';
|
---|
2211 | pszCFGMValueName++;
|
---|
2212 |
|
---|
2213 | /* does the node already exist? */
|
---|
2214 | pNode = CFGMR3GetChild(pRoot, pszExtraDataKey);
|
---|
2215 | if (pNode)
|
---|
2216 | CFGMR3RemoveValue(pNode, pszCFGMValueName);
|
---|
2217 | else
|
---|
2218 | {
|
---|
2219 | /* create the node */
|
---|
2220 | rc = CFGMR3InsertNode(pRoot, pszExtraDataKey, &pNode);
|
---|
2221 | if (RT_FAILURE(rc))
|
---|
2222 | {
|
---|
2223 | AssertLogRelMsgRC(rc, ("failed to insert node '%s'\n", pszExtraDataKey));
|
---|
2224 | continue;
|
---|
2225 | }
|
---|
2226 | Assert(pNode);
|
---|
2227 | }
|
---|
2228 | }
|
---|
2229 | else
|
---|
2230 | {
|
---|
2231 | /* root value (no node path). */
|
---|
2232 | pNode = pRoot;
|
---|
2233 | pszCFGMValueName = pszExtraDataKey;
|
---|
2234 | pszExtraDataKey--;
|
---|
2235 | CFGMR3RemoveValue(pNode, pszCFGMValueName);
|
---|
2236 | }
|
---|
2237 |
|
---|
2238 | /*
|
---|
2239 | * Now let's have a look at the value.
|
---|
2240 | * Empty strings means that we should remove the value, which we've
|
---|
2241 | * already done above.
|
---|
2242 | */
|
---|
2243 | Utf8Str strCFGMValueUtf8(strExtraDataValue);
|
---|
2244 | const char *pszCFGMValue = strCFGMValueUtf8.raw();
|
---|
2245 | if ( pszCFGMValue
|
---|
2246 | && *pszCFGMValue)
|
---|
2247 | {
|
---|
2248 | uint64_t u64Value;
|
---|
2249 |
|
---|
2250 | /* check for type prefix first. */
|
---|
2251 | if (!strncmp(pszCFGMValue, "string:", sizeof("string:") - 1))
|
---|
2252 | rc = CFGMR3InsertString(pNode, pszCFGMValueName, pszCFGMValue + sizeof("string:") - 1);
|
---|
2253 | else if (!strncmp(pszCFGMValue, "integer:", sizeof("integer:") - 1))
|
---|
2254 | {
|
---|
2255 | rc = RTStrToUInt64Full(pszCFGMValue + sizeof("integer:") - 1, 0, &u64Value);
|
---|
2256 | if (RT_SUCCESS(rc))
|
---|
2257 | rc = CFGMR3InsertInteger(pNode, pszCFGMValueName, u64Value);
|
---|
2258 | }
|
---|
2259 | else if (!strncmp(pszCFGMValue, "bytes:", sizeof("bytes:") - 1))
|
---|
2260 | rc = VERR_NOT_IMPLEMENTED;
|
---|
2261 | /* auto detect type. */
|
---|
2262 | else if (RT_SUCCESS(RTStrToUInt64Full(pszCFGMValue, 0, &u64Value)))
|
---|
2263 | rc = CFGMR3InsertInteger(pNode, pszCFGMValueName, u64Value);
|
---|
2264 | else
|
---|
2265 | rc = CFGMR3InsertString(pNode, pszCFGMValueName, pszCFGMValue);
|
---|
2266 | AssertLogRelMsgRC(rc, ("failed to insert CFGM value '%s' to key '%s'\n", pszCFGMValue, pszExtraDataKey));
|
---|
2267 | }
|
---|
2268 | }
|
---|
2269 |
|
---|
2270 | #undef H
|
---|
2271 | #undef RC_CHECK
|
---|
2272 | #undef STR_FREE
|
---|
2273 | #undef STR_CONV
|
---|
2274 |
|
---|
2275 | /* Register VM state change handler */
|
---|
2276 | int rc2 = VMR3AtStateRegister (pVM, Console::vmstateChangeCallback, pConsole);
|
---|
2277 | AssertRC (rc2);
|
---|
2278 | if (RT_SUCCESS (rc))
|
---|
2279 | rc = rc2;
|
---|
2280 |
|
---|
2281 | /* Register VM runtime error handler */
|
---|
2282 | rc2 = VMR3AtRuntimeErrorRegister (pVM, Console::setVMRuntimeErrorCallback, pConsole);
|
---|
2283 | AssertRC (rc2);
|
---|
2284 | if (RT_SUCCESS (rc))
|
---|
2285 | rc = rc2;
|
---|
2286 |
|
---|
2287 | /* Save the VM pointer in the machine object */
|
---|
2288 | pConsole->mpVM = pVM;
|
---|
2289 |
|
---|
2290 | LogFlowFunc (("vrc = %Rrc\n", rc));
|
---|
2291 | LogFlowFuncLeave();
|
---|
2292 |
|
---|
2293 | return rc;
|
---|
2294 | }
|
---|
2295 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|