VirtualBox

Changeset 37985 in vbox for trunk/src


Ignore:
Timestamp:
Jul 15, 2011 3:04:39 PM (13 years ago)
Author:
vboxsync
Message:

Main/Machine: fix the medium registry logic for linked clones. Previously creating a linked clone of a snapshot of a linked clone didn't result in the right medium registry update.

Location:
trunk/src/VBox/Main
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r37928 r37985  
    279279    HRESULT saveSettings();
    280280
    281     void addGuidToListUniquely(GuidList &llRegistriesThatNeedSaving, const Guid &uuid);
     281    static void addGuidToListUniquely(GuidList &llRegistriesThatNeedSaving, const Guid &uuid);
    282282    HRESULT saveRegistries(const GuidList &llRegistriesThatNeedSaving);
    283283
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r37971 r37985  
    62606260        optList = com::SafeArray<CloneOptions_T>(ComSafeArrayInArg(options)).toList();
    62616261
    6262     AssertReturn(!optList.contains(CloneOptions_Link) || (isSnapshotMachine() && mode == CloneMode_MachineState), E_INVALIDARG);
     6262    if (optList.contains(CloneOptions_Link))
     6263    {
     6264        if (!isSnapshotMachine())
     6265            return setError(E_INVALIDARG,
     6266                            tr("Linked clone can only be created from a snapshot\n"));
     6267        if (mode != CloneMode_MachineState)
     6268            return setError(E_INVALIDARG,
     6269                            tr("Linked clone can only be created for a single machine state\n"));
     6270    }
    62636271    AssertReturn(!(optList.contains(CloneOptions_KeepAllMACs) && optList.contains(CloneOptions_KeepNATMACs)), E_INVALIDARG);
    62646272
     
    92029210    if (pMedium->addRegistry(uuid, false /* fRecurse */))
    92039211        // registry actually changed:
    9204         mParent->addGuidToListUniquely(llRegistriesThatNeedSaving, uuid);
     9212        VirtualBox::addGuidToListUniquely(llRegistriesThatNeedSaving, uuid);
    92059213
    92069214    if (puuid)
  • trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp

    r37971 r37985  
    596596        typedef std::pair<Utf8Str, ComObjPtr<Medium> > TStrMediumPair;
    597597        TStrMediumMap map;
     598        GuidList llRegistriesThatNeedSaving;
    598599        size_t cDisks = 0;
    599600        for (size_t i = 0; i < d->llMedias.size(); ++i)
     
    812813            if (FAILED(mac.rc())) throw mac.rc();
    813814            AutoWriteLock mlock(pMedium COMMA_LOCKVAL_SRC_POS);
    814             pMedium->addRegistry(d->options.contains(CloneOptions_Link) ? d->pSrcMachine->mData->mUuid : d->pTrgMachine->mData->mUuid, false /* fRecurse */);
     815            Guid uuid = d->pTrgMachine->mData->mUuid;
     816            if (d->options.contains(CloneOptions_Link))
     817            {
     818                ComObjPtr<Medium> pParent = pMedium->getParent();
     819                mlock.release();
     820                if (!pParent.isNull())
     821                {
     822                    AutoCaller mac2(pParent);
     823                    if (FAILED(mac2.rc())) throw mac2.rc();
     824                    AutoReadLock mlock2(pParent COMMA_LOCKVAL_SRC_POS);
     825                    if (pParent->getFirstRegistryMachineId(uuid))
     826                        VirtualBox::addGuidToListUniquely(llRegistriesThatNeedSaving, uuid);
     827                }
     828                mlock.acquire();
     829            }
     830            pMedium->addRegistry(uuid, false /* fRecurse */);
    815831        }
    816832        /* Check if a snapshot folder is necessary and if so doesn't already
     
    867883        if (FAILED(rc)) throw rc;
    868884        trgLock.release();
    869         if (d->options.contains(CloneOptions_Link))
     885        if (!llRegistriesThatNeedSaving.empty())
    870886        {
    871887            srcLock.release();
    872             GuidList llRegistrySrc;
    873             llRegistrySrc.push_back(d->pSrcMachine->mData->mUuid);
    874             rc = p->mParent->saveRegistries(llRegistrySrc);
     888            rc = p->mParent->saveRegistries(llRegistriesThatNeedSaving);
    875889            if (FAILED(rc)) throw rc;
    876890        }
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r37941 r37985  
    32783278         ++it)
    32793279    {
    3280         m->pVirtualBox->addGuidToListUniquely(llRegistryIDs, *it);
     3280        VirtualBox::addGuidToListUniquely(llRegistryIDs, *it);
    32813281    }
    32823282
  • trunk/src/VBox/Main/src-server/SnapshotImpl.cpp

    r37851 r37985  
    19361936        // unconditionally add the parent registry. We do similar in SessionMachine::EndTakingSnapshot
    19371937        // (mParent->saveSettings())
    1938         mParent->addGuidToListUniquely(llRegistriesThatNeedSaving, mParent->getGlobalRegistryId());
     1938        VirtualBox::addGuidToListUniquely(llRegistriesThatNeedSaving, mParent->getGlobalRegistryId());
    19391939
    19401940        // let go of the locks while we're deleting image files below
     
    24802480
    24812481                // machine will need saving now
    2482                 mParent->addGuidToListUniquely(llRegistriesThatNeedSaving, getId());
     2482                VirtualBox::addGuidToListUniquely(llRegistriesThatNeedSaving, getId());
    24832483            }
    24842484        }
     
    26552655
    26562656            // One attachment is merged, must save the settings
    2657             mParent->addGuidToListUniquely(llRegistriesThatNeedSaving, getId());
     2657            VirtualBox::addGuidToListUniquely(llRegistriesThatNeedSaving, getId());
    26582658
    26592659            // prevent calling cancelDeleteSnapshotMedium() for this attachment
     
    26742674            aTask.pSnapshot->uninit();
    26752675
    2676             mParent->addGuidToListUniquely(llRegistriesThatNeedSaving, getId());
     2676            VirtualBox::addGuidToListUniquely(llRegistriesThatNeedSaving, getId());
    26772677        }
    26782678    }
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r37928 r37985  
    38383838                    pMedium->addRegistry(*puuidBetter, true /* fRecurse */);
    38393839                    // 3) and make sure the registry is saved below
    3840                     addGuidToListUniquely(llRegistriesThatNeedSaving, *puuidBetter);
     3840                    VirtualBox::addGuidToListUniquely(llRegistriesThatNeedSaving, *puuidBetter);
    38413841                }
    38423842            }
     
    38603860 * @param uuid
    38613861 */
     3862/* static */
    38623863void VirtualBox::addGuidToListUniquely(GuidList &llRegistriesThatNeedSaving,
    38633864                                       const Guid &uuid)
Note: See TracChangeset for help on using the changeset viewer.

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