VirtualBox

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


Ignore:
Timestamp:
Sep 21, 2023 10:51:17 AM (18 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
159198
Message:

Main: Moved i_controllerNameFromBusType() from Machine to StorageController, also now as a static function, and use this also in the Unattended installer, to avoid code duplication.

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

Legend:

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

    r101214 r101220  
    5858#include "AutostartDb.h"
    5959#include "SystemPropertiesImpl.h"
     60#include "StorageControllerImpl.h"
    6061#include "MachineImplMoveVM.h"
    6162#include "ExtPackManagerImpl.h"
     
    1511515116}
    1511615117
    15117 com::Utf8Str Machine::i_controllerNameFromBusType(StorageBus_T aBusType)
    15118 {
    15119     com::Utf8Str strControllerName = "Unknown";
    15120     switch (aBusType)
    15121     {
    15122         case StorageBus_IDE:
    15123         {
    15124             strControllerName = "IDE";
    15125             break;
    15126         }
    15127         case StorageBus_SATA:
    15128         {
    15129             strControllerName = "SATA";
    15130             break;
    15131         }
    15132         case StorageBus_SCSI:
    15133         {
    15134             strControllerName = "SCSI";
    15135             break;
    15136         }
    15137         case StorageBus_Floppy:
    15138         {
    15139             strControllerName = "Floppy";
    15140             break;
    15141         }
    15142         case StorageBus_SAS:
    15143         {
    15144             strControllerName = "SAS";
    15145             break;
    15146         }
    15147         case StorageBus_USB:
    15148         {
    15149             strControllerName = "USB";
    15150             break;
    15151         }
    15152         case StorageBus_PCIe:
    15153         {
    15154             strControllerName = "PCIe";
    15155             break;
    15156         }
    15157         case StorageBus_VirtioSCSI:
    15158         {
    15159             strControllerName = "VirtioSCSI";
    15160             break;
    15161         }
    15162         default:
    15163             AssertFailed(); /* Catch missing case above. */
    15164             break;
    15165     }
    15166     return strControllerName;
    15167 }
    15168 
    1516915118HRESULT Machine::applyDefaults(const com::Utf8Str &aFlags)
    1517015119{
     
    1527215221
    1527315222    /* GUI auto generates controller names using bus type. Do the same*/
    15274     strFloppyName = i_controllerNameFromBusType(StorageBus_Floppy);
     15223    strFloppyName = StorageController::i_controllerNameFromBusType(StorageBus_Floppy);
    1527515224
    1527615225    /* Floppy recommended? add one. */
     
    1529015239    if (FAILED(hrc)) return hrc;
    1529115240
    15292     strDVDName = i_controllerNameFromBusType(dvdStorageBusType);
     15241    strDVDName = StorageController::i_controllerNameFromBusType(dvdStorageBusType);
    1529315242
    1529415243    hrc = addStorageController(strDVDName, dvdStorageBusType, dvdController);
     
    1530515254    if (FAILED(hrc)) return hrc;
    1530615255
    15307     strHDName = i_controllerNameFromBusType(hdStorageBusType);
     15256    strHDName = StorageController::i_controllerNameFromBusType(hdStorageBusType);
    1530815257
    1530915258    if (hdStorageBusType != dvdStorageBusType && hdStorageControllerType != dvdStorageControllerType)
  • TabularUnified trunk/src/VBox/Main/src-server/StorageControllerImpl.cpp

    r101035 r101220  
    806806}
    807807
     808/**
     809 * Returns a controller name from a given storage bus type.
     810 *
     811 * @return Controller name.
     812 * @param  aBusType             Bus type to get controller name for.
     813 */
     814/* static */
     815com::Utf8Str StorageController::i_controllerNameFromBusType(StorageBus_T aBusType)
     816{
     817    com::Utf8Str strControllerName = "Unknown";
     818    switch (aBusType)
     819    {
     820        case StorageBus_IDE:
     821        {
     822            strControllerName = "IDE";
     823            break;
     824        }
     825        case StorageBus_SATA:
     826        {
     827            strControllerName = "SATA";
     828            break;
     829        }
     830        case StorageBus_SCSI:
     831        {
     832            strControllerName = "SCSI";
     833            break;
     834        }
     835        case StorageBus_Floppy:
     836        {
     837            strControllerName = "Floppy";
     838            break;
     839        }
     840        case StorageBus_SAS:
     841        {
     842            strControllerName = "SAS";
     843            break;
     844        }
     845        case StorageBus_USB:
     846        {
     847            strControllerName = "USB";
     848            break;
     849        }
     850        case StorageBus_PCIe:
     851        {
     852            strControllerName = "PCIe";
     853            break;
     854        }
     855        case StorageBus_VirtioSCSI:
     856        {
     857            strControllerName = "VirtioSCSI";
     858            break;
     859        }
     860        default:
     861            AssertFailed(); /* Catch missing case above. */
     862            break;
     863    }
     864    return strControllerName;
     865}
     866
    808867Machine* StorageController::i_getMachine()
    809868{
  • TabularUnified trunk/src/VBox/Main/src-server/UnattendedImpl.cpp

    r101204 r101220  
    31823182        if (strRecommendedControllerName.isEmpty())
    31833183        {
    3184             switch (enmRecommendedStorageBus)
    3185             {
    3186                 case StorageBus_IDE:    strRecommendedControllerName = "IDE";  break;
    3187                 case StorageBus_SATA:   strRecommendedControllerName = "SATA"; break;
    3188                 case StorageBus_SCSI:   strRecommendedControllerName = "SCSI"; break;
    3189                 case StorageBus_SAS:    strRecommendedControllerName = "SAS";  break;
    3190                 case StorageBus_USB:    strRecommendedControllerName = "USB";  break;
    3191                 case StorageBus_PCIe:   strRecommendedControllerName = "PCIe"; break;
    3192                 default:
    3193                     return setError(E_FAIL, tr("Support for recommended storage bus %d not implemented"),
    3194                                     (int)enmRecommendedStorageBus);
    3195             }
     3184            strRecommendedControllerName = StorageController::i_controllerNameFromBusType(enmRecommendedStorageBus);
     3185
    31963186            ComPtr<IStorageController> ptrControllerIgnored;
    31973187            hrc = rPtrSessionMachine->AddStorageController(Bstr(strRecommendedControllerName).raw(), enmRecommendedStorageBus,
Note: See TracChangeset for help on using the changeset viewer.

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