VirtualBox

Changeset 44029 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Dec 4, 2012 8:07:07 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
82453
Message:

Main/Medium: fix logic for updating image UUID and parent UUID so that arbitrary medium hierarchies (potentially with overlaps with known media) can be opened/fixed up to use their own UUIDs

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

Legend:

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

    r43915 r44029  
    56285628                 * be created for diff images. Only an overly smart user might
    56295629                 * manually create this case. Too bad for him. */
    5630                 if (   isImport
     5630                if (   (isImport || fSetParentId)
    56315631                    && !(uImageFlags & VD_VMDK_IMAGE_FLAGS_STREAM_OPTIMIZED))
    56325632                {
     
    56385638                     * MediumState_Inaccessible) */
    56395639
    5640                     Guid id = parentId;
    56415640                    ComObjPtr<Medium> pParent;
    5642                     rc = m->pVirtualBox->findHardDiskById(id, false /* aSetError */, &pParent);
     5641                    if (RTUuidIsNull(&parentId))
     5642                        rc = VBOX_E_OBJECT_NOT_FOUND;
     5643                    else
     5644                        rc = m->pVirtualBox->findHardDiskById(Guid(parentId), false /* aSetError */, &pParent);
    56435645                    if (FAILED(rc))
    56445646                    {
    5645                         lastAccessError = Utf8StrFmt(
    5646                                 tr("Parent medium with UUID {%RTuuid} of the medium '%s' is not found in the media registry ('%s')"),
    5647                                 &parentId, location.c_str(),
    5648                                 m->pVirtualBox->settingsFilePath().c_str());
    5649                         throw S_OK;
     5647                        if (fSetImageId && !fSetParentId)
     5648                        {
     5649                            /* If the image UUID gets changed for an existing
     5650                             * image then the parent UUID can be stale. In such
     5651                             * cases clear the parent information. The parent
     5652                             * information may/will be re-set later if the
     5653                             * API client wants to adjust a complete medium
     5654                             * hierarchy one by one. */
     5655                            rc = S_OK;
     5656                            alock.acquire();
     5657                            RTUuidClear(&parentId);
     5658                            vrc = VDSetParentUuid(hdd, 0, &parentId);
     5659                            alock.release();
     5660                            ComAssertRCThrow(vrc, E_FAIL);
     5661                        }
     5662                        else
     5663                        {
     5664                            lastAccessError = Utf8StrFmt(tr("Parent medium with UUID {%RTuuid} of the medium '%s' is not found in the media registry ('%s')"),
     5665                                                         &parentId, location.c_str(),
     5666                                                         m->pVirtualBox->settingsFilePath().c_str());
     5667                            throw S_OK;
     5668                        }
    56505669                    }
    56515670
     
    56535672                    treeLock.acquire();
    56545673
    5655                     Assert(m->pParent.isNull());
    5656                     m->pParent = pParent;
    5657                     m->pParent->m->llChildren.push_back(this);
     5674                    if (m->pParent)
     5675                        deparent();
     5676                    setParent(pParent);
    56585677
    56595678                    treeLock.release();
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r43907 r44029  
    19781978            return setError(E_INVALIDARG, "Device type must be HardDisk, DVD or Floppy %d", deviceType);
    19791979    }
    1980 
    19811980
    19821981    if (pMedium.isNull())
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