Changeset 86648 in vbox for trunk/src/VBox/Main/src-server/ApplianceImpl.cpp
- Timestamp:
- Oct 20, 2020 1:59:45 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 141024
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/ApplianceImpl.cpp
r86509 r86648 26 26 #include <VBox/com/array.h> 27 27 #include <map> 28 #include <stack> 28 29 29 30 #include "ApplianceImpl.h" … … 1409 1410 } 1410 1411 1412 HRESULT Appliance::i_findFirstBootableImage(ComPtr<IMedium>& bootMedium, const ComPtr<IMachine> &pMachine) 1413 { 1414 HRESULT hrc = S_OK; 1415 LogFlowFuncEnter(); 1416 1417 const ComPtr<IMachine> &baseMachine = pMachine; 1418 try 1419 { 1420 /* Fetch all available storage controllers */ 1421 com::SafeIfaceArray<IStorageController> aStorageControllers; 1422 // AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1423 hrc = baseMachine->COMGETTER(StorageControllers)(ComSafeArrayAsOutParam(aStorageControllers)); 1424 // alock.release(); 1425 bool fBootMediumFound = false; 1426 ComPtr<IMedium> ptrBootMedium; 1427 std::stack <StorageBus_T> aBuses; 1428 //insert buses in priority StorageBus_IDE - highest, StorageBus_SAS - lowest 1429 aBuses.push(StorageBus_SAS); 1430 aBuses.push(StorageBus_SCSI); 1431 aBuses.push(StorageBus_SATA); 1432 aBuses.push(StorageBus_IDE); 1433 1434 while (!aBuses.empty()) 1435 { 1436 Bstr bstrControllerName; 1437 Utf8Str strControllerName; 1438 ComPtr<IStorageController> sc; 1439 StorageBus_T eTargetStorageBusType = aBuses.top(); 1440 StorageBus_T eSourceStorageBusType; 1441 bool f = false; 1442 1443 for (size_t i=0; i<aStorageControllers.size(); ++i) 1444 { 1445 sc = aStorageControllers[i]; 1446 sc->COMGETTER(Name)(bstrControllerName.asOutParam()); 1447 sc->COMGETTER(Bus)(&eSourceStorageBusType); 1448 if (eSourceStorageBusType == eTargetStorageBusType) 1449 { 1450 f = true; 1451 break; 1452 } 1453 } 1454 1455 if (!f) 1456 { 1457 aBuses.pop(); 1458 continue; 1459 } 1460 1461 com::SafeIfaceArray<IMediumAttachment> aMediumAttachments; 1462 hrc = baseMachine->GetMediumAttachmentsOfController(bstrControllerName.raw(), 1463 ComSafeArrayAsOutParam(aMediumAttachments)); 1464 1465 strControllerName = bstrControllerName; 1466 AssertLogRelReturn(strControllerName.isNotEmpty(), setErrorBoth(E_UNEXPECTED, VERR_INTERNAL_ERROR_2)); 1467 1468 for (size_t j = 0; j < aMediumAttachments.size(); j++) 1469 { 1470 //some checks just in case 1471 LONG iPort = -1; 1472 hrc = aMediumAttachments[j]->COMGETTER(Port)(&iPort); 1473 AssertComRCReturn(hrc, hrc); 1474 1475 LONG iDevice = -1; 1476 hrc = aMediumAttachments[j]->COMGETTER(Device)(&iDevice); 1477 AssertComRCReturn(hrc, hrc); 1478 1479 DeviceType_T enmType; 1480 hrc = aMediumAttachments[j]->COMGETTER(Type)(&enmType); 1481 AssertComRCReturn(hrc, hrc); 1482 1483 if (enmType == DeviceType_HardDisk) 1484 { 1485 ComPtr<IMedium> ptrMedium; 1486 hrc = aMediumAttachments[j]->COMGETTER(Medium)(ptrMedium.asOutParam()); 1487 AssertComRCReturn(hrc, hrc); 1488 1489 if (ptrMedium.isNotNull()) 1490 { 1491 ptrBootMedium = ptrMedium; 1492 fBootMediumFound = true; 1493 break; 1494 } 1495 } 1496 } 1497 1498 if (fBootMediumFound) 1499 { 1500 hrc = S_OK; 1501 break; 1502 } 1503 else 1504 aBuses.pop(); 1505 } 1506 1507 if (ptrBootMedium != NULL && !ptrBootMedium.isNull()) 1508 ptrBootMedium.queryInterfaceTo(bootMedium.asOutParam()); 1509 } 1510 catch (HRESULT erc) 1511 { 1512 hrc = setError(erc, tr("Exception during finding a bootable disk ")); 1513 } 1514 1515 LogFlowFuncLeave(); 1516 return hrc; 1517 } 1518 1411 1519 void i_parseURI(Utf8Str strUri, LocationInfo &locInfo) 1412 1520 {
Note:
See TracChangeset
for help on using the changeset viewer.