VirtualBox

Changeset 72205 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
May 14, 2018 6:37:50 PM (7 years ago)
Author:
vboxsync
Message:

Main/VirtualBox+Machine: Change medium registry behavior, put new media into global registry until it is associated with a VM. This avoids the annoying glitch that the media registry can forget something unexpectedly if VBoxSVC terminates.

Location:
trunk/src/VBox/Main/src-server
Files:
2 edited

Legend:

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

    r71108 r72205  
    1081710817    // decide which medium registry to use now that the medium is attached:
    1081810818    Guid uuid;
    10819     if (mData->pMachineConfigFile->canHaveOwnMediaRegistry())
     10819    bool fCanHaveOwnMediaRegistry = mData->pMachineConfigFile->canHaveOwnMediaRegistry();
     10820    if (fCanHaveOwnMediaRegistry)
    1082010821        // machine XML is VirtualBox 4.0 or higher:
    1082110822        uuid = i_getId();     // machine UUID
     
    1082310824        uuid = mParent->i_getGlobalRegistryId(); // VirtualBox global registry UUID
    1082410825
     10826    if (fCanHaveOwnMediaRegistry && pMedium->i_removeRegistry(mParent->i_getGlobalRegistryId()))
     10827        mParent->i_markRegistryModified(mParent->i_getGlobalRegistryId());
    1082510828    if (pMedium->i_addRegistry(uuid))
    1082610829        mParent->i_markRegistryModified(uuid);
     
    1083210835        /* Tree lock needed by Medium::addRegistry when recursing. */
    1083310836        AutoReadLock treeLock(&mParent->i_getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
     10837        if (fCanHaveOwnMediaRegistry && pMedium->i_removeRegistryRecursive(mParent->i_getGlobalRegistryId()))
     10838        {
     10839            treeLock.release();
     10840            mParent->i_markRegistryModified(mParent->i_getGlobalRegistryId());
     10841            treeLock.acquire();
     10842        }
    1083410843        if (pBase->i_addRegistryRecursive(uuid))
    1083510844        {
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r69500 r72205  
    43824382    AssertComRCReturnRC(mediumCaller.rc());
    43834383
     4384    bool fAddToGlobalRegistry = false;
    43844385    const char *pszDevType = NULL;
     4386    Guid regId;
    43854387    ObjectsList<Medium> *pall = NULL;
    43864388    DeviceType_T devType;
     
    43884390        AutoReadLock mediumLock(pMedium COMMA_LOCKVAL_SRC_POS);
    43894391        devType = pMedium->i_getDeviceType();
     4392
     4393        if (!pMedium->i_getFirstRegistryMachineId(regId))
     4394            fAddToGlobalRegistry = true;
    43904395    }
    43914396    switch (devType)
     
    44624467        Assert(!i_getMediaTreeLockHandle().isWriteLockOnCurrentThread());
    44634468        *ppMedium = pDupMedium;
     4469    }
     4470
     4471    if (fAddToGlobalRegistry)
     4472    {
     4473        AutoWriteLock mediumLock(pMedium COMMA_LOCKVAL_SRC_POS);
     4474        if (pMedium->i_addRegistry(m->uuidMediaRegistry))
     4475            i_markRegistryModified(m->uuidMediaRegistry);
    44644476    }
    44654477
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