Changeset 24346 in vbox for trunk/src/VBox
- Timestamp:
- Nov 4, 2009 5:04:00 PM (15 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageStorageController.cpp
r24026 r24346 73 73 ComPtr<IMachine> machine; 74 74 ComPtr<IStorageController> storageCtl; 75 ComPtr<ISystemProperties> systemProperties; 75 76 76 77 if (a->argc < 9) … … 153 154 } 154 155 156 /* get the virtualbox system properties */ 157 CHECK_ERROR_RET(a->virtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()), 1); 158 155 159 /* try to find the given machine */ 156 160 if (!Guid(machineuuid).isEmpty()) … … 238 242 StorageBus_T storageBus = StorageBus_Null; 239 243 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 */ 241 248 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 } 242 262 243 263 if (storageBus == StorageBus_Floppy) … … 337 357 } 338 358 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 339 393 if (!RTStrICmp(pszType, "dvddrive")) 340 394 { -
trunk/src/VBox/Main/SystemPropertiesImpl.cpp
r23560 r24346 495 495 } 496 496 497 STDMETHODIMP 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 497 538 STDMETHODIMP SystemProperties::COMGETTER(DefaultMachineFolder) (BSTR *aDefaultMachineFolder) 498 539 { -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r24340 r24346 7587 7587 name="ISystemProperties" 7588 7588 extends="$unknown" 7589 uuid=" 4b78105a-d066-4eab-ae48-ccb2c0ba5057"7589 uuid="8030645c-8fef-4320-bb7b-c829f00069dc" 7590 7590 wsmap="managed" 7591 7591 > … … 7902 7902 <param name="maxInstances" type="unsigned long" dir="return"> 7903 7903 <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> 7904 7918 </param> 7905 7919 </method> -
trunk/src/VBox/Main/include/SystemPropertiesImpl.h
r23560 r24346 99 99 STDMETHOD(GetMaxPortCountForStorageBus) (StorageBus_T aBus, ULONG *aMaxPortCount); 100 100 STDMETHOD(GetMaxInstancesOfStorageBus)(StorageBus_T aBus, ULONG *aMaxInstances); 101 STDMETHOD(GetDeviceTypesForStorageBus)(StorageBus_T aBus, ComSafeArrayOut(DeviceType_T, aDeviceTypes)); 101 102 102 103 // public methods only for internal purposes
Note:
See TracChangeset
for help on using the changeset viewer.