- Timestamp:
- Mar 5, 2009 2:37:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HardDiskImpl.cpp
r17376 r17401 1447 1447 1448 1448 AutoWriteLock alock (this); 1449 1450 if (mParent.isNull()) 1451 return setError (VBOX_E_NOT_SUPPORTED, 1452 tr ("Hard disk '%ls' is not differencing"), 1453 m.locationFull.raw()); 1449 1454 1450 1455 HRESULT rc = LockWrite (NULL); … … 3550 3555 } 3551 3556 3552 size = VDGetFileSize (hdd, 0);3553 logicalSize = VDGetSize (hdd, 0) / _1M;3557 size = VDGetFileSize (hdd, 1); 3558 logicalSize = VDGetSize (hdd, 1) / _1M; 3554 3559 } 3555 3560 catch (HRESULT aRC) { rc = aRC; } … … 4013 4018 } 4014 4019 4015 size = VDGetFileSize ( hdd, 0);4016 logicalSize = VDGetSize ( hdd, 0) / _1M;4020 size = VDGetFileSize (targetHdd, 0); 4021 logicalSize = VDGetSize (targetHdd, 0) / _1M; 4017 4022 4018 4023 VDDestroy (targetHdd); … … 4157 4162 case Task::Reset: 4158 4163 { 4159 /// @todo 4164 /* The lock is also used as a signal from the task initiator (which 4165 * releases it only after RTThreadCreate()) that we can start the job */ 4166 AutoWriteLock thatLock (that); 4167 4168 /// @todo Below we use a pair of delete/create operations to reset 4169 /// the diff contents but the most efficient way will of course be 4170 /// to add a VDResetDiff() API call 4171 4172 uint64_t size = 0, logicalSize = 0; 4173 4174 try 4175 { 4176 PVBOXHDD hdd; 4177 int vrc = VDCreate (that->mm.vdDiskIfaces, &hdd); 4178 ComAssertRCThrow (vrc, E_FAIL); 4179 4180 Guid id = that->m.id; 4181 Utf8Str format (that->mm.format); 4182 Utf8Str location (that->m.locationFull); 4183 4184 Guid parentId = that->mParent->m.id; 4185 Utf8Str parentFormat (that->mParent->mm.format); 4186 Utf8Str parentLocation (that->mParent->m.locationFull); 4187 4188 Assert (that->m.state == MediaState_LockedWrite); 4189 4190 /* unlock before the potentially lengthy operation */ 4191 thatLock.leave(); 4192 4193 try 4194 { 4195 /* first, delete the storage unit */ 4196 vrc = VDOpen (hdd, format, location, 4197 VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_INFO, 4198 that->mm.vdDiskIfaces); 4199 if (RT_SUCCESS (vrc)) 4200 vrc = VDClose (hdd, true /* fDelete */); 4201 4202 if (RT_FAILURE (vrc)) 4203 { 4204 throw setError (E_FAIL, 4205 tr ("Could not delete the hard disk storage " 4206 "unit '%s'%s"), 4207 location.raw(), that->vdError (vrc).raw()); 4208 } 4209 4210 /* next, create it again */ 4211 vrc = VDOpen (hdd, parentFormat, parentLocation, 4212 VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_INFO, 4213 that->mm.vdDiskIfaces); 4214 if (RT_FAILURE (vrc)) 4215 { 4216 throw setError (E_FAIL, 4217 tr ("Could not open the hard disk storage " 4218 "unit '%s'%s"), 4219 parentLocation.raw(), that->vdError (vrc).raw()); 4220 } 4221 4222 /* needed for vdProgressCallback */ 4223 that->mm.vdProgress = task->progress; 4224 4225 vrc = VDCreateDiff (hdd, format, location, 4226 VD_IMAGE_FLAGS_NONE, 4227 NULL, id.raw(), 4228 parentId.raw(), 4229 VD_OPEN_FLAGS_NORMAL, 4230 that->mm.vdDiskIfaces, 4231 that->mm.vdDiskIfaces); 4232 4233 that->mm.vdProgress = NULL; 4234 4235 if (RT_FAILURE (vrc)) 4236 { 4237 throw setError (E_FAIL, 4238 tr ("Could not create the differencing hard disk " 4239 "storage unit '%s'%s"), 4240 location.raw(), that->vdError (vrc).raw()); 4241 } 4242 4243 size = VDGetFileSize (hdd, 1); 4244 logicalSize = VDGetSize (hdd, 1) / _1M; 4245 } 4246 catch (HRESULT aRC) { rc = aRC; } 4247 4248 VDDestroy (hdd); 4249 } 4250 catch (HRESULT aRC) { rc = aRC; } 4251 4252 thatLock.enter(); 4253 4254 that->m.size = size; 4255 that->mm.logicalSize = logicalSize; 4160 4256 4161 4257 if (isAsync)
Note:
See TracChangeset
for help on using the changeset viewer.