Changeset 17970 in vbox for trunk/src/VBox/Main
- Timestamp:
- Mar 16, 2009 7:08:16 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 44552
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImpl.cpp
r17965 r17970 2217 2217 2218 2218 /* Create a dynamic growing disk image with the given capacity */ 2219 rc = dstHdVBox->Create DynamicStorage(di.iCapacity / _1M, HardDiskVariant_Standard, progress.asOutParam());2219 rc = dstHdVBox->CreateBaseStorage(di.iCapacity / _1M, HardDiskVariant_Standard, progress.asOutParam()); 2220 2220 if (FAILED(rc)) throw rc; 2221 2221 -
trunk/src/VBox/Main/HardDiskImpl.cpp
r17911 r17970 58 58 struct HardDisk::Task : public com::SupportErrorInfoBase 59 59 { 60 enum Operation { Create Dynamic, CreateFixed, CreateDiff,60 enum Operation { CreateBase, CreateDiff, 61 61 Merge, Clone, Delete, Reset }; 62 62 … … 98 98 Data() : size (0) {} 99 99 100 /* Create Dynamic, CreateStatic*/100 /* CreateBase */ 101 101 102 102 uint64_t size; 103 103 104 /* Create Dynamic, CreateStatic, CreateDiff, Clone */104 /* CreateBase, CreateDiff, Clone */ 105 105 106 106 HardDiskVariant_T variant; … … 1178 1178 } 1179 1179 1180 STDMETHODIMP HardDisk::Create DynamicStorage(ULONG64 aLogicalSize,1181 1182 1180 STDMETHODIMP HardDisk::CreateBaseStorage(ULONG64 aLogicalSize, 1181 HardDiskVariant_T aVariant, 1182 IProgress **aProgress) 1183 1183 { 1184 1184 CheckComArgOutPointerValid (aProgress); … … 1189 1189 AutoWriteLock alock (this); 1190 1190 1191 if (!(mm.formatObj->capabilities() & 1192 HardDiskFormatCapabilities_CreateDynamic)) 1191 aVariant &= ~HardDiskVariant_Diff; 1192 if ( !(aVariant & HardDiskVariant_Fixed) 1193 && !(mm.formatObj->capabilities() & HardDiskFormatCapabilities_CreateDynamic)) 1193 1194 return setError (VBOX_E_NOT_SUPPORTED, 1194 1195 tr ("Hard disk format '%ls' does not support dynamic storage " 1196 "creation"), mm.format.raw()); 1197 if ( (aVariant & HardDiskVariant_Fixed) 1198 && !(mm.formatObj->capabilities() & HardDiskFormatCapabilities_CreateDynamic)) 1199 return setError (VBOX_E_NOT_SUPPORTED, 1200 tr ("Hard disk format '%ls' does not support fixed storage " 1195 1201 "creation"), mm.format.raw()); 1196 1202 … … 1205 1211 ComObjPtr <Progress> progress; 1206 1212 progress.createObject(); 1213 /// @todo include fixed/dynamic 1207 1214 HRESULT rc = progress->init (mVirtualBox, static_cast<IHardDisk*>(this), 1208 BstrFmt (tr ("Creating dynamic hard disk storage unit '%ls'"), 1209 m.locationFull.raw()), 1215 (aVariant & HardDiskVariant_Fixed) 1216 ? BstrFmt (tr ("Creating fixed hard disk storage unit '%ls'"), m.locationFull.raw()) 1217 : BstrFmt (tr ("Creating dynamic hard disk storage unit '%ls'"), m.locationFull.raw()), 1210 1218 FALSE /* aCancelable */); 1211 1219 CheckComRCReturnRC (rc); … … 1214 1222 * asynchronously */ 1215 1223 1216 std::auto_ptr <Task> task (new Task (this, progress, Task::CreateDynamic)); 1217 AssertComRCReturnRC (task->autoCaller.rc()); 1218 1219 task->d.size = aLogicalSize; 1220 task->d.variant = aVariant; 1221 1222 rc = task->startThread(); 1223 CheckComRCReturnRC (rc); 1224 1225 /* go to Creating state on success */ 1226 m.state = MediaState_Creating; 1227 1228 /* task is now owned by taskThread() so release it */ 1229 task.release(); 1230 1231 /* return progress to the caller */ 1232 progress.queryInterfaceTo (aProgress); 1233 1234 return S_OK; 1235 } 1236 1237 STDMETHODIMP HardDisk::CreateFixedStorage(ULONG64 aLogicalSize, 1238 HardDiskVariant_T aVariant, 1239 IProgress **aProgress) 1240 { 1241 CheckComArgOutPointerValid (aProgress); 1242 1243 AutoCaller autoCaller (this); 1244 CheckComRCReturnRC (autoCaller.rc()); 1245 1246 AutoWriteLock alock (this); 1247 1248 if (!(mm.formatObj->capabilities() & 1249 HardDiskFormatCapabilities_CreateFixed)) 1250 return setError (VBOX_E_NOT_SUPPORTED, 1251 tr ("Hard disk format '%ls' does not support fixed storage " 1252 "creation"), mm.format.raw()); 1253 1254 switch (m.state) 1255 { 1256 case MediaState_NotCreated: 1257 break; 1258 default: 1259 return setStateError(); 1260 } 1261 1262 ComObjPtr <Progress> progress; 1263 progress.createObject(); 1264 HRESULT rc = progress->init (mVirtualBox, static_cast<IHardDisk*>(this), 1265 BstrFmt (tr ("Creating fixed hard disk storage unit '%ls'"), 1266 m.locationFull.raw()), 1267 FALSE /* aCancelable */); 1268 CheckComRCReturnRC (rc); 1269 1270 /* setup task object and thread to carry out the operation 1271 * asynchronously */ 1272 1273 std::auto_ptr <Task> task (new Task (this, progress, Task::CreateFixed)); 1224 std::auto_ptr <Task> task (new Task (this, progress, Task::CreateBase)); 1274 1225 AssertComRCReturnRC (task->autoCaller.rc()); 1275 1226 … … 2987 2938 2988 2939 /* check the type */ 2989 VDIMAGETYPE type;2990 vrc = VDGetImage Type (hdd, 0, &type);2940 unsigned uImageFlags; 2941 vrc = VDGetImageFlags (hdd, 0, &uImageFlags); 2991 2942 ComAssertRCThrow (vrc, E_FAIL); 2992 2943 2993 if ( type == VD_IMAGE_TYPE_DIFF)2944 if (uImageFlags & VD_IMAGE_FLAGS_DIFF) 2994 2945 { 2995 2946 RTUUID parentId; … … 3397 3348 //////////////////////////////////////////////////////////////////////// 3398 3349 3399 case Task::CreateDynamic: 3400 case Task::CreateFixed: 3350 case Task::CreateBase: 3401 3351 { 3402 3352 /* The lock is also used as a signal from the task initiator (which … … 3444 3394 3445 3395 vrc = VDCreateBase (hdd, format, location, 3446 task->operation == Task::CreateDynamic ?3447 VD_IMAGE_TYPE_NORMAL :3448 VD_IMAGE_TYPE_FIXED,3449 3396 task->d.size * _1M, 3450 3397 task->d.variant, -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r17965 r17970 1804 1804 allocate a format-specific storage unit at the specified location: 1805 1805 <ul> 1806 <li><link to="IHardDisk::createDynamicStorage"/></li> 1807 <li><link to="IHardDisk::createFixedStorage"/></li> 1806 <li><link to="IHardDisk::createBaseStorage"/></li> 1808 1807 <li><link to="IHardDisk::createDiffStorage"/></li> 1809 1808 </ul> … … 8558 8557 <enum 8559 8558 name="HardDiskVariant" 8560 uuid=" 3bc36e8c-bf7a-4dba-b6cb-df87cdc9cc19"8559 uuid="99334b63-7ed0-4f61-8a7e-7ec3e20dd912" 8561 8560 > 8562 8561 <desc> … … 8579 8578 VMDK streamOptimized image. Special import/export format which is 8580 8579 read-only/append-only. 8580 </desc> 8581 </const> 8582 <const name="Fixed" value="0x1000"> 8583 <desc> 8584 Fixed image. Only allowed for base images. 8585 </desc> 8586 </const> 8587 <const name="Diff" value="0x2000"> 8588 <desc> 8589 Fixed image. Only allowed for base images. 8581 8590 </desc> 8582 8591 </const> … … 8618 8627 <interface 8619 8628 name="IHardDisk" extends="IMedium" 8620 uuid=" a4d391a5-e2b1-474d-824e-2ff668a92d58"8629 uuid="3498d065-dee6-48bf-bcc5-47018fee4f42" 8621 8630 wsmap="managed" 8622 8631 > … … 9157 9166 <!-- storage methods --> 9158 9167 9159 <method name="create DynamicStorage">9160 <desc> 9161 Starts creating a dynamically expanding hard disk storage unit in the9162 background. The previous storage unit created for this object, if9163 any, must first be deleted using <link to="#deleteStorage"/>, otherwise9164 the operation will fail.9168 <method name="createBaseStorage"> 9169 <desc> 9170 Starts creating a hard disk storage unit (fixed/dynamic, according 9171 to the variant flags) in in the background. The previous storage unit 9172 created for this object, if any, must first be deleted using 9173 <link to="#deleteStorage"/>, otherwise the operation will fail. 9165 9174 9166 9175 Before the operation starts, the hard disk is placed in … … 9175 9184 9176 9185 <result name="VBOX_E_NOT_SUPPORTED"> 9177 Dynamicstorage creation operation is not supported. See <link9186 The variant of storage creation operation is not supported. See <link 9178 9187 to="IHardDiskFormat::capabilities"/>. 9179 9188 </result> … … 9181 9190 <param name="logicalSize" type="unsigned long long" dir="in"> 9182 9191 <desc>Maximum logical size of the hard disk in megabytes.</desc> 9183 </param>9184 <param name="variant" type="HardDiskVariant" dir="in">9185 <desc>Exact image variant which should be created.</desc>9186 </param>9187 <param name="progress" type="IProgress" dir="return">9188 <desc>Progress object to track the operation completion.</desc>9189 </param>9190 </method>9191 9192 <method name="createFixedStorage">9193 <desc>9194 Starts creating a fixed-size hard disk storage unit in the background.9195 The previous storage unit created for this object, if9196 any, must be first deleted using <link to="#deleteStorage"/>, otherwise9197 the operation will fail.9198 9199 Before the operation starts, the hard disk is placed to9200 <link to="MediaState_Creating"/> state. If the create operation9201 fails, the media will placed back to <link to="MediaState_NotCreated"/>9202 state.9203 9204 After the returned progress object reports that the operation is9205 successfully complete, the media state will be set to <link9206 to="MediaState_Created"/>, the hard disk will be remembered by this9207 VirtualBox installation and may be attached to virtual machines.9208 9209 <result name="VBOX_E_NOT_SUPPORTED">9210 Fixed storage creation operation is not supported. See9211 <link to="IHardDiskFormat::capabilities"/>.9212 </result>9213 </desc>9214 <param name="logicalSize" type="unsigned long long" dir="in">9215 <desc>Logical size of the hard disk in megabytes.</desc>9216 9192 </param> 9217 9193 <param name="variant" type="HardDiskVariant" dir="in"> -
trunk/src/VBox/Main/include/HardDiskImpl.h
r17825 r17970 108 108 STDMETHOD(SetProperties) (ComSafeArrayIn (IN_BSTR, aNames), 109 109 ComSafeArrayIn (IN_BSTR, aValues)); 110 STDMETHOD(CreateDynamicStorage) (ULONG64 aLogicalSize, 111 HardDiskVariant_T aVariant, 112 IProgress **aProgress); 113 STDMETHOD(CreateFixedStorage) (ULONG64 aLogicalSize, 114 HardDiskVariant_T aVariant, 115 IProgress **aProgress); 110 STDMETHOD(CreateBaseStorage) (ULONG64 aLogicalSize, 111 HardDiskVariant_T aVariant, 112 IProgress **aProgress); 116 113 STDMETHOD(DeleteStorage) (IProgress **aProgress); 117 114 STDMETHOD(CreateDiffStorage) (IHardDisk *aTarget, -
trunk/src/VBox/Main/testcase/tstVBoxAPILinux.cpp
r17825 r17970 314 314 */ 315 315 nsCOMPtr <IProgress> progress; 316 rc = hardDisk->Create DynamicStorage(100, // size in megabytes317 318 316 rc = hardDisk->CreateBaseStorage(100, // size in megabytes 317 HardDiskVariant_Standard, 318 getter_AddRefs(progress)); // optional progress object 319 319 if (NS_FAILED(rc)) 320 320 {
Note:
See TracChangeset
for help on using the changeset viewer.