VirtualBox

Changeset 89192 in vbox for trunk


Ignore:
Timestamp:
May 20, 2021 9:23:37 AM (4 years ago)
Author:
vboxsync
Message:

Devices/Storage/VBoxSCSI: Introduce a helper to handle legacy saved states when VBoxSCSI is getting removed, bugref:4841

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VBoxSCSI.h

    r82968 r89192  
    7777#include <VBox/vmm/pdmstorageifs.h>
    7878#include <VBox/scsi.h>
     79#include <VBox/version.h>
    7980
    8081typedef enum VBOXSCSISTATE
     
    157158DECLHIDDEN(int) vboxscsiR3LoadExec(PCPDMDEVHLPR3 pHlp, PVBOXSCSI pVBoxSCSI, PSSMHANDLE pSSM);
    158159DECLHIDDEN(int) vboxscsiR3SaveExec(PCPDMDEVHLPR3 pHlp, PVBOXSCSI pVBoxSCSI, PSSMHANDLE pSSM);
     160
     161/**
     162 * Helper shared by the LsiLogic and BusLogic device emulations to load legacy saved states
     163 * before the removal of the VBoxSCSI interface.
     164 *
     165 * @returns VBox status code.
     166 * @param   pHlp                Pointer to the Ring-3 device helper table.
     167 * @param   pSSM                The SSM handle to operate on.
     168 */
     169DECLINLINE(int) vboxscsiR3LoadExecLegacy(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM)
     170{
     171    pHlp->pfnSSMSkip(pSSM, 4);
     172
     173    /*
     174     * The CDB buffer was increased with r104155 in trunk (backported to 5.0
     175     * in r104311) without bumping the SSM state versions which leaves us
     176     * with broken saved state restoring for older VirtualBox releases
     177     * (up to 5.0.10).
     178     */
     179    if (   (   pHlp->pfnSSMHandleRevision(pSSM) < 104311
     180            && pHlp->pfnSSMHandleVersion(pSSM)  < VBOX_FULL_VERSION_MAKE(5, 0, 12))
     181        || (   pHlp->pfnSSMHandleRevision(pSSM) < 104155
     182            && pHlp->pfnSSMHandleVersion(pSSM)  >= VBOX_FULL_VERSION_MAKE(5, 0, 51)))
     183        pHlp->pfnSSMSkip(pSSM, 12);
     184    else
     185        pHlp->pfnSSMSkip(pSSM, 20);
     186
     187    pHlp->pfnSSMSkip(pSSM, 1); /*iCDB*/
     188    uint32_t cbBufLeft, iBuf;
     189    pHlp->pfnSSMGetU32(pSSM, &cbBufLeft);
     190    pHlp->pfnSSMGetU32(pSSM, &iBuf);
     191    pHlp->pfnSSMSkip(pSSM, 2); /*fBusy, enmState*/
     192
     193    if (cbBufLeft + iBuf)
     194        pHlp->pfnSSMSkip(pSSM, cbBufLeft + iBuf);
     195
     196    return VINF_SUCCESS;
     197}
     198
     199
    159200RT_C_DECLS_END
    160201#endif /* IN_RING3 */
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