Changeset 56577 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Jun 22, 2015 3:08:04 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp
r56563 r56577 46 46 { 47 47 RTCList<MEDIUMTASK> chain; 48 DeviceType_T devType; 48 49 bool fCreateDiffs; 49 50 bool fAttachLinked; … … 270 271 if (FAILED(rc)) return rc; 271 272 272 /* Only harddisk's are of interest. */ 273 if (type != DeviceType_HardDisk) 273 /* Only harddisks and floppies are of interest. */ 274 if ( type != DeviceType_HardDisk 275 && type != DeviceType_Floppy) 274 276 continue; 275 277 … … 278 280 rc = pAtt->COMGETTER(Medium)(pSrcMedium.asOutParam()); 279 281 if (FAILED(rc)) return rc; 282 280 283 if (pSrcMedium.isNull()) 281 284 continue; … … 284 287 * contain one image only. */ 285 288 MEDIUMTASKCHAIN mtc; 289 mtc.devType = type; 286 290 mtc.fCreateDiffs = fCreateDiffs; 287 291 mtc.fAttachLinked = fAttachLinked; … … 377 381 if (FAILED(rc)) return rc; 378 382 379 /* Only harddisk's are of interest. */ 380 if (type != DeviceType_HardDisk) 383 /* Only harddisks and floppies are of interest. */ 384 if ( type != DeviceType_HardDisk 385 && type != DeviceType_Floppy) 381 386 continue; 382 387 … … 390 395 391 396 MEDIUMTASKCHAIN mtc; 397 mtc.devType = type; 392 398 mtc.fCreateDiffs = fCreateDiffs; 393 399 mtc.fAttachLinked = fAttachLinked; … … 520 526 if (FAILED(rc)) return rc; 521 527 522 /* Only harddisk's are of interest. */ 523 if (type != DeviceType_HardDisk) 528 /* Only harddisks and floppies are of interest. */ 529 if ( type != DeviceType_HardDisk 530 && type != DeviceType_Floppy) 524 531 continue; 525 532 … … 528 535 rc = pAtt->COMGETTER(Medium)(pSrcMedium.asOutParam()); 529 536 if (FAILED(rc)) return rc; 537 530 538 if (pSrcMedium.isNull()) 531 539 continue; … … 535 543 * will not create a full copy of the base/child relationship.) */ 536 544 MEDIUMTASKCHAIN mtc; 545 mtc.devType = type; 537 546 mtc.fCreateDiffs = fCreateDiffs; 538 547 mtc.fAttachLinked = fAttachLinked; … … 646 655 ++it4) 647 656 { 648 if ( it4->deviceType == DeviceType_HardDisk 657 if ( ( it4->deviceType == DeviceType_HardDisk 658 || it4->deviceType == DeviceType_Floppy) 649 659 && it4->uuid == bstrOldId) 650 660 { … … 996 1006 /* Reset media registry. */ 997 1007 trgMCF.mediaRegistry.llHardDisks.clear(); 1008 trgMCF.mediaRegistry.llDvdImages.clear(); 1009 trgMCF.mediaRegistry.llFloppyImages.clear(); 998 1010 /* If we got a valid snapshot id, replace the hardware/storage section 999 1011 * with the stuff from the snapshot. */ … … 1147 1159 /* Default format? */ 1148 1160 Utf8Str strDefaultFormat; 1149 p->mParent->i_getDefaultHardDiskFormat(strDefaultFormat); 1161 if (mtc.devType == DeviceType_HardDisk) 1162 p->mParent->i_getDefaultHardDiskFormat(strDefaultFormat); 1163 else 1164 strDefaultFormat = "RAW"; 1165 1150 1166 Bstr bstrSrcFormat(strDefaultFormat); 1151 1167 … … 1225 1241 strFile, 1226 1242 Guid::Empty /* empty media registry */, 1227 DeviceType_HardDisk);1243 mtc.devType); 1228 1244 if (FAILED(rc)) throw rc; 1229 1245 … … 1231 1247 pTarget->i_updateId(newId); 1232 1248 1233 srcLock.release();1234 1249 /* Do the disk cloning. */ 1235 1250 ComPtr<IProgress> progress2; 1236 1251 1237 1252 ComObjPtr<Medium> pLMedium = static_cast<Medium*>((IMedium*)pMedium); 1253 srcLock.release(); 1238 1254 rc = pLMedium->i_cloneToEx(pTarget, 1239 1255 srcVar, … … 1242 1258 uSrcParentIdx, 1243 1259 uTrgParentIdx); 1260 srcLock.acquire(); 1244 1261 if (FAILED(rc)) throw rc; 1245 1262 1246 1263 /* Wait until the async process has finished. */ 1264 srcLock.release(); 1247 1265 rc = d->pProgress->WaitForAsyncProgressCompletion(progress2); 1248 1266 srcLock.acquire(); … … 1264 1282 rc = pMedium->COMGETTER(Type)(&type); 1265 1283 if (FAILED(rc)) throw rc; 1284 trgLock.release(); 1285 srcLock.release(); 1266 1286 rc = pTarget->COMSETTER(Type)(type); 1287 srcLock.acquire(); 1288 trgLock.acquire(); 1267 1289 if (FAILED(rc)) throw rc; 1268 1290 map.insert(TStrMediumPair(Utf8Str(bstrSrcId), pTarget)); 1269 /* register the new harddisk*/1291 /* register the new medium */ 1270 1292 { 1271 1293 AutoWriteLock tlock(p->mParent->i_getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 1272 1294 rc = p->mParent->i_registerMedium(pTarget, &pTarget, 1273 tlock);1295 tlock); 1274 1296 if (FAILED(rc)) throw rc; 1275 1297 } … … 1463 1485 catch (HRESULT rc2) 1464 1486 { 1487 /* Error handling code only works correctly without locks held. */ 1488 trgLock.release(); 1489 srcLock.release(); 1465 1490 rc = rc2; 1466 1491 } … … 1488 1513 const ComObjPtr<Medium> &pMedium = newMedia.at(i - 1); 1489 1514 mrc = pMedium->i_deleteStorage(NULL /* aProgress */, 1490 true /* aWait */);1515 true /* aWait */); 1491 1516 pMedium->Close(); 1492 1517 }
Note:
See TracChangeset
for help on using the changeset viewer.