VirtualBox

Changeset 24346 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 4, 2009 5:04:00 PM (15 years ago)
Author:
vboxsync
Message:

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

Location:
trunk/src/VBox
Files:
4 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        {
  • trunk/src/VBox/Main/SystemPropertiesImpl.cpp

    r23560 r24346  
    495495}
    496496
     497STDMETHODIMP SystemProperties::GetDeviceTypesForStorageBus(StorageBus_T aBus,
     498                                 ComSafeArrayOut(DeviceType_T, aDeviceTypes))
     499{
     500    CheckComArgOutSafeArrayPointerValid(aDeviceTypes);
     501
     502    AutoCaller autoCaller(this);
     503    CheckComRCReturnRC(autoCaller.rc());
     504
     505    /* no need to lock, this is const */
     506    switch (aBus)
     507    {
     508        case StorageBus_SATA:
     509        case StorageBus_IDE:
     510        {
     511            com::SafeArray<DeviceType_T> saDeviceTypes(2);
     512            saDeviceTypes[0] = DeviceType_DVD;
     513            saDeviceTypes[1] = DeviceType_HardDisk;
     514            saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
     515            break;
     516        }
     517        case StorageBus_SCSI:
     518        {
     519            com::SafeArray<DeviceType_T> saDeviceTypes(1);
     520            saDeviceTypes[0] = DeviceType_HardDisk;
     521            saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
     522            break;
     523        }
     524        case StorageBus_Floppy:
     525        {
     526            com::SafeArray<DeviceType_T> saDeviceTypes(1);
     527            saDeviceTypes[0] = DeviceType_Floppy;
     528            saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes));
     529            break;
     530        }
     531        default:
     532            AssertMsgFailed(("Invalid bus type %d\n", aBus));
     533    }
     534
     535    return S_OK;
     536}
     537
    497538STDMETHODIMP SystemProperties::COMGETTER(DefaultMachineFolder) (BSTR *aDefaultMachineFolder)
    498539{
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r24340 r24346  
    75877587     name="ISystemProperties"
    75887588     extends="$unknown"
    7589      uuid="4b78105a-d066-4eab-ae48-ccb2c0ba5057"
     7589     uuid="8030645c-8fef-4320-bb7b-c829f00069dc"
    75907590     wsmap="managed"
    75917591     >
     
    79027902      <param name="maxInstances" type="unsigned long" dir="return">
    79037903        <desc>The maximum number of instances for the given storage bus.</desc>
     7904      </param>
     7905    </method>
     7906
     7907    <method name="getDeviceTypesForStorageBus">
     7908      <desc>Returns list of all the supported device types
     7909        (<link to="DeviceType"/>) for the given type of storage
     7910        bus.</desc>
     7911
     7912      <param name="bus" type="StorageBus" dir="in">
     7913        <desc>The storage bus type to get the value for.</desc>
     7914      </param>
     7915
     7916      <param name="deviceTypes" type="DeviceType" safearray="yes" dir="return">
     7917        <desc>The list of all supported device types for the given storage bus.</desc>
    79047918      </param>
    79057919    </method>
  • trunk/src/VBox/Main/include/SystemPropertiesImpl.h

    r23560 r24346  
    9999    STDMETHOD(GetMaxPortCountForStorageBus) (StorageBus_T aBus, ULONG *aMaxPortCount);
    100100    STDMETHOD(GetMaxInstancesOfStorageBus)(StorageBus_T aBus, ULONG *aMaxInstances);
     101    STDMETHOD(GetDeviceTypesForStorageBus)(StorageBus_T aBus, ComSafeArrayOut(DeviceType_T, aDeviceTypes));
    101102
    102103    // public methods only for internal purposes
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