VirtualBox

Ignore:
Timestamp:
Nov 4, 2009 5:04:00 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
54368
Message:

SystemProperties: function GetDeviceTypesForStorageBus() to get the supported device type for given storagebus

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageStorageController.cpp

    r24026 r24346  
    7373    ComPtr<IMachine> machine;
    7474    ComPtr<IStorageController> storageCtl;
     75    ComPtr<ISystemProperties> systemProperties;
    7576
    7677    if (a->argc < 9)
     
    153154    }
    154155
     156    /* get the virtualbox system properties */
     157    CHECK_ERROR_RET(a->virtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()), 1);
     158
    155159    /* try to find the given machine */
    156160    if (!Guid(machineuuid).isEmpty())
     
    238242            StorageBus_T storageBus = StorageBus_Null;
    239243            DeviceType_T deviceType = DeviceType_Null;
    240 
     244            com::SafeArray <DeviceType_T> saDeviceTypes;
     245            ULONG driveCheck = 0;
     246
     247            /* check if the device type is supported by the controller */
    241248            CHECK_ERROR(storageCtl, COMGETTER(Bus)(&storageBus));
     249            CHECK_ERROR(systemProperties, GetDeviceTypesForStorageBus(storageBus, ComSafeArrayAsOutParam(saDeviceTypes)));
     250            for (size_t i = 0; i < saDeviceTypes.size(); ++ i)
     251            {
     252                if (   (saDeviceTypes[i] == DeviceType_DVD)
     253                    || (saDeviceTypes[i] == DeviceType_Floppy))
     254                    driveCheck++;
     255            }
     256
     257            if (!driveCheck)
     258            {
     259                errorArgument("The Attachment is not supported by the Storage Controller: '%s'", pszCtl);
     260                goto leave;
     261            }
    242262
    243263            if (storageBus == StorageBus_Floppy)
     
    337357        }
    338358
     359        /* check if the device type is supported by the controller */
     360        {
     361            ULONG storageBus = StorageBus_Null;
     362            com::SafeArray <DeviceType_T> saDeviceTypes;
     363
     364            CHECK_ERROR(storageCtl, COMGETTER(Bus)(&storageBus));
     365            CHECK_ERROR(systemProperties, GetDeviceTypesForStorageBus(storageBus, ComSafeArrayAsOutParam(saDeviceTypes)));
     366            if (SUCCEEDED(rc))
     367            {
     368                ULONG driveCheck = 0;
     369                for (size_t i = 0; i < saDeviceTypes.size(); ++ i)
     370                {
     371                    if (   !RTStrICmp(pszType, "dvddrive")
     372                        && (saDeviceTypes[i] == DeviceType_DVD))
     373                        driveCheck++;
     374
     375                    if (   !RTStrICmp(pszType, "hdd")
     376                        && (saDeviceTypes[i] == DeviceType_HardDisk))
     377                        driveCheck++;
     378
     379                    if (   !RTStrICmp(pszType, "fdd")
     380                        && (saDeviceTypes[i] == DeviceType_Floppy))
     381                        driveCheck++;
     382                }
     383                if (!driveCheck)
     384                {
     385                    errorArgument("The Attachment is not supported by the Storage Controller: '%s'", pszCtl);
     386                    goto leave;
     387                }
     388            }
     389            else
     390                goto leave;
     391        }
     392
    339393        if (!RTStrICmp(pszType, "dvddrive"))
    340394        {
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