Ticket #19320: vbox-import_export_nvme.patch
| File vbox-import_export_nvme.patch, 18.8 KB (added by , 5 years ago) |
|---|
-
src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.cpp
482 482 case KVirtualSystemDescriptionType_HardDiskControllerSATA: value = UIApplianceEditorWidget::tr("Storage Controller (SATA)"); break; 483 483 case KVirtualSystemDescriptionType_HardDiskControllerSCSI: value = UIApplianceEditorWidget::tr("Storage Controller (SCSI)"); break; 484 484 case KVirtualSystemDescriptionType_HardDiskControllerSAS: value = UIApplianceEditorWidget::tr("Storage Controller (SAS)"); break; 485 case KVirtualSystemDescriptionType_HardDiskControllerNVMe: value = UIApplianceEditorWidget::tr("Storage Controller (NVMe)"); break; 485 486 case KVirtualSystemDescriptionType_CDROM: value = UIApplianceEditorWidget::tr("DVD"); break; 486 487 case KVirtualSystemDescriptionType_Floppy: value = UIApplianceEditorWidget::tr("Floppy"); break; 487 488 case KVirtualSystemDescriptionType_NetworkAdapter: value = UIApplianceEditorWidget::tr("Network Adapter"); break; … … 656 657 case KVirtualSystemDescriptionType_HardDiskControllerSATA: value = UIIconPool::iconSet(":/sata_16px.png"); break; 657 658 case KVirtualSystemDescriptionType_HardDiskControllerSCSI: value = UIIconPool::iconSet(":/scsi_16px.png"); break; 658 659 case KVirtualSystemDescriptionType_HardDiskControllerSAS: value = UIIconPool::iconSet(":/sas_16px.png"); break; 660 case KVirtualSystemDescriptionType_HardDiskControllerNVMe: value = UIIconPool::iconSet(":/pcie_16px.png"); break; 659 661 case KVirtualSystemDescriptionType_HardDiskImage: value = UIIconPool::iconSet(":/hd_16px.png"); break; 660 662 case KVirtualSystemDescriptionType_CDROM: value = UIIconPool::iconSet(":/cd_16px.png"); break; 661 663 case KVirtualSystemDescriptionType_Floppy: value = UIIconPool::iconSet(":/fd_16px.png"); break; … … 1340 1342 if (types[i] == KVirtualSystemDescriptionType_HardDiskControllerIDE || 1341 1343 types[i] == KVirtualSystemDescriptionType_HardDiskControllerSATA || 1342 1344 types[i] == KVirtualSystemDescriptionType_HardDiskControllerSCSI || 1343 types[i] == KVirtualSystemDescriptionType_HardDiskControllerSAS) 1345 types[i] == KVirtualSystemDescriptionType_HardDiskControllerSAS || 1346 types[i] == KVirtualSystemDescriptionType_HardDiskControllerNVMe) 1344 1347 controllerMap[i] = pHardwareItem; 1345 1348 } 1346 1349 } … … 1681 1684 KVirtualSystemDescriptionType_HardDiskControllerSATA, 1682 1685 KVirtualSystemDescriptionType_HardDiskControllerSCSI, 1683 1686 KVirtualSystemDescriptionType_HardDiskControllerSAS, 1687 KVirtualSystemDescriptionType_HardDiskControllerNVMe, 1684 1688 /* OCI */ 1685 1689 KVirtualSystemDescriptionType_CloudProfileName, 1686 1690 KVirtualSystemDescriptionType_CloudBucket, -
src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceExportEditorWidget.cpp
50 50 << KVirtualSystemDescriptionType_HardDiskControllerSATA 51 51 << KVirtualSystemDescriptionType_HardDiskControllerSCSI 52 52 << KVirtualSystemDescriptionType_HardDiskControllerSAS 53 << KVirtualSystemDescriptionType_HardDiskControllerNVMe 53 54 << KVirtualSystemDescriptionType_CloudProfileName; 54 55 } 55 56 }; -
src/VBox/Main/idl/VirtualBox.xidl
4024 4024 <const name="CloudOCISubnetCompartment" value="47" /> 4025 4025 <const name="CloudPublicSSHKey" value="48" /> 4026 4026 <const name="BootingFirmware" value="49" /> 4027 <const name="HardDiskControllerNVMe" value="50" /> 4027 4028 </enum> 4028 4029 4029 4030 <enum -
src/VBox/Main/include/ovfreader.h
534 534 { 535 535 uint32_t idController; // instance ID (Item/InstanceId); this gets referenced from VirtualDisk 536 536 537 enum ControllerSystemType { IDE, SATA, SCSI };538 ControllerSystemType system; // one of IDE, SATA, SCSI 537 enum ControllerSystemType { IDE, SATA, SCSI, NVMe }; 538 ControllerSystemType system; // one of IDE, SATA, SCSI, NVMe 539 539 540 540 RTCString strControllerType; 541 541 // controller subtype (Item/ResourceSubType); e.g. "LsiLogic"; can be empty (esp. for IDE) -
src/VBox/Main/src-server/ApplianceImpl.cpp
1770 1770 case VirtualSystemDescriptionType_HardDiskControllerSATA: 1771 1771 case VirtualSystemDescriptionType_HardDiskControllerSCSI: 1772 1772 case VirtualSystemDescriptionType_HardDiskControllerSAS: 1773 case VirtualSystemDescriptionType_HardDiskControllerNVMe: 1773 1774 if (d.strRef == strRef) 1774 1775 return &d; 1775 1776 break; -
src/VBox/Main/src-server/ApplianceImplExport.cpp
185 185 int32_t lIDEControllerSecondaryIndex = 0; 186 186 int32_t lSATAControllerIndex = 0; 187 187 int32_t lSCSIControllerIndex = 0; 188 int32_t lNVMeControllerIndex = 0; 188 189 189 190 /* Fetch all available storage controllers */ 190 191 com::SafeIfaceArray<IStorageController> nwControllers; … … 195 196 ComPtr<IStorageController> pSATAController; 196 197 ComPtr<IStorageController> pSCSIController; 197 198 ComPtr<IStorageController> pSASController; 199 ComPtr<IStorageController> pNVMeController; 198 200 for (size_t j = 0; j < nwControllers.size(); ++j) 199 201 { 200 202 StorageBus_T eType; … … 212 214 else if ( eType == StorageBus_SAS 213 215 && pSASController.isNull()) 214 216 pSASController = nwControllers[j]; 217 else if ( eType == StorageBus_PCIe) 218 pNVMeController = nwControllers[j]; 215 219 } 216 220 217 221 // <const name="HardDiskControllerIDE" value="6" /> … … 292 296 strVBox); 293 297 } 294 298 299 if (!pNVMeController.isNull()) 300 { 301 Utf8Str strVBox = "NVMe"; 302 lNVMeControllerIndex = (int32_t)pNewDesc->m->maDescriptions.size(); 303 pNewDesc->i_addEntry(VirtualSystemDescriptionType_HardDiskControllerNVMe, 304 Utf8StrFmt("%d", lNVMeControllerIndex), 305 strVBox, 306 strVBox); 307 } 308 295 309 // <const name="HardDiskImage" value="9" /> 296 310 // <const name="Floppy" value="18" /> 297 311 // <const name="CDROM" value="19" /> … … 344 358 strStBus = "SCSI"; 345 359 else if ( storageBus == StorageBus_SAS) 346 360 strStBus = "SAS"; 361 else if ( storageBus == StorageBus_PCIe) 362 strStBus = "PCIe"; 347 363 LogRel(("Warning: skip the medium (bus: %s, slot: %d, port: %d). No storage device attached.\n", 348 364 strStBus.c_str(), lDevice, lChannel)); 349 365 continue; … … 520 536 lControllerVsys = lSCSIControllerIndex; 521 537 break; 522 538 539 case StorageBus_PCIe: 540 lChannelVsys = lChannel; // should be between 0 and 255 541 lControllerVsys = lNVMeControllerIndex; 542 break; 543 523 544 case StorageBus_Floppy: 524 545 lChannelVsys = 0; 525 546 lControllerVsys = 0; … … 1477 1498 int32_t lSATAControllerIndex = 0; 1478 1499 uint32_t idSCSIController = 0; 1479 1500 int32_t lSCSIControllerIndex = 0; 1501 uint32_t idNVMeController = 0; 1502 int32_t lNVMeControllerIndex = 0; 1480 1503 1481 1504 uint32_t ulInstanceID = 1; 1482 1505 … … 1499 1522 : desc.type == VirtualSystemDescriptionType_HardDiskControllerSATA ? "HardDiskControllerSATA" 1500 1523 : desc.type == VirtualSystemDescriptionType_HardDiskControllerSCSI ? "HardDiskControllerSCSI" 1501 1524 : desc.type == VirtualSystemDescriptionType_HardDiskControllerSAS ? "HardDiskControllerSAS" 1525 : desc.type == VirtualSystemDescriptionType_HardDiskControllerNVMe ? "HardDiskControllerNVMe" 1502 1526 : desc.type == VirtualSystemDescriptionType_HardDiskImage ? "HardDiskImage" 1503 1527 : Utf8StrFmt("%d", desc.type).c_str()), 1504 1528 desc.strRef.c_str(), … … 1689 1713 } 1690 1714 break; 1691 1715 1716 case VirtualSystemDescriptionType_HardDiskControllerNVMe: 1717 /* <Item> 1718 <rasd:Caption>nvmeController0</rasd:Caption> 1719 <rasd:Description>NVMe Controller</rasd:Description> 1720 <rasd:InstanceId>4</rasd:InstanceId> 1721 <rasd:ResourceType>20</rasd:ResourceType> 1722 <rasd:ResourceSubType>nvme</rasd:ResourceSubType> 1723 <rasd:Address>0</rasd:Address> 1724 <rasd:BusNumber>0</rasd:BusNumber> 1725 </Item> 1726 */ 1727 if (uLoop == 1) 1728 { 1729 strDescription = "NVMe Controller"; 1730 strCaption = "nvmeController0"; 1731 type = ovf::ResourceType_OtherStorageDevice; // 20 1732 // it seems that OVFTool always writes these two, and since we can only 1733 // have one NVMe controller, we'll use this as well 1734 lAddress = 0; 1735 lBusNumber = 0; 1736 1737 if ( desc.strVBoxCurrent.isEmpty() // NVMe is the default in VirtualBox 1738 || (!desc.strVBoxCurrent.compare("nvme", Utf8Str::CaseInsensitive)) 1739 ) 1740 strResourceSubType = "nvme"; 1741 else 1742 throw setError(VBOX_E_NOT_SUPPORTED, 1743 tr("Invalid config string \"%s\" in NVMe controller"), 1744 desc.strVBoxCurrent.c_str()); 1745 1746 // remember this ID 1747 idNVMeController = ulInstanceID; 1748 lNVMeControllerIndex = lIndexThis; 1749 } 1750 break; 1751 1692 1752 case VirtualSystemDescriptionType_HardDiskImage: 1693 1753 /* <Item> 1694 1754 <rasd:Caption>disk1</rasd:Caption> … … 1725 1785 ulParent = idSCSIController; 1726 1786 else if (lControllerIndex == lSATAControllerIndex) 1727 1787 ulParent = idSATAController; 1788 else if (lControllerIndex == lNVMeControllerIndex) 1789 ulParent = idNVMeController; 1728 1790 } 1729 1791 if (pos2 != Utf8Str::npos) 1730 1792 RTStrToInt32Ex(desc.strExtraConfigCurrent.c_str() + pos2 + 8, NULL, 0, &lAddressOnParent); … … 1802 1864 ulParent = idSCSIController; 1803 1865 else if (lControllerIndex == lSATAControllerIndex) 1804 1866 ulParent = idSATAController; 1867 else if (lControllerIndex == lNVMeControllerIndex) 1868 ulParent = idNVMeController; 1805 1869 } 1806 1870 if (pos2 != Utf8Str::npos) 1807 1871 RTStrToInt32Ex(desc.strExtraConfigCurrent.c_str() + pos2 + 8, NULL, 0, &lAddressOnParent); -
src/VBox/Main/src-server/ApplianceImplImport.cpp
561 561 uint16_t cIDEused = 0; 562 562 uint16_t cSATAused = 0; NOREF(cSATAused); 563 563 uint16_t cSCSIused = 0; NOREF(cSCSIused); 564 uint16_t cNVMeused = 0; NOREF(cNVMeused); 564 565 ovf::ControllersMap::const_iterator hdcIt; 565 566 /* Iterate through all storage controllers */ 566 567 for (hdcIt = vsysThis.mapControllers.begin(); … … 649 650 strControllerID.c_str()); 650 651 ++cSCSIused; 651 652 break; 653 654 case ovf::HardDiskController::NVMe: 655 /* Check for the constrains */ 656 if (cNVMeused < 1) 657 { 658 /* We only support a plain NVMe controller, so use them always */ 659 pNewDesc->i_addEntry(VirtualSystemDescriptionType_HardDiskControllerNVMe, 660 strControllerID, 661 hdc.strControllerType, 662 "NVMe"); 663 } 664 else 665 { 666 /* Warn only once */ 667 if (cNVMeused == 1) 668 i_addWarning(tr("The virtual system \"%s\" requests support for more than one " 669 "NVMe controller, but VirtualBox has support for only one"), 670 vsysThis.strName.c_str()); 671 672 } 673 ++cNVMeused; 674 break; 652 675 } 653 676 } 654 677 … … 3516 3539 break; 3517 3540 } 3518 3541 3542 case ovf::HardDiskController::NVMe: 3543 { 3544 controllerName = "NVMe"; 3545 lControllerPort = (long)ulAddressOnParent; 3546 lDevice = (long)0; 3547 break; 3548 } 3549 3519 3550 default: break; 3520 3551 } 3521 3552 … … 4229 4260 if (FAILED(rc)) throw rc; 4230 4261 } 4231 4262 4263 /* Storage controller NVMe */ 4264 std::list<VirtualSystemDescriptionEntry*> vsdeHDCNVMe = 4265 vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskControllerNVMe); 4266 if (vsdeHDCNVMe.size() > 1) 4267 throw setError(VBOX_E_FILE_ERROR, 4268 tr("Too many NVMe controllers in OVF; import facility only supports one")); 4269 if (!vsdeHDCNVMe.empty()) 4270 { 4271 ComPtr<IStorageController> pController; 4272 const Utf8Str &hdcVBox = vsdeHDCNVMe.front()->strVBoxCurrent; 4273 if (hdcVBox == "NVMe") 4274 { 4275 rc = pNewMachine->AddStorageController(Bstr("NVMe").raw(), 4276 StorageBus_PCIe, 4277 pController.asOutParam()); 4278 if (FAILED(rc)) throw rc; 4279 } 4280 else 4281 throw setError(VBOX_E_FILE_ERROR, 4282 tr("Invalid NVMe controller type \"%s\""), 4283 hdcVBox.c_str()); 4284 } 4285 4232 4286 /* Now its time to register the machine before we add any storage devices */ 4233 4287 rc = mVirtualBox->RegisterMachine(pNewMachine); 4234 4288 if (FAILED(rc)) throw rc; -
src/VBox/Main/testcase/tstOVF.cpp
194 194 pcszType = "scsi"; 195 195 break; 196 196 197 case VirtualSystemDescriptionType_HardDiskControllerNVMe: 198 pcszType = "nvme"; 199 break; 200 197 201 case VirtualSystemDescriptionType_HardDiskImage: 198 202 pcszType = "hd"; 199 203 break; -
src/VBox/Main/xml/ovfreader.cpp
640 640 // handled separately in second loop below 641 641 break; 642 642 643 case ResourceType_OtherStorageDevice: // 20 SATA controller643 case ResourceType_OtherStorageDevice: // 20 SATA/NVMe controller 644 644 { 645 645 /* <Item> 646 646 <rasd:Description>SATA Controller</rasd:Description> … … 661 661 662 662 vsys.mapControllers[i.ulInstanceID] = hdc; 663 663 } 664 else if ( i.strResourceSubType.compare("nvme", RTCString::CaseInsensitive) == 0 665 || i.strResourceSubType.compare("vmware.nvme.controller", RTCString::CaseInsensitive) == 0) 666 { 667 HardDiskController hdc; 668 hdc.system = HardDiskController::NVMe; 669 hdc.idController = i.ulInstanceID; 670 hdc.strControllerType = i.strResourceSubType; 671 672 vsys.mapControllers[i.ulInstanceID] = hdc; 673 } 664 674 else 665 throw OVFLogicError(N_("Error reading \"%s\": Host resource of type \"Other Storage Device (%d)\" is supported with SATA AHCI controllers only, line %d (subtype:%s)"),675 throw OVFLogicError(N_("Error reading \"%s\": Host resource of type \"Other Storage Device (%d)\" is supported with SATA AHCI and NVMe controllers only, line %d (subtype:%s)"), 666 676 m_strPath.c_str(), 667 677 ResourceType_OtherStorageDevice, 668 678 i.ulLineNumber, i.strResourceSubType.c_str() );

