Changeset 101465 in vbox
- Timestamp:
- Oct 17, 2023 9:58:12 AM (15 months ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ConsoleImpl.h
r101464 r101465 843 843 KeyboardHIDType_T enmKbdHid, PointingHIDType_T enmPointingHid, PCFGMNODE *ppUsbDevices); 844 844 int i_configGuestDbg(ComPtr<IVirtualBox> pVBox, ComPtr<IMachine> pMachine, PCFGMNODE pRoot); 845 int i_configStorageCtrls(ComPtr<IMachine> pMachine, BusAssignmentManager *pBusMgr, PCVMMR3VTABLE pVMM, PUVM pUVM, 846 PCFGMNODE pDevices, PCFGMNODE pUsbDevices, PCFGMNODE pBiosCfg, bool *pfFdcEnabled); 845 847 846 848 static DECLCALLBACK(void) i_vmstateChangeCallback(PUVM pUVM, PCVMMR3VTABLE pVMM, VMSTATE enmState, -
trunk/src/VBox/Main/src-client/ConsoleImplConfigCommon.cpp
r101464 r101465 4285 4285 4286 4286 4287 /** 4288 * Translate IDE StorageControllerType_T to string representation. 4289 */ 4290 static const char* controllerString(StorageControllerType_T enmType) 4291 { 4292 switch (enmType) 4293 { 4294 case StorageControllerType_PIIX3: 4295 return "PIIX3"; 4296 case StorageControllerType_PIIX4: 4297 return "PIIX4"; 4298 case StorageControllerType_ICH6: 4299 return "ICH6"; 4300 default: 4301 return "Unknown"; 4302 } 4303 } 4304 4305 4306 int Console::i_configStorageCtrls(ComPtr<IMachine> pMachine, BusAssignmentManager *pBusMgr, PCVMMR3VTABLE pVMM, PUVM pUVM, 4307 PCFGMNODE pDevices, PCFGMNODE pUsbDevices, PCFGMNODE pBiosCfg, bool *pfFdcEnabled) 4308 { 4309 PCFGMNODE pDev = NULL; /* /Devices/Dev/ */ 4310 PCFGMNODE pCfg = NULL; /* /Devices/Dev/.../Config/ */ 4311 4312 com::SafeIfaceArray<IStorageController> ctrls; 4313 PCFGMNODE aCtrlNodes[StorageControllerType_VirtioSCSI + 1] = {}; 4314 HRESULT hrc = pMachine->COMGETTER(StorageControllers)(ComSafeArrayAsOutParam(ctrls)); H(); 4315 4316 for (size_t i = 0; i < ctrls.size(); ++i) 4317 { 4318 DeviceType_T *paLedDevType = NULL; 4319 4320 StorageControllerType_T enmCtrlType; 4321 hrc = ctrls[i]->COMGETTER(ControllerType)(&enmCtrlType); H(); 4322 AssertRelease((unsigned)enmCtrlType < RT_ELEMENTS(aCtrlNodes) 4323 || enmCtrlType == StorageControllerType_USB); 4324 4325 StorageBus_T enmBus; 4326 hrc = ctrls[i]->COMGETTER(Bus)(&enmBus); H(); 4327 4328 Bstr controllerName; 4329 hrc = ctrls[i]->COMGETTER(Name)(controllerName.asOutParam()); H(); 4330 4331 ULONG ulInstance = 999; 4332 hrc = ctrls[i]->COMGETTER(Instance)(&ulInstance); H(); 4333 4334 BOOL fUseHostIOCache; 4335 hrc = ctrls[i]->COMGETTER(UseHostIOCache)(&fUseHostIOCache); H(); 4336 4337 BOOL fBootable; 4338 hrc = ctrls[i]->COMGETTER(Bootable)(&fBootable); H(); 4339 4340 PCFGMNODE pCtlInst = NULL; 4341 const char *pszCtrlDev = i_storageControllerTypeToStr(enmCtrlType); 4342 if (enmCtrlType != StorageControllerType_USB) 4343 { 4344 /* /Devices/<ctrldev>/ */ 4345 pDev = aCtrlNodes[enmCtrlType]; 4346 if (!pDev) 4347 { 4348 InsertConfigNode(pDevices, pszCtrlDev, &pDev); 4349 aCtrlNodes[enmCtrlType] = pDev; /* IDE variants are handled in the switch */ 4350 } 4351 4352 /* /Devices/<ctrldev>/<instance>/ */ 4353 InsertConfigNode(pDev, Utf8StrFmt("%u", ulInstance).c_str(), &pCtlInst); 4354 4355 /* Device config: /Devices/<ctrldev>/<instance>/<values> & /ditto/Config/<values> */ 4356 InsertConfigInteger(pCtlInst, "Trusted", 1); 4357 InsertConfigNode(pCtlInst, "Config", &pCfg); 4358 } 4359 4360 #define MAX_BIOS_LUN_COUNT 4 4361 4362 static const char * const apszBiosConfigScsi[MAX_BIOS_LUN_COUNT] = 4363 { "ScsiLUN1", "ScsiLUN2", "ScsiLUN3", "ScsiLUN4" }; 4364 4365 static const char * const apszBiosConfigSata[MAX_BIOS_LUN_COUNT] = 4366 { "SataLUN1", "SataLUN2", "SataLUN3", "SataLUN4" }; 4367 4368 #undef MAX_BIOS_LUN_COUNT 4369 4370 switch (enmCtrlType) 4371 { 4372 case StorageControllerType_LsiLogic: 4373 { 4374 hrc = pBusMgr->assignPCIDevice("lsilogic", pCtlInst); H(); 4375 4376 InsertConfigInteger(pCfg, "Bootable", fBootable); 4377 4378 /* BIOS configuration values, first SCSI controller only. */ 4379 if ( !pBusMgr->hasPCIDevice("lsilogic", 1) 4380 && !pBusMgr->hasPCIDevice("buslogic", 0) 4381 && !pBusMgr->hasPCIDevice("lsilogicsas", 0) 4382 && pBiosCfg) 4383 { 4384 InsertConfigString(pBiosCfg, "ScsiHardDiskDevice", "lsilogicscsi"); 4385 hrc = SetBiosDiskInfo(pMachine, pCfg, pBiosCfg, controllerName, apszBiosConfigScsi); H(); 4386 } 4387 4388 /* Attach the status driver */ 4389 i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD), 4390 16, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance); 4391 break; 4392 } 4393 4394 case StorageControllerType_BusLogic: 4395 { 4396 hrc = pBusMgr->assignPCIDevice("buslogic", pCtlInst); H(); 4397 4398 InsertConfigInteger(pCfg, "Bootable", fBootable); 4399 4400 /* BIOS configuration values, first SCSI controller only. */ 4401 if ( !pBusMgr->hasPCIDevice("lsilogic", 0) 4402 && !pBusMgr->hasPCIDevice("buslogic", 1) 4403 && !pBusMgr->hasPCIDevice("lsilogicsas", 0) 4404 && pBiosCfg) 4405 { 4406 InsertConfigString(pBiosCfg, "ScsiHardDiskDevice", "buslogic"); 4407 hrc = SetBiosDiskInfo(pMachine, pCfg, pBiosCfg, controllerName, apszBiosConfigScsi); H(); 4408 } 4409 4410 /* Attach the status driver */ 4411 i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD), 4412 16, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance); 4413 break; 4414 } 4415 4416 case StorageControllerType_IntelAhci: 4417 { 4418 hrc = pBusMgr->assignPCIDevice("ahci", pCtlInst); H(); 4419 4420 ULONG cPorts = 0; 4421 hrc = ctrls[i]->COMGETTER(PortCount)(&cPorts); H(); 4422 InsertConfigInteger(pCfg, "PortCount", cPorts); 4423 InsertConfigInteger(pCfg, "Bootable", fBootable); 4424 4425 com::SafeIfaceArray<IMediumAttachment> atts; 4426 hrc = pMachine->GetMediumAttachmentsOfController(controllerName.raw(), 4427 ComSafeArrayAsOutParam(atts)); H(); 4428 4429 /* Configure the hotpluggable flag for the port. */ 4430 for (unsigned idxAtt = 0; idxAtt < atts.size(); ++idxAtt) 4431 { 4432 IMediumAttachment *pMediumAtt = atts[idxAtt]; 4433 4434 LONG lPortNum = 0; 4435 hrc = pMediumAtt->COMGETTER(Port)(&lPortNum); H(); 4436 4437 BOOL fHotPluggable = FALSE; 4438 hrc = pMediumAtt->COMGETTER(HotPluggable)(&fHotPluggable); H(); 4439 if (SUCCEEDED(hrc)) 4440 { 4441 PCFGMNODE pPortCfg; 4442 char szName[24]; 4443 RTStrPrintf(szName, sizeof(szName), "Port%d", lPortNum); 4444 4445 InsertConfigNode(pCfg, szName, &pPortCfg); 4446 InsertConfigInteger(pPortCfg, "Hotpluggable", fHotPluggable ? 1 : 0); 4447 } 4448 } 4449 4450 /* BIOS configuration values, first AHCI controller only. */ 4451 if ( !pBusMgr->hasPCIDevice("ahci", 1) 4452 && pBiosCfg) 4453 { 4454 InsertConfigString(pBiosCfg, "SataHardDiskDevice", "ahci"); 4455 hrc = SetBiosDiskInfo(pMachine, pCfg, pBiosCfg, controllerName, apszBiosConfigSata); H(); 4456 } 4457 4458 /* Attach the status driver */ 4459 i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD), 4460 cPorts, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance); 4461 break; 4462 } 4463 4464 case StorageControllerType_PIIX3: 4465 case StorageControllerType_PIIX4: 4466 case StorageControllerType_ICH6: 4467 { 4468 /* 4469 * IDE (update this when the main interface changes) 4470 */ 4471 hrc = pBusMgr->assignPCIDevice("piix3ide", pCtlInst); H(); 4472 InsertConfigString(pCfg, "Type", controllerString(enmCtrlType)); 4473 4474 /* Attach the status driver */ 4475 i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD), 4476 4, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance); 4477 4478 /* IDE flavors */ 4479 aCtrlNodes[StorageControllerType_PIIX3] = pDev; 4480 aCtrlNodes[StorageControllerType_PIIX4] = pDev; 4481 aCtrlNodes[StorageControllerType_ICH6] = pDev; 4482 break; 4483 } 4484 4485 case StorageControllerType_I82078: 4486 { 4487 /* 4488 * i82078 Floppy drive controller 4489 */ 4490 *pfFdcEnabled = true; 4491 InsertConfigInteger(pCfg, "IRQ", 6); 4492 InsertConfigInteger(pCfg, "DMA", 2); 4493 InsertConfigInteger(pCfg, "MemMapped", 0 ); 4494 InsertConfigInteger(pCfg, "IOBase", 0x3f0); 4495 4496 /* Attach the status driver */ 4497 i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_Floppy), 4498 2, NULL, &mapMediumAttachments, pszCtrlDev, ulInstance); 4499 break; 4500 } 4501 4502 case StorageControllerType_LsiLogicSas: 4503 { 4504 hrc = pBusMgr->assignPCIDevice("lsilogicsas", pCtlInst); H(); 4505 4506 InsertConfigString(pCfg, "ControllerType", "SAS1068"); 4507 InsertConfigInteger(pCfg, "Bootable", fBootable); 4508 4509 /* BIOS configuration values, first SCSI controller only. */ 4510 if ( !pBusMgr->hasPCIDevice("lsilogic", 0) 4511 && !pBusMgr->hasPCIDevice("buslogic", 0) 4512 && !pBusMgr->hasPCIDevice("lsilogicsas", 1) 4513 && pBiosCfg) 4514 { 4515 InsertConfigString(pBiosCfg, "ScsiHardDiskDevice", "lsilogicsas"); 4516 hrc = SetBiosDiskInfo(pMachine, pCfg, pBiosCfg, controllerName, apszBiosConfigScsi); H(); 4517 } 4518 4519 ULONG cPorts = 0; 4520 hrc = ctrls[i]->COMGETTER(PortCount)(&cPorts); H(); 4521 InsertConfigInteger(pCfg, "NumPorts", cPorts); 4522 4523 /* Attach the status driver */ 4524 i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD) /*?*/, 4525 8, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance); 4526 break; 4527 } 4528 4529 case StorageControllerType_USB: 4530 { 4531 if (pUsbDevices) 4532 { 4533 /* 4534 * USB MSDs are handled a bit different as the device instance 4535 * doesn't match the storage controller instance but the port. 4536 */ 4537 InsertConfigNode(pUsbDevices, "Msd", &pDev); 4538 pCtlInst = pDev; 4539 } 4540 else 4541 return pVMM->pfnVMR3SetError(pUVM, VERR_NOT_FOUND, RT_SRC_POS, 4542 N_("There is no USB controller enabled but there\n" 4543 "is at least one USB storage device configured for this VM.\n" 4544 "To fix this problem either enable the USB controller or remove\n" 4545 "the storage device from the VM")); 4546 break; 4547 } 4548 4549 case StorageControllerType_NVMe: 4550 { 4551 hrc = pBusMgr->assignPCIDevice("nvme", pCtlInst); H(); 4552 4553 ULONG cPorts = 0; 4554 hrc = ctrls[i]->COMGETTER(PortCount)(&cPorts); H(); 4555 InsertConfigInteger(pCfg, "NamespacesMax", cPorts); 4556 4557 /* Attach the status driver */ 4558 i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk), 4559 cPorts, NULL, &mapMediumAttachments, pszCtrlDev, ulInstance); 4560 break; 4561 } 4562 4563 case StorageControllerType_VirtioSCSI: 4564 { 4565 hrc = pBusMgr->assignPCIDevice("virtio-scsi", pCtlInst); H(); 4566 4567 ULONG cPorts = 0; 4568 hrc = ctrls[i]->COMGETTER(PortCount)(&cPorts); H(); 4569 InsertConfigInteger(pCfg, "NumTargets", cPorts); 4570 InsertConfigInteger(pCfg, "Bootable", fBootable); 4571 4572 /* Attach the status driver */ 4573 i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD) /*?*/, 4574 cPorts, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance); 4575 break; 4576 } 4577 4578 default: 4579 AssertLogRelMsgFailedReturn(("invalid storage controller type: %d\n", enmCtrlType), VERR_MAIN_CONFIG_CONSTRUCTOR_IPE); 4580 } 4581 4582 /* Attach the media to the storage controllers. */ 4583 com::SafeIfaceArray<IMediumAttachment> atts; 4584 hrc = pMachine->GetMediumAttachmentsOfController(controllerName.raw(), 4585 ComSafeArrayAsOutParam(atts)); H(); 4586 4587 /* Builtin I/O cache - per device setting. */ 4588 BOOL fBuiltinIOCache = true; 4589 hrc = pMachine->COMGETTER(IOCacheEnabled)(&fBuiltinIOCache); H(); 4590 4591 bool fInsertDiskIntegrityDrv = false; 4592 Bstr strDiskIntegrityFlag; 4593 hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EnableDiskIntegrityDriver").raw(), 4594 strDiskIntegrityFlag.asOutParam()); 4595 if ( hrc == S_OK 4596 && strDiskIntegrityFlag == "1") 4597 fInsertDiskIntegrityDrv = true; 4598 4599 for (size_t j = 0; j < atts.size(); ++j) 4600 { 4601 IMediumAttachment *pMediumAtt = atts[j]; 4602 int vrc = i_configMediumAttachment(pszCtrlDev, 4603 ulInstance, 4604 enmBus, 4605 !!fUseHostIOCache, 4606 enmCtrlType == StorageControllerType_NVMe ? false : !!fBuiltinIOCache, 4607 fInsertDiskIntegrityDrv, 4608 false /* fSetupMerge */, 4609 0 /* uMergeSource */, 4610 0 /* uMergeTarget */, 4611 pMediumAtt, 4612 mMachineState, 4613 NULL /* phrc */, 4614 false /* fAttachDetach */, 4615 false /* fForceUnmount */, 4616 false /* fHotplug */, 4617 pUVM, 4618 pVMM, 4619 paLedDevType, 4620 NULL /* ppLunL0 */); 4621 if (RT_FAILURE(vrc)) 4622 return vrc; 4623 } 4624 H(); 4625 } 4626 H(); 4627 4628 return VINF_SUCCESS; 4629 } 4630 4631 4287 4632 int Console::i_configGuestDbg(ComPtr<IVirtualBox> pVBox, ComPtr<IMachine> pMachine, PCFGMNODE pRoot) 4288 4633 { -
trunk/src/VBox/Main/src-client/ConsoleImplConfigX86.cpp
r101464 r101465 149 149 /* Comment out the following line to remove VMWare compatibility hack. */ 150 150 #define VMWARE_NET_IN_SLOT_11 151 152 /**153 * Translate IDE StorageControllerType_T to string representation.154 */155 static const char* controllerString(StorageControllerType_T enmType)156 {157 switch (enmType)158 {159 case StorageControllerType_PIIX3:160 return "PIIX3";161 case StorageControllerType_PIIX4:162 return "PIIX4";163 case StorageControllerType_ICH6:164 return "ICH6";165 default:166 return "Unknown";167 }168 }169 151 170 152 /** … … 521 503 pMachine->COMGETTER(Platform)(platform.asOutParam()); H(); 522 504 523 #if 1/* For now we only support running same-same architectures (e.g. x86 VMs on x86 hosts). */505 #if 0 /* For now we only support running same-same architectures (e.g. x86 VMs on x86 hosts). */ 524 506 PlatformArchitecture_T platformArchMachine; 525 507 hrc = platform->COMGETTER(Architecture)(&platformArchMachine); H(); … … 1695 1677 * Storage controllers. 1696 1678 */ 1697 com::SafeIfaceArray<IStorageController> ctrls;1698 PCFGMNODE aCtrlNodes[StorageControllerType_VirtioSCSI + 1] = {};1699 hrc = pMachine->COMGETTER(StorageControllers)(ComSafeArrayAsOutParam(ctrls)); H();1700 1701 1679 bool fFdcEnabled = false; 1702 for (size_t i = 0; i < ctrls.size(); ++i) 1703 { 1704 DeviceType_T *paLedDevType = NULL; 1705 1706 StorageControllerType_T enmCtrlType; 1707 hrc = ctrls[i]->COMGETTER(ControllerType)(&enmCtrlType); H(); 1708 AssertRelease((unsigned)enmCtrlType < RT_ELEMENTS(aCtrlNodes) 1709 || enmCtrlType == StorageControllerType_USB); 1710 1711 StorageBus_T enmBus; 1712 hrc = ctrls[i]->COMGETTER(Bus)(&enmBus); H(); 1713 1714 Bstr controllerName; 1715 hrc = ctrls[i]->COMGETTER(Name)(controllerName.asOutParam()); H(); 1716 1717 ULONG ulInstance = 999; 1718 hrc = ctrls[i]->COMGETTER(Instance)(&ulInstance); H(); 1719 1720 BOOL fUseHostIOCache; 1721 hrc = ctrls[i]->COMGETTER(UseHostIOCache)(&fUseHostIOCache); H(); 1722 1723 BOOL fBootable; 1724 hrc = ctrls[i]->COMGETTER(Bootable)(&fBootable); H(); 1725 1726 PCFGMNODE pCtlInst = NULL; 1727 const char *pszCtrlDev = i_storageControllerTypeToStr(enmCtrlType); 1728 if (enmCtrlType != StorageControllerType_USB) 1729 { 1730 /* /Devices/<ctrldev>/ */ 1731 pDev = aCtrlNodes[enmCtrlType]; 1732 if (!pDev) 1733 { 1734 InsertConfigNode(pDevices, pszCtrlDev, &pDev); 1735 aCtrlNodes[enmCtrlType] = pDev; /* IDE variants are handled in the switch */ 1736 } 1737 1738 /* /Devices/<ctrldev>/<instance>/ */ 1739 InsertConfigNode(pDev, Utf8StrFmt("%u", ulInstance).c_str(), &pCtlInst); 1740 1741 /* Device config: /Devices/<ctrldev>/<instance>/<values> & /ditto/Config/<values> */ 1742 InsertConfigInteger(pCtlInst, "Trusted", 1); 1743 InsertConfigNode(pCtlInst, "Config", &pCfg); 1744 } 1745 1746 static const char * const apszBiosConfigScsi[MAX_BIOS_LUN_COUNT] = 1747 { "ScsiLUN1", "ScsiLUN2", "ScsiLUN3", "ScsiLUN4" }; 1748 1749 static const char * const apszBiosConfigSata[MAX_BIOS_LUN_COUNT] = 1750 { "SataLUN1", "SataLUN2", "SataLUN3", "SataLUN4" }; 1751 1752 switch (enmCtrlType) 1753 { 1754 case StorageControllerType_LsiLogic: 1755 { 1756 hrc = pBusMgr->assignPCIDevice("lsilogic", pCtlInst); H(); 1757 1758 InsertConfigInteger(pCfg, "Bootable", fBootable); 1759 1760 /* BIOS configuration values, first SCSI controller only. */ 1761 if ( !pBusMgr->hasPCIDevice("lsilogic", 1) 1762 && !pBusMgr->hasPCIDevice("buslogic", 0) 1763 && !pBusMgr->hasPCIDevice("lsilogicsas", 0) 1764 && pBiosCfg) 1765 { 1766 InsertConfigString(pBiosCfg, "ScsiHardDiskDevice", "lsilogicscsi"); 1767 hrc = SetBiosDiskInfo(pMachine, pCfg, pBiosCfg, controllerName, apszBiosConfigScsi); H(); 1768 } 1769 1770 /* Attach the status driver */ 1771 i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD), 1772 16, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance); 1773 break; 1774 } 1775 1776 case StorageControllerType_BusLogic: 1777 { 1778 hrc = pBusMgr->assignPCIDevice("buslogic", pCtlInst); H(); 1779 1780 InsertConfigInteger(pCfg, "Bootable", fBootable); 1781 1782 /* BIOS configuration values, first SCSI controller only. */ 1783 if ( !pBusMgr->hasPCIDevice("lsilogic", 0) 1784 && !pBusMgr->hasPCIDevice("buslogic", 1) 1785 && !pBusMgr->hasPCIDevice("lsilogicsas", 0) 1786 && pBiosCfg) 1787 { 1788 InsertConfigString(pBiosCfg, "ScsiHardDiskDevice", "buslogic"); 1789 hrc = SetBiosDiskInfo(pMachine, pCfg, pBiosCfg, controllerName, apszBiosConfigScsi); H(); 1790 } 1791 1792 /* Attach the status driver */ 1793 i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD), 1794 16, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance); 1795 break; 1796 } 1797 1798 case StorageControllerType_IntelAhci: 1799 { 1800 hrc = pBusMgr->assignPCIDevice("ahci", pCtlInst); H(); 1801 1802 ULONG cPorts = 0; 1803 hrc = ctrls[i]->COMGETTER(PortCount)(&cPorts); H(); 1804 InsertConfigInteger(pCfg, "PortCount", cPorts); 1805 InsertConfigInteger(pCfg, "Bootable", fBootable); 1806 1807 com::SafeIfaceArray<IMediumAttachment> atts; 1808 hrc = pMachine->GetMediumAttachmentsOfController(controllerName.raw(), 1809 ComSafeArrayAsOutParam(atts)); H(); 1810 1811 /* Configure the hotpluggable flag for the port. */ 1812 for (unsigned idxAtt = 0; idxAtt < atts.size(); ++idxAtt) 1813 { 1814 IMediumAttachment *pMediumAtt = atts[idxAtt]; 1815 1816 LONG lPortNum = 0; 1817 hrc = pMediumAtt->COMGETTER(Port)(&lPortNum); H(); 1818 1819 BOOL fHotPluggable = FALSE; 1820 hrc = pMediumAtt->COMGETTER(HotPluggable)(&fHotPluggable); H(); 1821 if (SUCCEEDED(hrc)) 1822 { 1823 PCFGMNODE pPortCfg; 1824 char szName[24]; 1825 RTStrPrintf(szName, sizeof(szName), "Port%d", lPortNum); 1826 1827 InsertConfigNode(pCfg, szName, &pPortCfg); 1828 InsertConfigInteger(pPortCfg, "Hotpluggable", fHotPluggable ? 1 : 0); 1829 } 1830 } 1831 1832 /* BIOS configuration values, first AHCI controller only. */ 1833 if ( !pBusMgr->hasPCIDevice("ahci", 1) 1834 && pBiosCfg) 1835 { 1836 InsertConfigString(pBiosCfg, "SataHardDiskDevice", "ahci"); 1837 hrc = SetBiosDiskInfo(pMachine, pCfg, pBiosCfg, controllerName, apszBiosConfigSata); H(); 1838 } 1839 1840 /* Attach the status driver */ 1841 i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD), 1842 cPorts, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance); 1843 break; 1844 } 1845 1846 case StorageControllerType_PIIX3: 1847 case StorageControllerType_PIIX4: 1848 case StorageControllerType_ICH6: 1849 { 1850 /* 1851 * IDE (update this when the main interface changes) 1852 */ 1853 hrc = pBusMgr->assignPCIDevice("piix3ide", pCtlInst); H(); 1854 InsertConfigString(pCfg, "Type", controllerString(enmCtrlType)); 1855 1856 /* Attach the status driver */ 1857 i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD), 1858 4, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance); 1859 1860 /* IDE flavors */ 1861 aCtrlNodes[StorageControllerType_PIIX3] = pDev; 1862 aCtrlNodes[StorageControllerType_PIIX4] = pDev; 1863 aCtrlNodes[StorageControllerType_ICH6] = pDev; 1864 break; 1865 } 1866 1867 case StorageControllerType_I82078: 1868 { 1869 /* 1870 * i82078 Floppy drive controller 1871 */ 1872 fFdcEnabled = true; 1873 InsertConfigInteger(pCfg, "IRQ", 6); 1874 InsertConfigInteger(pCfg, "DMA", 2); 1875 InsertConfigInteger(pCfg, "MemMapped", 0 ); 1876 InsertConfigInteger(pCfg, "IOBase", 0x3f0); 1877 1878 /* Attach the status driver */ 1879 i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_Floppy), 1880 2, NULL, &mapMediumAttachments, pszCtrlDev, ulInstance); 1881 break; 1882 } 1883 1884 case StorageControllerType_LsiLogicSas: 1885 { 1886 hrc = pBusMgr->assignPCIDevice("lsilogicsas", pCtlInst); H(); 1887 1888 InsertConfigString(pCfg, "ControllerType", "SAS1068"); 1889 InsertConfigInteger(pCfg, "Bootable", fBootable); 1890 1891 /* BIOS configuration values, first SCSI controller only. */ 1892 if ( !pBusMgr->hasPCIDevice("lsilogic", 0) 1893 && !pBusMgr->hasPCIDevice("buslogic", 0) 1894 && !pBusMgr->hasPCIDevice("lsilogicsas", 1) 1895 && pBiosCfg) 1896 { 1897 InsertConfigString(pBiosCfg, "ScsiHardDiskDevice", "lsilogicsas"); 1898 hrc = SetBiosDiskInfo(pMachine, pCfg, pBiosCfg, controllerName, apszBiosConfigScsi); H(); 1899 } 1900 1901 ULONG cPorts = 0; 1902 hrc = ctrls[i]->COMGETTER(PortCount)(&cPorts); H(); 1903 InsertConfigInteger(pCfg, "NumPorts", cPorts); 1904 1905 /* Attach the status driver */ 1906 i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD) /*?*/, 1907 8, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance); 1908 break; 1909 } 1910 1911 case StorageControllerType_USB: 1912 { 1913 if (pUsbDevices) 1914 { 1915 /* 1916 * USB MSDs are handled a bit different as the device instance 1917 * doesn't match the storage controller instance but the port. 1918 */ 1919 InsertConfigNode(pUsbDevices, "Msd", &pDev); 1920 pCtlInst = pDev; 1921 } 1922 else 1923 return pVMM->pfnVMR3SetError(pUVM, VERR_NOT_FOUND, RT_SRC_POS, 1924 N_("There is no USB controller enabled but there\n" 1925 "is at least one USB storage device configured for this VM.\n" 1926 "To fix this problem either enable the USB controller or remove\n" 1927 "the storage device from the VM")); 1928 break; 1929 } 1930 1931 case StorageControllerType_NVMe: 1932 { 1933 hrc = pBusMgr->assignPCIDevice("nvme", pCtlInst); H(); 1934 1935 ULONG cPorts = 0; 1936 hrc = ctrls[i]->COMGETTER(PortCount)(&cPorts); H(); 1937 InsertConfigInteger(pCfg, "NamespacesMax", cPorts); 1938 1939 /* Attach the status driver */ 1940 i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk), 1941 cPorts, NULL, &mapMediumAttachments, pszCtrlDev, ulInstance); 1942 break; 1943 } 1944 1945 case StorageControllerType_VirtioSCSI: 1946 { 1947 hrc = pBusMgr->assignPCIDevice("virtio-scsi", pCtlInst); H(); 1948 1949 ULONG cPorts = 0; 1950 hrc = ctrls[i]->COMGETTER(PortCount)(&cPorts); H(); 1951 InsertConfigInteger(pCfg, "NumTargets", cPorts); 1952 InsertConfigInteger(pCfg, "Bootable", fBootable); 1953 1954 /* Attach the status driver */ 1955 i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD) /*?*/, 1956 cPorts, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance); 1957 break; 1958 } 1959 1960 default: 1961 AssertLogRelMsgFailedReturn(("invalid storage controller type: %d\n", enmCtrlType), VERR_MAIN_CONFIG_CONSTRUCTOR_IPE); 1962 } 1963 1964 /* Attach the media to the storage controllers. */ 1965 com::SafeIfaceArray<IMediumAttachment> atts; 1966 hrc = pMachine->GetMediumAttachmentsOfController(controllerName.raw(), 1967 ComSafeArrayAsOutParam(atts)); H(); 1968 1969 /* Builtin I/O cache - per device setting. */ 1970 BOOL fBuiltinIOCache = true; 1971 hrc = pMachine->COMGETTER(IOCacheEnabled)(&fBuiltinIOCache); H(); 1972 1973 bool fInsertDiskIntegrityDrv = false; 1974 Bstr strDiskIntegrityFlag; 1975 hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EnableDiskIntegrityDriver").raw(), 1976 strDiskIntegrityFlag.asOutParam()); 1977 if ( hrc == S_OK 1978 && strDiskIntegrityFlag == "1") 1979 fInsertDiskIntegrityDrv = true; 1980 1981 for (size_t j = 0; j < atts.size(); ++j) 1982 { 1983 IMediumAttachment *pMediumAtt = atts[j]; 1984 vrc = i_configMediumAttachment(pszCtrlDev, 1985 ulInstance, 1986 enmBus, 1987 !!fUseHostIOCache, 1988 enmCtrlType == StorageControllerType_NVMe ? false : !!fBuiltinIOCache, 1989 fInsertDiskIntegrityDrv, 1990 false /* fSetupMerge */, 1991 0 /* uMergeSource */, 1992 0 /* uMergeTarget */, 1993 pMediumAtt, 1994 mMachineState, 1995 NULL /* phrc */, 1996 false /* fAttachDetach */, 1997 false /* fForceUnmount */, 1998 false /* fHotplug */, 1999 pUVM, 2000 pVMM, 2001 paLedDevType, 2002 NULL /* ppLunL0 */); 2003 if (RT_FAILURE(vrc)) 2004 return vrc; 2005 } 2006 H(); 2007 } 2008 H(); 1680 vrc = i_configStorageCtrls(pMachine, pBusMgr, pVMM, pUVM, 1681 pDevices, pUsbDevices, pBiosCfg, &fFdcEnabled); VRC(); 2009 1682 2010 1683 /*
Note:
See TracChangeset
for help on using the changeset viewer.