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