VirtualBox

Changeset 358 in vbox for trunk


Ignore:
Timestamp:
Jan 26, 2007 2:53:21 PM (18 years ago)
Author:
vboxsync
Message:

Main: Hard disk consistensy errors such as UUID mismatch are now also returned through the lastAccessError property, not through the HRESULT of getAccessible() (because such conditions are not fatal and can be retried later).

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

Legend:

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

    r300 r358  
    11881188        {
    11891189            Bstr loc;
    1190             hdd->COMGETTER(Location)(loc.asOutParam());
     1190            hdd->COMGETTER(Location) (loc.asOutParam());
     1191            Bstr errMsg;
     1192            hdd->COMGETTER(LastAccessError) (errMsg.asOutParam());
    11911193            return setError (E_FAIL,
    1192                 tr ("VM cannot start because the hard disk '%ls' is not accessible"),
    1193                 loc.raw());
     1194                tr ("VM cannot start because the hard disk '%ls' is not accessible "
     1195                    "(%ls)"),
     1196                loc.raw(), errMsg.raw());
    11941197        }
    11951198    }
     
    12091212            Bstr filePath;
    12101213            dvdImage->COMGETTER(FilePath)(filePath.asOutParam());
     1214            /// @todo (r=dmik) grab the last access error once
     1215            //  IDVDImage::lastAccessError is there
    12111216            return setError (E_FAIL,
    12121217                tr ("VM cannot start because the DVD image '%ls' is not accessible"),
     
    12291234            Bstr filePath;
    12301235            floppyImage->COMGETTER(FilePath)(filePath.asOutParam());
     1236            /// @todo (r=dmik) grab the last access error once
     1237            //  IDVDImage::lastAccessError is there
    12311238            return setError (E_FAIL,
    12321239                tr ("VM cannot start because the floppy image '%ls' is not accessible"),
  • trunk/src/VBox/Main/HardDiskImpl.cpp

    r351 r358  
    12651265        CheckComRCBreakRC (rc);
    12661266
     1267        Assert (mId.isEmpty());
     1268       
    12671269        if (aFilePath && *aFilePath)
    12681270        {
     
    12731275             * it is the only way to get the UUID of the existing VDI and
    12741276             * initialize the vital mId property. */
    1275             rc = queryInformation (NULL);
     1277            Bstr errMsg;
     1278            rc = queryInformation (&errMsg);
     1279            if (SUCCEEDED (rc))
     1280            {
     1281                /* We are constructing a new HVirtualDiskImage object. If there
     1282                 * is a fatal accessibility error (we cannot read image UUID),
     1283                 * we have to fail. We do so even on non-fatal errors as well,
     1284                 * because it's not worth to keep going with the inaccessible
     1285                 * image from the very beginning (when nothing else depends on
     1286                 * it yet). */
     1287                if (!errMsg.isNull())
     1288                    rc = setErrorBstr (E_FAIL, errMsg);
     1289            }
    12761290        }
    12771291        else
     
    15561570    {
    15571571        return queryInformation (&aAccessError);
    1558         /* if we fail here, this means something like UUID mismatch.
    1559          * Do nothing, just return the failure (error info is already
    1560          * set by queryInformation()), in hope that one of subsequent
    1561          * attempts to check for acessibility will succeed */
    15621572    }
    15631573
     
    22042214
    22052215    Utf8Str filePath = mFilePathFull;
     2216    Bstr errMsg;
    22062217
    22072218    do
     
    22132224
    22142225        if (VBOX_FAILURE (vrc))
    2215         {
    2216             /* mId is empty only when constructing a HVirtualDiskImage object
    2217              * from an existing file image which UUID is not known. If we can't
    2218              * read it, we have to fail. */
    2219             if (mId.isEmpty())
    2220                 rc = setError (E_FAIL,
    2221                     tr ("Could not open the hard disk image '%s' (%Vrc)"),
    2222                     filePath.raw(), vrc);
    22232226            break;
    2224         }
    22252227
    22262228        if (!mId.isEmpty())
     
    22292231            if (mId != id)
    22302232            {
    2231                 rc = setError (E_FAIL,
     2233                errMsg = Utf8StrFmt (
    22322234                    tr ("Actual UUID {%Vuuid} of the hard disk image '%s' doesn't "
    22332235                        "match UUID {%Vuuid} stored in the registry"),
     
    22482250            if (mParent->id() != parentId)
    22492251            {
    2250                 rc = setError (E_FAIL,
     2252                errMsg = Utf8StrFmt (
    22512253                    tr ("UUID {%Vuuid} of the parent image '%ls' stored in "
    22522254                        "the hard disk image file '%s' doesn't match "
     
    22592261        else if (!parentId.isEmpty())
    22602262        {
    2261             rc = setError (E_FAIL,
     2263            errMsg = Utf8StrFmt (
    22622264                tr ("Hard disk image '%s' is a differencing image and "
    22632265                    "cannot be opened directly"),
     
    23082310    clearBusy();
    23092311   
    2310     if (VBOX_FAILURE (vrc) || FAILED (rc))
    2311     {
    2312         Log (("HVirtualDiskImage::queryInformation(): "
    2313               "WARNING: '%ls' is not accessible (%Vrc) (rc=%08X)\n",
    2314               mFilePathFull.raw(), vrc, rc));
    2315 
    2316         if (VBOX_FAILURE (vrc) && aAccessError)
    2317             *aAccessError =
    2318                 Utf8StrFmt ("Error accessing hard disk image '%ls' (%Vrc)",
    2319                             mFilePathFull.raw(), vrc);
    2320 
     2312    if (FAILED (rc) || VBOX_FAILURE (vrc) || !errMsg.isNull())
     2313    {
     2314        LogWarningFunc (("'%ls' is not accessible "
     2315                         "(rc=%08X, vrc=%Vrc, errMsg='%ls')\n",
     2316                         mFilePathFull.raw(), rc, vrc, errMsg.raw()));
     2317
     2318        if (aAccessError)
     2319        {
     2320            if (!errMsg.isNull())
     2321                *aAccessError = errMsg;
     2322            else if (VBOX_FAILURE (vrc))
     2323                *aAccessError = Utf8StrFmt (
     2324                    tr ("Could not access hard disk image '%ls' (%Vrc)"),
     2325                        mFilePathFull.raw(), vrc);
     2326        }
     2327       
    23212328        /* downgrade to not accessible */
    23222329        mState = Created;
     
    25372544        task->vdi->mState = HVirtualDiskImage::Created;
    25382545        /* update VDI data fields */
    2539         rc = task->vdi->queryInformation (NULL);
    2540         /* complete the progress object */
    2541         task->progress->notifyComplete (rc);
     2546        Bstr errMsg;
     2547        rc = task->vdi->queryInformation (&errMsg);
     2548        /* we want to deliver the access check result to the caller
     2549         * immediately, before he calls HardDisk::GetAccssible() himself. */
     2550        if (SUCCEEDED (rc) && !errMsg.isNull())
     2551            task->progress->notifyCompleteBstr (
     2552                E_FAIL, COM_IIDOF (IVirtualDiskImage), getComponentName(),
     2553                errMsg);
     2554        else
     2555            task->progress->notifyComplete (rc);
    25422556    }
    25432557    else
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