VirtualBox

Changeset 101472 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Oct 17, 2023 11:45:00 AM (16 months ago)
Author:
vboxsync
Message:

FE/VBoxManage,FE/Qt,Main/{VirtualBox.xidl,Appliance}: Add the ability to
export and import VMs which contain an NVMe storage controller.
bugref:10159 ticketref:19320

Location:
trunk/src/VBox/Main/src-server
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/ApplianceImpl.cpp

    r100852 r101472  
    18721872            case VirtualSystemDescriptionType_HardDiskControllerSCSI:
    18731873            case VirtualSystemDescriptionType_HardDiskControllerVirtioSCSI:
     1874            case VirtualSystemDescriptionType_HardDiskControllerNVMe:
    18741875            case VirtualSystemDescriptionType_HardDiskControllerSAS:
    18751876                if (d.strRef == id)
  • trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp

    r101456 r101472  
    205205        int32_t lSCSIControllerIndex = 0;
    206206        int32_t lVirtioSCSIControllerIndex = 0;
     207        int32_t lNVMeControllerIndex = 0;
    207208
    208209        /* Fetch all available storage controllers */
     
    214215        ComPtr<IStorageController> pSATAController;
    215216        ComPtr<IStorageController> pSCSIController;
     217        ComPtr<IStorageController> pSASController;
    216218        ComPtr<IStorageController> pVirtioSCSIController;
    217         ComPtr<IStorageController> pSASController;
     219        ComPtr<IStorageController> pNVMeController;
    218220        for (size_t j = 0; j < nwControllers.size(); ++j)
    219221        {
     
    236238                     && pVirtioSCSIController.isNull())
    237239                pVirtioSCSIController = nwControllers[j];
     240            else if (   eType == StorageBus_PCIe
     241                     && pNVMeController.isNull())
     242                pNVMeController = nwControllers[j];
    238243        }
    239244
     
    338343        }
    339344
     345        if (!pNVMeController.isNull())
     346        {
     347            Utf8Str strVBox = "NVMe";
     348            lNVMeControllerIndex = (int32_t)pNewDesc->m->maDescriptions.size();
     349            pNewDesc->i_addEntry(VirtualSystemDescriptionType_HardDiskControllerNVMe,
     350                                 Utf8StrFmt("%d", lNVMeControllerIndex),
     351                                 strVBox,
     352                                 strVBox);
     353        }
     354
    340355//     <const name="HardDiskImage" value="9" />
    341356//     <const name="Floppy" value="18" />
     
    390405                else if ( storageBus == StorageBus_SAS)
    391406                    strStBus = "SAS";
     407                else if ( storageBus == StorageBus_PCIe)
     408                    strStBus = "PCIe";
    392409                else if ( storageBus == StorageBus_VirtioSCSI)
    393410                    strStBus = "VirtioSCSI";
     
    574591                    break;
    575592
     593                case StorageBus_PCIe:
     594                    lChannelVsys = lChannel;        // should be between 0 and 255
     595                    lControllerVsys = lNVMeControllerIndex;
     596                    break;
     597
    576598                case StorageBus_Floppy:
    577599                    lChannelVsys = 0;
     
    15351557    uint32_t idVirtioSCSIController = 0;
    15361558    int32_t lVirtioSCSIControllerIndex = 0;
     1559    uint32_t idNVMeController = 0;
     1560    int32_t lNVMeControllerIndex = 0;
    15371561
    15381562    uint32_t ulInstanceID = 1;
     
    15571581                          : desc.type == VirtualSystemDescriptionType_HardDiskControllerSCSI ? "HardDiskControllerSCSI"
    15581582                          : desc.type == VirtualSystemDescriptionType_HardDiskControllerSAS ? "HardDiskControllerSAS"
     1583                          : desc.type == VirtualSystemDescriptionType_HardDiskControllerNVMe ? "HardDiskControllerNVMe"
    15591584                          : desc.type == VirtualSystemDescriptionType_HardDiskImage ? "HardDiskImage"
    15601585                          : Utf8StrFmt("%d", desc.type).c_str()),
     
    17731798                    break;
    17741799
     1800                case VirtualSystemDescriptionType_HardDiskControllerNVMe:
     1801                    /*  <Item>
     1802                            <rasd:Caption>NVMeController0</rasd:Caption>
     1803                            <rasd:Description>NVMe Controller</rasd:Description>
     1804                            <rasd:InstanceId>4</rasd:InstanceId>
     1805                            <rasd:ResourceType>20</rasd:ResourceType>
     1806                            <rasd:Address>0</rasd:Address>
     1807                            <rasd:BusNumber>0</rasd:BusNumber>
     1808                        </Item>
     1809                    */
     1810                    if (uLoop == 1)
     1811                    {
     1812                        strDescription = "NVMe Controller";
     1813                        strCaption = "nvmeController0";
     1814                        type = ovf::ResourceType_OtherStorageDevice; // 20
     1815                        lAddress = 0;
     1816                        lBusNumber = 0;
     1817                        strResourceSubType = "NVMe";
     1818                        // remember this ID
     1819                        idNVMeController = ulInstanceID;
     1820                        lNVMeControllerIndex = lIndexThis;
     1821                    }
     1822                    break;
     1823
    17751824                case VirtualSystemDescriptionType_HardDiskImage:
    17761825                    /*  <Item>
     
    18111860                            else if (lControllerIndex == lVirtioSCSIControllerIndex)
    18121861                                ulParent = idVirtioSCSIController;
     1862                            else if (lControllerIndex == lNVMeControllerIndex)
     1863                                ulParent = idNVMeController;
    18131864                        }
    18141865                        if (pos2 != Utf8Str::npos)
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r101057 r101472  
    419419
    420420                const settings::NetworkAdaptersList &llNetworkAdapters = pNewDesc->m->pConfig->hardwareMachine.llNetworkAdapters;
    421                 /* Check for the constrains */
     421                /* Check for the constraints */
    422422                if (llNetworkAdapters.size() > maxNetworkAdapters)
    423423                    i_addWarning(tr("Virtual appliance \"%s\" was configured with %zu network adapters however "
     
    449449                uint32_t const maxNetworkAdapters = PlatformProperties::s_getMaxNetworkAdapters(ChipsetType_PIIX3); /** @todo BUGBUG x86 only for now. */
    450450
    451                 /* Check for the constrains */
     451                /* Check for the constraints */
    452452                if (cEthernetAdapters > maxNetworkAdapters)
    453453                    i_addWarning(tr("Virtual appliance \"%s\" was configured with %zu network adapters however "
     
    582582            uint16_t cSCSIused = 0; NOREF(cSCSIused);
    583583            uint16_t cVIRTIOSCSIused = 0; NOREF(cVIRTIOSCSIused);
     584            uint16_t cNVMeused = 0; NOREF(cNVMeused);
    584585
    585586            ovf::ControllersMap::const_iterator hdcIt;
     
    594595                {
    595596                    case ovf::HardDiskController::IDE:
    596                         /* Check for the constrains */
     597                        /* Check for the constraints */
    597598                        if (cIDEused < 4)
    598599                        {
     
    621622
    622623                    case ovf::HardDiskController::SATA:
    623                         /* Check for the constrains */
     624                        /* Check for the constraints */
    624625                        if (cSATAused < 1)
    625626                        {
     
    645646
    646647                    case ovf::HardDiskController::SCSI:
    647                         /* Check for the constrains */
     648                        /* Check for the constraints */
    648649                        if (cSCSIused < 1)
    649650                        {
     
    674675
    675676                    case ovf::HardDiskController::VIRTIOSCSI:
    676                         /* Check for the constrains */
     677                        /* Check for the constraints */
    677678                        if (cVIRTIOSCSIused < 1)
    678679                        {
     
    693694                        }
    694695                        ++cVIRTIOSCSIused;
     696                    break;
     697
     698                    case ovf::HardDiskController::NVMe:
     699                        /* Check for the constraints */
     700                        if (cNVMeused < 1)
     701                        {
     702                            pNewDesc->i_addEntry(VirtualSystemDescriptionType_HardDiskControllerNVMe,
     703                                                 hdc.strIdController,
     704                                                 hdc.strControllerType,
     705                                                 "NVMe");
     706                        }
     707                        else
     708                        {
     709                            /* Warn only once */
     710                            if (cNVMeused == 1)
     711                                i_addWarning(tr("Virtual appliance \"%s\" was configured with more than one "
     712                                                "NVMe controller however VirtualBox supports a maximum "
     713                                                "of one NVMe controller."),
     714                                                vsysThis.strName.c_str());
     715
     716                        }
     717                        ++cNVMeused;
    695718                    break;
    696719
     
    48564879    }
    48574880
     4881    /* Storage controller NVMe */
     4882    std::list<VirtualSystemDescriptionEntry*> vsdeHDCNVMe =
     4883        vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskControllerNVMe);
     4884    if (vsdeHDCNVMe.size() > 1)
     4885        throw setError(VBOX_E_FILE_ERROR,
     4886                       tr("Too many NVMe controllers in OVF; import facility only supports one"));
     4887    if (!vsdeHDCNVMe.empty())
     4888    {
     4889        ComPtr<IStorageController> pController;
     4890        Utf8Str strName("NVMe");
     4891        const Utf8Str &hdcVBox = vsdeHDCNVMe.front()->strVBoxCurrent;
     4892        if (hdcVBox == "NVMe")
     4893        {
     4894            hrc = pNewMachine->AddStorageController(Bstr(strName).raw(), StorageBus_PCIe, pController.asOutParam());
     4895            if (FAILED(hrc)) throw hrc;
     4896
     4897            hrc = pController->COMSETTER(ControllerType)(StorageControllerType_NVMe);
     4898            if (FAILED(hrc)) throw hrc;
     4899        }
     4900        else
     4901            throw setError(VBOX_E_FILE_ERROR, tr("Invalid NVMe controller type \"%s\""), hdcVBox.c_str());
     4902    }
     4903
    48584904    /* Now its time to register the machine before we add any storage devices */
    48594905    hrc = mVirtualBox->RegisterMachine(pNewMachine);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette