Changeset 28727 in vbox for trunk/src/VBox/Main/ConsoleImpl2.cpp
- Timestamp:
- Apr 26, 2010 7:37:29 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 60601
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl2.cpp
r28580 r28727 231 231 empty.asOutParam(), aFilePath.asOutParam(), &fPresent); 232 232 if (RT_FAILURE(rc)) 233 AssertComRCReturn 233 AssertComRCReturn(rc, VERR_FILE_NOT_FOUND); 234 234 235 235 if (!fPresent) … … 279 279 BOOL fIs64BitGuest = false; 280 280 281 #if !defined 281 #if !defined(VBOX_WITH_XPCOM) 282 282 { 283 283 /* initialize COM */ … … 285 285 COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE | 286 286 COINIT_SPEED_OVER_MEMORY); 287 LogFlow 288 AssertComRCReturn 287 LogFlow(("Console::configConstructor(): CoInitializeEx()=%08X\n", hrc)); 288 AssertComRCReturn(hrc, VERR_GENERAL_FAILURE); 289 289 } 290 290 #endif 291 291 292 292 AssertReturn(pvConsole, VERR_GENERAL_FAILURE); 293 ComObjPtr<Console> pConsole = static_cast <Console *>(pvConsole);293 ComObjPtr<Console> pConsole = static_cast<Console *>(pvConsole); 294 294 295 295 AutoCaller autoCaller(pConsole); 296 AssertComRCReturn 296 AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED); 297 297 298 298 /* lock the console because we widely use internal fields and methods */ … … 933 933 if (SchemaDefs::MaxBootPosition > 9) 934 934 { 935 AssertMsgFailed 936 935 AssertMsgFailed(("Too many boot devices %d\n", 936 SchemaDefs::MaxBootPosition)); 937 937 return VERR_INVALID_PARAMETER; 938 938 } … … 943 943 944 944 char szParamName[] = "BootDeviceX"; 945 szParamName[sizeof 945 szParamName[sizeof(szParamName) - 2] = ((char (pos - 1)) + '0'); 946 946 947 947 const char *pszBootDevice; … … 1260 1260 for (size_t j = 0; j < atts.size(); ++j) 1261 1261 { 1262 ComPtr<IMedium> medium; 1263 hrc = atts[j]->COMGETTER(Medium)(medium.asOutParam()); H(); 1264 LONG lDev; 1265 hrc = atts[j]->COMGETTER(Device)(&lDev); H(); 1266 LONG lPort; 1267 hrc = atts[j]->COMGETTER(Port)(&lPort); H(); 1268 DeviceType_T lType; 1269 hrc = atts[j]->COMGETTER(Type)(&lType); H(); 1270 1271 unsigned uLUN; 1272 hrc = pConsole->convertBusPortDeviceToLun(enmBus, lPort, lDev, uLUN); H(); 1273 rc = CFGMR3InsertNodeF(pCtlInst, &pLunL0, "LUN#%u", uLUN); RC_CHECK(); 1274 1275 /* SCSI has a another driver between device and block. */ 1276 if (enmBus == StorageBus_SCSI || enmBus == StorageBus_SAS) 1277 { 1278 rc = CFGMR3InsertString(pLunL0, "Driver", "SCSI"); RC_CHECK(); 1279 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 1280 1281 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK(); 1282 } 1283 1284 BOOL fHostDrive = FALSE; 1285 if (!medium.isNull()) 1286 { 1287 hrc = medium->COMGETTER(HostDrive)(&fHostDrive); H(); 1288 } 1289 1290 if (fHostDrive) 1291 { 1292 Assert(!medium.isNull()); 1293 if (lType == DeviceType_DVD) 1294 { 1295 rc = CFGMR3InsertString(pLunL0, "Driver", "HostDVD"); RC_CHECK(); 1296 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 1297 1298 hrc = medium->COMGETTER(Location)(&str); H(); 1299 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 1300 STR_FREE(); 1301 1302 BOOL fPassthrough; 1303 hrc = atts[j]->COMGETTER(Passthrough)(&fPassthrough); H(); 1304 rc = CFGMR3InsertInteger(pCfg, "Passthrough", !!fPassthrough); RC_CHECK(); 1305 } 1306 else if (lType == DeviceType_Floppy) 1307 { 1308 rc = CFGMR3InsertString(pLunL0, "Driver", "HostFloppy"); RC_CHECK(); 1309 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 1310 1311 hrc = medium->COMGETTER(Location)(&str); H(); 1312 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 1313 STR_FREE(); 1314 } 1315 } 1316 else 1317 { 1318 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK(); 1319 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 1320 switch (lType) 1321 { 1322 case DeviceType_DVD: 1323 rc = CFGMR3InsertString(pCfg, "Type", "DVD"); RC_CHECK(); 1324 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK(); 1325 break; 1326 case DeviceType_Floppy: 1327 rc = CFGMR3InsertString(pCfg, "Type", "Floppy 1.44"); RC_CHECK(); 1328 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK(); 1329 break; 1330 case DeviceType_HardDisk: 1331 default: 1332 rc = CFGMR3InsertString(pCfg, "Type", "HardDisk"); RC_CHECK(); 1333 rc = CFGMR3InsertInteger(pCfg, "Mountable", 0); RC_CHECK(); 1334 } 1335 1336 if (!medium.isNull()) 1337 { 1338 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK(); 1339 rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK(); 1340 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK(); 1341 1342 hrc = medium->COMGETTER(Location)(&str); H(); 1343 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 1344 STR_FREE(); 1345 1346 hrc = medium->COMGETTER(Format)(&str); H(); 1347 rc = CFGMR3InsertStringW(pCfg, "Format", str); RC_CHECK(); 1348 STR_FREE(); 1349 1350 /* DVDs are always readonly */ 1351 if (lType == DeviceType_DVD) 1352 { 1353 rc = CFGMR3InsertInteger(pCfg, "ReadOnly", 1); RC_CHECK(); 1354 } 1355 /* Start without exclusive write access to the images. */ 1356 /** @todo Live Migration: I don't quite like this, we risk screwing up when 1357 * we're resuming the VM if some 3rd dude have any of the VDIs open 1358 * with write sharing denied. However, if the two VMs are sharing a 1359 * image it really is necessary.... 1360 * 1361 * So, on the "lock-media" command, the target teleporter should also 1362 * make DrvVD undo TempReadOnly. It gets interesting if we fail after 1363 * that. Grumble. */ 1364 else if (pConsole->mMachineState == MachineState_TeleportingIn) 1365 { 1366 rc = CFGMR3InsertInteger(pCfg, "TempReadOnly", 1); RC_CHECK(); 1367 } 1368 1369 /* Pass all custom parameters. */ 1370 bool fHostIP = true; 1371 SafeArray<BSTR> names; 1372 SafeArray<BSTR> values; 1373 hrc = medium->GetProperties(NULL, 1374 ComSafeArrayAsOutParam(names), 1375 ComSafeArrayAsOutParam(values)); H(); 1376 1377 if (names.size() != 0) 1378 { 1379 PCFGMNODE pVDC; 1380 rc = CFGMR3InsertNode(pCfg, "VDConfig", &pVDC); RC_CHECK(); 1381 for (size_t ii = 0; ii < names.size(); ++ii) 1382 { 1383 if (values[ii] && *values[ii]) 1384 { 1385 Utf8Str name = names[ii]; 1386 Utf8Str value = values[ii]; 1387 rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str()); RC_CHECK(); 1388 if ( name.compare("HostIPStack") == 0 1389 && value.compare("0") == 0) 1390 fHostIP = false; 1391 } 1392 } 1393 } 1394 1395 /* Create an inversed tree of parents. */ 1396 ComPtr<IMedium> parentMedium = medium; 1397 for (PCFGMNODE pParent = pCfg;;) 1398 { 1399 hrc = parentMedium->COMGETTER(Parent)(medium.asOutParam()); H(); 1400 if (medium.isNull()) 1401 break; 1402 1403 PCFGMNODE pCur; 1404 rc = CFGMR3InsertNode(pParent, "Parent", &pCur); RC_CHECK(); 1405 hrc = medium->COMGETTER(Location)(&str); H(); 1406 rc = CFGMR3InsertStringW(pCur, "Path", str); RC_CHECK(); 1407 STR_FREE(); 1408 1409 hrc = medium->COMGETTER(Format)(&str); H(); 1410 rc = CFGMR3InsertStringW(pCur, "Format", str); RC_CHECK(); 1411 STR_FREE(); 1412 1413 /* Pass all custom parameters. */ 1414 SafeArray<BSTR> aNames; 1415 SafeArray<BSTR> aValues; 1416 hrc = medium->GetProperties(NULL, 1417 ComSafeArrayAsOutParam(aNames), 1418 ComSafeArrayAsOutParam(aValues)); H(); 1419 1420 if (aNames.size() != 0) 1421 { 1422 PCFGMNODE pVDC; 1423 rc = CFGMR3InsertNode(pCur, "VDConfig", &pVDC); RC_CHECK(); 1424 for (size_t ii = 0; ii < aNames.size(); ++ii) 1425 { 1426 if (aValues[ii] && *aValues[ii]) 1427 { 1428 Utf8Str name = aNames[ii]; 1429 Utf8Str value = aValues[ii]; 1430 rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str()); RC_CHECK(); 1431 if ( name.compare("HostIPStack") == 0 1432 && value.compare("0") == 0) 1433 fHostIP = false; 1434 } 1435 } 1436 } 1437 1438 /* Custom code: put marker to not use host IP stack to driver 1439 * configuration node. Simplifies life of DrvVD a bit. */ 1440 if (!fHostIP) 1441 { 1442 rc = CFGMR3InsertInteger(pCfg, "HostIPStack", 0); RC_CHECK(); 1443 } 1444 1445 /* next */ 1446 pParent = pCur; 1447 parentMedium = medium; 1448 } 1449 } 1450 } 1451 1452 if (paLedDevType) 1453 paLedDevType[uLUN] = lType; 1262 rc = Console::configMediumAttachment(pCtlInst, pszCtrlDev, 1263 ulInstance, enmBus, atts[j], 1264 pConsole->mMachineState, 1265 NULL /* phrc */, 1266 false /* fAttachDetach */, 1267 false /* fForceUnmount */, 1268 NULL /* pVM */, 1269 paLedDevType); RC_CHECK(); 1454 1270 } 1455 1271 H(); … … 1637 1453 * Configure the network card now 1638 1454 */ 1639 rc = configNetwork(pConsole, pszAdapterName, ulInstance, 0, networkAdapter, 1640 pCfg, pLunL0, pInst, false /*fAttachDetach*/); RC_CHECK(); 1455 rc = pConsole->configNetwork(pszAdapterName, ulInstance, 0, 1456 networkAdapter, pCfg, pLunL0, pInst, 1457 false /*fAttachDetach*/); RC_CHECK(); 1641 1458 } 1642 1459 … … 1673 1490 { 1674 1491 ComPtr<ISerialPort> serialPort; 1675 hrc = pMachine->GetSerialPort 1492 hrc = pMachine->GetSerialPort(ulInstance, serialPort.asOutParam()); H(); 1676 1493 BOOL fEnabled = FALSE; 1677 1494 if (serialPort) … … 1901 1718 # endif 1902 1719 #endif /* RT_OS_LINUX */ 1903 #if defined (RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(VBOX_WITH_SOLARIS_OSS)1720 #if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(VBOX_WITH_SOLARIS_OSS) 1904 1721 case AudioDriverType_OSS: 1905 1722 { … … 2102 1919 { 2103 1920 /* Load the service */ 2104 rc = pConsole->mVMMDev->hgcmLoadService 1921 rc = pConsole->mVMMDev->hgcmLoadService("VBoxSharedClipboard", "VBoxSharedClipboard"); 2105 1922 2106 1923 if (RT_FAILURE(rc)) … … 2146 1963 } 2147 1964 2148 pConsole->mVMMDev->hgcmHostCall 1965 pConsole->mVMMDev->hgcmHostCall("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm); 2149 1966 2150 1967 Log(("Set VBoxSharedClipboard mode\n")); … … 2164 1981 { 2165 1982 /* Load the service */ 2166 rc = pConsole->mVMMDev->hgcmLoadService 1983 rc = pConsole->mVMMDev->hgcmLoadService("VBoxSharedCrOpenGL", "VBoxSharedCrOpenGL"); 2167 1984 if (RT_FAILURE(rc)) 2168 1985 { … … 2422 2239 2423 2240 /* Register VM state change handler */ 2424 int rc2 = VMR3AtStateRegister 2241 int rc2 = VMR3AtStateRegister(pVM, Console::vmstateChangeCallback, pConsole); 2425 2242 AssertRC(rc2); 2426 2243 if (RT_SUCCESS(rc)) … … 2428 2245 2429 2246 /* Register VM runtime error handler */ 2430 rc2 = VMR3AtRuntimeErrorRegister 2247 rc2 = VMR3AtRuntimeErrorRegister(pVM, Console::setVMRuntimeErrorCallback, pConsole); 2431 2248 AssertRC(rc2); 2432 2249 if (RT_SUCCESS(rc)) 2433 2250 rc = rc2; 2434 2251 2435 LogFlowFunc 2252 LogFlowFunc(("vrc = %Rrc\n", rc)); 2436 2253 LogFlowFuncLeave(); 2437 2254 … … 2450 2267 } 2451 2268 2269 /* static */ 2270 int Console::configMediumAttachment(PCFGMNODE pCtlInst, const char *pcszDevice, 2271 unsigned uInstance, StorageBus_T enmBus, 2272 IMediumAttachment *pMediumAtt, 2273 MachineState_T aMachineState, 2274 HRESULT *phrc, bool fAttachDetach, 2275 bool fForceUnmount, PVM pVM, 2276 DeviceType_T *paLedDevType) 2277 { 2278 int rc = VINF_SUCCESS; 2279 HRESULT hrc; 2280 BSTR str = NULL; 2281 2282 #define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } } while (0) 2283 #define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0) 2284 #define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%Rhrc\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0) 2285 2286 LONG lDev; 2287 hrc = pMediumAtt->COMGETTER(Device)(&lDev); H(); 2288 LONG lPort; 2289 hrc = pMediumAtt->COMGETTER(Port)(&lPort); H(); 2290 DeviceType_T lType; 2291 hrc = pMediumAtt->COMGETTER(Type)(&lType); H(); 2292 2293 unsigned uLUN; 2294 PCFGMNODE pLunL0 = NULL; 2295 PCFGMNODE pCfg = NULL; 2296 hrc = Console::convertBusPortDeviceToLun(enmBus, lPort, lDev, uLUN); H(); 2297 2298 /* First check if the LUN already exists. */ 2299 pLunL0 = CFGMR3GetChildF(pCtlInst, "LUN#%u", uLUN); 2300 if (pLunL0) 2301 { 2302 if (fAttachDetach) 2303 { 2304 if (lType != DeviceType_HardDisk) 2305 { 2306 /* Unmount existing media only for floppy and DVD drives. */ 2307 PPDMIBASE pBase; 2308 rc = PDMR3QueryLun(pVM, pcszDevice, uInstance, uLUN, &pBase); 2309 if (RT_FAILURE(rc)) 2310 { 2311 if (rc == VERR_PDM_LUN_NOT_FOUND || rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN) 2312 rc = VINF_SUCCESS; 2313 AssertRC(rc); 2314 } 2315 else 2316 { 2317 PPDMIMOUNT pIMount = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMOUNT); 2318 AssertReturn(pIMount, VERR_INVALID_POINTER); 2319 2320 /* Unmount the media. */ 2321 rc = pIMount->pfnUnmount(pIMount, fForceUnmount); 2322 if (rc == VERR_PDM_MEDIA_NOT_MOUNTED) 2323 rc = VINF_SUCCESS; 2324 } 2325 } 2326 2327 rc = PDMR3DeviceDetach(pVM, pcszDevice, 0, uLUN, PDM_TACH_FLAGS_NOT_HOT_PLUG); 2328 if (rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN) 2329 rc = VINF_SUCCESS; 2330 RC_CHECK(); 2331 2332 CFGMR3RemoveNode(pLunL0); 2333 } 2334 else 2335 AssertFailedReturn(VERR_INTERNAL_ERROR); 2336 } 2337 2338 rc = CFGMR3InsertNodeF(pCtlInst, &pLunL0, "LUN#%u", uLUN); RC_CHECK(); 2339 2340 /* SCSI has a another driver between device and block. */ 2341 if (enmBus == StorageBus_SCSI || enmBus == StorageBus_SAS) 2342 { 2343 rc = CFGMR3InsertString(pLunL0, "Driver", "SCSI"); RC_CHECK(); 2344 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2345 2346 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK(); 2347 } 2348 2349 ComPtr<IMedium> pMedium; 2350 hrc = pMediumAtt->COMGETTER(Medium)(pMedium.asOutParam()); H(); 2351 BOOL fPassthrough; 2352 hrc = pMediumAtt->COMGETTER(Passthrough)(&fPassthrough); H(); 2353 rc = Console::configMedium(pLunL0, !!fPassthrough, lType, 2354 pMedium, aMachineState, phrc); RC_CHECK(); 2355 2356 if (fAttachDetach) 2357 { 2358 /* Attach the new driver. */ 2359 rc = PDMR3DeviceAttach(pVM, pcszDevice, 0, uLUN, 2360 PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/); RC_CHECK(); 2361 2362 /* There is no need to handle removable medium mounting, as we 2363 * unconditionally replace everthing including the block driver level. 2364 * This means the new medium will be picked up automatically. */ 2365 } 2366 2367 if (paLedDevType) 2368 paLedDevType[uLUN] = lType; 2369 2370 #undef STR_FREE 2371 #undef H 2372 #undef RC_CHECK 2373 2374 return VINF_SUCCESS;; 2375 } 2376 2377 int Console::configMedium(PCFGMNODE pLunL0, 2378 bool fPassthrough, 2379 DeviceType_T enmType, 2380 IMedium *pMedium, 2381 MachineState_T aMachineState, 2382 HRESULT *phrc) 2383 { 2384 int rc = VINF_SUCCESS; 2385 HRESULT hrc; 2386 BSTR str = NULL; 2387 2388 #define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } } while (0) 2389 #define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0) 2390 #define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%Rhrc\n", hrc)); STR_FREE(); if (phrc) *phrc = hrc; return VERR_GENERAL_FAILURE; } } while (0) 2391 2392 PCFGMNODE pLunL1 = NULL; 2393 PCFGMNODE pCfg = NULL; 2394 2395 BOOL fHostDrive = FALSE; 2396 if (pMedium) 2397 { 2398 hrc = pMedium->COMGETTER(HostDrive)(&fHostDrive); H(); 2399 } 2400 2401 if (fHostDrive) 2402 { 2403 Assert(pMedium); 2404 if (enmType == DeviceType_DVD) 2405 { 2406 rc = CFGMR3InsertString(pLunL0, "Driver", "HostDVD"); RC_CHECK(); 2407 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2408 2409 hrc = pMedium->COMGETTER(Location)(&str); H(); 2410 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 2411 STR_FREE(); 2412 2413 rc = CFGMR3InsertInteger(pCfg, "Passthrough", fPassthrough); RC_CHECK(); 2414 } 2415 else if (enmType == DeviceType_Floppy) 2416 { 2417 rc = CFGMR3InsertString(pLunL0, "Driver", "HostFloppy"); RC_CHECK(); 2418 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2419 2420 hrc = pMedium->COMGETTER(Location)(&str); H(); 2421 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 2422 STR_FREE(); 2423 } 2424 } 2425 else 2426 { 2427 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK(); 2428 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2429 switch (enmType) 2430 { 2431 case DeviceType_DVD: 2432 rc = CFGMR3InsertString(pCfg, "Type", "DVD"); RC_CHECK(); 2433 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK(); 2434 break; 2435 case DeviceType_Floppy: 2436 rc = CFGMR3InsertString(pCfg, "Type", "Floppy 1.44"); RC_CHECK(); 2437 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK(); 2438 break; 2439 case DeviceType_HardDisk: 2440 default: 2441 rc = CFGMR3InsertString(pCfg, "Type", "HardDisk"); RC_CHECK(); 2442 rc = CFGMR3InsertInteger(pCfg, "Mountable", 0); RC_CHECK(); 2443 } 2444 2445 if (pMedium) 2446 { 2447 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK(); 2448 rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK(); 2449 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK(); 2450 2451 hrc = pMedium->COMGETTER(Location)(&str); H(); 2452 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 2453 STR_FREE(); 2454 2455 hrc = pMedium->COMGETTER(Format)(&str); H(); 2456 rc = CFGMR3InsertStringW(pCfg, "Format", str); RC_CHECK(); 2457 STR_FREE(); 2458 2459 /* DVDs are always readonly */ 2460 if (enmType == DeviceType_DVD) 2461 { 2462 rc = CFGMR3InsertInteger(pCfg, "ReadOnly", 1); RC_CHECK(); 2463 } 2464 2465 /* Start without exclusive write access to the images. */ 2466 /** @todo Live Migration: I don't quite like this, we risk screwing up when 2467 * we're resuming the VM if some 3rd dude have any of the VDIs open 2468 * with write sharing denied. However, if the two VMs are sharing a 2469 * image it really is necessary.... 2470 * 2471 * So, on the "lock-media" command, the target teleporter should also 2472 * make DrvVD undo TempReadOnly. It gets interesting if we fail after 2473 * that. Grumble. */ 2474 else if (aMachineState == MachineState_TeleportingIn) 2475 { 2476 rc = CFGMR3InsertInteger(pCfg, "TempReadOnly", 1); RC_CHECK(); 2477 } 2478 2479 /* Pass all custom parameters. */ 2480 bool fHostIP = true; 2481 SafeArray<BSTR> names; 2482 SafeArray<BSTR> values; 2483 hrc = pMedium->GetProperties(NULL, 2484 ComSafeArrayAsOutParam(names), 2485 ComSafeArrayAsOutParam(values)); H(); 2486 2487 if (names.size() != 0) 2488 { 2489 PCFGMNODE pVDC; 2490 rc = CFGMR3InsertNode(pCfg, "VDConfig", &pVDC); RC_CHECK(); 2491 for (size_t ii = 0; ii < names.size(); ++ii) 2492 { 2493 if (values[ii] && *values[ii]) 2494 { 2495 Utf8Str name = names[ii]; 2496 Utf8Str value = values[ii]; 2497 rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str()); RC_CHECK(); 2498 if ( name.compare("HostIPStack") == 0 2499 && value.compare("0") == 0) 2500 fHostIP = false; 2501 } 2502 } 2503 } 2504 2505 /* Create an inversed tree of parents. */ 2506 IMedium *pParentMedium = pMedium; 2507 for (PCFGMNODE pParent = pCfg;;) 2508 { 2509 hrc = pParentMedium->COMGETTER(Parent)(&pMedium); H(); 2510 if (!pMedium) 2511 break; 2512 2513 PCFGMNODE pCur; 2514 rc = CFGMR3InsertNode(pParent, "Parent", &pCur); RC_CHECK(); 2515 hrc = pMedium->COMGETTER(Location)(&str); H(); 2516 rc = CFGMR3InsertStringW(pCur, "Path", str); RC_CHECK(); 2517 STR_FREE(); 2518 2519 hrc = pMedium->COMGETTER(Format)(&str); H(); 2520 rc = CFGMR3InsertStringW(pCur, "Format", str); RC_CHECK(); 2521 STR_FREE(); 2522 2523 /* Pass all custom parameters. */ 2524 SafeArray<BSTR> aNames; 2525 SafeArray<BSTR> aValues; 2526 hrc = pMedium->GetProperties(NULL, 2527 ComSafeArrayAsOutParam(aNames), 2528 ComSafeArrayAsOutParam(aValues)); H(); 2529 2530 if (aNames.size() != 0) 2531 { 2532 PCFGMNODE pVDC; 2533 rc = CFGMR3InsertNode(pCur, "VDConfig", &pVDC); RC_CHECK(); 2534 for (size_t ii = 0; ii < aNames.size(); ++ii) 2535 { 2536 if (aValues[ii] && *aValues[ii]) 2537 { 2538 Utf8Str name = aNames[ii]; 2539 Utf8Str value = aValues[ii]; 2540 rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str()); RC_CHECK(); 2541 if ( name.compare("HostIPStack") == 0 2542 && value.compare("0") == 0) 2543 fHostIP = false; 2544 } 2545 } 2546 } 2547 2548 /* Custom code: put marker to not use host IP stack to driver 2549 * configuration node. Simplifies life of DrvVD a bit. */ 2550 if (!fHostIP) 2551 { 2552 rc = CFGMR3InsertInteger(pCfg, "HostIPStack", 0); RC_CHECK(); 2553 } 2554 2555 /* next */ 2556 pParent = pCur; 2557 pParentMedium = pMedium; 2558 } 2559 } 2560 } 2561 2562 #undef STR_FREE 2563 #undef H 2564 #undef RC_CHECK 2565 2566 return VINF_SUCCESS; 2567 } 2568 2452 2569 /** 2453 2570 * Construct the Network configuration tree … … 2455 2572 * @returns VBox status code. 2456 2573 * 2457 * @param pThis Pointer to the Console object.2458 2574 * @param pszDevice The PDM device name. 2459 2575 * @param uInstance The PDM device instance. … … 2467 2583 * configuration. 2468 2584 * 2469 * @note Locks th e Consoleobject for writing.2585 * @note Locks this object for writing. 2470 2586 */ 2471 /*static*/ int Console::configNetwork(Console *pThis, const char *pszDevice, 2472 unsigned uInstance, unsigned uLun, 2473 INetworkAdapter *aNetworkAdapter, 2474 PCFGMNODE pCfg, PCFGMNODE pLunL0, 2475 PCFGMNODE pInst, bool fAttachDetach) 2587 int Console::configNetwork(const char *pszDevice, unsigned uInstance, 2588 unsigned uLun, INetworkAdapter *aNetworkAdapter, 2589 PCFGMNODE pCfg, PCFGMNODE pLunL0, PCFGMNODE pInst, 2590 bool fAttachDetach) 2476 2591 { 2592 AutoCaller autoCaller(this); 2593 AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED); 2594 2477 2595 int rc = VINF_SUCCESS; 2478 2479 AutoCaller autoCaller(pThis); 2480 AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED); 2596 HRESULT hrc; 2597 BSTR str = NULL; 2598 2599 #define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } } while (0) 2600 #define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0) 2601 #define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%Rhrc\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0) 2481 2602 2482 2603 /* … … 2485 2606 * meAttachmentType member. 2486 2607 */ 2487 AutoWriteLock alock(pThis COMMA_LOCKVAL_SRC_POS); 2488 2489 PVM pVM = pThis->mpVM; 2490 BSTR str = NULL; 2491 2492 #define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } } while (0) 2493 #define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0) 2494 #define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%Rhrc\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0) 2495 2496 HRESULT hrc; 2497 ComPtr<IMachine> pMachine = pThis->machine(); 2608 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 2609 2610 PVM pVM = mpVM; 2611 2612 ComPtr<IMachine> pMachine = machine(); 2498 2613 2499 2614 ComPtr<IVirtualBox> virtualBox; … … 2512 2627 { 2513 2628 const char *pszNetDriver = "IntNet"; 2514 if ( pThis->meAttachmentType[uInstance] == NetworkAttachmentType_NAT)2629 if (meAttachmentType[uInstance] == NetworkAttachmentType_NAT) 2515 2630 pszNetDriver = "NAT"; 2516 2631 #if !defined(VBOX_WITH_NETFLT) && defined(RT_OS_LINUX) 2517 if ( pThis->meAttachmentType[uInstance] == NetworkAttachmentType_Bridged)2632 if (meAttachmentType[uInstance] == NetworkAttachmentType_Bridged) 2518 2633 pszNetDriver = "HostInterface"; 2519 2634 #endif … … 2701 2816 Log2((#res " %s pos:%d, ppos:%d\n", res.raw(), pos, ppos)); \ 2702 2817 ppos = pos + 1; \ 2703 } while (0)2818 } while (0) 2704 2819 ITERATE_TO_NEXT_TERM(strName, utf, pos, ppos); 2705 2820 ITERATE_TO_NEXT_TERM(strProto, utf, pos, ppos); … … 2758 2873 { 2759 2874 #if (defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)) && !defined(VBOX_WITH_NETFLT) 2760 hrc = pThis->attachToTapInterface(aNetworkAdapter);2875 hrc = attachToTapInterface(aNetworkAdapter); 2761 2876 if (FAILED(hrc)) 2762 2877 { … … 2777 2892 } 2778 2893 2779 Assert((int) pThis->maTapFD[uInstance] >= 0);2780 if ((int) pThis->maTapFD[uInstance] >= 0)2894 Assert((int)maTapFD[uInstance] >= 0); 2895 if ((int)maTapFD[uInstance] >= 0) 2781 2896 { 2782 2897 if (fSniffer) … … 2790 2905 rc = CFGMR3InsertString(pLunL0, "Driver", "HostInterface"); RC_CHECK(); 2791 2906 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2792 rc = CFGMR3InsertInteger(pCfg, "FileHandle", pThis->maTapFD[uInstance]); RC_CHECK();2907 rc = CFGMR3InsertInteger(pCfg, "FileHandle", maTapFD[uInstance]); RC_CHECK(); 2793 2908 } 2794 2909 … … 2972 3087 */ 2973 3088 if (!strncmp(pszHifName, "tap", sizeof "tap" - 1)) { 2974 hrc = pThis->attachToTapInterface(aNetworkAdapter);3089 hrc = attachToTapInterface(aNetworkAdapter); 2975 3090 if (FAILED(hrc)) 2976 3091 { … … 2991 3106 } 2992 3107 2993 Assert((int) pThis->maTapFD[uInstance] >= 0);2994 if ((int) pThis->maTapFD[uInstance] >= 0)3108 Assert((int)maTapFD[uInstance] >= 0); 3109 if ((int)maTapFD[uInstance] >= 0) 2995 3110 { 2996 3111 rc = CFGMR3InsertString(pLunL0, "Driver", "HostInterface"); RC_CHECK(); 2997 3112 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2998 rc = CFGMR3InsertInteger(pCfg, "FileHandle", pThis->maTapFD[uInstance]);RC_CHECK();3113 rc = CFGMR3InsertInteger(pCfg, "FileHandle", maTapFD[uInstance]); RC_CHECK(); 2999 3114 } 3000 3115 break; … … 3016 3131 if ((Req.ifr_flags & IFF_UP) == 0) 3017 3132 { 3018 setVMRuntimeErrorCallbackF(pVM, pThis, 0, "BridgedInterfaceDown", "Bridged interface %s is down. Guest will not be able to use this interface", pszHifName);3133 setVMRuntimeErrorCallbackF(pVM, this, 0, "BridgedInterfaceDown", "Bridged interface %s is down. Guest will not be able to use this interface", pszHifName); 3019 3134 } 3020 3135 … … 3510 3625 } 3511 3626 3512 pThis->meAttachmentType[uInstance] = eAttachmentType;3627 meAttachmentType[uInstance] = eAttachmentType; 3513 3628 3514 3629 #undef STR_FREE … … 3565 3680 parms[2].u.pointer.addr = (void *)pszFlags; 3566 3681 parms[2].u.pointer.size = strlen(pszFlags) + 1; 3567 pVMMDev->hgcmHostCall 3568 3682 pVMMDev->hgcmHostCall("VBoxGuestPropSvc", guestProp::SET_PROP_HOST, 3, 3683 &parms[0]); 3569 3684 } 3570 3685 … … 3581 3696 VBOXHGCMSVCPARM paParm; 3582 3697 paParm.setUInt32(eFlags); 3583 int rc = pVMMDev->hgcmHostCall 3584 3585 3698 int rc = pVMMDev->hgcmHostCall("VBoxGuestPropSvc", 3699 guestProp::SET_GLOBAL_FLAGS_HOST, 1, 3700 &paParm); 3586 3701 if (RT_FAILURE(rc)) 3587 3702 { … … 3604 3719 #ifdef VBOX_WITH_GUEST_PROPS 3605 3720 AssertReturn(pvConsole, VERR_GENERAL_FAILURE); 3606 ComObjPtr<Console> pConsole = static_cast <Console *>(pvConsole);3721 ComObjPtr<Console> pConsole = static_cast<Console *>(pvConsole); 3607 3722 3608 3723 /* Load the service */ 3609 int rc = pConsole->mVMMDev->hgcmLoadService 3724 int rc = pConsole->mVMMDev->hgcmLoadService("VBoxGuestPropSvc", "VBoxGuestPropSvc"); 3610 3725 3611 3726 if (RT_FAILURE(rc)) … … 3744 3859 #ifdef VBOX_WITH_GUEST_CONTROL 3745 3860 AssertReturn(pvConsole, VERR_GENERAL_FAILURE); 3746 ComObjPtr<Console> pConsole = static_cast <Console *>(pvConsole);3861 ComObjPtr<Console> pConsole = static_cast<Console *>(pvConsole); 3747 3862 3748 3863 /* Load the service */ 3749 int rc = pConsole->mVMMDev->hgcmLoadService 3864 int rc = pConsole->mVMMDev->hgcmLoadService("VBoxGuestControlSvc", "VBoxGuestControlSvc"); 3750 3865 3751 3866 if (RT_FAILURE(rc))
Note:
See TracChangeset
for help on using the changeset viewer.