VirtualBox

Ignore:
Timestamp:
Jun 23, 2011 12:38:29 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
72458
Message:

Main-CloneVM: explicitly add the machine registry to every new medium *after* all where created (fix sometimes missing registry entries)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp

    r37604 r37612  
    719719            d->updateStorageLists(trgMCF.storageMachine.llStorageControllers, bstrSrcId, bstrTrgId);
    720720            d->updateSnapshotStorageLists(trgMCF.llFirstSnapshot, bstrSrcId, bstrTrgId);
    721             /* Make sure all parent disks know of the new machine uuid. We do
    722              * this last to be able to change the medium type above. */
    723             rc = pNewParent->addRegistry(d->pTrgMachine->mData->mUuid, false /* fRecursive */);
    724             if (FAILED(rc)) throw rc;
     721        }
     722        /* Make sure all disks know of the new machine uuid. We do this last to
     723         * be able to change the medium type above. */
     724        for (size_t i = newMedias.size(); i > 0; --i)
     725        {
     726            ComObjPtr<Medium> &pMedium = newMedias.at(i - 1);
     727            AutoCaller mac(pMedium);
     728            if (FAILED(mac.rc())) throw mac.rc();
     729            AutoWriteLock mlock(pMedium COMMA_LOCKVAL_SRC_POS);
     730            pMedium->addRegistry(d->pTrgMachine->mData->mUuid, false /* fRecursive */);
    725731        }
    726732        /* Check if a snapshot folder is necessary and if so doesn't already
     
    760766        }
    761767
    762         if (false)
    763 //        if (!d->pOldMachineState.isNull())
    764         {
    765             SafeIfaceArray<IMediumAttachment> sfaAttachments;
    766             rc = d->pOldMachineState->COMGETTER(MediumAttachments)(ComSafeArrayAsOutParam(sfaAttachments));
    767             if (FAILED(rc)) throw rc;
    768             for (size_t a = 0; a < sfaAttachments.size(); ++a)
    769             {
    770                 const ComPtr<IMediumAttachment> &pAtt = sfaAttachments[a];
    771                 DeviceType_T type;
    772                 rc = pAtt->COMGETTER(Type)(&type);
    773                 if (FAILED(rc)) throw rc;
    774 
    775                 /* Only harddisk's are of interest. */
    776                 if (type != DeviceType_HardDisk)
    777                     continue;
    778 
    779                 /* Valid medium attached? */
    780                 ComPtr<IMedium> pSrcMedium;
    781                 rc = pAtt->COMGETTER(Medium)(pSrcMedium.asOutParam());
    782                 if (FAILED(rc)) throw rc;
    783                 if (pSrcMedium.isNull())
    784                     continue;
    785 
    786 //                ComObjPtr<Medium> pMedium = static_cast<Medium*>((IMedium*)pSrcMedium);
    787 //                ComObjPtr<Medium> diff;
    788 //                diff.createObject();
    789                 // store this diff in the same registry as the parent
    790 //                Guid uuidRegistryParent;
    791 //                if (!medium->getFirstRegistryMachineId(uuidRegistryParent))
    792 //                {
    793                     // parent image has no registry: this can happen if we're attaching a new immutable
    794                     // image that has not yet been attached (medium then points to the base and we're
    795                     // creating the diff image for the immutable, and the parent is not yet registered);
    796                     // put the parent in the machine registry then
    797 //                    addMediumToRegistry(medium, llRegistriesThatNeedSaving, &uuidRegistryParent);
    798 //                }
    799 //                rc = diff->init(mParent,
    800 //                                pMedium->getPreferredDiffFormat(),
    801 //                                strFullSnapshotFolder.append(RTPATH_SLASH_STR),
    802 //                                uuidRegistryParent,
    803 //                                pllRegistriesThatNeedSaving);
    804 //                if (FAILED(rc)) throw rc;
    805 //
    806 //                rc = pMedium->createDiffStorage(diff, MediumVariant_Standard,
    807 //                                                pMediumLockList,
    808 //                                                NULL /* aProgress */,
    809 //                                                true /* aWait */,
    810 //                                                pllRegistriesThatNeedSaving);
    811             }
    812         }
    813 
    814768        {
    815769            rc = d->pProgress->SetNextOperation(BstrFmt(p->tr("Create Machine Clone '%s' ..."), trgMCF.machineUserData.strName.c_str()).raw(), 1);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette