Changeset 17970 in vbox for trunk/src/VBox/Main/HardDiskImpl.cpp
- Timestamp:
- Mar 16, 2009 7:08:16 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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,
Note:
See TracChangeset
for help on using the changeset viewer.