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