VirtualBox

Changeset 101475 in vbox for trunk/src/VBox/Main/src-client


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

Main/src-client/ConsoleImplConfigArmV8.cpp: Get rid of most of the static config and use the common constructors for the different sub-systems, bugref:10528

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImplConfigArmV8.cpp

    r101468 r101475  
    4343#include "AutoCaller.h"
    4444
    45 #include <iprt/base64.h>
    4645#include <iprt/buildconfig.h>
    4746#include <iprt/ctype.h>
     
    6665#include <VBox/version.h>
    6766#include <VBox/platforms/vbox-armv8.h>
    68 #ifdef VBOX_WITH_SHARED_CLIPBOARD
    69 # include <VBox/HostServices/VBoxClipboardSvc.h>
    70 #endif
    71 #ifdef VBOX_WITH_DRAG_AND_DROP
    72 # include "GuestImpl.h"
    73 # include "GuestDnDPrivate.h"
    74 #endif
    75 
     67
     68#include "BusAssignmentManager.h"
    7669#ifdef VBOX_WITH_EXTPACK
    7770# include "ExtPackManagerImpl.h"
     
    10497{
    10598    RT_NOREF(pVM /* when everything is disabled */);
    106     VMMDev         *pVMMDev   = m_pVMMDev; Assert(pVMMDev);
    10799    ComPtr<IMachine> pMachine = i_machine();
    108100
     
    185177    LogRel(("Guest OS type: '%s'\n", Utf8Str(osTypeId).c_str()));
    186178
    187     ULONG maxNetworkAdapters;
    188     hrc = pPlatformProperties->GetMaxNetworkAdapters(chipsetType, &maxNetworkAdapters);     H();
     179    BusAssignmentManager *pBusMgr = mBusMgr = BusAssignmentManager::createInstance(pVMM, chipsetType, IommuType_None);
    189180
    190181    /*
     
    366357        PCFGMNODE pCfg = NULL;          /* /Devices/Dev/.../Config/ */
    367358        PCFGMNODE pLunL0 = NULL;        /* /Devices/Dev/0/LUN#0/ */
    368         PCFGMNODE pLunL1 = NULL;        /* /Devices/Dev/0/LUN#0/AttachedDriver/ */
    369359
    370360        InsertConfigNode(pRoot, "Devices", &pDevices);
     
    621611            InsertConfigNode(pDev,     "0", &pInst);
    622612            InsertConfigInteger(pInst, "Trusted",           1);
    623             InsertConfigInteger(pInst, "PCIBusNo",          0);
    624             InsertConfigInteger(pInst, "PCIDeviceNo",       2);
    625             InsertConfigInteger(pInst, "PCIFunctionNo",     0);
     613            hrc = pBusMgr->assignPCIDevice("vga", pInst);                                   H();
    626614            InsertConfigNode(pInst,    "Config", &pCfg);
    627615            InsertConfigInteger(pCfg,  "VRamSize",          32 * _1M);
     
    641629        }
    642630
    643         InsertConfigNode(pDevices, "VMMDev",          &pDev);
    644         InsertConfigNode(pDev,     "0",              &pInst);
    645         InsertConfigInteger(pInst, "Trusted",             1);
    646         InsertConfigInteger(pInst, "PCIBusNo",            0);
    647         InsertConfigInteger(pInst, "PCIDeviceNo",         0);
    648         InsertConfigInteger(pInst, "PCIFunctionNo",       0);
    649         InsertConfigNode(pInst,    "Config",          &pCfg);
    650         InsertConfigInteger(pCfg,  "MmioReq",             1);
    651 
    652         /* the VMM device's Main driver */
    653         InsertConfigNode(pInst,    "LUN#0", &pLunL0);
    654         InsertConfigString(pLunL0, "Driver",               "HGCM");
    655         InsertConfigNode(pLunL0,   "Config", &pCfg);
    656 
    657         /*
    658          * Attach the status driver.
    659          */
    660         i_attachStatusDriver(pInst, DeviceType_SharedFolder);
    661 
    662 #ifdef VBOX_WITH_SHARED_CLIPBOARD
    663         /*
    664          * Shared Clipboard.
    665          */
    666         {
    667             ClipboardMode_T enmClipboardMode = ClipboardMode_Disabled;
    668             hrc = pMachine->COMGETTER(ClipboardMode)(&enmClipboardMode); H();
    669 #  ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    670             BOOL fFileTransfersEnabled;
    671             hrc = pMachine->COMGETTER(ClipboardFileTransfersEnabled)(&fFileTransfersEnabled); H();
    672 #  endif
    673 
    674             /* Load the service */
    675             vrc = pVMMDev->hgcmLoadService("VBoxSharedClipboard", "VBoxSharedClipboard");
    676             if (RT_SUCCESS(vrc))
    677             {
    678                 LogRel(("Shared Clipboard: Service loaded\n"));
    679 
    680                 /* Set initial clipboard mode. */
    681                 vrc = i_changeClipboardMode(enmClipboardMode);
    682                 AssertLogRelMsg(RT_SUCCESS(vrc), ("Shared Clipboard: Failed to set initial clipboard mode (%d): vrc=%Rrc\n",
    683                                                  enmClipboardMode, vrc));
    684 
    685                 /* Setup the service. */
    686                 VBOXHGCMSVCPARM parm;
    687                 HGCMSvcSetU32(&parm, !i_useHostClipboard());
    688                 vrc = pVMMDev->hgcmHostCall("VBoxSharedClipboard", VBOX_SHCL_HOST_FN_SET_HEADLESS, 1, &parm);
    689                 AssertLogRelMsg(RT_SUCCESS(vrc), ("Shared Clipboard: Failed to set initial headless mode (%RTbool): vrc=%Rrc\n",
    690                                                  !i_useHostClipboard(), vrc));
    691 
    692 #  ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    693                 vrc = i_changeClipboardFileTransferMode(RT_BOOL(fFileTransfersEnabled));
    694                 AssertLogRelMsg(RT_SUCCESS(vrc), ("Shared Clipboard: Failed to set initial file transfers mode (%u): vrc=%Rrc\n",
    695                                                  fFileTransfersEnabled, vrc));
    696 
    697                 /** @todo Register area callbacks? (See also deregistration todo in Console::i_powerDown.) */
    698 #  endif
    699             }
    700             else
    701                 LogRel(("Shared Clipboard: Not available, vrc=%Rrc\n", vrc));
    702             vrc = VINF_SUCCESS;  /* None of the potential failures above are fatal. */
    703         }
    704 #endif /* VBOX_WITH_SHARED_CLIPBOARD */
    705 
    706 #ifdef VBOX_WITH_DRAG_AND_DROP
    707         /*
    708          * Drag and Drop.
    709          */
    710         {
    711             DnDMode_T enmMode = DnDMode_Disabled;
    712             hrc = pMachine->COMGETTER(DnDMode)(&enmMode);                                   H();
    713 
    714             /* Load the service */
    715             vrc = pVMMDev->hgcmLoadService("VBoxDragAndDropSvc", "VBoxDragAndDropSvc");
    716             if (RT_FAILURE(vrc))
    717             {
    718                 LogRel(("Drag and drop service is not available, vrc=%Rrc\n", vrc));
    719                 /* That is not a fatal failure. */
    720                 vrc = VINF_SUCCESS;
    721             }
    722             else
    723             {
    724                 vrc = HGCMHostRegisterServiceExtension(&m_hHgcmSvcExtDragAndDrop, "VBoxDragAndDropSvc",
    725                                                        &GuestDnD::notifyDnDDispatcher,
    726                                                        GuestDnDInst());
    727                 if (RT_FAILURE(vrc))
    728                     Log(("Cannot register VBoxDragAndDropSvc extension, vrc=%Rrc\n", vrc));
    729                 else
    730                 {
    731                     LogRel(("Drag and drop service loaded\n"));
    732                     vrc = i_changeDnDMode(enmMode);
    733                 }
    734             }
    735         }
    736 #endif /* VBOX_WITH_DRAG_AND_DROP */
    737 
    738         InsertConfigNode(pDevices, "usb-xhci",      &pDev);
    739         InsertConfigNode(pDev,     "0",            &pInst);
    740         InsertConfigInteger(pInst, "Trusted",           1);
    741         InsertConfigInteger(pInst, "PCIBusNo",          0);
    742         InsertConfigInteger(pInst, "PCIDeviceNo",       1);
    743         InsertConfigInteger(pInst, "PCIFunctionNo",     0);
    744         InsertConfigNode(pInst,    "Config",        &pCfg);
    745         InsertConfigNode(pInst,    "LUN#0",       &pLunL0);
    746         InsertConfigString(pLunL0, "Driver","VUSBRootHub");
    747         InsertConfigNode(pInst,    "LUN#1",       &pLunL0);
    748         InsertConfigString(pLunL0, "Driver","VUSBRootHub");
     631        /*
     632         * The USB Controllers and input devices.
     633         */
     634#if 0 /** @todo Make us of this and disallow PS/2 for ARM VMs for now. */
     635        KeyboardHIDType_T aKbdHID;
     636        hrc = pMachine->COMGETTER(KeyboardHIDType)(&aKbdHID);                               H();
     637#endif
     638
     639        PointingHIDType_T aPointingHID;
     640        hrc = pMachine->COMGETTER(PointingHIDType)(&aPointingHID);                          H();
     641
     642        PCFGMNODE pUsbDevices = NULL;
     643        vrc = i_configUsb(pMachine, pBusMgr, pRoot, pDevices, KeyboardHIDType_USBKeyboard, aPointingHID, &pUsbDevices);
     644
     645        /*
     646         * Storage controllers.
     647         */
     648        bool fFdcEnabled = false;
     649        vrc = i_configStorageCtrls(pMachine, pBusMgr, pVMM, pUVM,
     650                                   pDevices, pUsbDevices, NULL /*pBiosCfg*/, &fFdcEnabled);      VRC();
    749651
    750652        /*
    751653         * Network adapters
    752654         */
    753         PCFGMNODE pDevE1000 = NULL;          /* E1000-type devices */
    754         InsertConfigNode(pDevices, "e1000", &pDevE1000);
    755         PCFGMNODE pDevVirtioNet = NULL;          /* Virtio network devices */
    756         InsertConfigNode(pDevices, "virtio-net", &pDevVirtioNet);
    757 
    758         for (ULONG uInstance = 0; uInstance < maxNetworkAdapters; ++uInstance)
    759         {
    760             ComPtr<INetworkAdapter> networkAdapter;
    761             hrc = pMachine->GetNetworkAdapter(uInstance, networkAdapter.asOutParam());      H();
    762             BOOL fEnabledNetAdapter = FALSE;
    763             hrc = networkAdapter->COMGETTER(Enabled)(&fEnabledNetAdapter);                  H();
    764             if (!fEnabledNetAdapter)
    765                 continue;
    766 
    767             /*
    768              * The virtual hardware type. Create appropriate device first.
    769              */
    770             const char *pszAdapterName = "pcnet";
    771             NetworkAdapterType_T adapterType;
    772             hrc = networkAdapter->COMGETTER(AdapterType)(&adapterType);                     H();
    773             switch (adapterType)
    774             {
    775 #ifdef VBOX_WITH_E1000
    776                 case NetworkAdapterType_I82540EM:
    777                 case NetworkAdapterType_I82543GC:
    778                 case NetworkAdapterType_I82545EM:
    779                     pDev = pDevE1000;
    780                     pszAdapterName = "e1000";
    781                     break;
    782 #endif
    783 #ifdef VBOX_WITH_VIRTIO
    784                 case NetworkAdapterType_Virtio:
    785                     pDev = pDevVirtioNet;
    786                     pszAdapterName = "virtio-net";
    787                     break;
    788 #endif /* VBOX_WITH_VIRTIO */
    789                 case NetworkAdapterType_Am79C970A:
    790                 case NetworkAdapterType_Am79C973:
    791                 case NetworkAdapterType_Am79C960:
    792                 case NetworkAdapterType_NE1000:
    793                 case NetworkAdapterType_NE2000:
    794                 case NetworkAdapterType_WD8003:
    795                 case NetworkAdapterType_WD8013:
    796                 case NetworkAdapterType_ELNK2:
    797                 case NetworkAdapterType_ELNK1:
    798                 default:
    799                     AssertMsgFailed(("Invalid/Unsupported network adapter type '%d' for slot '%d'", adapterType, uInstance));
    800                     return pVMM->pfnVMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
    801                                                  N_("Invalid/Unsupported network adapter type '%d' for slot '%d'"), adapterType, uInstance);
    802             }
    803 
    804             InsertConfigNode(pDev, Utf8StrFmt("%u", uInstance).c_str(), &pInst);
    805             InsertConfigInteger(pInst, "Trusted",              1); /* boolean */
    806             /* the first network card gets the PCI ID 3, the next 3 gets 8..10,
    807              * next 4 get 16..19. */
    808             int iPCIDeviceNo;
    809             switch (uInstance)
    810             {
    811                 case 0:
    812                     iPCIDeviceNo = 3;
    813                     break;
    814                 case 1: case 2: case 3:
    815                     iPCIDeviceNo = uInstance - 1 + 8;
    816                     break;
    817                 case 4: case 5: case 6: case 7:
    818                     iPCIDeviceNo = uInstance - 4 + 16;
    819                     break;
    820                 default:
    821                     /* auto assignment */
    822                     iPCIDeviceNo = -1;
    823                     break;
    824             }
    825 
    826             InsertConfigNode(pInst, "Config", &pCfg);
    827 
    828             /*
    829              * The virtual hardware type. PCNet supports three types, E1000 three,
    830              * but VirtIO only one.
    831              */
    832             switch (adapterType)
    833             {
    834                 case NetworkAdapterType_Am79C970A:
    835                     InsertConfigString(pCfg, "ChipType", "Am79C970A");
    836                     break;
    837                 case NetworkAdapterType_Am79C973:
    838                     InsertConfigString(pCfg, "ChipType", "Am79C973");
    839                     break;
    840                 case NetworkAdapterType_Am79C960:
    841                     InsertConfigString(pCfg, "ChipType", "Am79C960");
    842                     break;
    843                 case NetworkAdapterType_I82540EM:
    844                     InsertConfigInteger(pCfg, "AdapterType", 0);
    845                     break;
    846                 case NetworkAdapterType_I82543GC:
    847                     InsertConfigInteger(pCfg, "AdapterType", 1);
    848                     break;
    849                 case NetworkAdapterType_I82545EM:
    850                     InsertConfigInteger(pCfg, "AdapterType", 2);
    851                     break;
    852                 case NetworkAdapterType_Virtio:
    853                 {
    854                     uint32_t GCPhysMmioBase = 0x0a000000 + uInstance * GUEST_PAGE_SIZE;
    855                     uint32_t uIrq = 16 + uInstance;
    856 
    857                     InsertConfigInteger(pCfg,  "MmioBase",          GCPhysMmioBase);
    858                     InsertConfigInteger(pCfg,  "Irq",               uIrq);
    859 
    860                     vrc = RTFdtNodeAddF(hFdt, "virtio_mmio@%RX32", GCPhysMmioBase);                         VRC();
    861                     vrc = RTFdtNodePropertyAddEmpty(  hFdt, "dma-coherent");                            VRC();
    862                     vrc = RTFdtNodePropertyAddCellsU32(hFdt, "interrupts", 3, 0x00, uIrq, 0x04);        VRC();
    863                     vrc = RTFdtNodePropertyAddCellsU32(hFdt, "reg", 4, 0, GCPhysMmioBase, 0, 0x200);    VRC();
    864                     vrc = RTFdtNodePropertyAddString(hFdt, "compatible", "virtio,mmio");                VRC();
    865                     vrc = RTFdtNodeFinalize(hFdt);                                                      VRC();
    866                     break;
    867                 }
    868                 case NetworkAdapterType_NE1000:
    869                     InsertConfigString(pCfg, "DeviceType", "NE1000");
    870                     break;
    871                 case NetworkAdapterType_NE2000:
    872                     InsertConfigString(pCfg, "DeviceType", "NE2000");
    873                     break;
    874                 case NetworkAdapterType_WD8003:
    875                     InsertConfigString(pCfg, "DeviceType", "WD8003");
    876                     break;
    877                 case NetworkAdapterType_WD8013:
    878                     InsertConfigString(pCfg, "DeviceType", "WD8013");
    879                     break;
    880                 case NetworkAdapterType_ELNK2:
    881                     InsertConfigString(pCfg, "DeviceType", "3C503");
    882                     break;
    883                 case NetworkAdapterType_ELNK1:
    884                     break;
    885                 case NetworkAdapterType_Null:      AssertFailedBreak(); /* (compiler warnings) */
    886 #ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK
    887                 case NetworkAdapterType_32BitHack: AssertFailedBreak(); /* (compiler warnings) */
    888 #endif
    889             }
    890 
    891             /*
    892              * Get the MAC address and convert it to binary representation
    893              */
    894             Bstr macAddr;
    895             hrc = networkAdapter->COMGETTER(MACAddress)(macAddr.asOutParam());              H();
    896             Assert(!macAddr.isEmpty());
    897             Utf8Str macAddrUtf8 = macAddr;
    898 #ifdef VBOX_WITH_CLOUD_NET
    899             NetworkAttachmentType_T eAttachmentType;
    900             hrc = networkAdapter->COMGETTER(AttachmentType)(&eAttachmentType);                 H();
    901             if (eAttachmentType == NetworkAttachmentType_Cloud)
    902             {
    903                 mGateway.setLocalMacAddress(macAddrUtf8);
    904                 /* We'll insert cloud MAC later, when it becomes known. */
    905             }
    906             else
    907             {
    908 #endif
    909             char *macStr = (char*)macAddrUtf8.c_str();
    910             Assert(strlen(macStr) == 12);
    911             RTMAC Mac;
    912             RT_ZERO(Mac);
    913             char *pMac = (char*)&Mac;
    914             for (uint32_t i = 0; i < 6; ++i)
    915             {
    916                 int c1 = *macStr++ - '0';
    917                 if (c1 > 9)
    918                     c1 -= 7;
    919                 int c2 = *macStr++ - '0';
    920                 if (c2 > 9)
    921                     c2 -= 7;
    922                 *pMac++ = (char)(((c1 & 0x0f) << 4) | (c2 & 0x0f));
    923             }
    924             InsertConfigBytes(pCfg, "MAC", &Mac, sizeof(Mac));
    925 #ifdef VBOX_WITH_CLOUD_NET
    926             }
    927 #endif
    928             /*
    929              * Check if the cable is supposed to be unplugged
    930              */
    931             BOOL fCableConnected;
    932             hrc = networkAdapter->COMGETTER(CableConnected)(&fCableConnected);              H();
    933             InsertConfigInteger(pCfg, "CableConnected", fCableConnected ? 1 : 0);
    934 
    935             /*
    936              * Line speed to report from custom drivers
    937              */
    938             ULONG ulLineSpeed;
    939             hrc = networkAdapter->COMGETTER(LineSpeed)(&ulLineSpeed);                       H();
    940             InsertConfigInteger(pCfg, "LineSpeed", ulLineSpeed);
    941 
    942             /*
    943              * Attach the status driver.
    944              */
    945             i_attachStatusDriver(pInst, DeviceType_Network);
    946 
    947             /*
    948              * Configure the network card now
    949              */
    950             bool fIgnoreConnectFailure = mMachineState == MachineState_Restoring;
    951             vrc = i_configNetwork(pszAdapterName,
    952                                   uInstance,
    953                                   0,
    954                                   networkAdapter,
    955                                   pCfg,
    956                                   pLunL0,
    957                                   pInst,
    958                                   false /*fAttachDetach*/,
    959                                   fIgnoreConnectFailure,
    960                                   pUVM,
    961                                   pVMM);
    962             if (RT_FAILURE(vrc))
    963                 return vrc;
    964         }
    965 
    966         PCFGMNODE pUsb = NULL;
    967         InsertConfigNode(pRoot,    "USB",           &pUsb);
    968 
    969         /*
    970          * Storage controllers.
    971          */
    972         com::SafeIfaceArray<IStorageController> ctrls;
    973         PCFGMNODE aCtrlNodes[StorageControllerType_VirtioSCSI + 1] = {};
    974         hrc = pMachine->COMGETTER(StorageControllers)(ComSafeArrayAsOutParam(ctrls));       H();
    975 
    976         for (size_t i = 0; i < ctrls.size(); ++i)
    977         {
    978             DeviceType_T *paLedDevType = NULL;
    979 
    980             StorageControllerType_T enmCtrlType;
    981             hrc = ctrls[i]->COMGETTER(ControllerType)(&enmCtrlType);                        H();
    982             AssertRelease((unsigned)enmCtrlType < RT_ELEMENTS(aCtrlNodes)
    983                           || enmCtrlType == StorageControllerType_USB);
    984 
    985             StorageBus_T enmBus;
    986             hrc = ctrls[i]->COMGETTER(Bus)(&enmBus);                                        H();
    987 
    988             Bstr controllerName;
    989             hrc = ctrls[i]->COMGETTER(Name)(controllerName.asOutParam());                   H();
    990 
    991             ULONG ulInstance = 999;
    992             hrc = ctrls[i]->COMGETTER(Instance)(&ulInstance);                               H();
    993 
    994             BOOL fUseHostIOCache;
    995             hrc = ctrls[i]->COMGETTER(UseHostIOCache)(&fUseHostIOCache);                    H();
    996 
    997             BOOL fBootable;
    998             hrc = ctrls[i]->COMGETTER(Bootable)(&fBootable);                                H();
    999 
    1000             PCFGMNODE pCtlInst = NULL;
    1001             const char *pszCtrlDev = i_storageControllerTypeToStr(enmCtrlType);
    1002             if (enmCtrlType != StorageControllerType_USB)
    1003             {
    1004                 /* /Devices/<ctrldev>/ */
    1005                 pDev = aCtrlNodes[enmCtrlType];
    1006                 if (!pDev)
    1007                 {
    1008                     InsertConfigNode(pDevices, pszCtrlDev, &pDev);
    1009                     aCtrlNodes[enmCtrlType] = pDev; /* IDE variants are handled in the switch */
    1010                 }
    1011 
    1012                 /* /Devices/<ctrldev>/<instance>/ */
    1013                 InsertConfigNode(pDev, Utf8StrFmt("%u", ulInstance).c_str(), &pCtlInst);
    1014 
    1015                 /* Device config: /Devices/<ctrldev>/<instance>/<values> & /ditto/Config/<values> */
    1016                 InsertConfigInteger(pCtlInst, "Trusted",   1);
    1017                 InsertConfigNode(pCtlInst,    "Config",    &pCfg);
    1018             }
    1019 
    1020             switch (enmCtrlType)
    1021             {
    1022                 case StorageControllerType_USB:
    1023                 {
    1024                     if (pUsb)
    1025                     {
    1026                         /*
    1027                          * USB MSDs are handled a bit different as the device instance
    1028                          * doesn't match the storage controller instance but the port.
    1029                          */
    1030                         InsertConfigNode(pUsb, "Msd", &pDev);
    1031                         pCtlInst = pDev;
    1032                     }
    1033                     else
    1034                         return pVMM->pfnVMR3SetError(pUVM, VERR_NOT_FOUND, RT_SRC_POS,
    1035                                 N_("There is no USB controller enabled but there\n"
    1036                                    "is at least one USB storage device configured for this VM.\n"
    1037                                    "To fix this problem either enable the USB controller or remove\n"
    1038                                    "the storage device from the VM"));
    1039                     break;
    1040                 }
    1041 
    1042                 case StorageControllerType_IntelAhci:
    1043                 {
    1044                     InsertConfigInteger(pCtlInst, "PCIBusNo",          0);
    1045                     InsertConfigInteger(pCtlInst, "PCIDeviceNo",       3);
    1046                     InsertConfigInteger(pCtlInst, "PCIFunctionNo",     0);
    1047 
    1048                     ULONG cPorts = 0;
    1049                     hrc = ctrls[i]->COMGETTER(PortCount)(&cPorts);                          H();
    1050                     InsertConfigInteger(pCfg, "PortCount", cPorts);
    1051                     InsertConfigInteger(pCfg, "Bootable",  fBootable);
    1052 
    1053                     com::SafeIfaceArray<IMediumAttachment> atts;
    1054                     hrc = pMachine->GetMediumAttachmentsOfController(controllerName.raw(),
    1055                                                                      ComSafeArrayAsOutParam(atts));  H();
    1056 
    1057                     /* Configure the hotpluggable flag for the port. */
    1058                     for (unsigned idxAtt = 0; idxAtt < atts.size(); ++idxAtt)
    1059                     {
    1060                         IMediumAttachment *pMediumAtt = atts[idxAtt];
    1061 
    1062                         LONG lPortNum = 0;
    1063                         hrc = pMediumAtt->COMGETTER(Port)(&lPortNum);                       H();
    1064 
    1065                         BOOL fHotPluggable = FALSE;
    1066                         hrc = pMediumAtt->COMGETTER(HotPluggable)(&fHotPluggable);          H();
    1067                         if (SUCCEEDED(hrc))
    1068                         {
    1069                             PCFGMNODE pPortCfg;
    1070                             char szName[24];
    1071                             RTStrPrintf(szName, sizeof(szName), "Port%d", lPortNum);
    1072 
    1073                             InsertConfigNode(pCfg, szName, &pPortCfg);
    1074                             InsertConfigInteger(pPortCfg, "Hotpluggable", fHotPluggable ? 1 : 0);
    1075                         }
    1076                     }
    1077                     break;
    1078                 }
    1079                 case StorageControllerType_VirtioSCSI:
    1080                 {
    1081                     InsertConfigInteger(pCtlInst, "PCIBusNo",          0);
    1082                     InsertConfigInteger(pCtlInst, "PCIDeviceNo",       3);
    1083                     InsertConfigInteger(pCtlInst, "PCIFunctionNo",     0);
    1084 
    1085                     ULONG cPorts = 0;
    1086                     hrc = ctrls[i]->COMGETTER(PortCount)(&cPorts);                          H();
    1087                     InsertConfigInteger(pCfg, "NumTargets", cPorts);
    1088                     InsertConfigInteger(pCfg, "Bootable",   fBootable);
    1089 
    1090                     /* Attach the status driver */
    1091                     i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD) /*?*/,
    1092                                          cPorts, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance);
    1093                     break;
    1094                 }
    1095 
    1096                 case StorageControllerType_NVMe:
    1097                 {
    1098                     InsertConfigInteger(pCtlInst, "PCIBusNo",          0);
    1099                     InsertConfigInteger(pCtlInst, "PCIDeviceNo",       3);
    1100                     InsertConfigInteger(pCtlInst, "PCIFunctionNo",     0);
    1101 
    1102                     /* Attach the status driver */
    1103                     i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD) /*?*/,
    1104                                          1, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance);
    1105                     break;
    1106                 }
    1107 
    1108                 case StorageControllerType_LsiLogic:
    1109                 case StorageControllerType_BusLogic:
    1110                 case StorageControllerType_PIIX3:
    1111                 case StorageControllerType_PIIX4:
    1112                 case StorageControllerType_ICH6:
    1113                 case StorageControllerType_I82078:
    1114                 case StorageControllerType_LsiLogicSas:
    1115 
    1116                 default:
    1117                     AssertLogRelMsgFailedReturn(("invalid storage controller type: %d\n", enmCtrlType), VERR_MAIN_CONFIG_CONSTRUCTOR_IPE);
    1118             }
    1119 
    1120             /* Attach the media to the storage controllers. */
    1121             com::SafeIfaceArray<IMediumAttachment> atts;
    1122             hrc = pMachine->GetMediumAttachmentsOfController(controllerName.raw(),
    1123                                                             ComSafeArrayAsOutParam(atts));  H();
    1124 
    1125             /* Builtin I/O cache - per device setting. */
    1126             BOOL fBuiltinIOCache = true;
    1127             hrc = pMachine->COMGETTER(IOCacheEnabled)(&fBuiltinIOCache);                    H();
    1128 
    1129             bool fInsertDiskIntegrityDrv = false;
    1130             Bstr strDiskIntegrityFlag;
    1131             hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/EnableDiskIntegrityDriver").raw(),
    1132                                          strDiskIntegrityFlag.asOutParam());
    1133             if (   hrc   == S_OK
    1134                 && strDiskIntegrityFlag == "1")
    1135                 fInsertDiskIntegrityDrv = true;
    1136 
    1137             for (size_t j = 0; j < atts.size(); ++j)
    1138             {
    1139                 IMediumAttachment *pMediumAtt = atts[j];
    1140                 vrc = i_configMediumAttachment(pszCtrlDev,
    1141                                                ulInstance,
    1142                                                enmBus,
    1143                                                !!fUseHostIOCache,
    1144                                                enmCtrlType == StorageControllerType_NVMe ? false : !!fBuiltinIOCache,
    1145                                                fInsertDiskIntegrityDrv,
    1146                                                false /* fSetupMerge */,
    1147                                                0 /* uMergeSource */,
    1148                                                0 /* uMergeTarget */,
    1149                                                pMediumAtt,
    1150                                                mMachineState,
    1151                                                NULL /* phrc */,
    1152                                                false /* fAttachDetach */,
    1153                                                false /* fForceUnmount */,
    1154                                                false /* fHotplug */,
    1155                                                pUVM,
    1156                                                pVMM,
    1157                                                paLedDevType,
    1158                                                NULL /* ppLunL0 */);
    1159                 if (RT_FAILURE(vrc))
    1160                     return vrc;
    1161             }
    1162             H();
    1163         }
    1164         H();
    1165 
    1166         InsertConfigNode(pUsb,     "HidKeyboard",   &pDev);
    1167         InsertConfigNode(pDev,     "0",            &pInst);
    1168         InsertConfigInteger(pInst, "Trusted",           1);
    1169         InsertConfigNode(pInst,    "Config",        &pCfg);
    1170         InsertConfigNode(pInst,    "LUN#0",       &pLunL0);
    1171         InsertConfigString(pLunL0, "Driver",       "KeyboardQueue");
    1172         InsertConfigNode(pLunL0,   "AttachedDriver",  &pLunL1);
    1173         InsertConfigString(pLunL1, "Driver",          "MainKeyboard");
    1174 
    1175         InsertConfigNode(pUsb,     "HidMouse", &pDev);
    1176         InsertConfigNode(pDev,     "0", &pInst);
    1177         InsertConfigNode(pInst,    "Config", &pCfg);
    1178         InsertConfigString(pCfg,   "Mode", "absolute");
    1179         InsertConfigNode(pInst,    "LUN#0", &pLunL0);
    1180         InsertConfigString(pLunL0, "Driver",        "MouseQueue");
    1181         InsertConfigNode(pLunL0,   "Config", &pCfg);
    1182         InsertConfigInteger(pCfg,  "QueueSize",            128);
    1183 
    1184         InsertConfigNode(pLunL0,   "AttachedDriver", &pLunL1);
    1185         InsertConfigString(pLunL1, "Driver",        "MainMouse");
     655        std::list<BootNic> llBootNics;
     656        vrc = i_configNetworkCtrls(pMachine, pPlatformProperties, chipsetType, pBusMgr,
     657                                   pVMM, pUVM, pDevices, llBootNics);                            VRC();
     658
     659        /*
     660         * The VMM device.
     661         */
     662        vrc = i_configVmmDev(pMachine, pBusMgr, pDevices, true /*fMmioReq*/);                    VRC();
     663
     664        /*
     665         * Audio configuration.
     666         */
     667        bool fAudioEnabled = false;
     668        vrc = i_configAudioCtrl(virtualBox, pMachine, pBusMgr, pDevices,
     669                                false /*fOsXGuest*/, &fAudioEnabled);                            VRC();
    1186670    }
    1187671    catch (ConfigError &x)
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