VirtualBox

Changeset 24917 in vbox


Ignore:
Timestamp:
Nov 24, 2009 3:45:00 PM (15 years ago)
Author:
vboxsync
Message:

SSM,Main: Fixed error propagation on the target side so that a source side cancellation ends up a s VERR_SSM_CANCELLED instead of VERR_SSM_LOADED_TOO_MUCH.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/ssm.h

    r24895 r24917  
    979979     * @returns VBox status code.
    980980     * @param   pvUser              The user argument.
     981     * @param   fCancelled          True if the operation was cancelled.
    981982     */
    982     DECLCALLBACKMEMBER(int, pfnClose)(void *pvUser);
     983    DECLCALLBACKMEMBER(int, pfnClose)(void *pvUser, bool fCancelled);
    983984
    984985    /** Struct magic + version (SSMSTRMOPS_VERSION). */
  • trunk/src/VBox/Main/ConsoleImplTeleporter.cpp

    r24899 r24917  
    148148    uint32_t    u32Magic;
    149149    /** The size of the data block following this header.
    150      * 0 indicates the end of the stream. */
     150     * 0 indicates the end of the stream, while UINT32_MAX indicates
     151     * cancelation. */
    151152    uint32_t    cb;
    152153} TELEPORTERTCPHDR;
     
    388389                return rc;
    389390            }
    390             if (   Hdr.u32Magic != TELEPORTERTCPHDR_MAGIC
    391                 || Hdr.cb > TELEPORTERTCPHDR_MAX_SIZE)
    392             {
     391
     392            if (RT_UNLIKELY(   Hdr.u32Magic != TELEPORTERTCPHDR_MAGIC
     393                            || Hdr.cb > TELEPORTERTCPHDR_MAX_SIZE
     394                            || Hdr.cb == 0))
     395            {
     396                if (    Hdr.u32Magic == TELEPORTERTCPHDR_MAGIC
     397                    &&  (   Hdr.cb == 0
     398                         || Hdr.cb == UINT32_MAX)
     399                   )
     400                {
     401                    pState->mfEndOfStream = true;
     402                    pState->mcbReadBlock  = 0;
     403                    return Hdr.cb ? VERR_SSM_CANCELLED : VERR_EOF;
     404                }
    393405                pState->mfIOError = true;
    394406                LogRel(("Teleporter/TCP: Invalid block: u32Magic=%#x cb=%#x\n", Hdr.u32Magic, Hdr.cb));
     
    397409
    398410            pState->mcbReadBlock = Hdr.cb;
    399             if (!Hdr.cb)
    400             {
    401                 pState->mfEndOfStream = true;
    402                 return VERR_EOF;
    403             }
    404 
    405411            if (pState->mfStopReading)
    406412                return VERR_EOF;
     
    499505 * @copydoc SSMSTRMOPS::pfnClose
    500506 */
    501 static DECLCALLBACK(int) teleporterTcpOpClose(void *pvUser)
     507static DECLCALLBACK(int) teleporterTcpOpClose(void *pvUser, bool fCancelled)
    502508{
    503509    TeleporterState *pState = (TeleporterState *)pvUser;
     
    505511    if (pState->mfIsSource)
    506512    {
    507         TELEPORTERTCPHDR EofHdr = { TELEPORTERTCPHDR_MAGIC, 0 };
     513        TELEPORTERTCPHDR EofHdr;
     514        EofHdr.u32Magic = TELEPORTERTCPHDR_MAGIC;
     515        EofHdr.cb       = fCancelled ? UINT32_MAX : 0;
    508516        int rc = RTTcpWrite(pState->mhSocket, &EofHdr, sizeof(EofHdr));
    509517        if (RT_SUCCESS(rc))
  • trunk/src/VBox/VMM/SSM.cpp

    r24897 r24917  
    18121812 * @copydoc SSMSTRMOPS::pfnClose
    18131813 */
    1814 static DECLCALLBACK(int) ssmR3FileClose(void *pvUser)
    1815 {
     1814static DECLCALLBACK(int) ssmR3FileClose(void *pvUser, bool fCancelled)
     1815{
     1816    NOREF(fCancelled);
    18161817    return RTFileClose((RTFILE)(uintptr_t)pvUser);
    18171818}
     
    21572158 * @returns VBox status code.
    21582159 * @param   pStrm           The stream handle.
    2159  */
    2160 static int ssmR3StrmClose(PSSMSTRM pStrm)
     2160 * @param   fCancelled      Indicates whether the operation was cancelled or
     2161 *                          not.
     2162 */
     2163static int ssmR3StrmClose(PSSMSTRM pStrm, bool fCancelled)
    21612164{
    21622165    /*
     
    21852188        }
    21862189
    2187         rc = pStrm->pOps->pfnClose(pStrm->pvUser);
     2190        rc = pStrm->pOps->pfnClose(pStrm->pvUser, fCancelled);
    21882191        if (RT_FAILURE(rc))
    21892192            ssmR3StrmSetError(pStrm, rc);
     
    21912194    else
    21922195    {
    2193         rc = pStrm->pOps->pfnClose(pStrm->pvUser);
     2196        rc = pStrm->pOps->pfnClose(pStrm->pvUser, fCancelled);
    21942197        if (RT_FAILURE(rc))
    21952198            ssmR3StrmSetError(pStrm, rc);
     
    41264129     */
    41274130    ssmR3SetCancellable(pVM, pSSM, false);
    4128     int rc = ssmR3StrmClose(&pSSM->Strm);
     4131    int rc = ssmR3StrmClose(&pSSM->Strm, pSSM->rc == VERR_SSM_CANCELLED);
    41294132    if (RT_SUCCESS(rc))
    41304133        rc = pSSM->rc;
     
    52245227    }
    52255228    /* bail out. */
    5226     int rc2 = ssmR3StrmClose(&pSSM->Strm);
     5229    int rc2 = ssmR3StrmClose(&pSSM->Strm, pSSM->rc == VERR_SSM_CANCELLED);
    52275230    RTMemFree(pSSM);
    52285231    rc2 = RTFileDelete(pszFilename);
     
    52755278 * decompressor, for saved file format version 1.
    52765279 *
    5277  * @returns VBox status code.
     5280 * @returns VBox status code. Set pSSM->rc on error.
    52785281 * @param   pvSSM       The SSM handle.
    52795282 * @param   pvBuf       Where to store the compressed data.
     
    52995302            return VINF_SUCCESS;
    53005303        }
    5301         return rc;
     5304        return pSSM->rc = rc;
    53025305    }
    53035306
    53045307    if (pSSM->enmAfter != SSMAFTER_DEBUG_IT)
    53055308        AssertMsgFailed(("SSM: attempted reading more than the unit!\n"));
    5306     return VERR_SSM_LOADED_TOO_MUCH;
     5309    return pSSM->rc = VERR_SSM_LOADED_TOO_MUCH;
    53075310}
    53085311
     
    53105313/**
    53115314 * Internal read worker for reading data from a version 1 unit.
     5315 *
     5316 * @returns VBox status code, pSSM->rc is set on error.
    53125317 *
    53135318 * @param   pSSM            The saved state handle.
     
    53965401 * Read reader that keep works the progress indicator and unit offset.
    53975402 *
    5398  * Does not set SSM::rc.
    5399  *
    5400  * @returns VBox status code.
     5403 * @returns VBox status code. Does NOT set pSSM->rc.
    54015404 * @param   pSSM            The saved state handle.
    54025405 * @param   pvBuf           Where to put the bits
     
    54135416    }
    54145417
    5415     /** @todo weed out lazy saving */
     5418    if (rc == VERR_SSM_CANCELLED)
     5419        return rc;
     5420
    54165421    if (pSSM->enmAfter != SSMAFTER_DEBUG_IT)
    54175422        AssertMsgFailed(("SSM: attempted reading more than the unit!\n"));
     
    54235428 * Reads and checks the LZF "header".
    54245429 *
    5425  * @returns VBox status code.
     5430 * @returns VBox status code. Sets pSSM->rc on error.
    54265431 * @param   pSSM            The saved state handle..
    54275432 * @param   pcbDecompr      Where to store the size of the decompressed data.
     
    54385443    int rc = ssmR3DataReadV2Raw(pSSM, &cKB, 1);
    54395444    if (RT_FAILURE(rc))
    5440         return rc;
     5445        return pSSM->rc = rc;
    54415446    pSSM->u.Read.cbRecLeft -= sizeof(cKB);
    54425447
     
    54565461 * buffer.
    54575462 *
    5458  * @returns VBox status code.
     5463 * @returns VBox status code. Sets pSSM->rc on error.
    54595464 * @param   SSM             The saved state handle.
    54605465 * @param   pvDst           Pointer to the output buffer.
     
    54805485        rc = ssmR3DataReadV2Raw(pSSM, &pSSM->u.Read.abComprBuffer[0], cbCompr);
    54815486        if (RT_FAILURE(rc))
    5482             return rc;
     5487            return pSSM->rc = rc;
    54835488        pb = &pSSM->u.Read.abComprBuffer[0];
    54845489    }
     
    54985503
    54995504    AssertLogRelMsgFailed(("cbCompr=%#x cbDecompr=%#x rc=%Rrc\n", cbCompr, cbDecompr, rc));
    5500     return VERR_SSM_INTEGRITY_DECOMPRESSION;
     5505    return pSSM->rc = VERR_SSM_INTEGRITY_DECOMPRESSION;
    55015506}
    55025507
     
    55055510 * Reads and checks the raw zero "header".
    55065511 *
    5507  * @returns VBox status code.
     5512 * @returns VBox status code. Sets pSSM->rc on error.
    55085513 * @param   pSSM            The saved state handle..
    55095514 * @param   pcbDecompr      Where to store the size of the zero data.
     
    55175522    int rc = ssmR3DataReadV2Raw(pSSM, &cKB, 1);
    55185523    if (RT_FAILURE(rc))
    5519         return rc;
     5524        return pSSM->rc = rc;
    55205525    pSSM->u.Read.cbRecLeft = 0;
    55215526
     
    55375542 * is returned.
    55385543 *
    5539  * @returns VBox status code.
     5544 * @returns VBox status code. Does not set pSSM->rc.
    55405545 * @param   pSSM            The saved state handle.
    55415546 */
     
    58185823 * Buffer miss, do a buffered read.
    58195824 *
     5825 * @returns VBox status code. Sets pSSM->rc on error.
     5826 *
    58205827 * @param   pSSM            The saved state handle.
    58215828 * @param   pvBuf           Where to store the read data.
     
    74497456
    74507457        /* failure path */
    7451         ssmR3StrmClose(&pSSM->Strm);
     7458        ssmR3StrmClose(&pSSM->Strm, pSSM->rc == VERR_SSM_CANCELLED);
    74527459    }
    74537460    else
     
    77747781 * Executes the loading of a V2.X file.
    77757782 *
    7776  * @returns VBox status code.
     7783 * @returns VBox status code.  May or may not set pSSM->rc, the returned
     7784 *          status code is ALWAYS the more accurate of the two.
    77777785 * @param   pVM                 The VM handle.
    77787786 * @param   pSSM                The saved state handle.
     
    81318139            }
    81328140        }
    8133         rc = Handle.rc;
    81348141
    81358142        /* progress */
     
    81388145
    81398146        ssmR3SetCancellable(pVM, &Handle, false);
    8140         ssmR3StrmClose(&Handle.Strm);
     8147        ssmR3StrmClose(&Handle.Strm, Handle.rc == VERR_SSM_CANCELLED);
     8148        rc = Handle.rc;
    81418149    }
    81428150
     
    82818289                           false /*fChecksumOnRead*/, 1 /*cBuffers*/, &Handle);
    82828290    if (RT_SUCCESS(rc))
    8283         ssmR3StrmClose(&Handle.Strm);
     8291        ssmR3StrmClose(&Handle.Strm, false /*fCancelled*/);
    82848292    else
    82858293        Log(("SSM: Failed to open saved state file '%s', rc=%Rrc.\n",  pszFilename, rc));
     
    83618369     * Close the stream and free the handle.
    83628370     */
    8363     int rc = ssmR3StrmClose(&pSSM->Strm);
     8371    int rc = ssmR3StrmClose(&pSSM->Strm, pSSM->rc == VERR_SSM_CANCELLED);
    83648372    if (pSSM->u.Read.pZipDecompV1)
    83658373    {
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