VirtualBox

Changeset 27213 in vbox for trunk/src


Ignore:
Timestamp:
Mar 9, 2010 1:03:27 PM (15 years ago)
Author:
vboxsync
Message:

VD: Move the readonly mode change after behind the differencing disk deletion to prevent an inconsistent chain if the mode change fails

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VBoxHDD.cpp

    r27211 r27213  
    20612061        /* Update parent UUID so that image chain is consistent. */
    20622062        RTUUID Uuid;
     2063        PVDIMAGE pImageChild = NULL;
    20632064        if (nImageFrom < nImageTo)
    20642065        {
     
    20882089                AssertRC(rc);
    20892090
    2090                 /* Reopen readonly if neccessary */
    2091                 if (pImageFrom->pNext != pDisk->pLast)
    2092                 {
    2093                     PVDIMAGE pImageChild = pImageFrom->pNext;
    2094 
    2095                     uOpenFlags = pImageChild->Backend->pfnGetOpenFlags(pImageChild->pvBackendData);
    2096                     uOpenFlags |= VD_OPEN_FLAGS_READONLY;
    2097                     rc = pImageChild->Backend->pfnSetOpenFlags(pImageChild->pvBackendData,
    2098                                                                uOpenFlags);
    2099                     /** @todo: What to do if this fails?. Breaking would
    2100                      * prevent the merged images from being removed
    2101                      * from the chain possibly causing inconsistent behavior.
    2102                      */
    2103                     if (RT_FAILURE(rc))
    2104                         break;
    2105                 }
     2091                pImageChild = pImageFrom->pNext;
    21062092            }
    2107         }
    2108 
    2109         /* Make sure destination image is back to read only if necessary. */
    2110         if (pImageTo != pDisk->pLast && pImageFrom != pDisk->pLast)
    2111         {
    2112             uOpenFlags = pImageTo->Backend->pfnGetOpenFlags(pImageTo->pvBackendData);
    2113             uOpenFlags |= VD_OPEN_FLAGS_READONLY;
    2114             rc = pImageTo->Backend->pfnSetOpenFlags(pImageTo->pvBackendData,
    2115                                                     uOpenFlags);
    2116             if (RT_FAILURE(rc))
    2117                 break;
    21182093        }
    21192094
     
    21312106            RTMemFree(pImg);
    21322107            pImg = pTmp;
     2108        }
     2109
     2110        /* Make sure destination image is back to read only if necessary. */
     2111        if (pImageTo != pDisk->pLast)
     2112        {
     2113            uOpenFlags = pImageTo->Backend->pfnGetOpenFlags(pImageTo->pvBackendData);
     2114            uOpenFlags |= VD_OPEN_FLAGS_READONLY;
     2115            rc = pImageTo->Backend->pfnSetOpenFlags(pImageTo->pvBackendData,
     2116                                                    uOpenFlags);
     2117            if (RT_FAILURE(rc))
     2118                break;
     2119        }
     2120
     2121        /*
     2122         * Make sure the child is readonly
     2123         * for the child -> parent merge direction
     2124         * if neccessary.
     2125        */
     2126        if (   nImageFrom > nImageTo
     2127            && pImageChild
     2128            && pImageChild != pDisk->pLast)
     2129        {
     2130            uOpenFlags = pImageChild->Backend->pfnGetOpenFlags(pImageChild->pvBackendData);
     2131            uOpenFlags |= VD_OPEN_FLAGS_READONLY;
     2132            rc = pImageChild->Backend->pfnSetOpenFlags(pImageChild->pvBackendData,
     2133                                                       uOpenFlags);
     2134            if (RT_FAILURE(rc))
     2135                break;
    21332136        }
    21342137    } while (0);
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