VirtualBox

Changeset 29036 in vbox for trunk


Ignore:
Timestamp:
May 4, 2010 2:54:12 PM (15 years ago)
Author:
vboxsync
Message:

Main/Snapshot: handle late failures more gracefully when the actual merging succeeded but something else failed. If the merge source is gone assume the merge worked and update the snapshot accordingly. Avoids inaccessible VM configs due to referring to an already gone image. Small additional cleanup with handling the flag whether VirtualBox.xml needs to be saved - do not depend on getting the "OR" done by the called method, do it explicitly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/SnapshotImpl.cpp

    r28875 r29036  
    2323#include "MachineImpl.h"
    2424#include "MediumImpl.h"
     25#include "MediumFormatImpl.h"
    2526#include "Global.h"
    2627#include "ProgressImpl.h"
     
    24742475                    /* No need to hold the lock any longer. */
    24752476                    mLock.release();
     2477                    bool fNeedsSave = false;
    24762478                    rc = pMedium->deleteStorage(&aTask.pProgress,
    24772479                                                true /* aWait */,
    2478                                                 &fNeedsSaveSettings);
     2480                                                &fNeedsSave);
     2481                    fNeedsSaveSettings |= fNeedsSave;
    24792482                    if (FAILED(rc))
    24802483                        throw rc;
     
    24862489            else
    24872490            {
     2491                bool fNeedsSave = false;
    24882492                if (it->mfNeedsOnlineMerge)
    24892493                {
     
    25042508                                           it->mpMediumLockList,
    25052509                                           aTask.pProgress,
    2506                                            &fNeedsSaveSettings);
     2510                                           &fNeedsSave);
    25072511                }
    25082512                else
     
    25162520                                               &aTask.pProgress,
    25172521                                               true /* aWait */,
    2518                                                &fNeedsSaveSettings);
     2522                                               &fNeedsSave);
    25192523                }
    2520 
     2524                fNeedsSaveSettings |= fNeedsSave;
     2525
     2526                // If the merge failed, we need to do our best to have a usable
     2527                // VM configuration afterwards. The return code doesn't tell
     2528                // whether the merge completed and so we have to check if the
     2529                // source medium (diff images are always file based at the
     2530                // moment) is still there or not. Be careful not to lose the
     2531                // error code below, before the "Delayed failure exit".
    25212532                if (FAILED(rc))
    2522                     throw rc;
     2533                {
     2534                    AutoReadLock mlock(it->mpSource COMMA_LOCKVAL_SRC_POS);
     2535                    const ComObjPtr<MediumFormat> &sourceFormat = it->mpSource->getMediumFormat();
     2536                    // No medium format description? get out of here.
     2537                    if (sourceFormat.isNull())
     2538                        throw rc;
     2539                    // Diff medium not backed by a file - cannot get status so
     2540                    // be pessimistic.
     2541                    if (!(sourceFormat->capabilities() & MediumFormatCapabilities_File))
     2542                        throw rc;
     2543                    const Utf8Str &loc = it->mpSource->getLocationFull();
     2544                    // Source medium is still there, so merge failed early.
     2545                    if (RTFileExists(loc.raw()))
     2546                        throw rc;
     2547
     2548                    // Source medium is gone. Assume the merge succeeded and
     2549                    // thus it's safe to remove the attachment. We use the
     2550                    // "Delayed failure exit" below.
     2551                }
    25232552
    25242553                // need to change the medium attachment for backward merges
     
    25832612            fMachineSettingsChanged = true;
    25842613
    2585             /* prevent from calling cancelDeleteSnapshotMedium() */
     2614            // prevent calling cancelDeleteSnapshotMedium() for this attachment
    25862615            it = toDelete.erase(it);
     2616
     2617            // Delayed failure exit when the merge cleanup failed but the
     2618            // merge actually succeeded.
     2619            if (FAILED(rc))
     2620                throw rc;
    25872621        }
    25882622
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