- Timestamp:
- Aug 2, 2010 2:55:22 PM (14 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r31307 r31308 3153 3153 if (FAILED(rc)) return rc; 3154 3154 3155 /* check that the port and device are not out of range. */ 3156 ULONG portCount; 3157 ULONG devicesPerPort; 3158 rc = ctl->COMGETTER(PortCount)(&portCount); 3155 // check that the port and device are not out of range 3156 rc = ctl->checkPortAndDeviceValid(aControllerPort, aDevice); 3159 3157 if (FAILED(rc)) return rc; 3160 rc = ctl->COMGETTER(MaxDevicesPerPortCount)(&devicesPerPort);3161 if (FAILED(rc)) return rc;3162 3163 if ( (aControllerPort < 0)3164 || (aControllerPort >= (LONG)portCount)3165 || (aDevice < 0)3166 || (aDevice >= (LONG)devicesPerPort)3167 )3168 return setError(E_INVALIDARG,3169 tr("The port and/or count parameter are out of range [%lu:%lu]"),3170 portCount,3171 devicesPerPort);3172 3158 3173 3159 /* check if the device slot is already busy */ … … 3230 3216 medium->getLocationFull().raw()); 3231 3217 3232 bool indirect = false;3218 bool fImplicit = false; 3233 3219 if (!medium.isNull()) 3234 indirect = medium->isReadOnly();3220 fImplicit = medium->isReadOnly(); 3235 3221 bool associate = true; 3236 3222 … … 3246 3232 if ((pAttachTemp = findAttachment(oldAtts, medium))) 3247 3233 { 3248 AssertReturn(! indirect, E_FAIL);3234 AssertReturn(!fImplicit, E_FAIL); 3249 3235 3250 3236 /* see if it's the same bus/channel/device */ … … 3265 3251 3266 3252 /* go further only if the attachment is to be indirect */ 3267 if (! indirect)3253 if (!fImplicit) 3268 3254 break; 3269 3255 … … 3333 3319 mediumLock.attach(medium); 3334 3320 /* not implicit, doesn't require association with this VM */ 3335 indirect = false;3321 fImplicit = false; 3336 3322 associate = false; 3337 3323 /* go right to the MediumAttachment creation */ … … 3477 3463 ComObjPtr<MediumAttachment> attachment; 3478 3464 attachment.createObject(); 3479 rc = attachment->init(this, medium, aControllerName, aControllerPort, aDevice, aType, indirect, 0 /* No bandwidth limit */); 3465 rc = attachment->init(this, 3466 medium, 3467 aControllerName, 3468 aControllerPort, 3469 aDevice, 3470 aType, 3471 fImplicit, 3472 0 /* No bandwidth limit */); 3480 3473 if (FAILED(rc)) return rc; 3481 3474 -
trunk/src/VBox/Main/MediumImpl.cpp
r31306 r31308 3236 3236 { 3237 3237 /* use the default format if not */ 3238 AutoReadLock propsLock(m->pVirtualBox-> systemProperties() COMMA_LOCKVAL_SRC_POS);3238 AutoReadLock propsLock(m->pVirtualBox->getSystemProperties() COMMA_LOCKVAL_SRC_POS); 3239 3239 strFormat = m->pVirtualBox->getDefaultHardDiskFormat(); 3240 3240 } … … 4843 4843 /* get the format object first */ 4844 4844 { 4845 AutoReadLock propsLock(m->pVirtualBox->systemProperties() COMMA_LOCKVAL_SRC_POS);4846 4847 unconst(m->formatObj) 4848 = m->pVirtualBox->systemProperties()->mediumFormat(aFormat);4845 SystemProperties *pSysProps = m->pVirtualBox->getSystemProperties(); 4846 AutoReadLock propsLock(pSysProps COMMA_LOCKVAL_SRC_POS); 4847 4848 unconst(m->formatObj) = pSysProps->mediumFormat(aFormat); 4849 4849 if (m->formatObj.isNull()) 4850 4850 return setError(E_INVALIDARG, -
trunk/src/VBox/Main/StorageControllerImpl.cpp
r29686 r31308 21 21 #include "MachineImpl.h" 22 22 #include "VirtualBoxImpl.h" 23 #include "SystemPropertiesImpl.h" 23 24 24 25 #include <iprt/string.h> … … 79 80 { 80 81 Data() 81 : pParent(NULL) 82 : pVirtualBox(NULL), 83 pSystemProperties(NULL), 84 pParent(NULL) 82 85 { } 86 87 VirtualBox * const pVirtualBox; 88 SystemProperties * const pSystemProperties; 83 89 84 90 Machine * const pParent; … … 131 137 132 138 m = new Data(); 139 140 unconst(m->pVirtualBox) = aParent->getVirtualBox(); 141 unconst(m->pSystemProperties) = m->pVirtualBox->getSystemProperties(); 133 142 134 143 unconst(m->pParent) = aParent; … … 412 421 413 422 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 414 415 ComPtr<IVirtualBox> VBox; 416 HRESULT rc = m->pParent->COMGETTER(Parent)(VBox.asOutParam()); 417 if (FAILED(rc)) 418 return rc; 419 420 ComPtr<ISystemProperties> sysProps; 421 rc = VBox->COMGETTER(SystemProperties)(sysProps.asOutParam()); 422 if (FAILED(rc)) 423 return rc; 424 425 rc = sysProps->GetMaxDevicesPerPortForStorageBus(m->bd->mStorageBus, aMaxDevices); 423 HRESULT rc = m->pSystemProperties->GetMaxDevicesPerPortForStorageBus(m->bd->mStorageBus, aMaxDevices); 424 426 425 return rc; 427 426 } … … 751 750 } 752 751 752 /** 753 * Returns S_OK if the given port and device numbers are within the range supported 754 * by this controller. If not, it sets an error and returns E_INVALIDARG. 755 * @param ulPort 756 * @param ulDevice 757 * @return 758 */ 759 HRESULT StorageController::checkPortAndDeviceValid(LONG aControllerPort, 760 LONG aDevice) 761 { 762 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 763 764 ULONG portCount = m->bd->mPortCount; 765 ULONG devicesPerPort; 766 HRESULT rc = m->pSystemProperties->GetMaxDevicesPerPortForStorageBus(m->bd->mStorageBus, &devicesPerPort); 767 if (FAILED(rc)) return rc; 768 769 if ( (aControllerPort < 0) 770 || (aControllerPort >= (LONG)portCount) 771 || (aDevice < 0) 772 || (aDevice >= (LONG)devicesPerPort) 773 ) 774 return setError(E_INVALIDARG, 775 tr("The port and/or count parameter are out of range [%lu:%lu]"), 776 portCount, 777 devicesPerPort); 778 779 return S_OK; 780 } 781 753 782 /** @note Locks objects for writing! */ 754 783 void StorageController::rollback() -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r31300 r31308 2939 2939 } 2940 2940 2941 const ComObjPtr<SystemProperties>& VirtualBox::systemProperties() const2941 SystemProperties* VirtualBox::getSystemProperties() const 2942 2942 { 2943 2943 return m->pSystemProperties; -
trunk/src/VBox/Main/include/MachineImpl.h
r31307 r31308 821 821 Machine* const mPeer; 822 822 823 VirtualBox * constmParent;823 VirtualBox * const mParent; 824 824 825 825 Shareable<Data> mData; -
trunk/src/VBox/Main/include/StorageControllerImpl.h
r30739 r31308 85 85 ULONG getInstance() const; 86 86 87 HRESULT checkPortAndDeviceValid(LONG aControllerPort, 88 LONG aDevice); 89 87 90 void rollback(); 88 91 void commit(); -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r31296 r31308 237 237 238 238 const ComObjPtr<Host>& host() const; 239 const ComObjPtr<SystemProperties>& systemProperties() const;239 SystemProperties* getSystemProperties() const; 240 240 #ifdef VBOX_WITH_RESOURCE_USAGE_API 241 241 const ComObjPtr<PerformanceCollector>& performanceCollector() const;
Note:
See TracChangeset
for help on using the changeset viewer.