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