Changeset 37558 in vbox
- Timestamp:
- Jun 20, 2011 2:44:35 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 72399
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp
r37555 r37558 454 454 AutoWriteLock trgLock(d->pTrgMachine COMMA_LOCKVAL_SRC_POS); 455 455 456 MultiResultrc = S_OK;456 HRESULT rc = S_OK; 457 457 458 458 /* … … 587 587 } 588 588 589 /* Start creating the clone. */590 ComObjPtr<Medium> pTarget;591 rc = pTarget.createObject();592 if (FAILED(rc)) throw rc;593 594 589 /* Check if this medium comes from the snapshot folder, if 595 590 * so, put it there in the cloned machine as well. … … 605 600 strFile = Utf8StrFmt("%s%c%lS", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, bstrSrcName.raw()); 606 601 602 /* Start creating the clone. */ 603 ComObjPtr<Medium> pTarget; 604 rc = pTarget.createObject(); 605 if (FAILED(rc)) throw rc; 606 607 607 rc = pTarget->init(p->mParent, 608 608 Utf8Str(bstrSrcFormat), 609 609 strFile, 610 d->pTrgMachine->mData->mUuid, /*media registry */611 NULL 610 Guid(), /* empty media registry */ 611 NULL /* llRegistriesThatNeedSaving */); 612 612 if (FAILED(rc)) throw rc; 613 613 … … 638 638 } 639 639 640 /* Get the medium type from the source and set it to the 641 * new medium. */ 642 MediumType_T type; 643 rc = pMedium->COMGETTER(Type)(&type); 644 if (FAILED(rc)) throw rc; 645 rc = pTarget->COMSETTER(Type)(type); 646 if (FAILED(rc)) throw rc; 640 647 map.insert(TStrMediumPair(Utf8Str(bstrSrcId), pTarget)); 641 648 … … 654 661 rc = pNewParent->COMGETTER(Id)(bstrSrcId.asOutParam()); 655 662 if (FAILED(rc)) throw rc; 656 GuidList *pllRegistriesThatNeedSaving;657 663 ComObjPtr<Medium> diff; 658 664 diff.createObject(); … … 660 666 pNewParent->getPreferredDiffFormat(), 661 667 Utf8StrFmt("%s%c", strTrgSnapshotFolder.c_str(), RTPATH_DELIMITER), 662 d->pTrgMachine->mData->mUuid,663 NULL); // pllRegistriesThatNeedSaving664 if (FAILED(rc)) throw rc; 665 MediumLockList *pMediumLockList(new MediumLockList()); /* todo: deleteeeeeeeee */668 Guid(), /* empty media registry */ 669 NULL); /* pllRegistriesThatNeedSaving */ 670 if (FAILED(rc)) throw rc; 671 MediumLockList *pMediumLockList(new MediumLockList()); 666 672 rc = diff->createMediumLockList(true /* fFailIfInaccessible */, 667 673 true /* fMediumLockWrite */, … … 691 697 d->updateStorageLists(trgMCF.storageMachine.llStorageControllers, bstrSrcId, bstrTrgId); 692 698 d->updateSnapshotStorageLists(trgMCF.llFirstSnapshot, bstrSrcId, bstrTrgId); 699 /* Make sure all disks know of the new machine uuid. We do this 700 * last to be able to change the medium type above. */ 701 rc = pNewParent->addRegistry(d->pTrgMachine->mData->mUuid, true /* fRecursive */); 702 if (FAILED(rc)) throw rc; 693 703 } 694 704 /* Clone all save state files. */ … … 783 793 } 784 794 785 /* The medias are created before the machine was there. We have to make786 * sure the new medias know of there new parent or we get in trouble787 * when the media registry is saved for this VM, especially in case of788 * difference image chain's. See VirtualBox::saveMediaRegistry.*/789 // for (size_t i = 0; i < newBaseMedias.size(); ++i)790 // {791 // rc = newBaseMedias.at(i)->addRegistry(d->pTrgMachine->mData->mUuid, true /* fRecursive */);792 // if (FAILED(rc)) throw rc;793 // }794 795 795 /* Now save the new configuration to disk. */ 796 796 rc = d->pTrgMachine->SaveSettings(); … … 806 806 } 807 807 808 MultiResult mrc(rc); 808 809 /* Cleanup on failure (CANCEL also) */ 809 810 if (FAILED(rc)) … … 815 816 vrc = RTFileDelete(newFiles.at(i).c_str()); 816 817 if (RT_FAILURE(vrc)) 817 rc = p->setError(VBOX_E_IPRT_ERROR, p->tr("Could not delete file '%s' (%Rrc)"), newFiles.at(i).c_str(), vrc);818 mrc = p->setError(VBOX_E_IPRT_ERROR, p->tr("Could not delete file '%s' (%Rrc)"), newFiles.at(i).c_str(), vrc); 818 819 } 819 820 /* Delete all already created medias. (Reverse, cause there could be … … 826 827 { 827 828 AutoCaller mac(pMedium); 828 if (FAILED(mac.rc())) { continue; rc = mac.rc(); }829 if (FAILED(mac.rc())) { continue; mrc = mac.rc(); } 829 830 AutoReadLock mlock(pMedium COMMA_LOCKVAL_SRC_POS); 830 831 fFile = pMedium->isMediumFormatFile(); … … 835 836 vrc = RTFileDelete(strLoc.c_str()); 836 837 if (RT_FAILURE(vrc)) 837 rc = p->setError(VBOX_E_IPRT_ERROR, p->tr("Could not delete file '%s' (%Rrc)"), strLoc.c_str(), vrc);838 mrc = p->setError(VBOX_E_IPRT_ERROR, p->tr("Could not delete file '%s' (%Rrc)"), strLoc.c_str(), vrc); 838 839 } 839 840 } … … 845 846 } 846 847 847 return rc;848 return mrc; 848 849 } 849 850
Note:
See TracChangeset
for help on using the changeset viewer.