Changeset 38119 in vbox for trunk/src/VBox
- Timestamp:
- Jul 22, 2011 2:57:03 PM (14 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/MachineImplCloneVM.h
r37971 r38119 34 34 protected: 35 35 HRESULT run(); 36 HRESULT createDiffHelper(const ComObjPtr<Medium> &pParent,37 const Utf8Str &strSnapshotFolder,38 RTCList<ComObjPtr<Medium> > *pNewMedia,39 ComObjPtr<Medium> *ppDiff);40 36 void destroy(); 41 37 -
trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp
r38116 r38119 114 114 void updateSnapshotStorageLists(settings::SnapshotsList &sl, const Bstr &bstrOldId, const Bstr &bstrNewId) const; 115 115 void updateStateFile(settings::SnapshotsList &snl, const Guid &id, const Utf8Str &strFile) const; 116 HRESULT createDifferencingMedium(const ComObjPtr<Medium> &pParent, const Utf8Str &strSnapshotFolder, RTCList<ComObjPtr<Medium> > &newMedia, ComObjPtr<Medium> *ppDiff) const; 116 117 static int copyStateFileProgress(unsigned uPercentage, void *pvUser); 117 118 … … 432 433 #endif 433 434 /* Check if there is a "step" in the histogram when going the chain 434 * upwards. If so, we need this image, cause there is another leave435 * upwards. If so, we need this image, cause there is another branch 435 436 * from here in the cloned VM. */ 436 437 if (hist > used) … … 611 612 updateStateFile(it->llChildSnapshots, id, strFile); 612 613 } 614 } 615 616 HRESULT MachineCloneVMPrivate::createDifferencingMedium(const ComObjPtr<Medium> &pParent, const Utf8Str &strSnapshotFolder, RTCList<ComObjPtr<Medium> > &newMedia, ComObjPtr<Medium> *ppDiff) const 617 { 618 HRESULT rc = S_OK; 619 try 620 { 621 Bstr bstrSrcId; 622 rc = pParent->COMGETTER(Id)(bstrSrcId.asOutParam()); 623 if (FAILED(rc)) throw rc; 624 ComObjPtr<Medium> diff; 625 diff.createObject(); 626 rc = diff->init(p->getVirtualBox(), 627 pParent->getPreferredDiffFormat(), 628 Utf8StrFmt("%s%c", strSnapshotFolder.c_str(), RTPATH_DELIMITER), 629 Guid::Empty, /* empty media registry */ 630 NULL); /* pllRegistriesThatNeedSaving */ 631 if (FAILED(rc)) throw rc; 632 MediumLockList *pMediumLockList(new MediumLockList()); 633 rc = diff->createMediumLockList(true /* fFailIfInaccessible */, 634 true /* fMediumLockWrite */, 635 pParent, 636 *pMediumLockList); 637 if (FAILED(rc)) throw rc; 638 rc = pMediumLockList->Lock(); 639 if (FAILED(rc)) throw rc; 640 /* this already registers the new diff image */ 641 rc = pParent->createDiffStorage(diff, MediumVariant_Standard, 642 pMediumLockList, 643 NULL /* aProgress */, 644 true /* aWait */, 645 NULL); // pllRegistriesThatNeedSaving 646 delete pMediumLockList; 647 if (FAILED(rc)) throw rc; 648 /* Remember created medium. */ 649 newMedia.append(diff); 650 *ppDiff = diff; 651 } 652 catch (HRESULT rc2) 653 { 654 rc = rc2; 655 } 656 catch (...) 657 { 658 rc = VirtualBox::handleUnexpectedExceptions(RT_SRC_POS); 659 } 660 661 return rc; 613 662 } 614 663 … … 972 1021 ComObjPtr<Medium> pDiff; 973 1022 /* create the diff under the snapshot medium */ 974 rc = createDiffHelper(pLMedium, strTrgSnapshotFolder,975 &newMedia, &pDiff);1023 rc = d->createDifferencingMedium(pLMedium, strTrgSnapshotFolder, 1024 newMedia, &pDiff); 976 1025 if (FAILED(rc)) throw rc; 977 1026 map.insert(TStrMediumPair(Utf8Str(bstrSrcId), pDiff)); … … 1142 1191 { 1143 1192 ComObjPtr<Medium> pDiff; 1144 rc = createDiffHelper(pNewParent, strTrgSnapshotFolder,1145 &newMedia, &pDiff);1193 rc = d->createDifferencingMedium(pNewParent, strTrgSnapshotFolder, 1194 newMedia, &pDiff); 1146 1195 if (FAILED(rc)) throw rc; 1147 1196 /* diff image has to be used... */ … … 1287 1336 } 1288 1337 1289 HRESULT MachineCloneVM::createDiffHelper(const ComObjPtr<Medium> &pParent,1290 const Utf8Str &strSnapshotFolder,1291 RTCList< ComObjPtr<Medium> > *pNewMedia,1292 ComObjPtr<Medium> *ppDiff)1293 {1294 DPTR(MachineCloneVM);1295 ComObjPtr<Machine> &p = d->p;1296 HRESULT rc = S_OK;1297 1298 try1299 {1300 Bstr bstrSrcId;1301 rc = pParent->COMGETTER(Id)(bstrSrcId.asOutParam());1302 if (FAILED(rc)) throw rc;1303 ComObjPtr<Medium> diff;1304 diff.createObject();1305 rc = diff->init(p->mParent,1306 pParent->getPreferredDiffFormat(),1307 Utf8StrFmt("%s%c", strSnapshotFolder.c_str(), RTPATH_DELIMITER),1308 Guid::Empty, /* empty media registry */1309 NULL); /* pllRegistriesThatNeedSaving */1310 if (FAILED(rc)) throw rc;1311 MediumLockList *pMediumLockList(new MediumLockList());1312 rc = diff->createMediumLockList(true /* fFailIfInaccessible */,1313 true /* fMediumLockWrite */,1314 pParent,1315 *pMediumLockList);1316 if (FAILED(rc)) throw rc;1317 rc = pMediumLockList->Lock();1318 if (FAILED(rc)) throw rc;1319 /* this already registers the new diff image */1320 rc = pParent->createDiffStorage(diff, MediumVariant_Standard,1321 pMediumLockList,1322 NULL /* aProgress */,1323 true /* aWait */,1324 NULL); // pllRegistriesThatNeedSaving1325 delete pMediumLockList;1326 if (FAILED(rc)) throw rc;1327 /* Remember created medium. */1328 pNewMedia->append(diff);1329 *ppDiff = diff;1330 }1331 catch (HRESULT rc2)1332 {1333 rc = rc2;1334 }1335 catch (...)1336 {1337 rc = VirtualBox::handleUnexpectedExceptions(RT_SRC_POS);1338 }1339 1340 return rc;1341 }1342 1343 1338 void MachineCloneVM::destroy() 1344 1339 {
Note:
See TracChangeset
for help on using the changeset viewer.